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: revert early in verifier contract for malformed proof inputs #4453

Merged
merged 7 commits into from
Feb 6, 2024

Conversation

TomAFrench
Copy link
Member

We currently check whether various points contained in the proof lie on the bn128 curve and then feed those points into the EC precompiles whether or not they failed the previous check. This means that the precompile then fails and eats all of the gas which the user has sent.

This PR modifies these checks so that we immediately revert if we find a point which doesn't satisfy this check. This avoids the behaviour of burning all the available gas which happens if we make the call to the precompile with invalid inputs.

@TomAFrench TomAFrench requested a review from LHerskind February 6, 2024 15:49
@TomAFrench TomAFrench force-pushed the tf/early-revert-on-invalid-points branch from 9084d3e to f6098ee Compare February 6, 2024 15:50
@AztecBot
Copy link
Collaborator

AztecBot commented Feb 6, 2024

Benchmark results

Metrics with a significant change:

  • note_trial_decrypting_time_in_ms (32): 107 (+100%)
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.

Values are compared against data from master at commit 00f99663 and shown if the difference exceeds 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 128 txs
l1_rollup_calldata_size_in_bytes 45,636 180,516 720,036
l1_rollup_calldata_gas 222,516 870,588 3,465,960
l1_rollup_execution_gas 315,003 988,328 3,685,617
l2_block_processing_time_in_ms 1,160 (-3%) 4,387 (-6%) 17,218 (-1%)
note_successful_decrypting_time_in_ms 308 (-2%) 979 (-5%) 3,611 (-5%)
note_trial_decrypting_time_in_ms 15.6 (-35%) ⚠️ 107 (+100%) 145 (-3%)
l2_block_building_time_in_ms 17,998 (-2%) 71,067 (-2%) 285,071 (-2%)
l2_block_rollup_simulation_time_in_ms 13,155 (-2%) 51,771 (-2%) 208,233 (-2%)
l2_block_public_tx_process_time_in_ms 4,811 (-3%) 19,173 (-1%) 76,557 (-2%)

L2 chain processing

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

Metric 5 blocks 10 blocks
node_history_sync_time_in_ms 14,105 (+2%) 26,424
note_history_successful_decrypting_time_in_ms 2,453 (+4%) 4,535 (-3%)
note_history_trial_decrypting_time_in_ms 100 (-6%) 223 (-6%)
node_database_size_in_bytes 17,309,776 33,046,608
pxe_database_size_in_bytes 29,923 59,478

Circuits stats

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

Circuit circuit_simulation_time_in_ms circuit_input_size_in_bytes circuit_output_size_in_bytes
private-kernel-init 310 (-1%) 44,476 26,153
private-kernel-ordering 199 44,473 16,553
base-rollup 1,405 (-1%) 128,930 881
root-rollup 82.3 (-1%) 4,088 677
private-kernel-inner 444 (-1%) 71,607 26,153
public-kernel-private-input 247 (-1%) 32,563 26,153
public-kernel-non-first-iteration 247 32,605 26,153
merge-rollup 7.61 (-1%) 2,608 881

Tree insertion stats

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

Metric 1 leaves 2 leaves 8 leaves 16 leaves 32 leaves 128 leaves 64 leaves 512 leaves 1024 leaves 2048 leaves 8192 leaves
batch_insert_into_append_only_tree_16_depth_ms 10.3 (-3%) 11.5 (-2%) 12.7 (-1%) 17.1 (-1%) 23.1 64.0 (-1%) N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.9 17.5 23.0 31.6 47.0 143 N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.600 (-3%) 0.641 (+1%) 0.542 (-1%) 0.528 (-2%) 0.482 0.441 N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A N/A N/A N/A 76.7 (+2%) 47.9 (-4%) 239 (-1%) 463 903 3,552 (-1%)
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A N/A N/A N/A 159 96.0 543 1,055 2,079 8,223
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A N/A N/A N/A 0.474 (+2%) 0.491 (-4%) 0.436 (-1%) 0.433 0.429 0.426 (-1%)
batch_insert_into_indexed_tree_20_depth_ms N/A N/A N/A N/A N/A 104 56.7 (-3%) 351 688 (-1%) 1,370 5,410
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A N/A N/A N/A 197 104 691 1,363 2,707 10,771
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A N/A N/A N/A 0.494 0.495 (-3%) 0.474 (-1%) 0.473 0.475 0.471
batch_insert_into_indexed_tree_40_depth_ms N/A N/A N/A 56.6 (-2%) N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A N/A 94.1 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A N/A 0.579 (-1%) N/A N/A N/A N/A N/A N/A N/A

Miscellaneous

Transaction sizes based on how many contracts are deployed in the tx.

Metric 0 deployed contracts 1 deployed contracts
tx_size_in_bytes 17,187 39,991

Transaction processing duration by data writes.

Metric 0 new commitments 1 new commitments
tx_pxe_processing_time_ms 557 (-1%) 1,319 (-1%)
Metric 0 public data writes 1 public data writes
tx_sequencer_processing_time_ms 0.562 (+12%) 592 (-1%)

Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

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

The removed and make it possible to ignore part of validation.

Base automatically changed from tf/check-verification-key-on-deploy to master February 6, 2024 17:12
@TomAFrench TomAFrench marked this pull request as ready for review February 6, 2024 17:13
@TomAFrench TomAFrench enabled auto-merge (squash) February 6, 2024 17:18
@TomAFrench TomAFrench merged commit d4a7716 into master Feb 6, 2024
81 of 83 checks passed
@TomAFrench TomAFrench deleted the tf/early-revert-on-invalid-points branch February 6, 2024 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants