↑ ↓ navigate↵ open

Slots and finality

The slot pipeline, consensus events and actions, votes, write-ahead persistence and the slot clock.

On this page · 7
  1. 01Slot pipeline (v1)
  2. 02Consensus state
  3. 03Blocks
  4. 04Votes
  5. 05Slot clock
  6. 06v1 simplifications
  7. 07v2 protocol

Slot pipeline (v1)

slot n1 sslot n + 1
  1. 1

    SlotStarted

    The slot opens

    The clock fires and the core says who leads it.

  2. 2

    build

    A block is built

    The leader fills it from the mempool, up to twice the target size.

  3. 3

    notarize

    First vote

    The core accepts the proposal and asks for a notarize vote, signed with ML-DSA-44.

  4. 4

    finalize

    Final

    One vote out of one is a quorum: the finalize vote makes the block final.

  5. 5

    applyTx

    Applied

    Each transaction runs through applyTx, then the base fee moves.

#Event → actionNode side
1slotStarted(slot) → buildBlock(slot, finalizedHash)only if leader(slot) = me; in v1 always
2—select txs, write pending/<hash>, then propose
3blockProposed(slot, proposer, parent, block) → castVote(notarize)sign, verify, feed back as voteReceived
4voteReceived(notarize) → castVote(finalize)on notarize quorum
5voteReceived(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

Spec/Consensus.lean
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
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

vote signing bytes (56)
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 voteReceived to 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 of consensus.state, this holds across crashes; tested with kill -9.

Slot clock

slot
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 and leansvm_clock_offset_slots reports the offset.
  • A restart takes the system clock as it is.

v1 simplifications

v1v2
One validator, quorum = 1 vote32–64 validators, quorum by stake
Equal weightstake-weighted
No timeouts or skip votesskip votes from 2/3
Blocks extend the last finalized blockmay extend a notarized block
Round-robin leaderstake-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