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

feat!: introduce UnconstrainedContext #6752

Merged
merged 6 commits into from
Jun 3, 2024
Merged

feat!: introduce UnconstrainedContext #6752

merged 6 commits into from
Jun 3, 2024

Conversation

nventuro
Copy link
Contributor

Continuing the work from #6442, this PR further formalizes the notion of a top-level unconstrained execution context by introducing a struct that represents it (instead of relying on the unit type). Not only is this less cryptic, it also provides access to data previously unavailable such as the current block number and contract address, which we'll need for some unconstrained getters like SharedMutable's.

The macro functions could potentially be refactored somewhat now that private, public and unconstrained are more similar, but I'm not sure we want to invest much effort there so I made the change as small as possible.

@AztecBot
Copy link
Collaborator

AztecBot commented May 29, 2024

Docs Preview

Hey there! 👋 You can check your preview at https://665df39c24f4511bafadfbf3--aztec-docs-dev.netlify.app

@AztecBot
Copy link
Collaborator

AztecBot commented May 29, 2024

Benchmark results

No metrics with a significant change found.

Detailed results

All benchmarks are run on txs on the Benchmarking contract on the repository. Each tx consists of a batch call to create_note and increment_balance, which guarantees that each tx has a private call, a nested private call, a public call, and a nested public call, as well as an emitted private note, an unencrypted log, and public storage read and write.

This benchmark source data is available in JSON format on S3 here.

Proof generation

Each column represents the number of threads used in proof generation.

Metric 1 threads 4 threads 16 threads 32 threads 64 threads
proof_construction_time_sha256_ms 5,736 (-1%) 1,554 (-1%) 701 (-1%) 749 (-1%) 782
proof_construction_time_sha256_30_ms 11,833 (-2%) 3,156 (-2%) 1,407 (-1%) 1,420 (-2%) 1,466 (-2%)
proof_construction_time_sha256_100_ms 44,857 (-2%) 12,075 (-3%) 5,663 (-2%) 5,551 (-1%) 5,481 (-1%)
proof_construction_time_poseidon_hash_ms 78.0 (-1%) 34.0 (-3%) 35.0 (+3%) 58.0 87.0
proof_construction_time_poseidon_hash_30_ms 1,520 (-1%) 419 (-1%) 202 227 268
proof_construction_time_poseidon_hash_100_ms 5,748 (-1%) 1,560 (-2%) 724 (-1%) 786 (-4%) 792 (-2%)

L2 block published to L1

Each column represents the number of txs on an L2 block published to L1.

Metric 8 txs 32 txs 64 txs
l1_rollup_calldata_size_in_bytes 1,412 1,412 1,412
l1_rollup_calldata_gas 9,464 9,476 9,452
l1_rollup_execution_gas 608,000 608,012 607,988
l2_block_processing_time_in_ms 1,290 (-2%) 4,826 (-1%) 9,602
l2_block_building_time_in_ms 43,924 (-1%) 173,919 (-1%) 347,840 (-1%)
l2_block_rollup_simulation_time_in_ms 43,729 (-1%) 173,189 (-1%) 346,383 (-1%)
l2_block_public_tx_process_time_in_ms 40,505 (-1%) 169,882 (-1%) 343,102 (-1%)

L2 chain processing

Each column represents the number of blocks on the L2 chain where each block has 16 txs.

Metric 3 blocks 5 blocks
node_history_sync_time_in_ms 9,326 (-4%) 14,270 (-2%)
node_database_size_in_bytes 14,487,632 21,348,432
pxe_database_size_in_bytes 18,071 29,868

Circuits stats

Stats on running time and I/O sizes collected for every kernel circuit run across all benchmarks.

Circuit simulation_time_in_ms witness_generation_time_in_ms proving_time_in_ms input_size_in_bytes output_size_in_bytes proof_size_in_bytes num_public_inputs size_in_gates
private-kernel-init 136 (+1%) 495 11,933 (-3%) 20,634 64,614 89,536 2,731 524,288
private-kernel-inner 407 1,006 45,216 (+1%) 92,326 64,614 89,536 2,731 2,097,152
private-kernel-tail 582 (-1%) 2,822 47,156 96,545 77,732 11,648 297 2,097,152
base-parity 6.54 890 (-1%) 2,601 (+1%) 128 64.0 2,208 2.00 131,072
root-parity 50.0 46.7 (-6%) 34,622 (+1%) 27,100 64.0 2,720 18.0 2,097,152
base-rollup 11,959 2,337 (-1%) 64,999 119,738 756 3,648 47.0 4,194,304
root-rollup 113 (+1%) 62.9 (-1%) 19,549 25,309 620 3,456 41.0 1,048,576
public-kernel-app-logic 568 (-1%) 3,469 (-2%) 39,010 (-1%) 108,073 86,550 116,768 3,582 2,097,152
public-kernel-tail 1,123 (-1%) 23,616 (+2%) 154,351 (-1%) 403,238 7,646 11,648 297 8,388,608
private-kernel-reset-small 589 (-1%) 2,074 (-1%) 40,709 120,737 64,614 89,536 2,731 2,097,152
public-kernel-setup 677 2,680 37,742 108,073 86,550 116,768 3,582 2,097,152
public-kernel-teardown 586 (+1%) 3,551 (-1%) 39,233 108,073 86,550 116,768 3,582 2,097,152
merge-rollup 28.9 N/A N/A 16,542 756 N/A N/A N/A
private-kernel-tail-to-public N/A 8,699 86,526 (+1%) N/A N/A 116,768 3,582 4,194,304

