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: add validation of address when registering a contract #8038

Merged

Conversation

sklppy88
Copy link
Contributor

@sklppy88 sklppy88 commented Aug 16, 2024

This PR adds validation upon adding a new contract. We had issues with devnet where the contract being added to the PXE was incorrect, as the contract class id matched the one passed in with the artifact, but the actual computed address was incorrect due to the artifacts being different.

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @sklppy88 and the rest of your teammates on Graphite Graphite

@sklppy88 sklppy88 changed the title init fix: add validation of address when registering a contract Aug 16, 2024
@sklppy88 sklppy88 force-pushed the ek/fix/add-validation-of-address-when-registering-a-contract branch 2 times, most recently from c1caf69 to 616aa80 Compare August 16, 2024 11:10
@AztecBot
Copy link
Collaborator

AztecBot commented Aug 16, 2024

Benchmark results

Metrics with a significant change:

  • protocol_circuit_simulation_time_in_ms (private-kernel-tail-to-public): 671 (-55%)
  • avm_simulation_time_ms (FeeJuice:set_portal): 13.0 (+38%)
  • avm_simulation_time_ms (Token:transfer_public): 27.4 (+35%)
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,784 1,578 715 (-1%) 756 (-1%) 777
proof_construction_time_sha256_30_ms 11,501 (-1%) 3,102 1,374 1,423 (-1%) 1,463
proof_construction_time_sha256_100_ms 44,486 (+1%) 11,856 5,412 (-1%) 5,621 (+4%) 5,739 (-2%)
proof_construction_time_poseidon_hash_ms 78.0 34.0 34.0 59.0 (+2%) 88.0
proof_construction_time_poseidon_hash_30_ms 1,533 423 204 (+1%) 226 269 (-2%)
proof_construction_time_poseidon_hash_100_ms 5,665 1,513 (-1%) 681 733 (+2%) 746

L2 block published to L1

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

Metric 4 txs 8 txs 16 txs
l1_rollup_calldata_size_in_bytes 4,324 7,844 14,852
l1_rollup_calldata_gas 49,768 92,502 177,656
l1_rollup_execution_gas 1,373,796 2,107,426 3,892,636
l2_block_processing_time_in_ms 246 (+1%) 444 (+1%) 800 (+3%)
l2_block_building_time_in_ms 8,980 17,521 34,931 (+1%)
l2_block_rollup_simulation_time_in_ms 8,980 17,521 34,930 (+1%)
l2_block_public_tx_process_time_in_ms 7,578 16,010 33,338 (+1%)

L2 chain processing

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

Metric 3 blocks 5 blocks
node_history_sync_time_in_ms 2,973 3,881 (+2%)
node_database_size_in_bytes 12,619,856 16,744,528
pxe_database_size_in_bytes 16,254 26,813

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 input_size_in_bytes output_size_in_bytes proving_time_in_ms
private-kernel-init 84.9 (-6%) 410 (+3%) 21,755 44,860 N/A
private-kernel-inner 171 (+3%) 705 (-1%) 72,566 45,007 N/A
private-kernel-reset-tiny 466 (+2%) 868 65,675 44,846 N/A
private-kernel-tail 195 160 (+1%) 50,686 52,257 N/A
base-parity 5.63 (+1%) N/A 160 96.0 N/A
root-parity 35.4 (-1%) N/A 73,948 96.0 N/A
base-rollup 2,763 N/A 189,136 664 N/A
root-rollup 40.3 (+1%) N/A 58,173 716 N/A
public-kernel-setup 84.0 (+1%) N/A 105,085 71,222 N/A
public-kernel-app-logic 95.4 (+1%) N/A 104,911 71,222 N/A
public-kernel-tail 554 (+1%) N/A 410,534 16,414 N/A
private-kernel-reset-small 454 (-1%) N/A 66,341 45,629 N/A
private-kernel-tail-to-public ⚠️ 671 (-55%) 644 (-1%) 460,796 1,825 N/A
public-kernel-teardown 82.6 (-1%) N/A 105,349 71,222 N/A
merge-rollup 20.1 N/A 38,174 664 N/A
undefined N/A N/A N/A N/A 77,246 (-5%)

