Slots and finality
The slot pipeline, consensus events and actions, votes, write-ahead persistence and the slot clock.
On this page · 7
Slot pipeline (v1)
- 1
SlotStarted
The slot opens
The clock fires and the core says who leads it.
- 2
build
A block is built
The leader fills it from the mempool, up to twice the target size.
- 3
notarize
First vote
The core accepts the proposal and asks for a notarize vote, signed with ML-DSA-44.
- 4
finalize
Final
One vote out of one is a quorum: the finalize vote makes the block final.
- 5
applyTx
Applied
Each transaction runs through applyTx, then the base fee moves.
| # | Event → action | Node side |
|---|---|---|
| 1 | slotStarted(slot) → buildBlock(slot, finalizedHash) | only if leader(slot) = me; in v1 always |
| 2 | — | select txs, write pending/<hash>, then propose |
| 3 | blockProposed(slot, proposer, parent, block) → castVote(notarize) | sign, verify, feed back as voteReceived |
| 4 | voteReceived(notarize) → castVote(finalize) | on notarize quorum |
| 5 | voteReceived(finalize) → finalized(slot, parent, block) | append to blocks.log, applyTx each tx, nextBaseFee |
Before executing the actions of any step, the node writes the returned state to consensus.state (write to consensus.tmp, fsync, rename, fsync the directory).
Consensus state
structure State where
me, validators : UInt64 -- 0 < validators ≤ 64, me < validators
slot, finalizedSlot : UInt64
finalizedHash : Hash32
proposal : Option Proposal -- { parent, block : Hash32 }
votedFinalize : Bool
notarizers, finalizers : UInt64 -- voter bitmasks
inductive Event
| slotStarted (slot : UInt64)
| blockProposed (slot proposer : UInt64) (parent block : Hash32)
| voteReceived (v : Vote)
inductive Action
| buildBlock (slot : UInt64) (parent : Hash32)
| castVote (v : Vote)
| finalized (slot : UInt64) (parent block : Hash32)
structure Vote where
kind : VoteKind -- notarize | finalize
slot : UInt64
block : Hash32
voter : UInt64
- Leader
- slot % validators (round-robin)
- Quorum
- 2 · validators < 3 · popcount(mask)
- Max validators
- 64 (u64 bitmask)
- v1 configuration
- me = 0, validators = 1
- Encoded state
- 20 u64 = 160 B
- Encoded action
- 10 u64 = 80 B
A proposal is accepted only if slot = state.slot, finalizedSlot < slot, no proposal is held yet, the proposer is the leader, and parent = finalizedHash: every block extends the last finalized block. A slotStarted for a higher slot resets the per-slot fields.
Blocks
block = slot u64 ‖ proposer u64 ‖ parent (32) ‖ tx_count u32 ‖ (len u32 ‖ tx)*
payload = tx_id_1 ‖ tx_id_2 ‖ … // integers little-endian
block_hash = SHA3-256("leansvm/block/v1" ‖ slot ‖ proposer ‖ parent ‖ SHA3-256(payload))
- Max bytes
- 2 × block_target_bytes
- Max txs
- 1,000
- Empty blocks
- yes, one per slot
- Building
- on an overlay of the ledger (no copy)
- Order
- highest effective tip, per account in nonce order
- Genesis hash
- SHA3-256("leansvm/genesis/v1" ‖ params ‖ validator ‖ allocs)
Votes
kind u64 (0 = notarize, 1 = finalize) ‖ slot u64 ‖ block (32) ‖ voter u64 // ML-DSA-44, context "leansvm/vote/v1"
- Rust verifies a vote’s signature before giving
voteReceivedto the core. - Rust signs only votes emitted as
castVote. run_no_equivocation: for any event sequence the core emits at most one vote per (kind, slot). Combined with the write-ahead ofconsensus.state, this holds across crashes; tested withkill -9.
Slot clock
slot(now) = now < genesis_time_ms ? 0 : (now − genesis_time_ms) / slot_ms + 1
- Slots that pass while the node is down are skipped.
- The node follows the system clock while it agrees with the monotonic clock within
slot_ms / 4. On a jump (NTP step, VM resume) slots continue at the measured pace; a warning is logged every 60 s andleansvm_clock_offset_slotsreports the offset. - A restart takes the system clock as it is.
v1 simplifications
| v1 | v2 |
|---|---|
| One validator, quorum = 1 vote | 32–64 validators, quorum by stake |
| Equal weight | stake-weighted |
| No timeouts or skip votes | skip votes from 2/3 |
| Blocks extend the last finalized block | may extend a notarized block |
| Round-robin leader | stake-weighted schedule per epoch |
With one validator the operator chooses inclusion and order. Forgery is detectable: signatures are published in blocks, so a replay of the chain verifies every transaction and every rule.
v2 protocol
- Validators
- 32–64, permissioned
- Slot
- ≈ 400–500 ms
- Finality
- < ≈ 1 s
- Fault tolerance
- malicious stake < 1/3
- Transport
- QUIC, ML-KEM in TLS 1.3
- Vote traffic
- ≈ 2.4 KB × validators per round