Stats on running time collected for app circuits

Function input_size_in_bytes output_size_in_bytes witness_generation_time_in_ms proof_size_in_bytes proving_time_in_ms size_in_gates num_public_inputs
ContractClassRegisterer:register 1,344 9,944 465 (-1%) N/A N/A N/A N/A
ContractInstanceDeployer:deploy 1,408 9,944 42.0 N/A N/A N/A N/A
MultiCallEntrypoint:entrypoint 1,920 9,944 1,789 N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 1,462 N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,817 (+2%) 16,768 50,211 (-1%) 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,660 (+1%) N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 1,135 16,768 10,112 (+1%) 524,288 457
Token:transfer 1,376 9,944 5,456 16,768 48,154 (+1%) 2,097,152 457
Benchmarking:create_note 1,344 9,944 1,468 (+5%) N/A N/A N/A N/A
SchnorrAccount:spend_private_authwit 1,280 9,944 81.7 N/A N/A N/A N/A
Token:unshield 1,376 9,944 3,933 (-3%) N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 4,805 (-4%) N/A N/A N/A N/A

Tree insertion stats

The duration to insert a fixed batch of leaves into each tree type.

Metric 1 leaves 16 leaves 64 leaves 128 leaves 512 leaves 1024 leaves 2048 leaves 4096 leaves 32 leaves
batch_insert_into_append_only_tree_16_depth_ms 10.4 (-1%) 17.4 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.7 31.8 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.607 (-1%) 0.522 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 48.8 76.2 247 471 (-1%) 937 1,859 N/A
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 159 543 1,055 2,079 4,127 N/A
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.498 0.469 0.449 0.440 (-1%) 0.444 0.443 N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 58.6 113 359 691 (-2%) 1,397 2,778 N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 106 208 692 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.506 0.506 0.486 0.475 (-1%) 0.482 (+1%) 0.482 N/A
batch_insert_into_indexed_tree_40_depth_ms N/A N/A N/A N/A N/A N/A N/A N/A 62.8 (-1%)
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A N/A N/A N/A N/A N/A N/A 107
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A N/A N/A N/A N/A N/A N/A 0.555

Miscellaneous

Transaction sizes based on how many contract classes are registered in the tx.

Metric 0 registered classes 1 registered classes
tx_size_in_bytes 84,053 665,267

Transaction size based on fee payment method

| Metric | |
| - | |

Copy link
Contributor

@benesjan benesjan left a comment

Choose a reason for hiding this comment

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

Nice

@nventuro nventuro enabled auto-merge (squash) May 30, 2024 13:32
@nventuro nventuro merged commit e00b251 into master Jun 3, 2024
114 checks passed
@nventuro nventuro deleted the nv/un-context branch June 3, 2024 18:14
Maddiaa0 pushed a commit that referenced this pull request Jun 5, 2024
Continuing the work from
#6442, this PR
further formalizes the notion of a top-level unconstrained execution
context by introducing a struct that represents it (instead of relying
on the unit type). Not only is this less cryptic, it also provides
access to data previously unavailable such as the current block number
and contract address, which we'll need for some unconstrained getters
like `SharedMutable`'s.

The macro functions could potentially be refactored somewhat now that
private, public and unconstrained are more similar, but I'm not sure we
want to invest much effort there so I made the change as small as
possible.
Maddiaa0 pushed a commit that referenced this pull request Jun 5, 2024
Continuing the work from
#6442, this PR
further formalizes the notion of a top-level unconstrained execution
context by introducing a struct that represents it (instead of relying
on the unit type). Not only is this less cryptic, it also provides
access to data previously unavailable such as the current block number
and contract address, which we'll need for some unconstrained getters
like `SharedMutable`'s.

The macro functions could potentially be refactored somewhat now that
private, public and unconstrained are more similar, but I'm not sure we
want to invest much effort there so I made the change as small as
possible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants