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

docs: Remove broadcast-all methods from class registerer #5298

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Changes from all 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
50 changes: 9 additions & 41 deletions yellow-paper/docs/contract-deployment/classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ unconstrained_functions_artifact_tree_root = merkleize(unconstrained_functions_a

artifact_hash = sha256(
private_functions_artifact_tree_root,
unconstrained_functions_artifact_tree_root,
unconstrained_functions_artifact_tree_root,
artifact_metadata_hash,
)
```
Expand Down Expand Up @@ -130,13 +130,13 @@ function register(
private_functions_root: Field,
public_bytecode_commitment: Point,
packed_public_bytecode: Field[],
)
)
version = 1

assert is_valid_packed_public_bytecode(packed_public_bytecode)
computed_bytecode_commitment = calculate_commitment(packed_public_bytecode)
assert public_bytecode_commitment == computed_bytecode_commitment

contract_class_id = pedersen([version, artifact_hash, private_functions_root, computed_bytecode_commitment], GENERATOR__CLASS_IDENTIFIER)

emit_nullifier contract_class_id
Expand All @@ -157,43 +157,7 @@ The `ContractClassRegisterer` will need to exist from the genesis of the Aztec N

The `ContractClassRegisterer` has an additional private `broadcast` functions that can be used for broadcasting on-chain the bytecode, both ACIR and Brillig, for private functions and unconstrained in the contract. Any user can freely call this function. Given that ACIR and Brillig [do not have a circuit-friendly commitment](../bytecode/index.md), it is left up to nodes to perform this check.

Broadcasted contract artifacts that do not match with their corresponding `artifact_hash`, or that reference a `contract_class_id` that has not been broadcasted, can be safely discarded.

```
function broadcast_all_private_functions(
contract_class_id: Field,
artifact_metadata_hash: Field,
unconstrained_functions_artifact_tree_root: Field,
functions: { selector: Field, metadata_hash: Field, vk_hash: Field, bytecode: Field[] }[],
)
emit_unencrypted_event ClassPrivateFunctionsBroadcasted(
contract_class_id,
artifact_metadata_hash,
unconstrained_functions_artifact_tree_root,
functions,
)
```

```
function broadcast_all_unconstrained_functions(
contract_class_id: Field,
artifact_metadata_hash: Field,
private_functions_artifact_tree_root: Field,
functions:{ selector: Field, metadata_hash: Field, bytecode: Field[] }[],
)
emit_unencrypted_event ClassUnconstrainedFunctionsBroadcasted(
contract_class_id,
artifact_metadata_hash,
unconstrained_functions_artifact_tree_root,
functions,
)
```

<!-- TODO: What representation of bytecode can we use here? -->

The broadcast functions are split between private and unconstrained to allow for private bytecode to be broadcasted, which is valuable for composability purposes, without having to also include unconstrained functions, which could be costly to do due to data broadcasting costs. Additionally, note that each broadcast function must include enough information to reconstruct the `artifact_hash` from the Contract Class, so nodes can verify it against the one previously registered.

The `ContractClassRegisterer` contract also allows broadcasting individual functions, in case not every function needs to be put on-chain. This requires providing a Merkle membership proof for the function within its tree, that nodes can validate.
Broadcasted function artifacts that do not match with their corresponding `artifact_hash`, or that reference a `contract_class_id` that has not been broadcasted, can be safely discarded.

```
function broadcast_private_function(
Expand Down Expand Up @@ -231,6 +195,10 @@ function broadcast_unconstrained_function(
)
```

<!-- TODO: What representation of bytecode can we use here? -->

The broadcast functions are split between private and unconstrained to allow for private bytecode to be broadcasted, which is valuable for composability purposes, without having to also include unconstrained functions, which could be costly to do due to data broadcasting costs. Additionally, note that each broadcast function must include enough information to reconstruct the `artifact_hash` from the Contract Class, so nodes can verify it against the one previously registered.

A node that captures a `ClassPrivateFunctionBroadcasted` should perform the following validation steps before storing the private function information in its database:

```
Expand Down Expand Up @@ -270,4 +238,4 @@ It is strongly recommended for developers registering new classes to broadcast t

### Bundling private function information into a single tree

Data about private functions is split across two trees: one for the protocol, that deals only with selectors and verification keys, and one for the artifact, which deals with bytecode and metadata. While bundling together both trees would simplify the representation, it would also pollute the protocol circuits and require more hashing there. In order to minimize in-circuit hashing, we opted for keeping non-protocol info completely out of circuits.
Data about private functions is split across two trees: one for the protocol, that deals only with selectors and verification keys, and one for the artifact, which deals with bytecode and metadata. While bundling together both trees would simplify the representation, it would also pollute the protocol circuits and require more hashing there. In order to minimize in-circuit hashing, we opted for keeping non-protocol info completely out of circuits.