Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue with run_nargo_fmt.sh + minor yellow paper naming improvements #3833

Merged
merged 4 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion yarn-project/run_nargo_fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Note: This script formats the files multiple times when the given project is included in a workspace.
# Tackling this became a time sink, so I decided to leave it as is for now.

set -eu
set -e

# We set the executable path as if we were in CI
nargo_executable="/usr/src/noir/target/release/nargo"
Expand Down
4 changes: 2 additions & 2 deletions yellow-paper/docs/contracts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ class StateTransitioner:

def body_available(
self,
content_hash: Fr,
body_hash: Fr,
txs_hash: Fr,
l1_to_l2_msgs: Fr[],
l2_to_l1_msgs: Fr[]
) -> bool:
assert self.registry.availability_oracle.is_available(txs_hash)
in_hash = SHA256(pad(l1_to_l2_msgs))
out_hash = MerkleTree(pad(l2_to_l1_msgs), SHA256)
return content_hash == SHA256(txs_hash, out_hash, in_hash)
return body_hash == SHA256(txs_hash, out_hash, in_hash)
)

def validate_header(
Expand Down
6 changes: 3 additions & 3 deletions yellow-paper/docs/rollup-circuits/base_rollup.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PartialStateReference {
}

class StateReference {
l1_to_l2_message_tree: Snapshot
l1_to_l2_messages_tree: Snapshot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree on this change. It makes the tree not match the others. Everything else seems to be singular_tree. See the PartialStateReference for naming of others as example

partial: PartialStateReference
}
StateReference *-- PartialStateReference: partial
Expand All @@ -44,11 +44,11 @@ class GlobalVariables {

class Header {
last_archive: Snapshot
content_hash: Fr[2]
body_hash: Fr[2]
state: StateReference
global_variables: GlobalVariables
}
Header *.. Body : content_hash
Header *.. Body : body_hash
Header *-- StateReference : state
Header *-- GlobalVariables : global_variables

Expand Down
18 changes: 9 additions & 9 deletions yellow-paper/docs/rollup-circuits/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class PartialStateReference {
}

class StateReference {
l1_to_l2_message_tree: Snapshot
l1_to_l2_messages_tree: Snapshot
partial: PartialStateReference
}
StateReference *-- PartialStateReference: partial
Expand All @@ -120,11 +120,11 @@ class GlobalVariables {

class Header {
last_archive: Snapshot
content_hash: Fr[2]
body_hash: Fr[2]
state: StateReference
global_variables: GlobalVariables
}
Header *.. Body : content_hash
Header *.. Body : body_hash
Header *-- StateReference : state
Header *-- GlobalVariables : global_variables

Expand Down Expand Up @@ -372,11 +372,11 @@ graph LR
```

#### State availability
To ensure that state is made available, we could broadcast all of a block's input data as public inputs of the final root rollup proof, but a proof with so many public inputs would be very expensive to verify onchain. Instead we reduce the proof's public inputs by committing to the block's body by iteratively computing a `TxsHash` and `OutHash` at each rollup circuit iteration. AT the final iteration a `content_hash` is computed committing to the complete body.
To ensure that state is made available, we could broadcast all of a block's input data as public inputs of the final root rollup proof, but a proof with so many public inputs would be very expensive to verify onchain. Instead we reduce the proof's public inputs by committing to the block's body by iteratively computing a `TxsHash` and `OutHash` at each rollup circuit iteration. AT the final iteration a `body_hash` is computed committing to the complete body.

To check that this body is published an Aztec node can reconstruct the `content_hash` from available data. Since we define finality as the point where the block is validated and included in the state of the [validating light node](./../contracts/index.md), we can define a block as being "available" if the validating light node can reconstruct the commitment `content_hash`.
To check that this body is published an Aztec node can reconstruct the `body_hash` from available data. Since we define finality as the point where the block is validated and included in the state of the [validating light node](./../contracts/index.md), we can define a block as being "available" if the validating light node can reconstruct the commitment `body_hash`.

Since we strive to minimize the compute requirements to prove blocks, we amortize the commitment cost across the full tree. We can do so by building merkle trees of partial "commitments", whose roots are ultimately computed in the final root rollup circuit. The `content_hash` is then computed from the roots of these trees, together with incoming messages.
Since we strive to minimize the compute requirements to prove blocks, we amortize the commitment cost across the full tree. We can do so by building merkle trees of partial "commitments", whose roots are ultimately computed in the final root rollup circuit. The `body_hash` is then computed from the roots of these trees, together with incoming messages.
Below, we outline the `TxsHash` merkle tree that is based on the `TxEffect`s and a `OutHash` which is based on the `l2_to_l1_msgs` (cross-chain messages) for each transaction. While the `TxsHash` implicitly includes the `l2_to_l1_msgs` we construct it separately since the `l2_to_l1_msgs` must be available to the L1 contract directly and not just proven available. This is not a concern when using L1 calldata as the data layer, but is a concern when using alternative data layers such as [Celestia](https://celestia.org/) or [Blobs](https://eips.ethereum.org/EIPS/eip-4844).

```mermaid
Expand Down Expand Up @@ -448,10 +448,10 @@ graph BT
K7 --> B3
```

The roots of these trees, together with incoming messages, makes up the `content_hash`.
The roots of these trees, together with incoming messages, makes up the `body_hash`.
```mermaid
graph BT
R[content_hash]
R[body_hash]
M0[TxsHash]
M1[OutHash]
M2[InHash]
Expand All @@ -465,7 +465,7 @@ graph BT
```

```python
def content_hash(body: Body):
def body_hash(body: Body):
txs_hash = merkle_tree(body.txs, SHA256).root
out_hash = merkle_tree([tx.l1_to_l2_msgs for tx in body.txs], SHA256).root
in_hash = SHA256(body.l1_to_l2_messages)
Expand Down
12 changes: 6 additions & 6 deletions yellow-paper/docs/rollup-circuits/root_rollup.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PartialStateReference {
}

class StateReference {
l1_to_l2_message_tree: Snapshot
l1_to_l2_messages_tree: Snapshot
partial: PartialStateReference
}
StateReference *-- PartialStateReference: partial
Expand All @@ -46,11 +46,11 @@ class GlobalVariables {

class Header {
last_archive: Snapshot
content_hash: Fr[2]
body_hash: Fr[2]
state: StateReference
global_variables: GlobalVariables
}
Header *.. Body : content_hash
Header *.. Body : body_hash
Header *-- StateReference : state
Header *-- GlobalVariables : global_variables

Expand Down Expand Up @@ -174,7 +174,7 @@ def RootRollupCircuit(

l1_to_l2_msg_subtree = MerkleTree(l1_to_l2_msgs)
l1_to_l2_msg_tree = merkle_insertion(
parent.state.l1_to_l2_message_tree,
parent.state.l1_to_l2_messages_tree,
l1_to_l2_msg_subtree.root,
l1_to_l2_msgs_sibling_path,
L1_TO_L2_SUBTREE_HEIGHT,
Expand All @@ -186,9 +186,9 @@ def RootRollupCircuit(

header = Header(
last_archive = left.inputs.constants.last_archive,
content_hash = SHA256(txs_hash | out_hash | SHA256(l1_to_l2_msgs)),
body_hash = SHA256(txs_hash | out_hash | SHA256(l1_to_l2_msgs)),
state = StateReference(
l1_to_l2_message_tree = l1_to_l2_msg_tree,
l1_to_l2_messages_tree = l1_to_l2_msg_tree,
partial = right.inputs.end,
),
global_variables = left.inputs.constants.global_variables,
Expand Down
6 changes: 3 additions & 3 deletions yellow-paper/docs/state/archive.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PartialStateReference {
}

class StateReference {
l1_to_l2_message_tree: Snapshot
l1_to_l2_messages_tree: Snapshot
partial: PartialStateReference
}
StateReference *-- PartialStateReference: partial
Expand All @@ -38,11 +38,11 @@ class GlobalVariables {

class Header {
last_archive: Snapshot
content_hash: Fr[2]
body_hash: Fr[2]
state: StateReference
global_variables: GlobalVariables
}
Header *.. Body : content_hash
Header *.. Body : body_hash
Header *-- StateReference : state
Header *-- GlobalVariables : global_variables

Expand Down
10 changes: 5 additions & 5 deletions yellow-paper/docs/state/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class PartialStateReference {
}

class StateReference {
l1_to_l2_message_tree: Snapshot
l1_to_l2_messages_tree: Snapshot
partial: PartialStateReference
}
StateReference *-- PartialStateReference: partial
Expand All @@ -84,11 +84,11 @@ class GlobalVariables {

class Header {
last_archive: Snapshot
content_hash: Fr[2]
body_hash: Fr[2]
state: StateReference
global_variables: GlobalVariables
}
Header *.. Body : content_hash
Header *.. Body : body_hash
Header *-- StateReference : state
Header *-- GlobalVariables : global_variables

Expand Down Expand Up @@ -186,9 +186,9 @@ class State {
nullifier_tree: NullifierTree
public_data_tree: PublicDataTree
contract_tree: ContractTree
l1_to_l2_message_tree: L1ToL2MessageTree
l1_to_l2_messages_tree: L1ToL2MessageTree
}
State *-- L1ToL2MessageTree : l1_to_l2_message_tree
State *-- L1ToL2MessageTree : l1_to_l2_messages_tree
State *-- Archive : archive
State *-- NoteHashTree : note_hash_tree
State *-- NullifierTree : nullifier_tree
Expand Down