Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The execution engine

One engine runs every transaction: the sequencer runs it directly for a public transaction, a prover runs the same code inside the circuit for a private one. The program receives the same input either way; ReceiveInput has no field saying which.

a_generated_call_graph_runs_the_same_whole_and_split asserts a generated call graph gives the same result run whole and split across the boundary (lee/state_machine/core/src/execution_state/tests.rs).

Source: lee/state_machine/core/src/execution_state.rs, about 1,700 lines, with settlement in lee/state_machine/src/validated_state_diff/mod.rs, the public execution environment in lee/state_machine/src/validated_state_diff/public_backend.rs, and the RISC Zero executor wrapper that runs one handler in lee/state_machine/src/program/mod.rs.

The shapes

pub enum TransactionEntry<R>      // the root: a sync message, or a consumed async one
pub struct PublicExecutionContext // actors, authorized accounts, promotions, private signers
pub struct WholeExecution<'w>     // a transaction with both halves
pub struct PrivatePart<'w>        // the half that runs under proof
pub struct PublicPart             // the half the sequencer runs
pub struct Delivery<S>            // one message on its way to one actor
pub enum BoundaryStep             // a crossing between the halves
pub enum Placement                // whether an actor is public or private
pub struct TransitionView<'e>     // one handler invocation, as the engine sees it

A transaction is not “public” or “private” as a whole: it is a sequence of segments on either side of a boundary (WholeExecution), and the engine tracks which half it is in.

Delivery order

A work stack, processed depth first, in the order Order of execution gives.

a_parents_async_messages_precede_its_childrens_and_never_run_their_recipients states the async ordering for recipients the transaction does not declare: a parent’s async messages come before its children’s, and each is stored rather than run. An async message to a declared public actor, or one the submitter promotes, is delivered in the transaction instead, carrying no grant, and its failure fails the transaction (AsyncMessage). On the private side, a_promoted_private_async_message_keeps_its_own_presentation_and_crosses_after_the_calls asserts async crosses the boundary after the calls, not with them.

A handler that sends two messages cannot assume they interleave: the first subtree finishes entirely first. a_failing_descendant_of_c1_stops_the_transaction_before_c2 asserts the consequence: a failure deep inside the first subtree stops the transaction before the second message is delivered.

Re-entry works by staging: a handler invoked again inside the same transaction sees the state the earlier invocation left, not the state the transaction started with.

No depth cap

The engine bounds neither the message tree’s depth nor its fan-out. What bounds a transaction instead:

ExecutionBound
Publicthe transaction’s declared gas_limit, at most MAX_GAS_EXEC (10M cycles, also the cap on a whole block), shared across every transition in the transaction
Privateprover time for the private part, and the settlement budget below for the public part. Sequencer RPC and gossip validation also refuse a submitted private transaction whose boundary (or fee fallback boundary) has more than MAX_BOUNDARY_STEPS (1024) steps, bounding the messages that cross between the halves

A private transaction’s public part is metered at settlement:

  • when a public signer pays the fee, against its declared gas_limit less the proof’s verification cost;
  • otherwise, against what the block has left of MAX_GAS_EXEC, and no more than the fee reserve pays for past the tip.

a_long_self_send_chain_completes_in_every_part asserts a chain of 128 self-sends on a public actor runs all 129 invocations both whole and in the public part of the split run, and a_long_self_send_chain_fits_the_public_budget (lee/state_machine/src/state/tests/chained_calls.rs) asserts a root plus 64 self-sends fits LEE’s default public budget, DEFAULT_PUBLIC_CYCLE_BUDGET (32M cycles), which is larger than the 10M a LEZ transaction may declare. transitions_share_one_budget (lee/state_machine/src/validated_state_diff/tests.rs) confirms the budget is shared across every transition, not granted per handler.

The missing cap is one of the limits that are missing and may be added in a later release.

The boundary

Each crossing between public and private is a BoundaryStep carrying a message whose sender and recipient are Actors, and an Actor is { account_id, program_account_id }.

Blinding a sender replaces the account id and leaves the program account id in the clear, so a boundary crossing always reveals which program was on the private side. This is why an undisclosed program’s identity survives only a transaction that never crosses the boundary; Programs, deployment and identity covers what that means for an undisclosed claim.

The engine predicts the messages that will cross, and the circuit checks the prediction. The mismatch errors (MissingPredictedCrossMessages, UnusedPredictedCrossMessages, BoundaryMismatch, CrossMessageMismatch, IncompleteBoundary) all mean the prover and the sequencer disagree about what crossed. a_nested_mixed_graph_is_predicted_bracketed_and_replayed_through_every_part exercises the mechanism on a nested graph, and a_nested_boundary_settles_both_public_writes checks that a crossing nested inside another still settles both public writes.

Settlement

For a private transaction the sequencer does not re-run the private handlers: it verifies the proof, then runs the public part (the handlers of the public actors the transaction reaches) in the order the traversal emitted them, against live state.

A prepared private transaction still settles later against public state that has since moved, because that state was never in the proof. Every guard on public state must be strong on its own: the sequencer will not re-derive the reasoning that produced it.

The privacy circuit is the other half: what the proof covers.

How this chapter was checked

Most claims above cite a named test. Sources says how to run them and what a pass does and does not prove.