Skip to main content

Merge Rollup

The Merge rollup circuit is our in-between circuit, it doesn't need to perform any state updates, but mainly check the consistency of its inputs.

Overview

Below is a subset of the data structures figure from earlier for easy reference.

Validity Conditions

def MergeRollupCircuit(
left: ChildRollupData,
right: ChildRollupData
) -> BaseOrMergeRollupPublicInputs:
assert left.proof.is_valid(left.public_inputs)
assert right.proof.is_valid(right.public_inputs)

assert left.public_inputs.constants == right.public_inputs.constants
assert left.public_inputs.end == right.public_inputs.start
assert left.public_inputs.type == right.public_inputs.type
assert left.public_inputs.height_in_block_tree == right.public_inputs.height_in_block_tree

return BaseOrMergeRollupPublicInputs(
type=1,
height_in_block_tree=left.public_inputs.height_in_block_tree + 1,
txs_hash=SHA256(left.public_inputs.txs_hash | right.public_inputs.txs_hash),
out_hash=SHA256(left.public_inputs.out_hash | right.public_inputs.out_hash),
start=left.public_inputs.start,
end=right.public_inputs.end,
constants=left.public_inputs.constants
)