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: false decryption #7047

Closed
wants to merge 3 commits into from
Closed

Conversation

benesjan
Copy link
Contributor

We get incorrect decryption when a note is empty because the overflow check fails.

Copy link
Contributor Author

benesjan commented Jun 13, 2024

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

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

@benesjan benesjan changed the title fix: false decryption fix fix: false decryption Jun 13, 2024
@benesjan benesjan requested a review from LHerskind June 13, 2024 14:19
@@ -82,6 +85,7 @@ export class TaggedLog<Payload extends L1NotePayload | L1EventPayload> {
// as some field will likely end up not being in the field etc.
try {
if (payloadType === L1EventPayload) {
console.log("decrypting as L1EventPayload");
Copy link
Contributor

Choose a reason for hiding this comment

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

Wanted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks bbed780

@benesjan benesjan force-pushed the 06-13-fix_false_decryption_fix branch from 57d87a5 to 8396770 Compare June 13, 2024 14:23
@fcarreiro
Copy link
Contributor

I'll let Lasse approve since IDK about the logic involved :)

@benesjan benesjan marked this pull request as draft June 13, 2024 15:00
@benesjan benesjan marked this pull request as draft June 13, 2024 15:00
@benesjan benesjan removed the request for review from LHerskind June 13, 2024 15:00
@AztecBot
Copy link
Collaborator

Benchmark results

Metrics with a significant change:

  • avm_simulation_time_ms (Token:mint_public): 70.4 (-87%)
  • avm_simulation_time_ms (Token:assert_minter_and_mint): 227 (+205%)
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,727 1,563 (+1%) 694 767 (+2%) 774 (+1%)
proof_construction_time_sha256_30_ms 11,408 3,060 1,367 1,406 (-1%) 1,447 (-1%)
proof_construction_time_sha256_100_ms 43,851 11,748 5,427 5,383 5,376 (+1%)
proof_construction_time_poseidon_hash_ms 78.0 (-1%) 34.0 34.0 58.0 88.0
proof_construction_time_poseidon_hash_30_ms 1,518 416 199 230 272 (+1%)
proof_construction_time_poseidon_hash_100_ms 5,730 1,563 724 769 (-1%) 793

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 1,412 1,412 1,412
l1_rollup_calldata_gas 9,440 9,450 9,452
l1_rollup_execution_gas 610,261 610,271 610,273
l2_block_processing_time_in_ms 768 (+2%) 1,408 (-1%) 2,753 (+2%)
l2_block_building_time_in_ms 23,398 (+1%) 45,841 (-1%) 91,436 (+1%)
l2_block_rollup_simulation_time_in_ms 23,304 (+1%) 45,554 (-1%) 91,089 (+1%)
l2_block_public_tx_process_time_in_ms 19,972 (+1%) 42,111 (-1%) 87,628 (+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 6,368 (-2%) 9,250 (-1%)
node_database_size_in_bytes 10,588,240 14,368,848
pxe_database_size_in_bytes 9,242 15,127

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 129 (-1%) 491 (-2%) 12,106 (-2%) 20,634 65,142 90,304 2,755 524,288
private-kernel-inner 391 1,004 (-1%) 46,321 (+3%) 92,854 65,142 90,304 2,755 2,097,152
private-kernel-tail 370 1,882 47,861 (+4%) 97,073 73,629 14,912 399 2,097,152
base-parity 6.34 (-1%) 1,817 (-3%) 2,814 (+9%) 128 64.0 2,208 2.00 131,072
root-parity 51.1 50.1 (+5%) 34,808 (+2%) 27,100 64.0 2,720 18.0 2,097,152
base-rollup 7,725 (-1%) 4,454 (-1%) 74,160 (+2%) 170,330 756 3,648 47.0 4,194,304
root-rollup 116 (+3%) 62.0 (-6%) 19,634 25,309 620 3,456 41.0 1,048,576
public-kernel-setup 698 (-2%) 2,878 38,426 (-1%) 113,321 91,286 123,296 3,786 2,097,152
public-kernel-app-logic 593 (-1%) 3,970 40,126 113,321 91,286 123,296 3,786 2,097,152
public-kernel-tail 1,179 31,245 (-3%) 157,543 (-1%) 412,582 10,014 14,912 399 8,388,608
private-kernel-reset-small 593 2,129 (+1%) 42,952 (+6%) 121,265 65,142 90,304 2,755 2,097,152
public-kernel-teardown 597 (-1%) 3,892 39,971 (+1%) 113,321 91,286 123,296 3,786 2,097,152
merge-rollup 29.3 N/A N/A 16,542 756 N/A N/A N/A
private-kernel-tail-to-public N/A 7,114 (-2%) 90,486 (+6%) N/A N/A 123,296 3,786 4,194,304
avm-circuit N/A N/A 3,253 (+3%) N/A N/A 86,117 0.00 0.00

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 406 N/A N/A N/A N/A
ContractInstanceDeployer:deploy 1,408 9,944 41.7 N/A N/A N/A N/A
MultiCallEntrypoint:entrypoint 1,920 9,944 2,023 (+1%) N/A N/A N/A N/A
GasToken:deploy 1,376 9,944 967 N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 1,489 (+2%) N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,840 16,768 50,809 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,758 (+1%) N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 367 16,768 10,201 (+1%) 524,288 457
Token:transfer 1,312 9,944 4,953 (+1%) 16,768 47,573 (+3%) 2,097,152 457
Benchmarking:create_note 1,344 9,944 1,410 N/A N/A N/A N/A
SchnorrAccount:spend_private_authwit 1,280 9,944 76.3 (+1%) N/A N/A N/A N/A
Token:unshield 1,376 9,944 3,988 (+1%) N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 4,909 N/A N/A N/A N/A

AVM Simulation

Time to simulate various public functions in the AVM.

Function time_ms bytecode_size_in_bytes
GasToken:_increase_public_balance 67.7 (-3%) 13,873
GasToken:set_portal 16.6 3,495
Token:constructor 93.7 24,207
FPC:constructor 62.8 (-2%) 13,893
GasToken:mint_public 54.5 10,241
Token:mint_public ⚠️ 70.4 (-87%) 19,216
Token:assert_minter_and_mint ⚠️ 227 (+205%) 13,034
SchnorrAccount:approve_public_authwit 33.7 (+7%) 7,767
FPC:prepare_fee 78.8 (+6%) 15,187
Token:transfer_public 50.2 (-2%) 31,236
FPC:pay_refund 63.6 (-4%) 20,080
Benchmarking:increment_balance 2,413 15,465
Token:_increase_public_balance 58.1 (-19%) 15,089
FPC:pay_refund_with_shielded_rebate 54.9 (+8%) 21,167

Public DB Access

Time to access various public DBs.

Function time_ms
get-nullifier-index 0.171 (-3%)

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 10.4 (+1%) 17.0 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
batch_insert_into_append_only_tree_16_depth_hash_ms 0.608 (+1%) 0.520 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 (+1%) 76.4 135 (+3%) 244 (-1%) 484 (+4%)
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 159 288 543 1,055
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.499 (+1%) 0.471 0.461 (+3%) 0.443 (-1%) 0.451 (+3%)
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 60.2 (+1%) 113 (+1%) 186 (+3%) 352 (-1%) 706 (+3%)
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 109 208 355 691 1,363
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.511 (+1%) 0.507 (+1%) 0.493 (+3%) 0.477 (-1%) 0.485 (+2%)
batch_insert_into_indexed_tree_40_depth_ms N/A N/A 74.9 N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A 135 N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A 0.524 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 83,854 676,749

Transaction size based on fee payment method

| Metric | |
| - | |

@benesjan
Copy link
Contributor Author

Check disabled for now in #7022

@benesjan benesjan closed this Jun 14, 2024
@benesjan benesjan deleted the 06-13-fix_false_decryption_fix branch August 27, 2024 16:20
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