Module outbox_proof

Module outbox_proof 

Source
Expand description

Merkle proof construction for L2→L1 send messages.

Implements the NodeInterface.constructOutboxProof(size, leaf) algorithm from Nitro’s execution/nodeinterface/node_interface.go.

The algorithm walks the Merkle accumulator tree from leaf toward the root, collecting sibling positions at each level. Nodes that fall inside the committed range (< size) come from L2ToL1Tx / SendMerkleUpdate event logs; nodes past the balanced-tree boundary are filled from “partial” accumulator state.

The tree structure, level numbering, and partial-reconstruction logic mirror Nitro exactly so a client holding a proof generated here verifies against the same sendRoot that Nitro produces.

Structs§

LevelAndLeaf
A position in the Merkle tree: level (0 = leaves) + leaf index within that level.
ProofPlan
Result of planning a proof construction: which nodes to fetch from logs (query) and which nodes form the proof path (nodes), plus which of those are “partials” that are computed from the accumulator state rather than fetched.

Functions§

encode_outbox_proof
ABI-encode the outbox proof return value.
finalize_proof
Given a resolved map from LevelAndLeaf → hash (fetched from log scan + partials), walk the proof path and return (send, root, proof_vec) ready for ABI encoding.
plan_proof
Plan the outbox-proof walk: given the tree size (send count) and the leaf we want to prove, compute the list of sibling positions that together form the proof path.