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.num_txs >= right.public_inputs.num_txs

return BaseOrMergeRollupPublicInputs(
type=1,
num_txs=left.public_inputs.num_txs + right.public_inputs.num_txs,
txs_effect_hash=SHA256(left.public_inputs.txs_effect_hash | right.public_inputs.txs_effect_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
)