Kernel
What each function of the kernel does, who may call it, when, and what it checks.
Kernel. Every member is a proxy whose implementation slot points at its kernel, written once at its creation and afterwards only by its owner’s switch to a newer listed kernel (switchKernel). The kernel runs in the member’s storage, answers its own functions and delegates every other call to the member’s current logic, under a guard: it reads the implementation slot and the five fixed words of its own storage before the call and again after, and any difference reverts the whole call, so no logic can change who owns the member, who created it, its owner’s generation or what it may become. It is immutable, has no constructor argument and refuses every call made to its own address. A member moves only to its line’s newest release on its registry, with a higher number and code matching the hash the release lists (never an EIP-7702 delegation), checked in the call that applies it: the owner’s own call, or its signed envelope relayed to each member it names, each taking its item at its exact next nonce, once. A migration moves the member to a successor registry its registry lists as open, and only while that registry has not stopped the group of the member’s run. The owner’s Stop, signed for named members (each at its recorded run, its count of stops and its owner generation) or called, runs the logic’s stop under the guard and requires the count of stops to rise, so a Stop acts once; it takes no nonce. The owner’s ownership moves by a transfer the owner and the new wallet both sign, naming the strategy’s hub and every member: each member switches on its own, one owner generation higher, so every message signed for an earlier generation is refused there, a transfer back included. The member’s creator never changes.
The other contracts, and every caller on one table, are on the overview.
The owner’s wallet, by signature
A message signed by the member’s owner, one wallet: an ECDSA signature on every chain or, on Ethereum only, ERC-1271 for a contract wallet. Anyone may submit the transaction; submitting it gives no power, the signature does.
upgradeSigned
function upgradeSigned(
KernelMessages.Upgrade calldata u,
bytes calldata sig
) externalApplies at once the item of the owner’s signed envelope that names this member on this chain: an upgrade or a migration, as by the owner’s call. One envelope may name members on several chains; each takes its own item where it is relayed.
Who may call: Anyone; the owner’s signature is the authority.
When: Before the deadline.
Parameters
| Name | Type | Description |
|---|---|---|
u | KernelMessages.Upgrade | The signed envelope. |
sig | bytes | The owner’s signature. |
What it checks
- The deadline has not passed (
Expired). - Exactly one item names this member here (
NotNamed,NamedTwice), at its owner generation (StaleGeneration), and its nonce is the member’s next (BadNonce), which it consumes: a replay is refused. - The signature is the owner’s (
NotOwner). - The target is valid as for a call (
NotNewest,NotNewer,CodeChanged,DelegatedCode,NotSuccessor,GroupStopped,LowGas,BadItem).
ownerStopSigned
function ownerStopSigned(
KernelMessages.Stop calldata s,
bytes calldata sig
) externalTakes the item of the owner’s signed Stop that names this member on this chain, and runs the logic’s stop under the guard; the call reverts unless the member’s count of stops rose. One Stop may name members on several chains and strategies; each takes its own item where it is relayed. It takes no nonce.
Who may call: Anyone; the owner’s signature is the authority.
When: Before the deadline, while the member records the item’s run at the item’s count of stops.
Parameters
| Name | Type | Description |
|---|---|---|
s | KernelMessages.Stop | The signed Stop. |
sig | bytes | The owner’s signature. |
What it checks
- The deadline has not passed (
Expired) and the signature is the owner’s (NotOwner). - Exactly one item names this member here (
NotNamed,NamedTwice), at its owner generation (StaleGeneration). - The logic records the item’s run (
WrongRun) and its count of stops is the item’s (StaleStop): a Stop once applied is refused. - The logic’s stop succeeds (
AlreadyStoppedat a member already stopped; a leg with no run stops at run 0) and raises the count (NotStopped).
transferOwner
function transferOwner(
KernelMessages.Transfer calldata t,
bytes calldata ownerSig,
bytes calldata newOwnerSig
) externalMoves the member’s ownership to the new owner the owner’s and the new wallet’s signed Transfer names: the owner generation rises by one, then the logic’s transfer hook runs under the guard. Each member switches on its own where the message is relayed; every message signed for an earlier generation is refused here from then on. The creator, the upgrade nonce and the owner nonce stay.
Who may call: Anyone; the two signatures are the authority.
When: Before the deadline, at the generation each item names.
Parameters
| Name | Type | Description |
|---|---|---|
t | KernelMessages.Transfer | The signed Transfer. |
ownerSig | bytes | The owner’s signature. |
newOwnerSig | bytes | The new owner’s signature of the same message. |
What it checks
- The deadline has not passed (
Expired). - Exactly one item names this member here (
NotNamed,NamedTwice), at its owner generation (StaleGeneration). - The new owner is neither zero nor the owner (
BadNewOwner). - The owner’s signature (
NotOwner). - The message names exactly this member and its links, each once at its address on its chain (
NotWhole), as the logic reads them under the guard. - The new owner’s signature: ECDSA, or ERC-1271 only when every member lives on this chain (
NotNewOwner).
The owner’s wallet
The member’s owner, one wallet (a Safe included), calling it directly, and nothing else.
upgrade
function upgrade(bytes32 release) externalMoves the member to the line’s newest release at once, then runs the logic’s upgrade hook under the guard. It consumes the next nonce, so a signature made before it never lands after it.
Who may call: The owner.
When: At any time.
Parameters
| Name | Type | Description |
|---|---|---|
release | bytes32 | The release id. |
What it checks
- The caller is the owner (
NotOwner). - The release is the line’s newest (
NotNewest), higher than the member’s (NotNewer), and its logic holds the listed code (CodeChanged), not an EIP-7702 delegation (DelegatedCode).
migrate
function migrate(address newRegistry) externalMoves the member to a successor registry at once, keeping its line and its release. It consumes the next nonce.
Who may call: The owner.
When: At any time.
Parameters
| Name | Type | Description |
|---|---|---|
newRegistry | address | The new registry. |
What it checks
- The caller is the owner (
NotOwner). - The registry is listed as an open successor by the current one, by its address and its code hash now, and is no EIP-7702 delegation (
NotSuccessor), and has not stopped the group of the member’s run, read as the escape hatch reads it with bounded gas: a read that fails counts as stopped (GroupStopped); too little gas left for the read isLowGas.
switchKernel
function switchKernel(bytes32 release) externalMoves the member to the kernel line’s newest release at once: the member’s proxy then runs that kernel from its next call, with its owner, registry, line, logic and release kept. It consumes the next nonce and calls nothing after the switch.
Who may call: The owner, by their own transaction.
When: At any time.
Parameters
| Name | Type | Description |
|---|---|---|
release | bytes32 | The kernel release id. |
What it checks
- The caller is the owner (
NotOwner). - The release is the kernel line’s newest on the member’s registry (
NotNewest); its kernel holds the listed code (CodeChanged), not an EIP-7702 delegation (DelegatedCode); itskernelNumber()answers the listed number (NumberMismatch), and that number is above this kernel’s (NotNewer).
ownerStop
function ownerStop() externalThe owner’s own Stop of the member’s recorded run: runs the logic’s stop under the guard; the call reverts unless the member’s count of stops rose. It takes no nonce, so it voids a signed Stop not yet relayed only by moving the count.
Who may call: The owner.
When: While the member is not stopped (a leg with no run recorded stops at run 0).
What it checks
- The caller is the owner (
NotOwner). - The logic’s stop succeeds (
AlreadyStopped; a leg with no run stops at run 0) and raises the count (NotStopped).
Anyone
Any address. These functions take no recipient and act only as the code allows: they move nothing anywhere the owner did not choose.
initialize
function initialize(
address owner_,
address registry_,
bytes32 line_,
bytes32 release,
bytes calldata initData
) externalSets a new member’s owner, registry, line and first release, then runs the logic’s own initialisation under the guard.
Who may call: Whoever creates the member, once, in the creating transaction (the builder); the kernel itself checks only that the member is not yet initialised.
When: Once, while the member has no owner.
Parameters
| Name | Type | Description |
|---|---|---|
owner_ | address | The owner. |
registry_ | address | The registry. |
line_ | bytes32 | The member’s line. |
release | bytes32 | The release id: an open release of the line (the builder names it). |
initData | bytes | The logic’s own initialisation data. |
What it checks
- The call comes through a proxy (
NotProxied). - The member has no owner yet (
AlreadyInitialised) and the owner is not zero (NotOwner). - The release is an open
VERSIONentry of the member’s line, listed and not retired (NotOpen), and its logic holds the listed code (CodeChanged), not an EIP-7702 delegation (DelegatedCode).
fallback
fallback() external payableDelegates every call it does not answer itself to the member’s current logic under the guard, with its value; return and revert data pass on unchanged. The logic’s seven kernel-only selectors are refused from outside.
Who may call: Anyone; the logic decides what each function allows.
When: At any time once the member is initialised.
What it checks
- The call comes through a proxy (
NotProxied). - The selector is not one the kernel alone reaches (
Reserved). - The member has a logic (
NotInitialised). - The implementation slot and the five protected words are unchanged by the call (
KernelChanged).
Read-only
Views and constants: they change nothing, and anyone may read them.
kernelNumber
function kernelNumber() public pure returns (uint32)This kernel’s own release number, fixed in its code: 1 for the first kernel.
owner
function owner() external view returns (address)The member’s owner.
registry
function registry() external view returns (address)The member’s registry.
line
function line() external view returns (bytes32)The member’s line: its kind and place in the kind.
logic
function logic() external view returns (address)The member’s current logic.
number
function number() external view returns (uint32)The release number of the member’s logic.
nonce
function nonce() external view returns (uint64)The member’s next upgrade nonce: a signed upgrade item must carry it, and every upgrade or migration consumes it.
generation
function generation() external view returns (uint64)The owner’s generation: 0 at the creation, one more at each transfer. Every owner message names it, and is refused at any other.
Events
Initialised event
event Initialised(address owner, address registry, bytes32 line, uint32 number);A member was initialised.
Emitted by: initialize
Fields
| Name | Type | Description |
|---|---|---|
owner | address | The owner. |
registry | address | The registry. |
line | bytes32 | The line. |
number | uint32 | The first release’s number. |
UpgradeApplied event
event UpgradeApplied(uint8 what, bytes32 target, uint32 fromNumber);An upgrade or migration was applied.
Emitted by: upgrade, migrate, upgradeSigned
Fields
| Name | Type | Description |
|---|---|---|
what | uint8 | 1 upgrade, 2 migration. |
target | bytes32 | The release id, or the registry as a bytes32. |
fromNumber | uint32 | The release number before. |
OwnerStopApplied event
event OwnerStopApplied(bytes32 digest, uint64 stopCount);The owner’s Stop stopped the member.
Emitted by: ownerStopSigned, ownerStop
Fields
| Name | Type | Description |
|---|---|---|
digest | bytes32 | The signed Stop’s EIP-712 digest, or zero for the owner’s call. |
stopCount | uint64 | The member’s count of stops after it. |
OwnerTransferred event
event OwnerTransferred(address previous, address next, uint64 generation);The member’s ownership moved.
Emitted by: transferOwner
Fields
| Name | Type | Description |
|---|---|---|
previous | address | The owner before. |
next | address | The new owner. |
generation | uint64 | The owner generation now. |
Upgraded event
event Upgraded(address indexed implementation);The member’s proxy points at a new kernel (ERC-1967).
Emitted by: switchKernel
Fields
| Name | Type | Description |
|---|---|---|
implementation | address · indexed | The new kernel. |
KernelSwitched event
event KernelSwitched(uint32 fromNumber, uint32 toNumber, address kernel);The owner moved the member to a newer kernel.
Emitted by: switchKernel
Fields
| Name | Type | Description |
|---|---|---|
fromNumber | uint32 | The kernel’s number before. |
toNumber | uint32 | Its number now. |
kernel | address | The new kernel. |
Errors
A call that fails reverts with one of these, so a block explorer or a simulation shows which rule refused it.
| Error | When | Raised by |
|---|---|---|
LowGas() | The caller left too little gas for a registry read (30,000 gas and its margin): the whole call reverts, so a starved read never opens the hatch or forgives a fee. | — |
NoKey() | The registry has no execution key for the group: no run starts in it and no member moves into it, since nobody could protect it. | — |
GroupStopped() | The registry has stopped the run’s group, or failed to say it did not. | — |
NotOwner() | The caller, or the key behind the signature, is not the owner, or the owner is zero. | initialize, upgrade, migrate, upgradeSigned, switchKernel, ownerStopSigned, ownerStop, transferOwner |
AlreadyInitialised() | The member already has an owner. | initialize |
NotNewest() | The release is not its line’s newest on the registry. | initialize, upgrade, migrate, upgradeSigned, switchKernel |
NotNewer() | The release’s number is not above the member’s. | upgrade, migrate, upgradeSigned, switchKernel |
CodeChanged() | The listed logic’s code is not the code listed. | initialize, upgrade, migrate, upgradeSigned, switchKernel |
BadNonce() | The item’s nonce is not the member’s next. | upgradeSigned |
NotNamed() | No item names this member on this chain. | upgradeSigned, ownerStopSigned, transferOwner |
NamedTwice() | Two items name this member on this chain. | upgradeSigned, ownerStopSigned, transferOwner |
BadItem() | An item of a kind the kernel does not apply. | upgrade, migrate, upgradeSigned |
Expired() | The message’s deadline has passed. | upgradeSigned, ownerStopSigned, transferOwner |
NotSuccessor() | The target is not a registry with code, other than the current one, that the current registry lists as an open successor. | upgrade, migrate, upgradeSigned |
Reserved() | A call from outside named one of the logic selectors reached only by the kernel. | fallback |
KernelChanged() | A delegated call changed the implementation slot or a protected word. | — |
NotProxied() | The call was made to the kernel itself, not through a member. | initialize, upgrade, migrate, upgradeSigned, switchKernel, ownerStopSigned, ownerStop, transferOwner, owner, registry, line, logic, number, nonce, generation, fallback |
NotInitialised() | The member has no logic yet. | fallback |
WrongRun() | The logic does not record the named run. | ownerStopSigned |
StaleStop() | The member’s count of stops is not the one the Stop names: a Stop once applied, or one signed before a later stop. | ownerStopSigned |
NotStopped() | The logic’s stop did not raise the member’s count of stops. | ownerStopSigned, ownerStop |
StaleGeneration() | The item names another owner generation than the member’s. | upgradeSigned, ownerStopSigned, transferOwner |
NotWhole() | The transfer does not name exactly this member and every member it links to, each once. | transferOwner |
BadNewOwner() | The new owner is zero or the owner. | transferOwner |
NotNewOwner() | The signature is not the new owner’s (by ERC-1271 only when every member lives on this chain). | transferOwner |
DelegatedCode() | The release’s logic is an EIP-7702 delegation (its code begins with 0xEF), which its holder could point elsewhere. | initialize, upgrade, migrate, upgradeSigned, switchKernel |
NotOpen() | The first release is not an open VERSION entry of the member’s line. | initialize |
NumberMismatch() | The kernel release’s listed number is not the number its code answers. | switchKernel |