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(avm): JUMPI opcode in AVM circuit #6800

Merged
merged 4 commits into from
May 31, 2024
Merged

Conversation

jeanmon
Copy link
Contributor

@jeanmon jeanmon commented May 31, 2024

Resolves #6795

@jeanmon jeanmon marked this pull request as ready for review May 31, 2024 15:11
@jeanmon jeanmon requested a review from dbanks12 May 31, 2024 15:17
auto trace_no_jump = Execution::gen_trace(instructions, returndata, std::vector<FF>{ 0 }, public_inputs_vec);

// Expected sequence of PCs during execution with jump
std::vector<FF> pc_sequence_jump{ 0, 1, 2, 4, 5 };
Copy link
Member

Choose a reason for hiding this comment

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

nice test vectors

Copy link
Member

@Maddiaa0 Maddiaa0 left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -373,8 +375,12 @@ namespace avm_main(256);

//===== CONTROL FLOW =======================================================
//===== JUMP ===============================================================
#[PC_JUMP]
Copy link
Member

Choose a reason for hiding this comment

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

i suppose these could potentially be combined into the same relation? sel_jump feels like a subset of jumpi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it is. In addition one can combine with:

  • sel_internal_call * (pc' - ia) = 0;
  • sel_internal_return * (pc' - ia) = 0;

I suggest to favor readability for the time being and I will write a comment in PIL file about this consolidation.

@jeanmon jeanmon force-pushed the jm/6795-avm-circuit-jumpi branch from b2c4624 to 7366170 Compare May 31, 2024 15:38
@jeanmon jeanmon enabled auto-merge (squash) May 31, 2024 15:42
Copy link
Collaborator

@AztecBot AztecBot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'C++ Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: 7366170 Previous: b2c4624 Ratio
nativeClientIVCBench/Full/6 16399.12603799999 ms/iter 15475.607738000008 ms/iter 1.06
nativeconstruct_proof_ultrahonk_power_of_2/20 6500.152414999988 ms/iter 5522.661730999999 ms/iter 1.18
wasmconstruct_proof_ultrahonk_power_of_2/20 17933.838886 ms/iter 16872.300216 ms/iter 1.06

This comment was automatically generated by workflow using github-action-benchmark.

CC: @ludamad @codygunton

@jeanmon jeanmon force-pushed the jm/6795-avm-circuit-jumpi branch from 7366170 to 1ccab1d Compare May 31, 2024 15:57
@AztecBot
Copy link
Collaborator

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,715 1,544 696 744 (-3%) 782 (+1%)
proof_construction_time_sha256_30_ms 11,726 (+3%) 3,141 (+2%) 1,407 (+2%) 1,426 (+1%) 1,468 (+1%)
proof_construction_time_sha256_100_ms 44,746 (+2%) 12,065 (+2%) 5,674 (+5%) 5,533 (+2%) 5,510 (+3%)
proof_construction_time_poseidon_hash_ms 78.0 34.0 34.0 57.0 (+2%) 87.0
proof_construction_time_poseidon_hash_30_ms 1,517 420 202 221 264 (-1%)
proof_construction_time_poseidon_hash_100_ms 5,727 1,558 (-1%) 718 (-3%) 785 (-1%) 788 (-1%)

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,452 9,464
l1_rollup_execution_gas 616,105 616,093 616,105
l2_block_processing_time_in_ms 1,306 4,835 9,520 (-2%)
l2_block_building_time_in_ms 43,865 (-2%) 173,472 (-2%) 346,616 (-2%)
l2_block_rollup_simulation_time_in_ms 43,669 (-2%) 172,739 (-2%) 345,166 (-2%)
l2_block_public_tx_process_time_in_ms 40,468 (-2%) 169,503 (-2%) 341,888 (-2%)

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,439 (-1%) 14,401 (-1%)
node_database_size_in_bytes 14,499,920 21,340,240
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%) 472 13,060 (+2%) 20,634 64,614 89,536 2,731 524,288
private-kernel-inner 407 947 (+1%) 51,708 (+4%) 92,326 64,614 89,536 2,731 2,097,152
private-kernel-tail 585 2,683 (-1%) 53,023 96,545 77,732 11,648 297 2,097,152
base-parity 6.46 1,052 (-2%) 2,841 (-3%) 128 64.0 2,208 2.00 131,072
root-parity 49.9 (+1%) 60.5 (-4%) 41,581 (-1%) 27,100 64.0 2,720 18.0 2,097,152
base-rollup 8,875 (-1%) 2,402 78,953 119,738 756 3,648 47.0 4,194,304
root-rollup 110 76.0 (-5%) 23,274 (-1%) 25,309 620 3,456 41.0 1,048,576
public-kernel-app-logic 567 (-1%) 3,667 (+2%) 48,762 (+8%) 108,073 86,550 116,768 3,582 2,097,152
public-kernel-tail 1,120 (-1%) 24,083 (-2%) 186,893 (+2%) 403,238 7,646 11,648 297 8,388,608
private-kernel-reset-small 589 (-1%) 1,971 (-13%) 46,230 (+2%) 120,737 64,614 89,536 2,731 2,097,152
public-kernel-setup 658 (-1%) 2,787 (-1%) 45,408 (+2%) 108,073 86,550 116,768 3,582 2,097,152
public-kernel-teardown 561 (-1%) 3,578 (-4%) 46,656 (-3%) 108,073 86,550 116,768 3,582 2,097,152
merge-rollup 29.5 (+1%) N/A N/A 16,542 756 N/A N/A N/A
private-kernel-tail-to-public N/A 8,661 (+5%) 101,834 (-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 463 (-1%) N/A N/A N/A N/A
ContractInstanceDeployer:deploy 1,408 9,944 41.4 N/A N/A N/A N/A
MultiCallEntrypoint:entrypoint 1,920 9,944 1,764 N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 1,426 N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,750 16,768 58,299 (+8%) 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,578 N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 1,053 16,768 11,069 (+1%) 524,288 457
Token:transfer 1,376 9,944 5,311 16,768 54,736 (+4%) 2,097,152 457
Benchmarking:create_note 1,344 9,944 1,397 (+1%) N/A N/A N/A N/A
SchnorrAccount:spend_private_authwit 1,280 9,944 76.1 (-2%) N/A N/A N/A N/A
Token:unshield 1,376 9,944 3,902 (-1%) N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 4,794 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 (-6%) 17.3 (-1%) 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.603 (-6%) 0.518 (-1%) 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.5 77.9 (+2%) 252 (+2%) 475 933 1,835 (-1%) 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.495 0.480 (+2%) 0.456 (+2%) 0.443 0.441 0.438 (-1%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 58.5 113 359 (+1%) 698 1,391 2,752 (-1%) 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.505 0.505 0.485 (+1%) 0.479 0.479 0.478 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.7
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.554

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 | |
| - | |

@jeanmon jeanmon merged commit 64d4ba9 into master May 31, 2024
88 of 90 checks passed
@jeanmon jeanmon deleted the jm/6795-avm-circuit-jumpi branch May 31, 2024 16:55
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.

AVM circuit: JUMPI opcode
3 participants