Reference for src/core/ and src/storage/. The audience is an engineer who has to extend
this, or write a second implementation that agrees with it byte for byte. Every claim here is
taken from the code as it stands; where a number is not measured anywhere it says
unmeasured rather than guessing.
Line numbers are as of commit 9220195. Be precise
about what that is worth, because it is not uniform across this file, and one part of it is worth
stating plainly rather than leaving a reader to discover. src/core/blockchain.ts has been
rewritten by another workstream continuously since this chapter was first taken: it was 3,918
lines when the first pass started, 4,239 when the rule x site table in section 5.2 was taken, and
5,913 at 9220195 — and it grew by a further 46 lines, in the working tree, while this pass
was reading it. So:
- Sections 2.1, 2.4, 4.4, 5.4, 5.5, 9, 10.1 through 10.6, and 12 were re-opened for this pass
and every line they cite was read at that line before it was written about. Their numbers are
taken against the working tree at
9220195— the commit plus the uncommitted edits present while the pass ran — because that is whatnpm run citationschecks and what a reader with the checkout in front of them sees. Forledger-manager.ts,yggdrasil.ts,charon.ts,draupnir.ts,mimir.ts,hestia.ts,helgrind.ts,tokens.tsandtransaction.tsthe two are the same file; forblockchain.ts,snotra.ts,genesis.ts,config.tsandstrblk.tsthey are not, and the working-tree number is the one written down. - The rule x site table in section 5.2 was taken in one pass at 4,239 lines and every cell was verified to land on the check it names. At 5,959 lines those numbers are stale by well over a thousand lines in the later half of the file and have not been re-taken.
- Section 12.4 keeps the original text of entries 1 to 6 with the line numbers they carried when the defects were found, deliberately. That text is a record of a moment, not a current claim.
- Everything else carries numbers from the pass that wrote it and should be treated the same way.
Each citation therefore names the symbol, message string or line of code it points at. That name
is the anchor; the number is a shortcut that grep restores when it goes stale.
npm run citations checks the subset of citations written in the `Symbol` (`src/path.ts:N`)
form and fails CI on one that lands more than 25 lines from a definition of that symbol; the
bare file.ts:N form is not machine-checked and is only as good as the pass that took it.
Contents:
- Yggdrasil — the account ledger
- LedgerManager — the seven ledgers and the state root
- Glasir — the state tree
- Charon — the mempool
- The block lifecycle and the four execution sites
- Deferred execution
- Timestamps: the chain's clock
- The Merkle transaction root
- Genesis and the production guard
- Storage: Draupnir and Mimir
- Canonical encoding
- Known limits
1. Yggdrasil — the account ledger#
src/core/yggdrasil.ts. One instance per token. It holds accounts, it holds a running supply,
and it holds a Glasir tree that commits to both.
1.1 The account#
AccountState { balanceMinor, lockedMinor, lockedForLifeMinor, nonce } // all bigintsrc/core/yggdrasil.ts:18-28. All four fields are bigint; there is no floating point anywhere
in the money path. Minor units are 13 decimals for every token (src/core/tokens.ts:42).
balanceMinoris everything the account holds, locks included.getAvailable()isbalance - locked - lockedForLife(yggdrasil.ts:117-120) and is what every spend, burn and lock is checked against.nonceis the sender's replay counter. It is chain-wide, not per token: only the STR ledger's nonce is ever read, and the non-native transfer path advances it explicitly (src/core/ledger-manager.ts:345-347,ledger-manager.ts:382).
An address that has never held anything is answered from one frozen shared object,
EMPTY_ACCOUNT (yggdrasil.ts:36-38), through the private read() (yggdrasil.ts:288-290).
That indirection exists because of a specific failure recorded there: reads used to auto-create.
Validating a transaction from an unknown address inserted a zero-balance account, which changed
the state root on the validating node and on nobody else — so a peer could fork every node that
merely looked at its rejected transactions, and grow their account maps for the price of an
invalid signature.
Writes go through mutable() (yggdrasil.ts:298-305), which creates on demand and adds the
address to the dirty set. There is no other way to obtain a writable account, so the dirty set
cannot drift from the map.
1.2 The two lock kinds, and why there are two#
| Kind | Field | Released by | Burnable | Counted in balance |
|---|---|---|---|---|
| Releasable lock | lockedMinor | release(), and its only production caller is applyDomainBurn | no (burn checks getAvailable) | yes |
| Lock for life | lockedForLifeMinor | nothing, at any amount | no | yes |
The 1000 STR domain lock is a RELEASABLE lock, and it is worth being exact about that.
What made it unrecoverable was never the lock kind — it was that nothing on the chain called
release() for a domain. Since 2026-09-07 something does: burning the domain
(applyDomainBurn). lockForLife still has no caller anywhere in src/, so
lockedForLifeMinor is zero on every account of every SourceLess chain that has run, and the
rule below is untouched by the burn. getReleasableLocked() exists so a caller about to pay a
refund measures against lockedMinor alone rather than against getLocked(), which would let
a burn look payable out of value release() then refuses.
release() deliberately cannot reach lockedForLifeMinor — the comment at yggdrasil.ts:181
states it as a rule, and the arithmetic enforces it: only lockedMinor is compared and
decremented.
Both kinds are subtracted by getAvailable, which is why burn() checks availability rather
than raw balance (yggdrasil.ts:245): what is locked for life can never be destroyed, and what
is locked against a domain cannot be spent out from under the domain.
The 1000 STR domain lock is a releasable lock (applyRegistration, blockchain.ts:3810).
Nothing on this chain is locked for life. lockForLife has no caller in src/, and the
docstring above it (yggdrasil.ts:145-169) now says so: its one caller was the Feeless Pool's
domain-lock exit, and that exit is sealed because it minted to a caller-named address on no
authorisation and outside any block. The primitive is kept because permanence is enforced by the
readers of lockedForLifeMinor — release refuses it at any amount, burn and lock measure
against getAvailable, and leafCommitment puts it in the state root — and because removing the
field would change the account leaf preimage and therefore every state root, the genesis one
included. See Known limits.
The lock counter being shared between kinds is load-bearing elsewhere. docs/NAMING.md:87
records that the WSTR wrapper backs itself at a keyless vault address rather than through
YggdrasilLedger.lock(), precisely because the lock counter is shared with the domain lock, so
wrapping through it would have satisfied LedgerManager.reconcileDomains() with no domain lock
ever placed.
1.3 Supply#
supplyMinor (yggdrasil.ts:219) is a running counter, maintained by seed, loadSnapshot,
mint and burn. It counts balanceMinor only — locks sit inside balances, so locking moves
nothing.
It is a counter rather than a sum because mint() reads it to check the cap
(yggdrasil.ts:227-232), and summing the map was O(accounts), so minting got linearly slower as
the chain grew (yggdrasil.ts:53-59). auditSupplyMinor() (yggdrasil.ts:264-268) recomputes
from scratch and exists for reconciliation and assertions;
tests/integration/glasir.integration.test.ts:171 ("tracks supply exactly against a full
recount") is the check that the two never part.
Caps come from TOKEN_DEFINITIONS[token].maxSupplyMinor (src/core/tokens.ts:136 ff). null
means no cap and mint skips the check entirely — which is why STR_USD acquired one:
tokens.ts:115-134 records an auditor minting 10^25 minor $TR through a path where every other
control had already failed, and the cap is the one control the ledger itself enforces.
1.4 The eight mutators#
apply is one of eight entry points that change an account. This is not a stylistic
observation. docs/BUILD_STATUS.md:89 records the gate
All money-moving paths go through one deterministic primitive
as NOT MET, for exactly this reason: "the primitive named in the old version of this table
did not exist. The real ledger is YggdrasilLedger, and apply is one of eight mutating entry
points (seed, lock, lockForLife, release, apply, bumpNonce, mint, burn), with six
modules calling the others directly."
Measured against the tree as it stands:
| Mutator | Line | What it changes | Production callers |
|---|---|---|---|
seed | seed yggdrasil.ts:295 | replaces the whole account; supply | LedgerManager.seed (ledger-manager.ts:883) ← initGenesis (blockchain.ts:16260) and replayChain (blockchain.ts:15448) |
lock | lock yggdrasil.ts:402 | lockedMinor | applyRegistration (blockchain.ts:17495); LedgerManager.registerDomain (ledger-manager.ts:832) |
lockForLife | lockForLife yggdrasil.ts:435 | lockedForLifeMinor | none (tests only) |
release | release yggdrasil.ts:465 | lockedMinor | none |
apply | apply yggdrasil.ts:501 | both balances, sender nonce | LedgerManager.apply, STR branch only (LedgerManager.apply ledger-manager.ts:802) |
bumpNonce | bumpNonce yggdrasil.ts:509 | nonce | LedgerManager.apply, non-STR branch (ledger-manager.ts:382); applyWrapRecord (src/economics/echo.ts:332, echo.ts:382) |
mint | mint yggdrasil.ts:517 | balance; supply | LedgerManager.apply non-STR (ledger-manager.ts:381), registerDomain (ledger-manager.ts:853), applyPostMining (ledger-manager.ts:882); applyRegistration (blockchain.ts:17495); genesis WNFT mint (blockchain.ts:3318, :3016); contractValuePort (src/core/contract-state.ts:232); Echo (echo.ts:356-357, :381); FeelessPool.credit (src/economics/feeless-pool.ts:218); applyCollateralRecord (src/economics/stable-pool.ts:899) |
burn | burn yggdrasil.ts:541 | balance; supply | LedgerManager.apply non-STR (ledger-manager.ts:380); contractValuePort (contract-state.ts:232); Echo (echo.ts:355, :379-380); FeelessPool (feeless-pool.ts:184); applyCollateralRecord (stable-pool.ts:899); governance effects (applyGovernanceEffect src/governance/effects.ts:305) |
Six modules outside LedgerManager reach a mutator other than apply: blockchain.ts,
contract-state.ts, echo.ts, feeless-pool.ts, stable-pool.ts, effects.ts. That matches
the count in docs/BUILD_STATUS.md:89.
loadSnapshot (yggdrasil.ts:94-109) is a ninth way to change every account at once. It is not
counted as a mutator because it is state replacement, but a second implementation must handle
it identically: clear the map, clear the dirty set, clear the tree, rebuild supplyMinor from
the loaded balances, mark every restored address dirty.
A contradiction to name rather than repeat. README.md:254 says "Value moves only through
YggdrasilLedger.apply, which validates before it mutates", and this domain's standing rule is
"no balance mutation outside YggdrasilLedger.apply". Neither is true of the code. What is true,
and is the property the rest of the system actually rests on, is narrower: no balance moves
outside block execution — blockchain.ts:1004 states it that way, and that is the invariant
validateState() can actually check. The eight-mutator surface is the recorded gap; the
block-execution boundary is the enforced one.
1.5 The leaf commitment#
sha256_utf8( "yggdrasil:account:v1" | address | balanceMinor | lockedMinor
| lockedForLifeMinor | nonce ) // the six parts joined with "|"yggdrasil.ts:341-352; bigints as decimal strings via toString(). Every field that can affect
validation is in the preimage, so two ledgers agreeing on the root agree on all of it, and the
address is in the preimage as well as being the key, so a leaf cannot be lifted from one account
onto another.
stateRootHex() (yggdrasil.ts:328-331) flushes the dirty set into the tree and returns
tree.rootHex(). flush() (yggdrasil.ts:308-319) rehashes only dirty leaves. Accounts are
never removed on any path, so the tree.delete branch at yggdrasil.ts:313 is unreachable
today; it is kept because flush is the only place that could observe a removal.
2. LedgerManager — the seven ledgers and the state root#
src/core/ledger-manager.ts. SourceLess keeps one ledger per token rather than one ledger with a
token column (ledger-manager.ts:26-37): ledgers are independent, so a fault in one cannot
corrupt another's balances, and they can be validated in parallel.
2.1 The seven#
ALL_TOKENS (src/core/tokens.ts:31). The order is consensus-visible, because the state root
folds it in exactly this sequence:
| # | Token | Cap (minor) | Transferable | Notes |
|---|---|---|---|---|
| 1 | STR | 63e9 × 10^13 (tokens.ts:73, :145) | yes | native; nonces and the domain lock live here |
| 2 | CCOS | 63e6 × 10^13, and the premine is the same number | yes | financialOnly: refuses any tx not marked purpose: 'financial' (ledger-manager.ts:306-308). Premined at genesis by two allocations carrying token: CCOS — 42e6 treasury, 21e6 public, summing to the cap — so supply is 63e6 from block zero and both controls bind: assertMintable refuses every later mint through its premined branch, and the seed leaves the ledger no headroom |
| 3 | WSTR | bounded by the STR it wraps | yes | minted only by applyWrapRecord |
| 4 | ARSS | null — no cap (tokens.ts:281) | yes | emission policy |
| 5 | STR_USD | 1e9 × 10^13 (tokens.ts:134) | yes | bridge-minted; the cap is a policy ceiling, not a forecast |
| 6 | WNFT | null (tokens.ts:316) | no (tokens.ts:322) | one per proved domain |
| 7 | ESTR | 50e6 × 10^13, and the premine is the same number | yes | premined at genesis by an allocation carrying token: ESTR; assertMintable refuses every mint afterwards through its premined branch, and the seed reaches the cap so the ledger refuses one too — see ESTR_MAX in tokens.ts |
Beside the seven the manager owns five more pieces of committed state, each with the same
stateRootHex / snapshot / loadSnapshot shape:
contracts: SindriLedger(ledger-manager.ts:95) — code and storage. It was per-process RAM: two nodes could hold different contract state and both reportvalidateChain() === accepted.governance: Odin(governanceledger-manager.ts:312) — proposals, ballots, parameters, the Althing roll, ejections. It was an in-memory voting record in one process.collateral: CollateralBook(collateralledger-manager.ts:245) — the bridge's reserves and the deposit references this chain has spent. It was replayed by every node and committed to by none, so a divergence in "has this deposit reference already been spent" was invisible to a root comparison (ledger-manager.ts:526-528).domains.wnfts— the Idunn identity vault, folded under the keyIDENTITY.domains.burned— Helgrind, the gate a burned STR.domain leaves behind, folded underBURNED-DOMAINS(ledger-manager.ts:533). Added on 2026-09-07 with domain burning.HelgrindGate(src/identity/helgrind.ts:478) is deliberately the same shape as the four above rather than a fifth invention: it holds records, folds each into one Glasir leaf keyedhelgrind:burned|<domain>(helgrind.ts:452), and exposesstateRootHex()(helgrind.ts:768),snapshot()(:396) andloadSnapshot()(:409).docs/book/IDENTITY_AND_WALLET.mdowns what a burn means; what belongs here is why it is chain state at all, and that is in §2.4.
2.2 Admission: validate()#
LedgerManager.validate (src/core/ledger-manager.ts:583), in this order:
- token is transferable (
:313); financialOnlytokens requirepurpose === 'financial'(:317);- sender holds a PROVED
STR.domain(:328) — the sybil cost that replaces the transaction fee SourceLess does not charge. This has never moved and does not move here; - the recipient rule, which is the whole of what the recipient must satisfy (
:370-399):- a deployed contract passes unconditionally.
contracts.hasis membership of the deployed set, which is in the state root, never a pattern match on the address string; - anything else must not be a Hnitbjorg account (
:386), and must be a well-formed address (:397); - there is no identity requirement. An address with no STR.domain at all may receive and hold;
- a deployed contract passes unconditionally.
- nonce equals the STR-ledger nonce (
:402) — chain-wide, so one account cannot replay a nonce across tokens; - amount positive, and available balance on the named ledger covers it (
:407-409).
2.2.1 The recipient rule as it was, and why it moved#
It required an allocated domain until the domainless-recipient change. The reason given was that a newcomer must be able to receive the 1000 STR before it can lock them — requiring proof to receive would have made the lock unfundable and nobody could ever have joined. That reason was correct and it did not stop where it was stopped: a newcomer still had to know what an STR.domain was and claim a name before anyone could pay them, and a wallet generated offline, on a machine that had never seen this chain, could not be paid at all.
It costs nothing in sybil resistance. A domainless account is a place value can sit, not a participant: to move anything out of it its holder must register a domain and lock 1000 STR, which is the same toll, charged at the moment value first leaves rather than before value first arrives.
This is a consensus rule change and the genesis hash does not move. A chain that accepts a
transfer the previous code refused is a different chain, and two nodes on either side of the
change agree on their genesis, agree on their chain id, and disagree about whether a block is
valid. When it was made there was no activation-height mechanism, so it was a flag day: every node ran
the old rule or every node ran the new one. Corrected 2026-11-23: this paragraph went on to say that
no such mechanism exists anywhere in the tree. One has since 2026-09-18, Logretta
(src/core/logretta.ts): a rule is read by the version in force at a block's height, and a later version
takes an activation height.
2.2.2 What the old rule was carrying that was not identity — Hnitbjorg#
Two accounts on this chain are derived from a hash rather than from a key, and both keep books beside the ledger and compare the two:
| Account | Derived from | The comparison |
|---|---|---|
Echo vault (ECHO_VAULT_ADDRESS) | a fixed domain tag | EchoVault.reconcile(): WSTR total supply == the vault's STR balance |
Feeless Pool (feelessPoolAddress) | the genesis hash | FeelessPool.reconcile(token): the pool's own availableMinor == getBalance(poolAddress) |
A domain allocation is signed by the wallet it names (claimDomain / verifyDomainClaim), so
neither account could ever hold one, and the old recipient gate therefore refused them for
free — echo.ts said so in its own docstring, as the reason its 1:1 backing was exact rather
than approximate. One minor STR arriving from outside either book makes its comparison false
permanently: neither exit can spend a surplus its books never recorded.
So the property is now stated in its own right, by Hnitbjorg (src/core/hnitbjorg.ts) — the
mountain with no door, which the mead of poetry left by exactly one path. reservedAccountRefusal
is called from LedgerManager.validate (the transfer path), from ValueJournal.transfer
(src/core/contract-state.ts, the VM path) and from GhostLedger.checkProjection
(src/ledger/ghost.ts, the projection gate), so the three cannot drift. Both addresses are pure
functions of the chain binding, which is why the throwaway LedgerManager a replay builds
computes the same two without being wired to anything.
Deployed contracts are deliberately not in the set. They are keyless too, and they are the one
class of keyless account that must be payable — a call record carries no value, so an escrow, a
vesting schedule or a token sale is funded by a plain transfer or not at all. The difference is
that a contract's balance is not a book kept somewhere else: the ledger is its balance
(SindriLedger.balanceOfContract), so crediting one breaks no invariant.
2.2.3 The real cost: state growth, measured#
An account leaf is created for any address that receives, and the old rule made an attacker pay for one extra record per leaf. That is the whole of what it was worth as a growth bound, and it is a factor rather than a category.
Measured on this build, Node 22.14.0 on Windows 11. Measured means observed by running it; derived means arithmetic over measured quantities and is marked as such.
| Quantity | Value | How |
|---|---|---|
canonical bytes of a dust transfer, as produceBlock counts it | 474 | measured |
| canonical bytes of a signed domain allocation record | 353 | measured |
per-block record byte budget (MAX_BLOCK_BYTES 400,000 − 16,384 envelope headroom) | 383,616 | constant |
| new leaves in one sealed block, 24 proved senders queueing dust to fresh addresses | 807 | measured — the block sealed at 385,287 bytes |
| time to produce that block | 93.9 ms | measured |
| leaves per block under the OLD rule (allocation + transfer per leaf, 827 B) | 463 | derived |
| ratio | 1.74x | derived |
| heap per leaf, over 200,000 accounts (account map + Glasir leaf) | 609 bytes | measured |
| Mimir snapshot bytes per leaf | 134 bytes | measured |
| incremental re-root, 1 leaf touched, at 1,000 / 10,000 / 100,000 / 200,000 leaves | 0.0146 / 0.0206 / 0.0242 / 0.0282 ms | measured |
The default producer seals 100 transactions, not 807. produceBlock reads
opts.maxTx ?? 100 (src/core/blockchain.ts:2472), so an honest default node creates at most 100
leaves a block. maxTx is a caller-supplied number with no ceiling, and acceptBlock bounds a
block by BYTES and not by transaction count, so a producer that raises it seals the 807 above and
every follower accepts it. Both numbers are therefore real: 100 is what the network does, 807 is
what it permits.
At the 3-second block target — 28,800 blocks a day — that is 23.2M new leaves a day at the
permitted ceiling: 14.2 GB of heap and 3.11 GB of Mimir snapshot per day, against 13.3M leaves,
8.1 GB and 1.79 GB under the old rule. At the default maxTx it is 2.88M leaves, 1.75 GB and
386 MB. The value cost to the attacker is negligible under either rule — 23.2M minor STR is
2.3e-6 STR at 13 decimals — and Charon.maxPerSender (64) means saturating one block takes
thirteen proved domains, or 13,000 STR locked, under both rules alike. The sybil cost of the
attack did not move; only its throughput did, by 1.74x.
The state root does not degrade. Glasir re-hashes only the path from a changed leaf to the root, and the measurement above shows that path growing as log N: 0.0282 ms per touched leaf at 200,000 leaves, so 807 new leaves cost about 23 ms of rooting — consistent with the 93.9 ms the whole block took, most of which is signature verification. That is the same shape of cost the old rule had; the tree is not what breaks.
Unbounded state growth is a real, pre-existing property of this chain, and this change makes it 1.74x faster rather than creating it. There is no rent, no expiry, no leaf-count bound and no minimum transfer amount, before or after.
No mitigation is built, and that is a decision rather than an omission. A minimum transfer amount is the obvious candidate and it is an economic parameter: choosing a floor under what a payment may be worth is a policy question with an owner, and this chain's standing rule is that a conflict of that kind is escalated to governance rather than settled in a source file. Every candidate has the same shape — a per-block cap on leaf-creating transfers is a consensus parameter and is grief-able, since an attacker filling the cap blocks the honest newcomers it exists to admit; a leaf deferred until a threshold has to hold the pending credit somewhere, which is state. None of them is this change's debt, because all of them apply to the old rule equally. What this change is honestly answerable for is the 1.74x, and it is written down above rather than estimated.
2.3 The two posting primitives, and the rule drift they create#
LedgerManager.apply (ledger-manager.ts:361-383) has two branches:
if (token === TokenType.STR) {
ledger.apply(tx); // one primitive: debit, nonce++, credit
} else {
ledger.burn(tx.from, tx.amountMinor); // burn BEFORE mint
ledger.mint(tx.to, tx.amountMinor);
this.native.bumpNonce(tx.from);
}Burn precedes mint because minting first pushes supply transiently over the cap, so a token
sitting exactly at its cap would become untransferable, and the failure would land inside block
production rather than at admission (ledger-manager.ts). The comment there used to illustrate
this with "eSTR is premined to exactly 50M". That was wrong when it was written — nothing premined
eSTR then — and it is right again since 2026-09-07, for a reason worth keeping: eSTR is now
seeded to exactly its cap at genesis, so it is precisely the token that would become untransferable
if a transfer minted before it burned. CCOS joined it on the same day and matters more: its
premine also lands exactly on its cap, and CCOS is the ledger ordinary financial transfers use, so
this ordering is what keeps the financial ledger usable at all rather than protecting a token
nothing moves. WSTR at full wrap is the third case. The guard at ledger-manager.ts:385-387
re-reads the supply and throws if the pair did not net to zero.
The drift risk, stated plainly. These branches are not the same code and do not enforce the same rules:
YggdrasilLedger.validate()(yggdrasil.ts:187-197) runs on the STR path only, becauseapply()calls it. On the non-STR path it never runs. Its three checks — positive amount, nonce equality, sufficient available balance — are duplicated inLedgerManager.validate, so the two agree today. A rule added toYggdrasilLedger.validatelater would silently apply to STR and to nothing else.assertMintable()refusespending-governanceandpreminedtokens. Its only production caller isapplyPostMining(ledger-manager.ts:861); the burn+mint transfer path does not call it, and neither doesYggdrasilLedger.mint. So an ESTR transfer is implemented as a mint the mint-authority guard cannot see. That is the right behaviour for a transfer — it must work — but it means "who may mint" is enforced by the caller, never bymint. What bounds eSTR is not that guard: the genesis seed reaches the cap exactly, sominthas no headroom to give, and a directledger(ESTR).mint()of one minor unit throws. Two controls, and the one that holds here is the ledger's own arithmetic rather than the authority check. The same is true of CCOS since 2026-09-07, and there it is the load-bearing case rather than a theoretical one: CCOS is premined to its cap and is the token financial transfers actually move, so every CCOS transfer runs through a mint the guard cannot see, into a ledger with zero headroom, and works only because the burn precedes it.- The nonce advances inside
applyon one path and outside it on the other. Any third caller that moves value has to remember thebumpNonce;applyWrapRecord(echo.ts:358,:382) is that third caller, and it does.
This is the concrete content of the NOT-MET gate in §1.4: there is no single function a token movement must pass through, so parity between the branches is maintained by review rather than by structure.
2.4 The state root#
LedgerManager.stateRoot() (src/core/ledger-manager.ts:1059):
sha256( canonicalStringify([
{ token: "STR", rootHex },
{ token: "CCOS", rootHex },
{ token: "WSTR", rootHex },
{ token: "ARSS", rootHex },
{ token: "STR_USD", rootHex },
{ token: "WNFT", rootHex },
{ token: "ESTR", rootHex },
{ token: "CONTRACTS", rootHex: contracts.stateRootHex() },
{ token: "GOVERNANCE", rootHex: governance.stateRootHex() },
{ token: "IDENTITY", rootHex: domains.wnfts.stateRootHex() },
{ token: "COLLATERAL", rootHex: collateral.stateRootHex() },
{ token: "BURNED-DOMAINS", rootHex: domains.burned.stateRootHex() },
]) )Twelve UNCONDITIONAL entries, in exactly that order — and up to seven more that appear only when they hold something. The block above is the fold on a chain that has never delegated, never sealed a hostless space, never opened a message thread, never posted a validator bond, never rotated its bridge attestors, never rotated an account key and never changed a validator seat. That is every chain at block zero, which is why the twelve are what the genesis digests commit to.
The seven conditional entries, each appended by ...(register.isEmpty() ? [] : [...]) in the order
they are folded:
| Label | Register | Arrived |
|---|---|---|
SPEND-DELEGATIONS | spending delegations | the first absent-when-empty entry, and the one that set the rule |
HOSTLESS-SPACES | hostless spaces and who may read them | |
MESSAGE-THREADS | message threads and inbox keys | |
VALIDATOR-BONDS | validator bonds | |
BRIDGE-ATTESTORS | enacted attestor rotations | the genesis set is covered by the genesis hash, so only CHANGES fold |
KEY-ROTATIONS | Hamskipti account-key rotations | |
VALIDATOR-ROLL | Einherjar seat changes | 2026-09-14; the genesis roll is covered by genesisNodeSetRoot, so only CHANGES fold |
Absent and empty must mean the same thing, and that is the whole reason for the rule. An
unconditional entry would have changed the state root of every block of every existing chain,
height 0 included, to introduce a register none of them uses — and Midgard's genesis digests and
the development chain's three are pinned in CI. "This chain has no live delegation" and "this chain
has never rotated a key" are each one fact, so one digest is the correct answer for both.
isEmpty() rather than list().length, everywhere: list() materialises and sorts, and this
method runs at least once per block.
Array order matters: canonicalStringify sorts object
keys, never array elements. The key is IDENTITY rather than WNFT because WNFT is already a
token-ledger key and the two would collide in the array, making the root ambiguous
(ledger-manager.ts:522-524).
BURNED-DOMAINS is the twelfth and the newest (ledger-manager.ts:533). It is committed for the
reason GOVERNANCE and COLLATERAL are, and the code states it at the fold
(ledger-manager.ts:529-532): a cooldown one node remembers is a fork. Two honest nodes would
disagree about whether a burned name is available, one would seal a registration and the other
would refuse the block, and both would report a valid chain — the failure this root exists to make
visible. Folding it turns that disagreement into a differing state root, which is a thing the
protocol can act on. The gate holds one leaf per burned domain, and the leaf preimage carries the
barred set and the burn stamp as well as the domain, so two gates agreeing on the root agree on
every verdict either will give (src/identity/helgrind.ts:464).
That is 12 hashes over 12 cached roots on a chain using none of the conditional registers, and up
to 19 on one using all seven. It used to snapshot, sort and serialise every account of
every ledger on every call — O(accounts × ledgers) per block, whether the block changed one
account or none. Measured today at 6.3 µs per state root after a block
(docs/BUILD_STATUS.md:335) — taken when the fold was 11 entries, so it is one cached-root hash
light of the current shape rather than wrong by anything measurable.
The docstring above the method still says "a fixed 7 hashes over 7 cached roots"
(ledger-manager.ts:506-510). It has been wrong since CONTRACTS was added and is wrong by five
now; it is a stale comment rather than a stale rule, and it is recorded in
§12.4 rather than silently fixed here.
Deliberately not in the root: requiredConfirmations (a node-local policy; a setting that
changed the root would fork the chain on a configuration choice, blockchain.ts:730-740),
finalizedFloor (blockchain.ts:2390), the mempool, the pending record queues, and the
Feeless Pool's books (its balance is ledger state and is in the root; its bookkeeping is
derived).
2.5 Reconciliation#
reconcileDomains() (ledger-manager.ts:524-549) is an assertion, not a consensus rule: every
proved domain holds ≥ 1 WNFT, its wnftId equals wnftIdForDomain(domain), every non-genesis
domain has DOMAIN_LOCK_MINOR locked, and WNFT total supply equals the number of proved domains.
Genesis domains are exempt from the lock because genesis membership is defined by the spec rather
than bought.
3. Glasir — the state tree#
src/core/glasir.ts. A sparse Merkle tree over key = SHA-256("glasir:key:v1|" + address)
(glasir.ts:193-195), holding one valueHashHex per key. It knows nothing about accounts —
YggdrasilLedger, SindriLedger, Odin, the Idunn vault and CollateralBook all commit through
the same structure with their own leaf preimages, which is why the state root can be a fold over
eleven of them.
3.1 Hashes#
EMPTY_ROOT = sha256("glasir:empty:v1") glasir.ts:31
leaf = sha256("glasir:leaf:v1|" + keyHex + "|" + valueHashHex) glasir.ts:177-184
branch = sha256("glasir:branch:v1|" + leftHash + "|" + rightHash) glasir.ts:172An absent child hashes as EMPTY_ROOT (glasir.ts:168-169). Leaf and branch carry different
domain tags, so a leaf can never be presented as a branch with the same bytes.
bitAt(keyHex, depth) (glasir.ts:187-190) reads the depth-th bit of the hex key, most
significant first: byte depth >> 3, bit 7 - (depth & 7). 0 goes left, 1 goes right.
3.2 Why it is order-independent#
Two properties do the work:
- Path compression (
glasir.ts:105-116). A subtree holding exactly one leaf is that leaf, so depth is log2(N) in practice rather than the 256 the key length implies, and a tree of three accounts is three nodes deep rather than 768. When a second key lands in an occupied slot, a branch is created and both leaves are pushed down until their keys diverge — the split happens exactly where they differ, which is a function of the two keys and of nothing else. - Collapse only into a leaf, never into a branch (
glasir.ts:149-161). This is the subtle one and the comment records the failure: a leaf carries no depth in its hash, so lifting one up is invisible and restores exactly the shape the tree had before its sibling was inserted. A branch's children were chosen by the key bit at its own depth, so lifting a branch would put them at the wrong level and give a tree no fresh build of the same leaf set can reproduce. Collapsing branches made the root depend on deletion history — two nodes holding identical state disagreed because one of them had once seen an extra account.
The result is the property a replaying node depends on: the root is a function of the set of
(key, valueHash) pairs and of nothing else — not insertion order, not the shape some
particular sequence of writes produced. tests/integration/glasir.integration.test.ts:29 (same
root regardless of insertion order), :52 (returns to the previous root when an insert is
undone), :79 (a leaf cannot be passed off as a subtree) and :92 (agrees with a naive reference
on every random input) are the checks.
The tree also stays shallow on adversarially similar addresses, because the key is a hash of the
address rather than the address itself (glasir.ts:193-195;
tests/integration/glasir.integration.test.ts:121).
3.3 The dirty set#
The dirty set lives in YggdrasilLedger, not in the tree (YggdrasilLedger yggdrasil.ts:213). Every mutation
routes through mutable(), which adds to it; stateRootHex() calls flush(), which rehashes
exactly the dirty leaves and clears the set. flush returns immediately when the set is empty, so
asking for the root twice costs one cached read
(tests/integration/glasir.integration.test.ts:137).
Inside the tree, dirtiness is hashHex: undefined on a BranchNode (glasir.ts:47-48), set by
insert and remove on every node along the path and recomputed lazily by hashOf. A write is
therefore O(log N) hashes rather than O(N), against the O(accounts × ledgers) per block the whole
structure replaced (glasir.ts:10-15).
GlasirTree.from(entries) (glasir.ts:93-97) rebuilds from scratch; clear()
(glasir.ts:58-61) drops every leaf and is what loadSnapshot uses.
4. Charon — the mempool#
src/core/charon.ts. Transactions waiting to cross into a block.
4.1 Shape#
A flat Map<id, tx> (charon.ts:103) plus per-sender queues (bySender charon.ts:131). Each
SenderQueue (charon.ts:88-100) carries the aggregates the ordering needs:
earliestMs— the sender's position in the ordering, maintained on insert (insertcharon.ts:627) and on removal (charon.ts:384-389);settledNext— the first nonce this sender has not had settled by a block Charon has seen commit. Held per queue rather than in a pool-wide map so it is released with the queue; a map keyed by every address ever seen would be the same unbounded growth in a different field.
The aggregates exist because of a measurement. ordered() used to call an O(n) full-pool scan
from inside the sort comparator, making peek O(n² log n). On the audit's shape — 50 senders,
interleaved arrival — peek(100) over 8,000 queued transactions took 6,524 ms: twice the 3 s
block interval, so a producer could never catch up, and with nothing evicting it never recovered.
Same shape, same process, after the fix: 0.008 ms (charon.ts:79-86).
4.2 Ordering#
peek(maxCount) (charon.ts:182-194) does not remove. Senders are ordered by earliestMs, then
by compareBytes(address) (charon.ts:299-309); within a sender, by nonce, then by
compareBytes(id) (charon.ts:428-433). Only the queues actually consumed are sorted, and the
sender key is read, never computed inside the comparator.
Ordering by sender first is not a preference. The old flat comparator sorted same-sender pairs
by nonce and cross-sender pairs by timestamp, which is intransitive —
X#2@100 < Y@200 < X#1@300 < X#2@100 — and Array.prototype.sort given an intransitive
comparator is entitled to return a sender's nonces backwards (charon.ts:302-307).
compareBytes, never localeCompare; see §11.
4.3 Bounds#
| Bound | Default | Line | Rationale as recorded |
|---|---|---|---|
maxTransactions | 8,192 | charon.ts:75 | ~4 minutes of backlog at a 3 s target and 100 tx/block. Measured: a full pool holds 8,192 entries in 4.3 MB of heap — 531 bytes an entry, transaction bodies included. Unbounded, an audit reached 250,000 entries and 115 MB without a complaint. |
maxPerSender | 64 | charon.ts:76 | one account cannot occupy more than 0.8% of the pool, so filling Charon takes at least 128 distinct funded accounts rather than one loop |
journalSize | 256 | charon.ts:77 | how many drop events stay in memory |
All three are floored at 1 in the constructor (charon.ts:120-122).
4.4 Admission#
add() (charon.ts:133-169), in order: duplicate id; timestamp not an integer, negative, or past
MAX_TIMESTAMP_MS — "dead on arrival", because stateless validation bounds timestamps so such a
transaction can never be sealed; nonce below the sender's settledNext, which is spent and can
never apply, so holding it is pure occupancy; sender queue full; pool full.
Above Charon, BlockchainCore.addTransaction (src/core/blockchain.ts:7391) runs, in order:
assertRecordFitsABlock (:2219, see §5.4);
stateless validation; ledgers.validate with the settled nonce substituted (so the entry rule
and the token rules are checked without the nonce); tx.nonce === projectedNonce; then the
available balance on that ledger covering everything the sender already has queued on that
same ledger plus this one. Summing across tokens would let a sender over-draw a non-STR ledger
while looking solvent (charon.ts:232-238).
The size gate is first, and a transaction needs it for a reason a record does not. payloadHashHex
is the one free-length field a transaction carries and nothing validates it: not
validateTransactionStateless, which checks every other field's shape, and not the network
decoder, which does String(raw.payloadHashHex). Its name says hash and its type says string, and
the type is what the chain enforces. So a sender can sign a transaction carrying a 400 KB
payloadHashHex, the id binds it, the signature verifies, Charon sorts it by timestamp — and an
old one sits at the head of the batch and breaks the transaction loop on every block for the
life of the node (blockchain.ts:2211-2218). MAX_RECORD_BYTES at this door is the only thing
between that field and a permanently wedged producer. The MAX_RECORD_BYTES docstring 1,700
lines above says the opposite — that a transaction is "already bounded by its own shape … by
payloadHashHex being a hash" (blockchain.ts:470) — and the door is right and the docstring is
wrong; see §12.4.
4.5 Nonce contiguity and eviction#
projectedNonce(address, settledNonce) is settledNonce + pendingFrom(address)
(charon.ts:257-259) — it counts entries rather than inspecting them. Without it a sender
could only ever have one transaction in flight, because the canonical nonce does not move until a
block seals. It is sound only while a sender's queued nonces are contiguous from the settled nonce
upward, which is what the eviction policy exists to protect.
worstEntry() (charon.ts:329-360). The policy is the highest nonce of the largest queue — a
queue tail, never a head.
Evicting the oldest entry is wrong. A sender's queued transactions form a chain from the settled
nonce upward, so removing a low nonce strands every higher one behind a gap they can never cross.
Worse, because projectedNonce counts rather than inspects, after such a gap it hands the sender a
nonce that is already queued: the next transaction collides and the account is wedged. A tail
carries nothing — dropping it leaves the queue contiguous and moves the projected nonce back to
exactly the value the sender should resubmit.
The largest queue is chosen so a flood displaces its own transactions before anyone else's. Ties
break toward the sender furthest from inclusion (latest earliestMs, then greatest address), so
the choice is deterministic and never lands on the batch about to be sealed.
The incoming transaction is considered as if already inserted (charon.ts:344-349, :353). If the
newcomer is itself the worst entry it is refused rather than admitted (charon.ts:157-162):
evicting someone else to admit a transaction we would evict next is strictly worse, and this way
the flooder pays for its own flood.
4.6 The drop journal#
Every way a transaction leaves other than being sealed is journalled (charon.ts:405-424):
| Kind | Meaning | Raised by |
|---|---|---|
rejected | refused at the gate; add() threw with this reason | refuse(), charon.ts:399-403 |
evicted | was in the pool, removed to make room | drop(..., 'evicted'), charon.ts:163 |
expired | was in the pool, can never apply | expireBelow charon.ts:437 |
committed is the fourth disposition and is deliberately not journalled (charon.ts:392):
the block is the record.
Each event carries a monotonic seq, so a reader that sees a gap knows it missed events rather
than guessing (charon.ts:27). The journal is bounded and drops from the front
(record charon.ts:683); stats().eventsRecorded is the true total and recentEvents() is what
survives. Observers are notified inside a try/catch and a throwing observer is counted in
observerFailures rather than swallowed or allowed to take the pool down
(charon.ts:419-423).
The rule the journal encodes: a transaction that vanishes with nobody able to say why is
indistinguishable from theft (charon.ts:13-14).
4.7 Commit and sweep#
commit(txs) (charon.ts:202-213) removes sealed transactions and then, per sender, calls
expireBelow(from, highestSealedNonce + 1n). A sealed nonce retires every lower nonce still
queued for that sender; without the sweep those entries sit in the pool until the process dies,
because nothing else would ever remove them. acceptBlock calls commit(block.transactions)
(blockchain.ts:2554) so a follower sweeps on a block it did not produce.
5. The block lifecycle and the four execution sites#
This is the most important section here, and the reason is stated four separate times in the
source: four copies of a rule is how a producer and its own replay come to disagree
(ledger-manager.ts:249-252, ledger-manager.ts:264-266, blockchain.ts:3923,
blockchain.ts:3289). docs/BUILD_STATUS.md:356-360 records that two parity failures were found
and fixed this cycle, and asks an auditor to enumerate every rule against every site, "or the sites
should be collapsed into one".
5.1 The four sites#
| Site | Entry point | What it is |
|---|---|---|
| P produce | produceBlock, blockchain.ts:1750 | assembles and seals a block. May refuse an individual record and seal the rest. |
| A accept | acceptBlock, blockchain.ts:2503 | applies a block from somebody else that extends the head. Must apply exactly what was sealed, or reject the block. |
| R replay | replayChain, blockchain.ts:3113, exposed as validateChain() (:3066) and validateState() (:3086) | re-derives every hash, link, balance and root from genesis into a throwaway LedgerManager. |
| T trial | tryBestFork, blockchain.ts:2791 | fork choice. Builds the candidate branch in a throwaway BlockchainCore (:2808), running A on every block and then R once. |
T is A followed by R, by construction, so it inherits every rule both enforce. The one thing T
must get right on its own is that the throwaway core is built with this node's mode and declared
validator set (blockchain.ts:2808-2819): it used to inherit neither, so it was a development
chain with an open producer set, a branch of unauthorised blocks replayed cleanly, and the reorg
went through. The one place fork choice actually executes a branch was the one place the validator
set was not consulted.
offerBlock (blockchain.ts:11051) is the peer entry point rather than a fifth site: it calls A
when the block extends the head, and otherwise checks the block on its own merits
(verifyBlockOrdering when the parent is known, verifyBlockSelfConsistency when it is not, both
at blockchain.ts:2739) plus authorisation (:2747) and turn (:2751), then hands it to the fork
pool and runs T. Holding a parentless block is deliberate — gossip does not promise order, and a
node that refuses everything it cannot immediately link can never assemble a competing branch,
which is the same as having no fork choice arrived at by a different route
(blockchain.ts:427-433).
The rollback discipline is identical at P and A: ledgers.snapshot(), domains.clone(),
feeless.snapshot() and postMinedMinor are captured before anything applies
(blockchain.ts:1818-1823, :2529-2531) and restored on any failure (:2215, :2648). A
partially applied block is worse than a rejected one, because it is invisible.
5.2 Rule x site#
OK enforced. -- not applicable at that site, because P constructs the value rather than
checking it. GAP means not enforced, and worth an auditor's attention. Bare :NNN are
src/core/blockchain.ts, all taken in one pass while that file was 4,239 lines; the rule
named in each row is the anchor, and grep finds it after the file moves.
| # | Rule | P | A | R | T |
|---|---|---|---|---|---|
| 1 | declared height equals chain length | -- | OK :2569 | OK :3318 | OK |
| 2 | links to the parent hash | -- :2312 | OK :412 | OK :3321 | OK |
| 3 | height = parent + 1 | -- | OK :415 | OK (index) | OK |
| 4 | producedAtMs finite and >= 0 | -- | OK :456 | OK :3336 | OK |
| 5 | producedAtMs <= MAX_TIMESTAMP_MS | GAP | OK :459 | OK :3339 | OK |
| 6 | producedAtMs <= now + 120 s | -- (clamps, :1802) | OK :462 | deliberately not | OK via A |
| 7 | not stamped before the parent | -- (clamps, :1802) | OK :424 | OK :3342 | OK |
| 8 | txRootHex matches the transactions | -- :2283 | OK :465 | OK :3345 | OK |
| 9 | recordsRootHex matches all seven record kinds | -- :2316 | OK :470 | OK :3348 | OK |
| 10 | a header naming a proof carries it | -- | OK :475 | OK :3351 | OK |
| 11 | hashHex matches the contents | -- :2345 | OK :478 | OK :3354 | OK |
| 12 | PoE proof bound to this block | ~ verifyPoEProof :2262 | OK verifyPoEProofForBlock :484 | OK :3360 | OK |
| 13 | producer signature authenticates the header | -- :2329 | OK :488 | OK :3368 | OK |
| 14 | producer authorised at this height | OK :1841 | OK :2582 | OK :3378 | OK |
| 15 | producer is the leader of its slot | OK :1871 | OK :2587 | OK :3387 | OK |
| 16 | attestations verify | -- (seals []) | GAP | OK :3400 | OK via R |
| 17 | Styx shape screen: governance / wNFT / collateral | GAP (submit only: :941, :961, :974) | OK :2648, :2672, :2685 | GAP | partial |
| 17b | Styx shape screen: wrap records | OK :2171 | OK :2658 | GAP | partial |
| 18 | per-record gas <= 10,000,000 | OK :2056 | OK :2622 | OK :3464 | OK |
| 19 | block gas <= 60,000,000 | OK :2058 | OK :2625 | OK :3469 | OK |
| 20 | contract caller holds a proved domain, or is a contract | OK :2054 | OK :2616 | OK :3460 | OK |
| 21 | serialised block <= 400,000 bytes | OK :1929, :2374 | GAP | GAP | GAP |
| 22 | transaction stateless validity | OK :2251 | OK :2699 | OK :3562 | OK |
| 23 | transaction signature | OK (inside :2251) | OK batched :2693 | OK batched :3555 | OK |
| 24 | transaction stateful validity (domain, nonce, balance) | OK :2257 (skips the sender) | OK :2703 (rejects the block) | OK :3568 (rejects the chain) | OK |
| 25 | allocations applied | OK applyAllocation :1987 | OK applyAllocation :2599 | ~ hand-rolled :3413 | OK |
| 26 | registrations applied | OK applyRegistration :2005 | OK :2603 | OK :3438 | OK |
| 27 | collateral records applied | OK :2136 (left queued on failure) | OK :2649 (strict) | OK :3501 (strict) | OK |
| 28 | wrap records applied | OK :2172 (dropped on failure) | OK :2659 | OK :3513 | OK |
| 29 | governance folded, then expire(producedAtMs) | OK :2206, :2219 | OK :2674, :2676 | OK :3527, :3538 | OK |
| 30 | wNFT records applied | OK :2230 (refused individually) | OK :2686 (strict) | OK :3545 | OK |
| 31 | post-mining minted from measured gas | OK :2071 | OK :2640 | OK :3391 | OK |
| 32 | seating observed after the block | OK :2450 | OK :2758 | OK :3541 | OK |
| 33 | committed root equals the local root at H - 3 | -- :2320 | OK :2718 | OK :3580 | OK |
| 34 | transactions applied in block order | OK :2270 | OK :2705 | OK :3572 | OK |
Notes on the rows that are not plain ticks:
- Row 12. P verifies the proof it has just built (
verifyPoEProof), not the block-bound form. It built that proof from this block's own transactions and root, so the two coincide; a second implementation should still prefer theForBlockvariant, because "verifies standalone" is exactly the weaker predicate that once let a 3-transaction block ship a proof over 0 transactions with a garbage merkle root and pass (blockchain.ts:475). - Row 24 — P differs on purpose. A producer may skip a transaction; a follower may not. When a
transfer fails stateful validation at P the sender goes into
blockedSenders(blockchain.ts:2203) and the rest of that sender's batch waits. This used to be abreak, which wedged production permanently: a peer's block advances a sender's nonce past a transaction this node still holds, that transaction sorts first by timestamp, fails forever, and every healthy transaction behind it is never included — the node produces empty blocks for the rest of its life. The comment always said "skipping the rest of that sender"; the code did not. - Row 25. Registrations were collapsed into one
applyRegistrationafter the replay was found to be a diverging fourth copy (blockchain.ts:3286-3299). Allocations were not: P and A callapplyAllocation(blockchain.ts:18710), R hand-rollsverifyDomainClaim+replayDomains.allocate(blockchain.ts:3274). They agree today only becauseStrDomainRegistry.allocateis itself idempotent for the same holder (src/identity/str-domain.ts:334-341). The structural risk the registration fix removed is still present here. - Rows 27 and 28 — the deliberate asymmetry. A collateral record that will not apply stays
queued and is retried, because a bridge confirmation is money that has already moved on another
network: refusing to seal it is a delay, discarding it is a loss (
blockchain.ts:2023-2025). A wrap that will not apply is dropped, because nothing has moved — the STR is still the holder's, sitting where it was — and the ordinary failure is a nonce consumed by a transfer in the same block, which will not apply any better next block (blockchain.ts:2089-2097). For the same reason there is deliberately norequeueDisplacedWrap(blockchain.ts:2959): the rollback that discarded the branch also released the holder's nonce, so the record is signed for a nonce the holder no longer has.
5.3 The two parity failures fixed this cycle#
Both landed in commit f33b215, and both have the same shape: a rule one site enforced and another
did not.
produceBlocksealed identity records it had refused to apply. The refusal-aware loops filled locals; the block was then built fromthis.pendingAllocations/this.pendingRegistrations— the whole queue, including every record examined, refused and rolled back. Reproduced: one wallet claimsSTR.alphaandSTR.betawith only enough STR to lock one. The producer applies alpha, refuses beta, and seals both. Every follower rejects the block, and the producer's ownvalidateChain()rejects its own chain, because a replay refuses what the producer refused. Permanent, unrecoverable split at height 2 for the price of two signed claims. Fixed atblockchain.ts:2246.- Block timestamps were enforced at ingress and by nothing in replay. A node could hold a chain
its own
validateChain()accepted and every peer refused. The deterministic half of the rule is now repeated in the replay (blockchain.ts:3194-3201); the clock-relative half is deliberately not — see section 7.
Two earlier fixes of the same shape are worth knowing, because they show the failure recurring
rather than being closed once. The contract caller gate held at three sites out of four until
bd48ef1 — "a rule that a restart does not enforce is a rule an attacker only has to outlast"
(blockchain.ts:3317-3322) — and the in-turn check reached the replay only in 6c7f981
(blockchain.ts:3243-3247).
5.4 Production: what a producer refuses, and what it seals#
produceBlock runs inside one try with a full rollback taken at blockchain.ts:2463 and the
try opening at :2561. Before that it refuses four things outright: sealing in production mode
without supplied producer keys (:2366), sealing a block this chain would not accept (:2387),
sealing a timestamp that is negative or past MAX_TIMESTAMP_MS (:2436, :2439), and sealing out
of turn (:2456). Each is a loud failure at the moment of misconfiguration rather than a silent
one at every block after it — a production validator that could not seal used to sit at
height 0, produced 0, needsAttention false and call itself healthy.
The order of operations inside the try is fixed, and every other site uses the same one:
allocations, registrations, contract records, collateral, wrap, governance,
governance.expire(), wNFT, transfers.
Each position has a reason. Identity settles before transfers so a domain proved in this block can
be paid in it; $TR settles before transfers so a deposit arriving in this block can be spent in it;
Echo settles after the bridge for the same reason; governance folds before transfers so a passed
parameter change is in force for them; expire() runs once per block after this block's records,
because expiry is caused by time rather than by a record and needs a point every node reaches
identically.
Two budgets are spent as records are added, rather than checked after assembly:
MAX_BLOCK_GAS = 60,000,000(src/core/blockchain.ts:312) overMAX_RECORD_GAS_LIMIT = 10,000,000per record (blockchain.ts:303). The per-record ceiling is measured: at ~6.4 ns per gas unit, a single record declaring 1e9 gas took 5.7 s to produce, 6.2 s to accept on every follower and 6.6 s on every fullvalidateChain(); thirty-two records at 1e8 in one block took 20.4 s. The most expensive template entry point measured 3,380 gas, so ten million is generous and bounds one record at roughly 60 ms.MAX_BLOCK_BYTES = 400,000(blockchain.ts:335), lessBLOCK_ENVELOPE_HEADROOM_BYTES = 16,384(blockchain.ts:438) reserved for the header, hash, attestations and JSON envelope. The headroom is itself measured, not chosen: the running budget counts records only, and without the reserve an assembled block ran 1,127 bytes over a budget built right up to the limit (blockchain.ts:2489-2493). The block limit exists because a producer sealed a 729,810-byte block against a 523,235-byte frame ceiling using only legal records inside every published bound, and nothing reported it: over real TCP the producer reached height 11, its follower stopped at 4, gossip threw on encode, sync refused the frame while still counting it as served, and both nodes reported a valid chain withneedsAttention: false.
Both identity loops spend the byte budget too, and did not until this cycle. Measured on this
branch: 1,024 queued allocations at 411 bytes each beside 90 registrations at 518 bytes each
assembled a 470,002-byte block against the 400,000 limit, using entirely legal records — so the
"unreachable" backstop below was reachable, and it fired after the ledger had been mutated and
the mempool committed (blockchain.ts:2583-2590).
The record bound, and why the block bound alone was a wedge#
MAX_BLOCK_BYTES bounds the block. Nothing bounded the record, and that is what made the block
bound a wedge rather than a cut-off (blockchain.ts:441-474).
produceBlock spends a running budget and stops at the first record the remaining budget cannot
cover (fits(), blockchain.ts:2529), leaving it queued. That is right for a record that does
not fit this block and permanently wrong for one that fits no block: the budget resets to full
on every block, so a record larger than it is skipped at index 0 forever and everything behind it
in the queue starves. Measured on this branch: one 420,653-byte deploy record queued ahead
of an ordinary one produced 2 queued, 0 sealed across five blocks — and it survived a restart,
because the queue goes into chainSnapshot() and comes back through submitContractRecord.
So the rule is split, and each half is enforced where it is true:
- At the door.
assertRecordFitsABlock(src/core/blockchain.ts:1831), overrecordFitsABlock(:485), refuses a record no block could ever carry, with a message carrying the measured size and the budget and saying explicitly that this is not a "try again later". It never occupies a queue slot. - In the loop.
fits()makes a record that does not fit this block wait. It is unchanged, still queued, and the next block starts with an empty budget it is known to fit inside.
MAX_RECORD_BYTES = MAX_BLOCK_BYTES - BLOCK_ENVELOPE_HEADROOM_BYTES (blockchain.ts:475), which
is 383,616 — arithmetic over the two constants above, not a measurement.
The two halves depend on each other, and the code says so at the break
(blockchain.ts:2519-2528, :2668-2685): the loop's break is only safe because the door refuses
the permanent cases, and the door's refusal is only tolerable because a record that merely arrived
at a busy moment is not refused by it. continue would be wrong on its own terms as well — the
drain below splices the first n considered entries, so skipping one would splice records the loop
never looked at, and contract authorisations are nonce-ordered per caller.
The gate is on all ten submit doors: submitContractRecord (:1023), submitGovernance
(:1204), submitWnft (:1225), submitCollateralRecord (:1239), submitWrapRecord (:1273),
submitDomainBurn (:1318), submitWnftTransfer (:1372), submitAllocation (:2047),
submitRegistration (:2095) and addTransaction (:2173) — including the kinds already
bounded by their own shape, because "this kind happens to be bounded today" is a property of a
shape someone may widen, and a gate that is only on some doors is the defect shape this file has
been bitten by repeatedly. (For transactions the "already bounded" reading is not merely fragile,
it is false today: see §4.4.)
The gas twin of the question is safe for the reason the byte one now is, and by arithmetic rather
than by habit: MAX_RECORD_GAS_LIMIT (10,000,000) is below MAX_BLOCK_GAS (60,000,000), so
contractGasGate at the door already refuses every record that could not fit an empty block.
Assembly, backstop and drainage#
A record that does not fit is not taken: it stays queued and goes in the next block, which is
what a full block is supposed to mean. Checking after assembly and throwing is the wedge pattern
this file has been bitten by twice — a queue whose records together exceed a limit throws on every
block forever (blockchain.ts:2483-2488). The backstop at blockchain.ts:3167-3182 restores the
node exactly as it was found before throwing, because it used to sit after mempool.commit(txs)
and after the ledger had been mutated: it destroyed the transactions it was protecting, and then
threw identically on every later produceBlock().
Queue drainage is by records considered, not records sealed (blockchain.ts:3184-3221).
Splicing by the sealed count leaves a refused record at the head to be re-refused on every block for
the life of the node. Refused records move to refusedContracts (blockchain.ts:3384),
refusedIdentity (:949), refusedWrap (:913) or refusedCollateral (:979), so a submitter
can be told; a record that vanished with no trace is the other half of the same failure. Collateral
is the exception: only sealed references leave the queue (blockchain.ts:3209-3210).
5.5 Acceptance#
acceptBlock (src/core/blockchain.ts:10457) is three stages, cheapest first: ordering from the
block alone (:3401-3420); execution against a snapshot (:3424-3573); then the committed root
(:3575-3588). Its rule everywhere is the opposite of the producer's — a record already in a
sealed block is not a request this node may decline; it must apply exactly as the producer applied
it, or the whole block is rejected (blockchain.ts:3496-3499, :3512-3514, :3523-3527,
:3536-3540).
Signatures are verified for the whole block at once across cores
(batchVerifyTransactionSignatures src/core/transaction.ts:426) and each transaction is then
re-validated with signatureAlreadyVerified: true (src/core/transaction.ts:121), which skips the
arithmetic and not the rule: the id must still bind the contents and the key must still derive the
sender. Signature verification is 82% of the cost of accepting a block; verifying is a pure
predicate, so batching changes the speed and nothing else. Applying the transactions stays strictly
in order, because that is what decides the state root (blockchain.ts:3557-3566). Measured on one
machine (2026-09-21, Windows 11 / Node 22.14.0 / Intel Core i9-14900KF): a follower accepts 10 x
512-transaction blocks at 21.08 ms/block, 24,284 tx/s (holocron/RESULTS.md,
npm run bench). This is a single-process figure, not network throughput. Until 2026-11-17 this
read 17.1 ms/block and 29,906 tx/s, undated and hostless; that figure was withdrawn on 2026-09-21
because it does not reproduce, and the line it cited no longer carries it.
Attestations are stripped, not grounds to refuse#
The last thing acceptBlock does before the push is keepVerifiedAttestations
(blockchain.ts:3612, defined at :4369), and it is placed exactly where it is for a reason the
code states: everything above that line could still refuse the block; nothing below it can
(blockchain.ts:3608-3611).
This is the single enforcement point for attestations, and dropping is the enforcement. It is
called on admission and again on restore (blockchain.ts:2027), takes the seating as a parameter,
and keeps only what admissibleAttestations can verify against the block hash and against the
seating at that height. No seating for a height means keep nothing — fail-closed, because "I
cannot say who was seated" is not "everyone is admissible". Nothing that decides anything is lost:
attestations are evidence, they are in no state root, and they do not gate settlement.
The defect it closes was live and cheap. The rule used to live in replayChain and nowhere else.
acceptBlock never looked at block.attestations, attestations sit outside the block hash by
design, and they survive the wire (serializeBlock / deserializeBlock,
src/storage/mimir.ts:994, :1030, reached from
parseWireBlock src/network/protocol.ts:1078). So a peer could take an honest block off the gossip, append one
fabricated attestation — the hash still matched — and offer it; acceptBlock took it, and from
that moment the node's own validateChain() answered "block N carries an attestation that does not
verify" for the rest of that chain's life. One worthless signature, and a node could never
validate its own chain again. The one site that enforced the rule was the one site that cannot
refuse a block, only condemn the whole chain.
Why drop rather than refuse. Nothing signs how many attestations a block carries, so two honest nodes holding the identical block legitimately hold different sets of them — whatever gossip reached each. A rule that refused a block over its attestations would have to refuse only the invalid ones, never absent or fewer ones, and even then it would hand an attacker a cheap way to make an honest block unusable to whichever nodes hear the attacker's copy first. Dropping has neither problem: it is monotone, it converges — every honest node removes exactly the junk and keeps exactly what was real — and it leaves block validity a function of hashed content alone, which is the only thing a producer's signature covers.
The other half of the repair is that replayChain now deliberately does not ask, and the long
comment where the check used to be says why (blockchain.ts:4600-4622). That is a statement about
what a chain is, not a convenience: the block hash covers the header, the transactions and the
records and does not cover the attestation list, so a verdict on the chain that read the list would
be a verdict depending on which gossip arrived and on bytes anyone who can write the snapshot file
may choose. What replaces it is an invariant maintained at every door — acceptBlock and
restoreSnapshot both drop what they cannot verify — so nothing unverified is on the chain for a
replay to find.
After the push#
dropSettledIdentity (blockchain.ts:10200, called at :3613) removes queued identity records
the block settled, matched on the name rather than on record equality: two nodes can hold
byte-different claims for one domain, and once the chain holds the name every one of them is settled
or refused. That is structural rather than best-effort because a queue that only drains on a local
seal is a queue that grows on every node that is not the leader — twelve out of thirteen of them at
any instant.
5.6 Fork choice and reorganisation#
offerBlock, then resolveForks, then tryBestFork, at most MAX_FORK_ATTEMPTS = 4 branches per
offer (blockchain.ts:387). Each attempt costs a full trial replay, so this bounds what a single
peer message can make a node do; rejected branches stay rejected (blockchain.ts:2825), so a
poisoned pool drains over a few offers rather than being re-tried on every block that follows.
The rebuild is a full replay from genesis in a throwaway core, never an undo
(blockchain.ts:2619-2624): undo has to invert every effect a block had, and anything it forgets to
invert survives into the new chain as state nobody can account for. Replaying is O(chain) and
obviously correct, and a reorg is rare.
On adoption the winning branch's state is taken whole from the trial: chain, ledgers, domains,
Feeless Pool books, postMinedMinor, seating and trailing roots
(blockchain.ts:2854-2875). The seating in particular is taken whole rather than rewound and
patched, because an anchor "corrected" in place would be a seating derived from one branch answering
for a block on another. Displaced blocks are offered back to the fork pool so the old branch can win
back, and their records are re-queued per kind: governance (:2911), contracts (:2940), wNFT
(:2949), collateral (:2973, only where the reference is not already spent on the winning
branch).
5.7 Settlement#
requiredConfirmations is a getter, not a captured number (blockchain.ts:542-550), so a passed
governance proposal is actually obeyed; it is floored at DEFERRED_DEPTH + 1. The constructor
refuses a configured depth at or below DEFERRED_DEPTH (blockchain.ts:1861-1864): at or under it, a
block would be called settled in the same breath as the first check of its execution result.
finalizedHeight() (blockchain.ts:13265) computes head - depth + 1 and ratchets — the answer
is never lowered. Governance may raise the depth from 12 to 24, and without the ratchet that would
silently un-settle every block between the old line and the new one: a merchant who took payment
at 12 confirmations, under the rule in force when they took it, would have that settlement reopened
by a vote they were not party to. It is called when a block lands (blockchain.ts:2382, :2691)
rather than when someone asks, because a ratchet that only advanced on a read would record nothing
at all at the exact moment it exists to protect.
The resolver is handed the depth and the floor as thunks (blockchain.ts:1329) so the chain and
fork choice can never hold two different depth lines. The depth alone was not enough: the chain
kept the floor and the resolver recomputed without it, so a governed depth increase let the resolver
rewrite a block the chain was still calling settled.
6. Deferred execution#
DEFERRED_DEPTH = 3 (blockchain.ts:201).
A block header's stateRootHex is not the root after that block. It is the root as of
height - DEFERRED_DEPTH. Consensus agrees on ordering first; the execution result is committed
three blocks later.
6.1 What the root at height H actually commits to#
committedRootFor(H) (blockchain.ts:3602) returns rootAtHeight(max(0, H - 3)). rootAtHeight
(blockchain.ts:3608) answers from three places, in this order:
- height 0, from
genesisStateRootHex— held separately because it is the one root that is always derivable, a pure function of the genesis spec, and it is what every block inside the first three heights commits to (blockchain.ts:512-520); - the in-memory
recentRootswindow; - otherwise, the header at
H + 3, because the root after H is carried by that header.
The chain therefore stores every root older than the window, and only the trailing window has to be
remembered. recordRoot (blockchain.ts:16823) keeps a little more than the window: it evicts below
height - 2 * DEFERRED_DEPTH, six heights.
Concretely, for the block at height H the committed root is the eleven-entry
LedgerManager.stateRoot() taken after executing every block up to and including H-3: every
transfer, every identity record, every contract record and its post-mining mint, every collateral
and wrap movement, every governance effect. It commits to nothing that happened in blocks H-2,
H-1 or H.
In the replay this is the check at blockchain.ts:3441:
header.stateRootHex === replayRoots[max(0, index - 3)], where replayRoots[i] is
replay.stateRoot() taken after block i (blockchain.ts:3436). Block zero is consistent with
this: initGenesis seeds the allocations, computes the root and records it at height 0
(blockchain.ts:3469), then puts committedRootFor(0) — which is that same root — into the genesis
header (blockchain.ts:3491).
6.2 Why#
Recorded at blockchain.ts:183-197:
- A peer can accept and relay a block without executing it. Linkage, transaction root, records root, block hash, producer signature and the PoE proof are all checkable from the block alone, so execution leaves the propagation path — which is where it costs latency on every hop.
- Execution gets a whole block interval instead of the tail of one. Ordering no longer waits for it, so the two proceed in parallel rather than in series.
- It cannot be retrofitted. It changes what a header means, so it is a decision that has to be made before there is a chain to be compatible with.
6.3 What it costs, stated plainly#
Block N no longer commits to its own execution. A producer that executes incorrectly at height H is
caught at H + 3, not immediately. Settlement must therefore sit strictly deeper than the lag, which
the constructor enforces rather than leaving to configuration (blockchain.ts:1337), and
tests/integration/deferred-execution.integration.test.ts:161 guards.
Two consequences a second implementation has to get right:
- A contract reads the height of the block it is IN, never H-3. The lag is on the commitment,
not on the read. Reading H-3 would unlock a time-lock three blocks early and make a contract
disagree with itself across a reorg boundary (
blockchain.ts:2566-2571,src/core/contract-state.ts:161-166). - The producer set that governs a block at H is the set committed by state at H-3
(
blockchain.ts:3512-3528). Not the set at H — that state is committed by nothing yet, so a rule reading it would be a rule about state the chain has not agreed on, and two honest nodes could reach different answers for the same block. And not what the node holds now, because membership has to survive a reorg: a block authorised when it arrived must still be authorised when it is replayed, which is only true if the answer is a function of the branch the block sits on.Gladsheimquantises the answer to epochs ofVALIDATOR_EPOCH_BLOCKSanchored atepochStart - DEFERRED_DEPTH, so the set is only allowed to move at heights every node already agrees on; without that, Tyr'sleader = roster[slot mod n]would renumber every future assignment and a producer that was the lawful leader when it started assembling would not be the leader by the time its block was judged.
The practical cost is that a validator admission takes three blocks to bind. That is the same lag execution already has, and it is stated rather than worked around.
The tests that pin the behaviour are
tests/integration/deferred-execution.integration.test.ts:63 (names the root as of
height - DEFERRED_DEPTH), :82 (the earliest blocks commit to the genesis root), :136 (rejects
a chain whose committed root does not match the replay) and :149 (names the height whose execution
actually disagreed).
7. Timestamps: the chain's clock#
header.producedAtMs is not a display field. governance.expire() and every timelock maturity
check run against it, contract execution takes its atMs from it, wNFT records apply against it,
and Norn's density fork choice ranks branches by the slots it implies (blockchain.ts:274-282).
It used to be checked by nothing at all — not against the parent, not against a clock, not even for
sign. A producer could seal one block dated far in the future and, on every honest follower that
accepted it: mature and execute a passed governance proposal instantly, defeating the 7-day and
30-day timelocks that are the central governance safeguard; expire every open proposal, which is
single-validator censorship of governance; score a private branch at density 1.0 against an honest
chain's real gaps, inverting the defence so the honest chain is punished for reporting its gaps
truthfully; and make minimumChainDensity iterate the implied slot range, which at a year-3000
timestamp is hours of blocked event loop per offered block.
7.1 The four rules#
| Rule | Value | Where |
|---|---|---|
| finite and non-negative | — | blockchain.ts:450 (ingress), :3194 (replay) |
| absolute ceiling | MAX_TIMESTAMP_MS = 32_503_680_000_000 — year 3000 (src/core/transaction.ts:11) | blockchain.ts:453, :3055 |
| monotonic against the parent | equal is allowed | blockchain.ts:418, :3203 |
| drift bound | MAX_BLOCK_DRIFT_MS = 120_000 (blockchain.ts:292) | blockchain.ts:456, reached only when a caller supplies nowMs |
Equal is allowed on purpose: two blocks can be sealed inside one millisecond, and refusing that
would refuse an honest producer under load (blockchain.ts:417). Monotonicity is not cosmetic —
several time-based rules subtract producedAtMs from a stored time as an unsigned integer, so the
staking and vesting templates revert with an arithmetic underflow for as long as a block carrying a
rewound clock is the head, which is a chain-wide freeze of every stake, claim and release.
Two minutes is generous against a 3-second block target and still small enough that the timelock and
density attacks are worth nothing. It is deliberately a tolerance rather than an equality: nodes
do not share a clock, and a bound tight enough to require that would reject honest blocks whenever
NTP drifted (blockchain.ts:287-291).
The same absolute ceiling applies to transactions (src/core/transaction.ts:147-149), and Charon
refuses one outside it at the door, because such a transaction can never be sealed
(charon.ts:139-142).
7.2 Why the drift bound must not be in replay#
verifyBlockSelfConsistency takes nowMs as an optional parameter (blockchain.ts:434-437)
and applies the drift bound only when one is supplied. Live ingress supplies it — acceptBlock at
blockchain.ts:2513 and offerBlock at :2739, both Date.now(). The replay does not, and
re-states the deterministic rules inline instead.
The reason is at blockchain.ts:3193: a replay must reach the verdict the accepting node reached,
however long afterwards. A rule that consulted Date.now() during replay would make a chain's
validity depend on when it was checked, and every chain would eventually stop validating just by
getting old.
The absolute bounds are different in kind and therefore apply everywhere, replay included: a block
outside them was never valid, and must not become valid by being old (blockchain.ts:444-451).
tests/integration/block-timestamp.integration.test.ts:158 is the check — "does not apply the drift
bound during replay, so validity cannot depend on when it is checked" — and :85 is its
counterpart, "enforces the deterministic half of the rule in replay too".
7.3 The producer-side clamp#
blockchain.ts:1799-1804:
const requestedAtMs = opts.producedAtMs ?? Date.now();
const producedAtMsForBlock = this.chain.length === 0
? requestedAtMs
: Math.max(requestedAtMs, this.head.header.producedAtMs);Date.now() is not monotonic: one NTP correction, a VM resume or a suspended laptop steps it
backwards. A producer would then seal a block every peer refuses with "stamped before its parent" —
while keeping it, extending it, and reporting its own chain valid. A validator can drift off the
network permanently that way with a clean health report.
It clamps rather than throwing, because the producer has done nothing wrong: its clock has. An
explicit opts.producedAtMs is clamped too, because a caller passing a stale stamp is the same
defect arriving through a different door, and tests that seal a batch at one instant stay legal
because equal is allowed.
The clamped value is used for everything in the block: the header, contract execution's atMs, the
governance fold and expire(), and the PoE proof's createdAtMs (blockchain.ts:1970, :2143,
:2156, :2226). this.applyingAtMs is set from it (blockchain.ts:1970) so the Feeless Pool
timestamps its movements with the block time rather than with Date.now(): two nodes replaying the
same chain must write the same movement log (blockchain.ts:615-619).
The clamp is not a ceiling. A caller that passes a producedAtMs beyond MAX_TIMESTAMP_MS seals a
block that every peer and its own replay reject — see section 12.
8. The Merkle transaction root#
computeTxRoot (blockchain.ts:16978).
empty block: sha256("str-tx-leaf-v1|empty")
leaf: sha256("str-tx-leaf-v1|" + tx.id)
node: sha256("str-tx-node-v1|" + leftHex + rightHex) // the two hex strings, concatenatedTags at blockchain.ts:3715-3716. A leaf and an interior node must never hash the same bytes, or an
attacker can present an interior node as a leaf and claim a transaction the block does not carry —
the classic second-preimage attack on an untagged Merkle tree, and the reason Bitcoin's untagged
tree needed a separate rule to survive it.
The empty-block root is a constant with its own tag rather than the hash of an empty string, which is easy to produce by accident elsewhere.
Odd levels duplicate the last node; they do not promote it (blockchain.ts:3748). Promotion
makes trees of different shapes collide — a two-leaf tree and a three-leaf tree whose third leaf
equals its second produce the same root — and a root two different blocks can share is not a
commitment. Duplicating costs one hash per odd level and closes it.
This replaced sha256(canonicalStringify(ids)), a flat hash of the whole list. That committed to the
transactions correctly and could not do the one thing a transaction root exists for: prove that one
transaction is in a block without handing over every id in it. A light client could follow the chain
and never verify a payment. The PoE field beside it has been called merkleRootHex the whole time,
which made the gap easy to miss. It was changed in this cycle deliberately, because the root is
inside the signed header: after launch, changing its construction is a hard fork that breaks every
wallet, bridge and exchange integration built against it.
8.1 Inclusion proofs#
txMerkleProof(transactions, index) (blockchain.ts:3770) returns
{ siblingHex, siblingIsRight } per level, where siblingIsRight is true when the running digest
is the left child. At an odd level the last node's sibling is itself
(Math.min(position + 1, level.length - 1)), which is the duplication rule seen from the proof
side.
verifyTxMerkleProof(txId, steps, rootHex) (blockchain.ts:3800) re-derives the root from the id
alone. It takes the id, not the transaction: a verifier that has already bound the id to its
contents has done the harder half, and one that has not must not be handed a transaction object to
trust.
Cost is ceil(log2(n)) sibling digests — for a 1000-transaction block, 10 hashes instead of 1000
ids.
8.2 What the block hash and the records root cover#
computeBlockHash (blockchain.ts:17061) is
sha256(canonicalStringify({ header, txs, allocations, registrations })). Note what it does not
cover directly: contract, collateral, governance, wNFT and wrap records; the consensus proof; the
attestations. The first five are bound through header.recordsRootHex; the proof through
header.consensusProofHashHex plus the rule that a header naming a proof must carry it — stripping
the proof left the block hash unchanged, so a block could shed its own evidence in flight
(blockchain.ts:467-470). Attestations are bound by nothing, which is deliberate and has a
consequence — see section 12.
computeRecordsRoot (blockchain.ts:18800) folds
{ domain: "str-block-records-v1", allocations, registrations, contracts, collateral, governance,
wnft, wrap }, where:
- allocations and registrations are sorted by domain with
compareBytes(blockchain.ts:4063,:4074) and coerced field by field. Sorted, so the root depends on the set rather than on the order one producer happened to queue them (blockchain.ts:3913). Coerced withString(...)/Number(...)defaults so the function is total on malformed input: it runs insideverifyBlockOrderingon blocks straight off the wire, and a record missing a field has to produce a root that fails to match rather than an exception — a throw there is a node-wide halt triggered by one crafted frame. - everything else is order-dependent, one canonical string per record in sequence. Calling a then b is not calling b then a; a mint and a redemption against one reserve do not commute; a vote after a proposal closes is not a vote before it; superseding a wNFT entry and then burning it is not burning then superseding; and a wrap and an unwrap by one holder consume consecutive values of the same chain-wide nonce, so swapping them is a pair of records neither of which applies.
- contract records use
canonicalRecord(src/core/contract-state.ts:1435-1455), notcanonicalStringify. The latter renders a bigint as a decimal string, so7nand"7"hashed identically and the records root did not commit to an argument's type — a relay could flip a wire type tag and hand chosen peers a block that was hash-valid and unusable, while others accepted the same hash.
Records were covered by the block hash but not by the producer's signature until the records root existed, and a hash nobody signed is a checksum rather than a commitment.
blockSigningPayload (blockchain.ts:16884) binds ten header fields plus the domain tag
str-block-header-v1 and the genesis hash, so a block authored for one chain cannot be
presented on another.
9. Genesis and the production guard#
Not the primary subject of this file, but the ledger's initial state and the chain's identity come from here, and a reimplementation has to reproduce both.
genesisHash (src/core/genesis.ts:563) is sha256(canonicalStringify({ chainId, chainName,
producedAtMs, nodeSetRoot, bridgeAttestorSetRoot, allocations })), where allocations are sorted by
address and then by token and carry { address, balanceMinor, token?, domain | null } with the
domain case-folded. Who may produce (genesisNodeSetRoot genesis.ts:506) and who may mint $TR
(genesisBridgeAttestorSetRoot genesis.ts:544) are inside the identity, because a producer
set or a mint authority the genesis hash does not cover is a rule every node enforces locally and no
two of them are obliged to agree on. Someone shipping an edited genesis-nodes.ts previously ran a
different validator set under an identical genesis hash. The empty attestor set is hashed, not
skipped: declaring no attestor and omitting the field are the same statement and must produce the
same chain. A spec declaring no validator nodes is refused rather than hashed around
(genesis.ts:564-570): hashing the other four fields would hand back a plausible chain identity for
a chain that cannot run.
initGenesis (blockchain.ts:16260) seeds every allocation through LedgerManager.seed
on the ledger the allocation names, STR when it names none (:4896), registers each declared
genesis domain (:4899), mints one WNFT per genesis domain (:4901), computes and records the
genesis state root (:4907-4908), and pushes block zero — the one block with no producer signature
(producerSignatureHex: 'genesis', producer: GENESIS_PRODUCER, genesis.ts:23). Its authority is
the genesis hash, which is why verifyProducerAuthorised (blockchain.ts:16914) and the author
check (:4218) both exempt height 0. replayChain seeds identically, on the same ledgers, at
blockchain.ts:4492-4505 — a replay that folded every allocation onto STR would rebuild a different
opening state from the same genesis and reject the chain it had just been running, and it would do
so silently: 50M eSTR and 63M CCOS both fit inside the STR ledger's remaining headroom, so the
cap check would pass and the only symptom would be a state root two nodes disagree about
(blockchain.ts:4493-4499).
9.1 The development genesis hash moved twice on 2026-09-07#
It is now
8ee28b94b15c1db6cfb7e052d2ade53b5e1a8be5d8698e17a679f4b567a576ea (docs/BUILD_STATUS.md:48).
The value matters here for one reason: moving it is a new chain. The hash is the network's
identity, every signature on this chain is bound to it (src/core/transaction.ts), and the Feeless
Pool's account is derived from it (feelessPoolAddress, blockchain.ts:555), so a genesis that
hashes differently is not a corrected chain, it is a different one.
| From | To | What moved |
|---|---|---|
42fb6409…b778f | 0ae2ca8d…d686 | chain id 1313 → 31337; chainName "SourceLess Mainnet Candidate" → "SourceLess Development"; a fifth allocation, the 50,000,000 eSTR premine |
0ae2ca8d…d686 | 8ee28b94…76ea | two more allocations, the CCOS premine — 42,000,000 treasury and 21,000,000 public, 63,000,000 total, landing exactly on the cap |
docs/book/ECONOMICS.md owns the token economics; §1.7b and §1.7c there carry the arithmetic,
the supply consequences and the measurement that removing exactly the two CCOS allocations
reproduces 0ae2ca8d…d686 byte for byte. The figures above are here because they are what the
hash covers, not as an account of what they mean. What belongs to this volume is the
state-and-identity half, which is three things.
One. GenesisAllocation now carries an optional token, and the fold inside genesisHash is
...(a.token && a.token !== TokenType.STR ? { token: a.token } : {}) (genesis.ts:589-612). That
encodes the meaning: an omitted token and an explicit STR are the same statement about the same
chain, so they must produce the same preimage. The two rejected encodings are recorded at that line
and both are wrong for stated reasons — token: a.token ?? null folds a field into every allocation
and moves the hash of every chain that ever existed; a.token !== undefined ? … preserves the old
hashes and buys that with a lie, putting two operators who wrote the same genesis two defensible
ways on two networks. The sort key gained a second component for the same reason: one address may
now hold an allocation on two ledgers, and a sort that stopped at the address would order those two
by however the array happened to be written (genesis.ts:585-590).
Two. validateGenesisSpec (genesis.ts:284) now totals per token against that token's own
cap (:290-298, :352-357). It used to sum every allocation into one number and charge it to the
STR cap, which was correct only while every allocation was STR: the moment token existed that was
two defects in one line — a 50M eSTR allocation would have been charged against STR's 63B ceiling,
and eSTR's own 50M ceiling would not have been checked at all. Its duplicate key is now
(address, token) (:302-312), because one custody account legitimately holds rows on two ledgers
while the real duplicate — one address seeded twice on one ledger, where the second seed
silently overwrites the first — is still refused. That relaxation carried a second one with it and
it was caught: keying by address alone had been accidentally refusing "one address, two domains", so
an explicit domainHolders check was added (:313-324), or a spec could give one address a domain
on its STR allocation and another on its eSTR allocation and registerGenesis would take both.
Three, and this is the cost. Nothing is deployed, so both moves cost zero — there is no
migration and no stored hash to reconcile, because the old digests never identified a network that
exists. That will not be true later. The 42M/21M CCOS split conflicts with TOKEN_ECONOMICS.md's
20,790,000 / 42,210,000; both readings total 63,000,000, so neither the cap nor the premine is in
dispute, only the line between the halves — and that line is now inside the genesis hash, where
revising it is a new chain. It is not this volume's decision; see docs/book/ECONOMICS.md §11
item 10.
9.2 The Snotra pin#
assertGenesisMatchesNetwork (src/core/snotra.ts:746) runs two checks that are not the same
check (snotra.ts:427-442):
- The chain id must match (
:345-351). Cheap, and it catches the common operator error of running a node against a genesis file left over from something else. - The genesis hash must match the pin, where a pin exists (
:353-363). This is the real one. The chain id is shared by design across SourceLess deployments and separates nothing on its own; the hash covers the allocations, the declared validator set and the bridge attestors, so a file differing in any of them is a different chain and is refused at start-up rather than discovered as a fork.
Where no pin exists — MIDGARD and ASGARD, both genesisHashHex: null — the absence is
reported by describeGenesisTrust (snotra.ts:877) rather than quietly tolerated: a node that
says nothing about an unpinned network is indistinguishable from one that verified it. DEV is
pinned to 8ee28b94…76ea (snotra.ts:213), and the pin is not a constant anyone invented — a test
recomputes genesisHash(devGenesisSpec()) rather than repeating the string.
Corrected 2026-10-29 1 of 4 Next
The realms as they stand: mainnet (Asgard) is chain id 1313, ratified by the owner on
2026-09-07, and the development chain moved to 31337 (src/core/config.ts:34, :47) — the
collision this record existed to document, 1313 labelled "SourceLess Mainnet Candidate" while
producing a genesis whose every private key derives from a string in core/genesis.ts, is gone.
Ratifying the id did not ratify the genesis. Withdrawn: Asgard still refuses to start, pending key custody.
An id is a label a network agrees to answer to, a genesis is a list of addresses whose private keys
somebody holds, and on 2026-09-07 only the first had been decided. Corrected 2026-10-29: the second
was decided on 2026-09-24, outside this repository, and Asgard launched on 2026-10-05 with genesis
hash 1cf86551… pinned in its realm record (src/core/snotra.ts:638). GOVERNANCE_AND_OPERATIONS.md owns the
operator-facing register.
The production guard is two checks, both refusals rather than warnings, because an operator who has already shipped a genesis cannot act on a log line:
mode === 'production'on the development genesis is refused outright (blockchain.ts:1723).reproducibleKeyAddresses(spec)(genesis.ts:269) is the check that actually protects a mainnet. The documented way to build a production genesis is to export the development template and replace the custody addresses; replace the allocations and stop there — the obvious, careful-looking half of the job — and the hash moves, the dev check stops firing, and all 1313sourceless-genesis-node-${i}addresses are still the declared validator set. Reproduced against the built code: production boot accepted,validatorSetSource: 'genesis', and a block sealed with a key derived from a public string validated clean. The same check is applied tooptions.validatorsthroughreproducibleAmong(blockchain.ts:1794), because a declared set replaces the genesis-committed one outright and is not in the genesis hash, so two production nodes given differentvalidatorsdisagree about which blocks are valid while both reportmode: 'production'.
Sealing is refused separately at blockchain.ts:2366 when a production node has no supplied producer
keys, because the fallback derives from the public constant producer:local-validator.
10. Storage: Draupnir and Mimir#
Two stores with different jobs. A running node uses Draupnir. Mimir is the file format an operator
and strblk verify read.
10.1 Draupnir: the append-only log#
src/storage/draupnir.ts. A directory holding log.ndjson and snapshot.json
(draupnir.ts:105-107).
It replaced a store that wrote the entire chain and every ledger to one JSON file on every save,
straight onto the target path (draupnir.ts:22-31). Two things were wrong, both of the kind that
only hurt in production: writeFile truncates the target and then streams into it, so a power
loss in that window leaves the node's only copy half-written and the node does not come back; and it
cost O(history) per save, so persisting got slower forever.
Appends are synchronous, and that is the whole of the durability property#
appendSync (src/storage/draupnir.ts:228). One record per line — the checksum, a space, then
JSON.stringify(record) — where the checksum is the first 16 hex characters of SHA-256 over the
body (draupnir.ts:438). mkdirSync, openSync(logPath, 'a'), writeSync, fsyncSync,
closeSync — and this.seq advanced only once the record is on the disk
(draupnir.ts:181-184). When it returns, the record is on the platter. A SIGKILL one instruction
later costs zero records (draupnir.ts:39-43): there is no buffer between the caller and the
disk, no batching window, no debounce and no flush interval, so an operator does not have to know a
window size, because there is not one.
It costs about 0.75 ms of blocked event loop per record on a commodity SSD
(draupnir.ts:45-47), and that is the price of two things that were both missing.
The flush. Without it the record lives in the OS page cache and a power loss takes it, which turns "the node acknowledged this" into a lie.
The order — and this is a durability defect that was reached in practice, not a hardening.
append used to be an ordinary async method: await mkdir, then take a sequence number, then
await open, await write, await sync (draupnir.ts:139-146). Every one of those awaits is a
point at which another append can start, and the node's callers start several at once — submit
writes one pending record per accepted transaction without awaiting it, and persistBlock wrote
the sealed block the same way. Sequence numbers stayed in call order because they were assigned
first; the writes completed in whatever order the libuv threadpool finished them.
A log holding 1, 3, 2 is not detectably different from a corrupt one. readLog refuses to
replay across a sequence that skips (draupnir.ts:416-428) — correctly, because no crash produces
a hole — so it stopped at the 3, and load then repaired the file by rewriting it with only the
prefix it had accepted. A producer that had sealed three blocks and been SIGKILLed came back at
genesis with a one-record log, having destroyed on read three complete, correctly checksummed
block records that were sitting on the disk at the moment it died. The self-repair deleted intact
blocks. Nothing in the reader can distinguish a reordered log from a corrupt one, and it should not
try; serialising the writer is what removes the failure.
Measured, not inferred (draupnir.ts:148-159), on this repository's own e2e harness:
| Harness | the e2e crash-durability scenario |
| Before | failed 2 runs in 12 |
| The evidence | the data directory copied at the instant of the SIGKILL held a 9,982-byte log carrying sequences 1, 3, 2, 4, 5, 6, 7, 8 — three block records among them, every checksum valid — and the restarted node reported height 0 with a 549-byte log |
| After | the same scenario has run 52 times consecutively without a failure |
this.seq advancing only after the write is the same rule pointed at itself: claiming the number
first would leave the next append to write across a sequence nothing occupies, which is the one
shape of damage recovery cannot tell from a crash (draupnir.ts:181-183).
There is no suspension point inside appendSync, so two calls cannot interleave whatever the caller
does with the promise. append() (draupnir.ts:316) survives as the promise-returning form for
callers already on an async path and carries exactly the same promise — it calls appendSync,
so the work is done by the time the promise exists.
The block path uses the synchronous form directly: Hestia.persistBlock calls
this.store.appendSync('block', serializeBlock(block)) (src/node/hestia.ts:1784), and the comment
above it states the operator-facing version — a SIGKILL costs this node zero sealed blocks — and
records what the old code did instead: the append was fired and not awaited, so the block was
broadcast to the network and the sealing RPC answered sealed: true while the write was still
somewhere on the threadpool (hestia.ts:1762-1777). A failed local write raises
local-write-failed rather than taking the node down (hestia.ts:1786-1789).
Snapshots, and the log they cover#
snapshot() (draupnir.ts:340), then writeSnapshot (:364): temp file, write, sync(),
rename() over the target, then drop the records the snapshot covers. The order is not
interchangeable: the snapshot must be durable before the log is trimmed, or a crash loses both.
The rename is what makes the swap atomic, so a reader sees either the old snapshot or the new one
and never a mixture; the sync() has to precede the rename, or the rename can land ahead of the
data and publish an empty file (draupnir.ts:236-243). Snapshot bodies are
{ seq, checksum: sha256_16(JSON.stringify(state)), state } (draupnir.ts:232).
Concurrent snapshots are serialised through a promise tail (snapshotting draupnir.ts:127, :220-227): two
callers — a reorg replacing the log while a shutdown writes the same store — both wrote the same
temporary file and both renamed it, so the second failed with ENOENT on a path the first had already
moved, and worse, whichever finished second decided the contents. The sequence the snapshot covers
is read synchronously at the call, not inside writeSnapshot, because the caller built that
state object immediately before the call and the two describe the same instant; reading it later
would pair a state with a sequence that had moved on, and the records in between would be dropped as
covered by a snapshot that does not contain them (draupnir.ts:217-222).
The trim is dropCoveredRecords (draupnir.ts:414) and it is no longer rm(logPath). It was,
and that is right only if nothing appends while the snapshot is being written. Something does: a
snapshot is several awaits long, and two of Hestia's five snapshot call sites — the reorg path and
the one behind persistBlock — do not await it at all, so the node keeps running through it by
design. A block sealed in that window was silently gone at the next restart, and the log was left
starting at a sequence the snapshot did not lead into, so recovery refused the rest of it too. It is
synchronous from the read through to the rename for the same reason appendSync is: an append
landing between the two would be rewritten out of existence by a repair that never saw it
(draupnir.ts:250-265).
Recovery is a prefix#
load() (draupnir.ts:447) returns the last snapshot plus the complete records after it, never a
mixture and never a gap. readLog (draupnir.ts:532) is where each rule sits:
- Every line is checksummed, not only the last (
:390-406): a checksum that guards the tail alone does not detect corruption anywhere else. - The first malformed line stops the scan and sets
tornTail. A crash mid-append leaves exactly one partial last line, and the node comes back at the last whole record rather than not at all. - A
seqgap also stops the scan (:416-428): no crash produces a hole in the middle, and replaying across a discontinuity would paper over something a crash did not do. The first record after a rejected snapshot is exempt, because the log legitimately restarts after each snapshot and there is no trustworthy baseline to compare against. - A recovered store repairs itself (
draupnir.ts:317-320,truncateToat:332): the surviving prefix is rewritten atomically. Leaving the torn bytes in place would mean every later append sits behind them, unreadable — the node would appear to recover, accept work, and lose all of it at the next restart.
There are now two atomic writers, and the reason is the one that made appends synchronous.
writeAtomic (draupnir.ts:641) is temp, flush, rename, and repairs a torn log inside load()
before the node has started, so it is free to be asynchronous; the flush was missing for a while and
it mattered most where it was least visible, because that repair is the crash-recovery path
(draupnir.ts:450-459). writeAtomicSync (draupnir.ts:666) is the same write with no suspension
point in the middle, and it is what dropCoveredRecords uses, because it runs on a node that is
sealing blocks and a record appended between the read and the rename of an asynchronous rewrite is
a record the rewrite discards without ever having seen it (draupnir.ts:476-485).
snapshotRejected is reported rather than hidden (draupnir.ts:82-97). The records after a
rejected snapshot are still returned, because they are genuinely intact, but they are a delta
against a base that is gone; a node seeing this must re-sync from peers rather than treat local
state as authoritative. Hestia escalates it on sight as local-state-untrusted and stops
producing (src/node/hestia.ts:1465, :1674), because replaying local state cannot repair a
failure of local state, and the attempts would only be chances to report success on the wreckage:
a node that had lost four blocks rewound to genesis, genesis alone validated trivially, and a loud
correct fault became a silent all-clear.
10.2 What a node actually stores#
Hestia.chainSnapshot() (src/node/hestia.ts:10262) returns
{ chain: Block[], pendingIdentity?: SerializedPendingRecords }and nothing else. A node's durable state is the block log plus its unsealed record queues. No ledger, no state root, no seating, no pool books, no settlement floor.
pendingIdentity is written only when the node actually holds queued work, and the count is taken
across every kind pendingIdentityRecords() returns rather than an enumerated list
(hestia.ts:2022-2026). That is not tidiness: the same omission has now happened twice. It counted
two while the getter returned six, so a restart lost queued contract records, ballots, identity
updates and confirmed bridge deposits outright — measured on a clean stop, with the submitter
having been told each one was accepted — and when the getter grew to nine, a node whose only
queued work was a domain burn or a wNFT sale counted zero, wrote no pendingIdentity at all, and
came back holding neither. A burn is a thousand STR; a sale is two parties' signed agreement.
Recovery (hestia.ts:1452-1616) rebuilds by feeding every stored block back through
BlockchainCore.acceptBlock — the same site a peer's block goes through, with the same rules — and
stops at the first block the chain rejects rather than building on a contradiction. The height the
log claims is recorded before the replay, because the replay is what may fail to reach it and
afterwards the evidence is gone; a rebuild that lands lower raises local-state-untrusted
(hestia.ts:1564-1583).
Queued records are re-queued after the replay and through their own submission gates
(restorePendingIdentity, blockchain.ts:1522). Both halves were defects: it used to run against a
chain of height 0, so every gate — is this name allocated, is the lock funded, has this reference
been spent — was answered against genesis state; and the registration branch used to apply,
calling domains.prove, locking 1000 STR and minting the wNFT outside block execution on every
restart that found a queued registration. Measured: a restarted node held a lock and a WNFT no block
on its chain accounts for, validateState() reported the divergence, validateChain() still
reported the chain as valid because a replay never looks at held state, and then the record sealed
in the next block and applyRegistration locked the 1000 STR a second time.
Records that no longer apply are dropped and reported (blockchain.ts:1518-1520, :1533,
:1542; the caller turns each into a recovery warning at hestia.ts:1607-1611).
A stored block or pending entry the codec cannot read is a gap, not a stop (2026-11-23). An older
build sealed and took transfers whose purpose the codec refuses, and deserializeBlock and
deserializeTransaction throw on one. Read outside a try, one such entry stopped start() for
good. Every read of the snapshot, the log, the archive and the pending log now drops what it cannot
decode, with a recovery warning naming it:
- An unreadable block is a hole, exactly as an archived block whose hash does not describe it is.
The replay stops at it. If a readable block above it is in the store, the node raises
local-state-untrustedand holds the snapshot floor at that height, as for any short replay, and re-syncs. If the unreadable block was the TOP one, the height the store claims is read off the blocks that decode and falls with it, so neither fires; the node follows its peers from where it stopped, and escalatesblock-rejectedso an operator hears of it. - An unreadable pending entry is not restored. The client that sent it was told it was accepted, so the warning names its kind and id.
- A crash between a reorganisation and its snapshot can start on the earlier block at a height. If the node stops before the snapshot that follows a reorganisation, and the adopted block at a height is the one it cannot read, the store may still answer that height with the block the reorganisation replaced. The node then starts on that earlier block, and fork choice decides between it and its peers' chain as it would for any fork. Unmeasured: no test reaches this.
10.3 Mimir: the snapshot file#
src/storage/mimir.ts. Draupnir's header says it replaced this store, and for a node's live path it
did. What was left behind was the defect, not the store: save was a writeFile straight onto the
target and load threw whatever the parse threw, so a torn file came back as a stack trace rather
than a finding. It is kept because strblk verify is the one thing that reads a snapshot from
outside a node, and because serializeBlock and its siblings are how Hestia, Verdandi and the STARW
node all encode a block (mimir.ts:18-43). Nothing in src/ constructs a MimirStore; the
class is reached by tests and the format is reached by strblk verify.
save (mimir.ts:103) is the same three steps as Draupnir — stage, sync(), rename — under
{ mimir: 1, checksum, state } where the checksum is over canonicalStringify(state). Canonical
rather than plain JSON.stringify, because the reader re-renders what it parsed: key order has to be
a function of the data rather than of how the parser happened to bucket the keys.
readSnapshotFile (src/storage/mimir.ts:154) never throws. Absent, unreadable, not JSON, torn
mid-write, or a shape nothing recognises all come back as { ok: false, reason }, because a corrupt
snapshot is a finding about the file and an operator asking "is this snapshot good?" deserves an
answer rather than a stack trace. It reads three formats (SnapshotFormat mimir.ts:85):
| Format | Written by | Carries | Checksum over |
|---|---|---|---|
mimir | MimirStore.save | chain and ledgers | canonicalStringify(state) |
mimir-legacy | this store before it checksummed | chain and ledgers | nothing |
draupnir | a running node | blocks only | JSON.stringify(state) |
The two renderings are chosen by the mimir tag rather than guessed, because guessing would make a
good file look torn, which is worse than not checking at all (mimir.ts:179-197). Reading both
formats is not a convenience: strblk verify expected Mimir's shape and died on a TypeError
reading chain.map of undefined when handed the file a node actually wrote.
A draupnir file returns snapshot: null and blocks only. A caller holding null must replay rather
than restore — which is the stronger check anyway (mimir.ts:71-78).
10.4 What a Mimir snapshot carries#
BlockchainSnapshot (src/core/blockchain.ts:677) and SerializedSnapshot (mimir.ts:288):
| Field | Content |
|---|---|
genesisHashHex | chain identity; a mismatch is refused outright (blockchain.ts:1908) |
chain | every block, through per-record codecs, field by field |
ledgers.ledgers | the seven token ledgers as [address, {balanceMinor, lockedMinor, lockedForLifeMinor, nonce}], all decimal strings |
ledgers.contracts / .governance / .identity / .collateral | tagged encoding ($bigint, $map) (mimir.ts:441-444, :472-475) |
trailingRoots | the roots no header commits to yet (mimir.ts:267) |
finalizedFloor | what the writing node believed the line was, as a decimal string, and an input to nothing (mimir.ts:302) |
The four extra ledger sections were absent once, and that is what made this store unusable for any
chain that had ever done anything: it wrote ledgers.ledgers alone, restoreSnapshot replayed,
compared roots and refused — correctly and permanently (mimir.ts:268-284).
Closed 2026-09-07 2 of 4 Next
Closed: That defect has recurred, for the fifth section, and it is open. Closed 2026-09-07 in LedgerManager.snapshot() now
holds six things and serializeSnapshot writes five: burnedDomains appears nowhere in
src/storage/mimir.ts. A Mimir round trip therefore returns a chain whose Helgrind gate is empty —
loadSnapshot reads a missing section as { burned: [] }, which is the honest reading of an older
snapshot and the wrong reading of a current one.d18d323; amended here
2026-09-12, and the amendment is kept in place because this chapter's convention is that a closed gap
is amended rather than deleted. burnedDomains is now written (src/storage/mimir.ts:588) and read (:634), and the
property the omission broke — the ledgers in the file reproduce the leaf they were taken at with no
block replayed — is held by tests/integration/domain-burn.integration.test.ts:598. A file written
before the section existed still deserializes, because absent is not corrupt. Two parts of the old
diagnosis are corrected rather than dropped: the roots did not differ and the restore did not
throw, because rebuildDomains and StrDomainRegistry.absorb overwrote the loaded gate on the way
in — which is why a test written against restoreSnapshot would have passed on the broken codec.
See §12.4 item 11.
The $bigint / $map tagging exists because JSON has neither: JSON.stringify throws on a bigint
and turns a Map into {}, so a snapshot written without it would either fail to write or come back
holding nothing — and "comes back holding nothing" is the dangerous failure, because an empty
contract ledger looks exactly like a chain that never had one (mimir.ts:306-313). The decoder
requires the exact one-key shape rather than merely the presence of the key.
Two decode rules worth copying. wholeNumber (mimir.ts:1812) refuses rather than coerces,
because Number("abc") is NaN, which travels as far as the records root and then throws
refusing to encode a non-finite number out of acceptBlock — a hostile-input boundary that holds
because of a blanket catch somewhere else is not a boundary. And decodePurpose
(mimir.ts:1102) validates rather than casts, because purpose is inside the signing payload and
therefore inside tx.id: anything but an exact round trip changes the id and the transaction stops
binding its own contents. purpose was dropped by this encoder once, and CCOS — which is
financialOnly — could not survive a single hop or a single restart. Since 2026-09-07 that is the
load-bearing case rather than the illustrative one: CCOS is premined at genesis, so it is a token
that actually moves.
10.5 What is earned by replay, and what is believed#
restoreSnapshot (src/core/blockchain.ts:6872) is where the trust boundary is drawn, and the
comment at :1982-1991 states the reason: everything above that line trusted the file. A snapshot
arrives from the data directory, which is to say from anywhere — a backup, a container image,
another process on the host. Its ledger was adopted on sight, so whoever could write that directory
could write balances: 1e21 minor STR into the treasury, chain blocks untouched, and the node came
up, validated, and served the forged supply to every peer that asked.
The blocks are what an attacker cannot forge, so the blocks are what the state is checked against. Re-checksumming the file would have proved only that the forgery was stored intact.
| Piece | Earned or believed |
|---|---|
| the seven token ledgers, contracts, governance, identity, collateral, burned domains | earned — replayChain() runs (blockchain.ts:1993) and the replayed stateRoot() must equal the loaded one, or the restore throws (:1997-2001) |
collateral book (spent references) | earned twice — additionally overwritten from the replay's own book (blockchain.ts:2016) |
| seating / validator schedule | earned — taken whole from the replay (blockchain.ts:2020); it is derived from blocks and stored nowhere |
postMinedMinor | earned — accumulated by the replay (blockchain.ts:2010) |
| Feeless Pool books | earned, and honest about what it cannot reconstruct — available = postMined - governanceBurned (blockchain.ts:2037), and spentOnExecution and lockedForLife are 0, because no block carries a pool exit for them, which is stated rather than assumed (:2034-2036) |
| domains, allocations, registrations, wNFT records | earned — rebuildDomains replays them from the chain (blockchain.ts:1973, function at :111) before any root is recorded, because identity is part of the root |
| attestations on every restored block | earned — keepVerifiedAttestations is run over the whole restored chain against the seating the replay derived (blockchain.ts:2027), so an honest node keeps every honest signature its chain ever collected and a tampered file contributes none. The disk is a door a block enters through, and it is screened like the wire one |
trailingRoots | believed — loaded from the file (blockchain.ts:1964-1966) and nothing compares them to the replay |
finalizedFloor | derived, not believed. See below |
| pending records | believed as bytes, earned as records — re-queued through the same submission gates a fresh record passes |
The depth line is derived, not adopted#
deriveFinalizedFloor (src/core/blockchain.ts:13583) replays the confirmation depth across the
restored chain: it walks execute governance records that set chain.requiredConfirmations, reads
the action out of governance state — which is covered by the state root, and so is authenticated
by every header above it — and takes the max of h - depth(h) + 1 over every height. A node-local
configuredConfirmations short-circuits it, because a constant for the life of a process has no
timeline: the deepest line it ever drew is the one it draws now.
It needs no explicit clamp to stay at or below head - DEFERRED_DEPTH, and that is arithmetic
rather than a guard: every depth is floored above DEFERRED_DEPTH, by the constructor for an
override and by the parameter registry for a governed value, so h - depth + 1 <= h - DEFERRED_DEPTH
falls out.
Measured against the running node it replaces: on a 43-block chain whose depth governance took
from 12 to 40 at height 43, a live node holds 31 and this derives 31
(blockchain.ts:4060-4061).
The derived line is never shallower than what the exporting node held, because the exported floor is a max over the heights that node happened to evaluate and this is the max over all of them. That is exactly why deriving is safe as a replacement for carrying — and the reverse is not true, which is why a disagreement cannot be treated as proof of tampering and cannot be grounds to refuse the restore. Refusing on mismatch would brick honest nodes.
So the field is read and decides nothing. restoredFinalityLine() (blockchain.ts:13624) reports
{ derived, claimed, agreed } so an operator is told rather than the disagreement being
swallowed, and strblk verify prints all four cases — agreed, shallower (ordinary), deeper (no
honest exporter produces this), and absent (src/cli/strblk.ts:524-538). claimed: null covers both
"the file carried no field" and "the field would not parse", undistinguished because neither is
read: parsing is defensive, since throwing on a corrupt value would turn a recoverable node into a
dead one over a number nothing consults (blockchain.ts:1939-1948).
What was there before adopted the field, bounded to head - DEFERRED_DEPTH, and both directions of
tampering were reachable. See §12.2 for the measurements.
validateState() (blockchain.ts:15416) is the standing version of the same question: does the state
this node holds follow from the blocks it holds. validateChain() never looks at the held ledger,
which is exactly why a snapshot with a rewritten balance passed it — and why finalizedFloor, which
is not in the state root, had nothing checking it at all.
10.6 The crash-safety argument, end to end#
draupnir.ts's own header makes four claims about what the store promises. Each is checked here
at the line, because until this cycle the first of them was false on the shipped path and the
comment that asserted it had been asserting it for some time.
- A block is on the disk before the node reports it. True now.
persistBlockcallsappendSync(src/node/hestia.ts:1784), which opens, writes,fsyncs and closes with no suspension point, and only then advances the sequence (draupnir.ts:165-187).Hestia.produceBlockreturns aBlock, not a promise, and callspersistBlockbeforebroadcastBlock(hestia.ts:871-876), so the block is on the disk before any peer hears of it. It was false while the append wasasyncand unawaited: the block was broadcast and the sealing RPC answeredsealed: truewhile the write was still on the libuv threadpool, and several unawaited appends in flight at once landed out of order. See §10.1 for the measurement. - A crash can tear only the last line, and a torn tail is survivable rather than fatal. True.
Recovery checksums every line, not only the last, keeps every complete record before the first
failure, and rewrites the survivors atomically (
draupnir.ts:390-406,:317-320). The gap rule sits beside it and is now sound for the reason it always claimed to be: a hole in the middle is something no crash produces, and since appends cannot reorder, a hole is no longer something the writer produces either (draupnir.ts:416-428). - Snapshots are atomic, and durable before the log they cover is trimmed. True. Temp file,
write,
sync(),rename(), then trim (draupnir.ts:230-247). The trim isdropCoveredRecordsand keeps every record the snapshot does not cover, which is what makes "durable before" mean anything on a node that is still sealing (draupnir.ts:266). - Recovery is a prefix — never a mixture, never a gap. True.
load()returns the last snapshot plus the complete records after it (draupnir.ts:310-329). A snapshot that fails its own checksum is rejected rather than used, the intact records after it are still returned, and the node sayslocal-state-untrustedand re-syncs rather than pretending (draupnir.ts:82-97,src/node/hestia.ts:1465).
Above the store, whatever survives is re-validated: every recovered block goes back through
acceptBlock — the same site a peer's block goes through, with the same rules — and a Mimir-format
restore additionally replays the whole chain and refuses unless the loaded ledger lands on exactly
the replayed root.
The property the whole argument rests on is that a node's authoritative state is its blocks. Ledgers, roots, seating, pool books and the depth line are consequences, and every one of them is re-derived rather than trusted. The self-repair defect in §10.1 is worth reading as the exception that proves it: the one moment recovery destroyed data was the moment it treated its own repair as authoritative over records that were sitting intact on the disk.
What is still not covered. The argument is about blocks and the record queues. It says nothing
about the mempool, which is not persisted at all (§12.5), and nothing about trailingRoots, which
is the one field of a restored snapshot that is still taken on the file's word (§12.2).
11. Canonical encoding#
src/core/canonical.ts, 55 lines, and every hash in this document goes through it.
canonicalStringify(value) is JSON.stringify(normalize(value)) where normalize
(canonical.ts:30-55):
- renders a
bigintas its decimal string; - throws on a non-finite number, on
undefined, on a function and on a symbol; - maps arrays element-wise, preserving order;
- for objects, emits keys sorted with
compareBytes, skipping any key whose value is exactlyundefined; - passes everything else through.
The refusals are the interesting part. JSON.stringify turns NaN and Infinity into null and
drops undefined from objects, so two different values would hash identically and neither would
raise anything. A canonical encoder has to refuse what it cannot represent, loudly. An explicitly
undefined property is a hole JSON would drop silently, taking the difference between {a:1} and
{a:1,b:undefined} with it.
sha256Hex(input) (canonical.ts:26-28) is SHA-256 over the UTF-8 bytes of the string, hex output.
11.1 Why localeCompare is banned#
compareBytes (canonical.ts:21-24) is byte-order string comparison and is the only ordering
permitted anywhere consensus can see. The comment at canonical.ts:8-19 gives the reason:
String.prototype.localeCompareconsults the runtime's default locale and its ICU data. Two nodes on the same code, differing only in how their Node binary was built (small-icu against full-icu) or in the ICU version they link, can order the same two strings differently. That silently changes mempool order, and therefore block contents; it changes the genesis hash, and therefore chain identity; it changes which chain wins a fork choice. Each of those is a chain split with no error anywhere.
It is not hypothetical, and it has already happened here: docs/BUILD_STATUS.md:231 records
CollateralBook.stateRootHex() sorting with localeCompare, measured as an en-US node and a
da-DK node computing different COLLATERAL roots from identical state. The comparable industry
failure is cited in the source: a deserialisation difference between two versions of one client —
one accepting an encoding the other rejected — split Cardano for fourteen and a half hours in 2025.
Ordering differences are the same shape and quieter.
Every consensus-visible sort in the tree uses compareBytes: object keys inside canonicalStringify
(canonical.ts:46), Charon's sender and id tiebreaks (charon.ts:307, :338, :357, :432), the
records root's allocation and registration ordering (blockchain.ts:4063, :4074), the genesis node
set (genesisNodeSetRoot genesis.ts:514), the attestor set (genesis.ts:388) and the genesis allocations
(genesis.ts:431).
11.2 What a second implementation must match#
- Object key order is byte order, applied recursively, after normalisation.
- Array order is preserved — it is the encoding of sequence, and the state root's eleven ledger entries and the records root's per-kind lists both depend on it.
- Bigints are decimal strings, no separators, a leading
-for negatives. - Numbers are JSON numbers, and non-finite ones are an error rather than a value. Every consensus-visible number in the tree is either a bigint or a millisecond integer.
- String escaping is JSON's, and the hash is over the UTF-8 encoding of the resulting string.
Getting this subtly wrong is not theoretical either:
docs/BUILD_STATUS.md:216-220records contract storage slot names built as UTF-16 and hashed as UTF-8, so"\uD800"and the replacement character collided into one state-tree leaf, and a restarted node computed a different contract state root than one that stayed up — from two ordinary signed calls.
12. Known limits#
Blunt, in the order an auditor should read them.
12.1 There is no single money primitive, and the gate says so#
apply is one of eight mutators (seed, lock, lockForLife, release, apply, bumpNonce,
mint, burn), reached directly by six modules outside LedgerManager.
docs/BUILD_STATUS.md:89 records the gate "all money-moving paths go through one deterministic
primitive" as NOT MET, and sections 1.4 and 2.3 above are the measurement behind it.
README.md:254 ("Value moves only through YggdrasilLedger.apply") and this domain's standing rule
("no balance mutation outside YggdrasilLedger.apply") both state a property the code does not
have. The property the code does have is that no balance moves outside block execution, which is
narrower and is the one validateState() can check. That contradiction is for governance to settle,
not for a silent edit here.
One of the eight has no production caller: lockForLife (yggdrasil.ts:432). So the documented
"a domain funded from the Feeless Pool locks for life" is a path with no entrance rather than an
approximation, and the docstring above it states that outright.
release is no longer one of them, and this section said it was. Corrected here rather than
deleted, because §1.2 has said since 2026-09-07 that burning a domain releases the lock and this
section still said nothing released one — a contradiction inside one file, which is the shape the
book is supposed to catch. release (yggdrasil.ts:139) now has two production callers, both
inside block execution: applyDomainBurn refunds the burner (blockchain.ts:5537) and
applyWnftTransfer moves the lock from seller to buyer (:5756, paired with a lock on the next
line). applyRegistration's idempotency (blockchain.ts:5394) was needed for the old reason — a
registration that ran twice locked 1000 STR twice and nothing ever gave it back — and it is still
needed, but "no lock is ever released on any path" is no longer true and should not be read as an
argument for anything.
The code has the mirror-image staleness: release's own docstring still says "Unreachable today -
nothing in src/ calls this, which docs/book/LEDGER_AND_STATE.md records"
(yggdrasil.ts:209-212), citing this document for a fact this document has stopped asserting. Both
halves of that circle are recorded in §12.4; neither is
edited from here.
12.2 A snapshot still believes one field#
Corrected after this chapter was written, and corrected again. When it was first taken, this
section named two fields a restored BlockchainSnapshot takes on the file's word. finalizedFloor
is no longer one of them — replay derives it (§10.5) — so trailingRoots is the only one left.
trailingRoots is bounded by nothing: a snapshot naming a wrong root for a height inside the
deferred window makes the restored node seal a block committing to that wrong root, which every
follower then rejects. The blast radius is the node itself, but it is state accepted on the file's
word, and it is loaded before the replay that would contradict it (blockchain.ts:1964-1966).
The old bound on finalizedFloor — clamped to head - DEFERRED_DEPTH — was real but much weaker
than it read, and the test covering it passed vacuously. Both tamper directions were reachable and
were measured on a 43-block chain whose honest line was 31: a floor of 1 walked the line back to
4, reopening 27 settled heights to a reorg, and 500 pushed it to 40, nine past what the
chain had earned, so 3-confirmation blocks reported final and a valid branch forking there was
refused (blockchain.ts:1919-1932). The entry cost was prior write access to a file an operator
hands the tool — no peer can supply a snapshot — so this was tamper-robustness, not a remote break.
The second correction is to what this section said next. It used to close by arguing that
because Hestia.chainSnapshot() (src/node/hestia.ts:10262) writes { chain, pendingIdentity } and
nothing else, the ratchet was not durable on the path every restart takes, and that a restart
re-derived the floor "with whatever depth is now in force" — the un-finalization the ratchet exists
to prevent, with a restart as the trigger instead of a vote. That was wrong as stated in two
different ways, and it also contradicted item 7 of §12.4 in this same file.
- It is still true that the shipped node writes neither field:
BlockchainSnapshot.finalizedFloor(blockchain.ts:107) and Mimir'sfinalizedFloor(mimir.ts:302) are never produced by a running node. - It has never followed that the ratchet is lost. Recovery replays every block after genesis through
acceptBlock, which advances the ratchet at each height (blockchain.ts:3619). Measured: a live line of 31 comes back as 31. The ratchet survives a restart, reconstructed by replay rather than carried. - And "with whatever depth is now in force" was never how the derivation works.
deriveFinalizedFloorwalks the chain's own governance history and takes the max ofh - depth(h) + 1at each height under the depth that was in force at that height (blockchain.ts:4049-4061). A depth raised today does not reach backwards through it.
What remains true, and is the honest residue of the original complaint, is narrower: the floor is a
consequence on this node rather than a stored fact, so anything that stops the replay from
reaching the head — a torn log, a rejected snapshot, a block the chain now refuses — takes the line
down with it. That failure raises local-state-untrusted (hestia.ts:1577-1583) rather than
passing silently, which is the difference between the two readings.
12.3 Mimir is still a JSON snapshot store#
Durable storage is owed. Mimir writes one whole-state JSON file per save (mimir.ts:103-119) —
atomic and checksummed, but O(state) per write. Draupnir carries the live node path and is a log plus
periodic snapshots, so the O(history) cost is bounded there (snapshotEvery defaults to 256 records,
draupnir.ts:117); Mimir has no such structure. Neither store has a compaction story, a pruning
story, or a measured ceiling on the account map: accounts are never removed on any path, so the
tree.delete branch in Yggdrasil.flush (yggdrasil.ts:349-356) and GlasirTree.remove
(glasir.ts:136-162) are unreachable today, and long-run state growth is unmeasured.
validateChain is measured at 43.8 ms at height 200, 0.22 ms/block, and the per-block cost
falls as the chain grows (0.35 ms/block at height 10) — validation is not quadratic in history
(docs/BUILD_STATUS.md:337-341). Behaviour beyond height 200 is unmeasured.
12.4 Defects found while writing this#
Reported here as they were found. Five of the first seven were fixed in commit d40fd4b, which
this chapter caused; entries 8 to 12 were added by later passes over the same file. They are kept
below rather than deleted, with their resolutions, because a reader asking "was this ever
reachable?" deserves the answer, and because the reasoning that settled each one is worth more than
the diff. One entry, 7, is marked wrong as stated and corrected in place rather than removed,
which is the standard the rest of the register is held to.
| # | State |
|---|---|
| 1 Attestations verified only in the replay | Fixed. Worse than described: any peer completing a Bifrost handshake could do it — handleHandshake has no allowlist — and the gossip dedup key projects the whole decoded block including attestations, so the poisoned copy was not deduped against the honest one and honest nodes relayed it onward. The old replay rule was also too weak in the other direction: it checked that a signature verified, never that the signer was seated, so a valid signature from an unseated domain lived on the block forever and fed the quorum measurement. Resolved by stripping invalid attestations and keeping the block, not by refusing it — nothing signs how many attestations a block carries, so validity cannot be a function of the set, and refusing would hand an attacker a censorship primitive. admissibleAttestations is now the single definition of a countable signature |
| 2 Styx screen absent from the replay and the re-queue | Fixed at both sites. The replay half was live; the re-queue half was not independently exploitable, since records reach a displaced block only by having passed submit* or acceptBlock — a broken invariant one new door away from being live. Contract records have no Styx rule to restore |
3 produceBlock has no timestamp ceiling | Fixed. Thrown rather than clamped: a rewound clock has an honest repair (the parent's stamp), a stamp past representable time does not, and any value invented there would be a fabricated time in a signed header |
4 MAX_BLOCK_BYTES is producer-side only | Assessed, deliberately unchanged. Needs a seated validator running modified software, not any peer. The real bound on a peer's block is the frame ceiling: 523,235 bytes for the block protocol against a 400,000 limit, so the exploitable band is ~31% over and hard-capped — a bounded asymmetric-work advantage, not a break. Enforcing it is a consensus rule change: blocks in that band are legal today, so it must land at acceptance and in the replay simultaneously or it recreates the ingress/replay split just closed, and any chain already holding such a block stops validating. Still true at 9220195: sealedBytes > MAX_BLOCK_BYTES is checked in produceBlock (blockchain.ts:3167-3182) and at no acceptance or replay site. Entry 9 below is a different rule and does not close this one — assertRecordFitsABlock is on the submit doors, which a peer's sealed block does not pass through |
5 YggdrasilLedger.release() writes before it checks | Fixed, plus the missing amountMinor <= 0n guard its two siblings already state — without it a negative amount grew the lock by subtracting a negative. The "unreachable today" in the original text below has expired: release gained two production callers on 2026-09-07 (applyDomainBurn, blockchain.ts:5537; applyWnftTransfer, :5756), so the fix was made about four months of calendar time before the first caller arrived rather than in the abstract. The argument for taking it early — "the defect is invisible until the first caller arrives, and by then it is a state-root divergence rather than an obvious mistake" (yggdrasil.ts:209-212) — is the one that was tested and held |
| 6 The allocation rule is a hand-rolled second copy in the replay | Assessed, deliberately unchanged, and the two divergences are real: applyAllocation early-returns for a domain already held by the same wallet while the replay calls allocate unconditionally with a fresh allocatedAtMs; and for an already-proved domain the replay inserts a stray allocation entry. Invisible today only because stateRoot() commits domains.wnfts and not the allocation map. It deserves its own change with its own test rather than riding along |
| 7 The settlement ratchet is not durable on the shipped node path | Wrong as stated, and corrected here. chainSnapshot() does write { chain, pendingIdentity } only — but recovery replays every block after genesis and acceptBlock advances the ratchet at each height. Measured: a live line of 31 comes back as 31. The ratchet survives a restart, reconstructed by replay rather than carried |
| 8 Appends could reorder, and recovery deleted the intact records that followed | Fixed, and it is the only defect in this register that was reached in production-shaped running rather than found by reading. DraupnirStore.append was async with five suspension points and the node's callers fired several at once, so sequence numbers were in call order and the bytes were in libuv completion order. readLog correctly refuses to replay across a skipped sequence, so load stopped at the skip and then rewrote the file without the records after it — a producer that had sealed three blocks came back at genesis, having destroyed on read three complete, correctly checksummed block records that were on the disk at the moment it died. Measured on the e2e crash-durability scenario: 2 failures in 12 runs, a 9,982-byte log holding sequences 1, 3, 2, 4, 5, 6, 7, 8 with every checksum valid, a restarted node reporting height 0 and a 549-byte log; 52 consecutive passes since. Resolved by making the write synchronous end to end (appendSync src/storage/draupnir.ts:218) and advancing this.seq only after the bytes land, because claiming the number first leaves the next append writing across a sequence nothing occupies — the one shape of damage recovery cannot tell from a crash. dropCoveredRecords and writeAtomicSync were made synchronous in the same pass and for the same reason. See §10.1 |
| 9 Nothing bounded a single record, so the block bound was a wedge | Fixed. MAX_BLOCK_BYTES bounded the block; no rule anywhere bounded a record. produceBlock breaks at the first record the remaining budget cannot cover, and the budget resets every block, so a record larger than the whole budget was skipped at index 0 forever and everything behind it starved — and it survived restarts, because the queue is in chainSnapshot(). Measured: one 420,653-byte deploy record ahead of an ordinary one gave 2 queued, 0 sealed over five blocks. Resolved by splitting the rule: assertRecordFitsABlock refuses at every one of the ten submit* doors what no block could carry, and fits() in the loop still makes a record that does not fit this block wait. The two halves depend on each other — the loop's break is only safe because the door refuses the permanent cases. The identity loops were spending no budget at all in the same pass: 1,024 allocations beside 90 registrations assembled a 470,002-byte block against a 400,000 limit, on legal records, and the backstop fired after the ledger was mutated and the mempool committed. See §5.4 |
10 payloadHashHex is a free-length unvalidated field, and one docstring says it is not | Half fixed, half open, and the open half is a documentation defect with teeth. addTransaction now calls assertRecordFitsABlock first (blockchain.ts:2219) and the comment above it is correct: payloadHashHex is the one free-length field a transaction carries and nothing validates it — not validateTransactionStateless, which checks every other field's shape, and not the network decoder, which does String(raw.payloadHashHex). Its name says hash and its type says string, and the type is what the chain enforces. The MAX_RECORD_BYTES docstring 1,700 lines above states the opposite — that a transaction is "already bounded by its own shape … by payloadHashHex being a hash" (blockchain.ts:470) — and it is that reading, not the door, that would be used to argue the door is unnecessary. Not edited from here, but it is the reason the "every door, even the bounded kinds" rule is load-bearing rather than defensive: on this kind, "bounded today" was already false when it was written |
11 BURNED-DOMAINS is in the state root and not in the Mimir snapshot format | Closed 2026-09-07 3 of 4 Next Closed: |
| 12 Two docstrings assert facts their own file has stopped having | Open, and both are one-line comment repairs deliberately not taken here. LedgerManager.stateRoot's docstring says "a fixed 7 hashes over 7 cached roots" (ledger-manager.ts:506-510) where the fold is twelve entries; it has been wrong since CONTRACTS was added. YggdrasilLedger.release's docstring says "Unreachable today - nothing in src/ calls this, which docs/book/LEDGER_AND_STATE.md records" (yggdrasil.ts:209-212), citing this document for a claim this document has withdrawn (§12.1) and which two callers falsify. Recorded rather than fixed because this pass changes one file, and because a comment that cites a document which cites the comment is worth seeing whole once before either end of it is edited |
The original text of entries 1 to 6 follows, unedited, with the line numbers they carried when they were found. Entries 7 to 12 were written after that pass and have no earlier text to keep.
- Attestations are verified in the replay and nowhere else.
verifyValkyrieruns atblockchain.ts:3261insidereplayChain, andverifyQuorumatblockchain.ts:3041insideattachAttestations.acceptBlockandverifyBlockSelfConsistencynever look atblock.attestations. Attestations are outside the block hash by design and they survive the wire (mimir.ts:903,:947), so a peer can offer a block carrying a fabricated attestation, the hash still matches,acceptBlockaccepts it, and the node pushes it onto its chain — after which its ownvalidateChain()returns "block N carries an attestation that does not verify" for the rest of that chain's life. The one site that enforces the rule is the one that cannot reject a block, only condemn the whole chain. This is the ingress-versus-replay asymmetry the file names elsewhere as a permanent, unrecoverable split, pointing the other way. - The Styx shape screen is not in the replay, and not at seal time for three record kinds.
styxAdmit*runs at submission (blockchain.ts:889,:909,:922,:955), at acceptance for all four kinds (:2582,:2592,:2606,:2619), at seal time for wrap records only (:2105), and inreplayChainfor none. Two consequences: (a)validateChain()accepts a chain containing a blockacceptBlockwould refuse, so a node can hold a chain it validates and every peer rejects; (b)requeueDisplacedGovernance/-Contracts/-Wnft/-Collateral(blockchain.ts:2911,:2940,:2949,:2973) push records straight onto the pending arrays without going throughsubmitGovernanceand friends, so after a reorg an unscreened record can reachproduceBlock, be sealed, and split the producer from its own followers. The screen exists because an undeclared field is signed by its author, committed under the producer's signature, propagated, accepted by every follower and kept forever, while the code applying the record reads only the fields it knows (blockchain.ts:751-768). produceBlockhas noMAX_TIMESTAMP_MSceiling. The clamp atblockchain.ts:1799-1804only enforces monotonicity. A caller passingopts.producedAtMsbeyond year 3000 seals a block thatacceptBlock(:453) andreplayChain(:3197) both refuse — the producer forks itself off its own chain.Date.now()cannot reach the ceiling, so this needs an explicit argument; the same argument is already treated as hostile enough to clamp for monotonicity. A related sharp edge:opts.producedAtMs = NaNpropagates throughMath.maxinto the header and surfaces asrefusing to encode a non-finite numberfromcanonicalStringifyduring signing, which is a correct refusal arriving from the wrong layer.MAX_BLOCK_BYTESis a producer-side rule only. It is enforced by the runningfits()budget (produceBlockblockchain.ts:7816) and the backstop (:2311), and by nothing at A, R or T. A modified producer can seal an oversized block; a follower that manages to receive it will accept it. The consequence is self-limiting in practice, because the frame ceiling is below the block limit — but "no peer can receive it" is a network property, not a consensus rule, and the constant's own docstring argues the bound belongs at seal rather than at send (blockchain.ts:260).YggdrasilLedger.release()creates an account before it throws.releaseyggdrasil.ts:444callsthis.mutable(address)— which inserts a zero account and marks the leaf dirty — and only then compareslockedMinorand throws. That is precisely the read-turned-write shape the same file removed fromread(), whose comment explains that inserting a zero-balance account "changed the state root on the validating node and on nobody else" (yggdrasil.ts:279-287). It is unreachable today because nothing callsrelease, which is exactly why it will be missed when something does.lock,lockForLife,mintandburnall check before callingmutableand are correct.- The allocation rule is still a hand-rolled second copy in the replay. P and A call
applyAllocation(blockchain.ts:1923,:2536); R callsverifyDomainClaimand thenreplayDomains.allocatedirectly (blockchain.ts:3274). They agree today only becauseStrDomainRegistry.allocatehappens to be idempotent for the same holder (src/identity/str-domain.ts:334-341). This is the same structural defect that was found and fixed for registrations, where the comment reads "The replay was the fourth copy, still diverging" (blockchain.ts:3286-3299).
12.5 Things that are simply not there yet#
- Queued transactions are not durable. Charon's contents are in memory only;
pendingIdentitypersists the nine record kinds (blockchain.ts:1523-1531) but not the mempool. A restart loses every admitted, unsealed transfer, and the submitter is not told. The record half has now been under-counted twice by the same omission — see §10.2. - Charon's journal is in memory and bounded at 256 events (
charon.ts:77,:122). A node under sustained load can drop more than it can account for;stats().eventsRecordedreports the true total, so the loss is visible as a number but not as reasons. ARSSandWNFThave no supply cap (tokens.ts:281,:316).mintskips the check entirely when the cap isnull(yggdrasil.ts:268-269), so for those two the ledger-level backstop described in section 1.3 does not exist and authority is entirely in the callers.- Post-mining for a deploy is unmeasured, and is left unmeasured.
postMineForContractRecordreturns0nfor anything that is not a call, because the contract ledger does not report the gas a deploy's initialiser burned, and inventing a number would be the asserted-instead-of-measured value this codebase refuses elsewhere (blockchain.ts:5801). - The Feeless Pool's exits are only partly reconstructable. A replay can rebuild credits and
governance burns; no block carries a pool exit for a domain lock or an execution payment, so a
replayed pool reports zero for both and says so rather than assuming (
blockchain.ts:2005-2009,:2034-2036). attachAttestationshas no production caller (blockchain.ts:4100; the only other reference insrc/is a comment inledger/ghost.ts) and settlement is depth alone (docs/BUILD_STATUS.md:134-149states the reason and what a fix would cost). Point 1 of section 12.4 was the part of that which was a defect rather than a missing feature; it is closed, and what remains is the missing feature. Note what closing it did not buy:keepVerifiedAttestationsmakes every attestation on this node's chain one it has verified against the block hash and the seating, which is what makesquorumAt()(blockchain.ts:14398) a measurement of something real — and it still measures rather than gates.Closed 2026-09-07 4 of 4
Closed:
A Mimir snapshot cannot round-trip a chain that has burned a domain.CLOSED 2026-09-07 inburnedDomainsis in the state root and not in the file format; item 11 of section 12.4 has the detail. No shipped path writes that format, which is the only reason this is not worse.d18d323; amended 2026-09-12. It round-trips.serializeSnapshotwritesburnedDomains(src/storage/mimir.ts:588),deserializeSnapshotreads it (:634), andtests/integration/domain-burn.integration.test.ts:598holds the property by rebuilding the gate from the file alone and comparing its state root against the live one. Item 11 of §12.4 carries the full amendment, including the half of the old entry that was wrong rather than stale.