Stats on running time collected for app circuits

Function input_size_in_bytes output_size_in_bytes witness_generation_time_in_ms
ContractClassRegisterer:register 1,344 11,731 345 (+1%)
ContractInstanceDeployer:deploy 1,408 11,731 18.2
MultiCallEntrypoint:entrypoint 1,920 11,731 408 (+1%)
FeeJuice:deploy 1,376 11,731 392 (+2%)
SchnorrAccount:constructor 1,312 11,731 74.6
SchnorrAccount:entrypoint 2,304 11,731 414 (+1%)
Token:privately_mint_private_note 1,280 11,731 106 (+7%)
FPC:fee_entrypoint_public 1,344 11,731 30.3 (+11%)
Token:transfer 1,312 11,731 230
Benchmarking:create_note 1,344 11,731 88.8 (+2%)
SchnorrAccount:verify_private_authwit 1,280 11,731 27.2 (-1%)
Token:unshield 1,376 11,731 524
FPC:fee_entrypoint_private 1,376 11,731 710 (+2%)

AVM Simulation

Time to simulate various public functions in the AVM.

Function time_ms bytecode_size_in_bytes
FeeJuice:_increase_public_balance 59.4 (+4%) 7,739
FeeJuice:set_portal ⚠️ 13.0 (+38%) 2,354
Token:constructor 80.6 (-15%) 26,051
FPC:constructor 55.0 (+1%) 18,001
FeeJuice:mint_public 39.6 (-1%) 5,877
Token:mint_public 45.3 (+3%) 10,917
Token:assert_minter_and_mint 66.6 (+1%) 7,512
AuthRegistry:set_authorized 47.7 (+2%) 4,391
FPC:prepare_fee 241 (+3%) 7,043
Token:transfer_public ⚠️ 27.4 (+35%) 39,426
FPC:pay_refund 58.4 (-2%) 10,234
Benchmarking:increment_balance 935 6,563
Token:_increase_public_balance 42.5 (+5%) 8,433
FPC:pay_refund_with_shielded_rebate 65.4 (+5%) 10,783

Public DB Access

Time to access various public DBs.

Function time_ms
get-nullifier-index 0.164 (+1%)

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 256 leaves 512 leaves 1024 leaves
batch_insert_into_append_only_tree_16_depth_ms 2.20 (+1%) 3.91 (+2%) N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.8 31.7 N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.115 (+2%) 0.111 (+3%) N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 11.6 (+1%) 18.1 (+3%) 30.9 58.9 (+1%) 113 (+3%)
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 159 287 543 1,055
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.111 (+1%) 0.105 (+3%) 0.101 0.101 (+1%) 0.102 (+2%)
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 14.6 (+1%) 25.7 (+1%) 44.2 (+1%) 82.4 (+1%) 162 (+3%)
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 109 207 355 691 1,363
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.111 (+1%) 0.103 0.107 (+1%) 0.102 0.104 (+4%)
batch_insert_into_indexed_tree_40_depth_ms N/A N/A 16.6 (+2%) N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A 132 N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A 0.106 (+1%) N/A N/A N/A N/A

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 64,779 668,997

Transaction size based on fee payment method

| Metric | |
| - | |

@sklppy88 sklppy88 force-pushed the ek/fix/add-validation-of-address-when-registering-a-contract branch 3 times, most recently from e16d051 to 9c963e1 Compare August 16, 2024 13:34
@sklppy88 sklppy88 force-pushed the ek/fix/add-validation-of-address-when-registering-a-contract branch from 9c963e1 to 0e3c2c7 Compare August 22, 2024 16:16
@sklppy88 sklppy88 requested a review from alexghr August 22, 2024 20:33
@sklppy88 sklppy88 marked this pull request as ready for review August 22, 2024 20:33
Copy link
Contributor

@alexghr alexghr left a comment

Choose a reason for hiding this comment

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

Nice one!

@sklppy88 sklppy88 merged commit 9f57fff into master Aug 23, 2024
101 checks passed
@sklppy88 sklppy88 deleted the ek/fix/add-validation-of-address-when-registering-a-contract branch August 23, 2024 10:53
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