Skip to content

Commit

Permalink
chore: cleaning inconsistency (#3851)
Browse files Browse the repository at this point in the history
- Fixing an inconsistency in the diagram/validity conditions of the root
rollup.
- Renaming inputs to public inputs in the validity conditions.
  • Loading branch information
LHerskind committed Jan 5, 2024
1 parent a3920fb commit 9bbd70a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 33 deletions.
8 changes: 5 additions & 3 deletions yellow-paper/docs/rollup-circuits/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,17 +308,19 @@ class MergeRollupInputs {
MergeRollupInputs *-- ChildRollupData: left
MergeRollupInputs *-- ChildRollupData: right
class RootRollupInputs {
l1_to_l2_msgs_tree: Snapshot
l1_to_l2_msgs: List~Fr~
l1_to_l2_msgs_sibling_path: List~Fr~
parent: Header,
parent_sibling_path: List~Fr~
archive_sibling_path: List~Fr~
left: ChildRollupData
right: ChildRollupData
}
RootRollupInputs *-- ChildRollupData: left
RootRollupInputs *-- ChildRollupData: right
RootRollupInputs *-- Header : parent
class RootRollupPublicInputs {
Expand Down Expand Up @@ -428,7 +430,7 @@ graph BT
K2[l2_to_l1_msgs 1.0]
K3[l2_to_l1_msgs 1.1]
K4[l2_to_l1_msgs 2.0]
K5[TxEffect 2.1]
K5[l2_to_l1_msgs 2.1]
K6[l2_to_l1_msgs 3.0]
K7[l2_to_l1_msgs 3.1]
Expand Down
24 changes: 12 additions & 12 deletions yellow-paper/docs/rollup-circuits/merge_rollup.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@ def MergeRollupCircuit(
left: ChildRollupData,
right: ChildRollupData
) -> BaseOrMergeRollupPublicInputs:
assert left.proof.is_valid(left.inputs)
assert right.proof.is_valid(right.inputs)
assert left.proof.is_valid(left.public_inputs)
assert right.proof.is_valid(right.public_inputs)

assert left.inputs.constants == right.inputs.constants
assert right.inputs.start == left.inputs.end
assert left.inputs.type == right.inputs.type
assert left.inputs.height_in_block_tree == right.inputs.height_in_block_tree
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.inputs.height_in_block_tree + 1,
height_in_block_tree=left.public_inputs.height_in_block_tree + 1,
aggregation_object=AggregationObject(left.proof, right.proof),
txs_hash=SHA256(left.inputs.txs_hash | right.inputs.txs_hash),
out_hash=SHA256(left.inputs.out_hash | right.inputs.out_hash),
start=left.inputs.start,
end=right.inputs.end,
constants=left.inputs.constants
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
)
```
43 changes: 25 additions & 18 deletions yellow-paper/docs/rollup-circuits/root_rollup.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ class ChildRollupData {
ChildRollupData *-- BaseOrMergeRollupPublicInputs: public_inputs
class RootRollupInputs {
l1_to_l2_msgs_tree: Snapshot
l1_to_l2_msgs: List~Fr~
l1_to_l2_msgs_sibling_path: List~Fr~
parent: Header,
parent_sibling_path: List~Fr~
archive_sibling_path: List~Fr~
left: ChildRollupData
right: ChildRollupData
}
RootRollupInputs *-- Header : parent
RootRollupInputs *-- ChildRollupData: left
RootRollupInputs *-- ChildRollupData: right
Expand All @@ -149,29 +150,33 @@ RootRollupPublicInputs *--Header : header

```python
def RootRollupCircuit(
left: ChildRollupData,
right: ChildRollupData,
l1_to_l2_msgs: List[Fr],
l1_to_l2_msgs_sibling_path: List[Fr],
parent: Header,
parent_sibling_path: List[Fr],
archive_sibling_path: List[Fr],
left: ChildRollupData,
right: ChildRollupData,
) -> RootRollupPublicInputs:
assert left.proof.is_valid(left.inputs)
assert right.proof.is_valid(right.inputs)
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

assert left.inputs.constants == right.inputs.constants
assert right.inputs.start == left.inputs.end
assert left.inputs.type == right.inputs.type
assert left.inputs.height_in_block_tree == right.inputs.height_in_block_tree
assert parent.state.partial == left.public_inputs.start

# Check that the parent is a valid parent
assert merkle_inclusion(
parent.hash(),
parent_sibling_path,
left.inputs.constants.global_variables.block_number,
left.inputs.constants.last_archive.root
left.public_inputs.constants.global_variables.block_number,
left.public_inputs.constants.last_archive.root
)

# Update the l1 to l2 msg tree
l1_to_l2_msg_subtree = MerkleTree(l1_to_l2_msgs)
l1_to_l2_msg_tree = merkle_insertion(
parent.state.l1_to_l2_message_tree,
Expand All @@ -181,17 +186,17 @@ def RootRollupCircuit(
L1_To_L2_HEIGHT
)

txs_hash = SHA256(left.inputs.txs_hash | right.inputs.txs_hash)
out_hash = SHA256(left.inputs.txs_hash | right.inputs.out_hash)
txs_hash = SHA256(left.public_inputs.txs_hash | right.public_inputs.txs_hash)
out_hash = SHA256(left.public_inputs.txs_hash | right.public_inputs.out_hash)

header = Header(
last_archive = left.inputs.constants.last_archive,
last_archive = left.public_inputs.constants.last_archive,
body_hash = SHA256(txs_hash | out_hash | SHA256(l1_to_l2_msgs)),
state = StateReference(
l1_to_l2_message_tree = l1_to_l2_msg_tree,
partial = right.inputs.end,
partial = right.public_inputs.end,
),
global_variables = left.inputs.constants.global_variables,
global_variables = left.public_inputs.constants.global_variables,
)

archive = merkle_insertion(
Expand All @@ -203,7 +208,9 @@ def RootRollupCircuit(
)

return RootRollupPublicInputs(
aggregation_object = left.inputs.aggregation_object + right.inputs.aggregation_object,
aggregation_object =
left.public_inputs.aggregation_object +
right.public_inputs.aggregation_object,
archive = archive,
header: Header,
)
Expand Down

0 comments on commit 9bbd70a

Please sign in to comment.