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: making sent tx's fail at validation, rather than waiting for the non inclusion of the tx at a block #7841

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sklppy88
Copy link
Contributor

@sklppy88 sklppy88 commented Aug 8, 2024

Right now when we send a TX to the node, it gets "fake" validated; because if invalid, a no-op occurs, it doesn't give users feedback directly in any way. The transaction is not forwarded to the p2p client, and nothing is returned to the user.

This change makes a sent transaction fail early if the transaction is invalid (that is, unable to be included in any block to advance state).

The mechanism by which this occurs is similar to what is implemented for a simulation, that is we use the previously introduced endpoint on the node to validate if the transaction is not invalid according to our above definition, and if it is invalid, we throw an error on the spot.

Addresses #8231.

@sklppy88 sklppy88 force-pushed the ek/fix/4781/transaction-simulation-should-be-validated branch from a51d888 to 71e587c Compare August 8, 2024 10:34
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from 152f234 to 684caac Compare August 8, 2024 10:34
@sklppy88 sklppy88 changed the title init fix: making sent tx's fail at validation, rather than at being dropped by the p2p node Aug 8, 2024
@AztecBot
Copy link
Collaborator

AztecBot commented Aug 8, 2024

Benchmark results

Metrics with a significant change:

  • protocol_circuit_simulation_time_in_ms (base-rollup): 3,122 (+19%)
  • protocol_circuit_simulation_time_in_ms (private-kernel-tail-to-public): 1,079 (-22%)
  • avm_simulation_time_ms (Token:mint_public): 301 (+474%)
  • avm_simulation_time_ms (AuthRegistry:set_authorized): 49.2 (+31%)
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,757 1,559 717 767 (+1%) 776 (-1%)
proof_construction_time_sha256_30_ms 11,456 3,084 1,381 (-1%) 1,454 (+1%) 1,455 (-1%)
proof_construction_time_sha256_100_ms 44,107 11,840 5,475 5,518 (+1%) 5,633 (-2%)
proof_construction_time_poseidon_hash_ms 78.0 34.0 34.0 57.0 87.0 (-2%)
proof_construction_time_poseidon_hash_30_ms 1,531 421 202 (-1%) 221 (-2%) 269 (+1%)
proof_construction_time_poseidon_hash_100_ms 5,643 1,511 (-1%) 678 724 (-1%) 750

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,356 7,876 14,884
l1_rollup_calldata_gas 50,268 92,980 178,144
l1_rollup_execution_gas 843,087 1,576,695 3,361,915
l2_block_processing_time_in_ms 250 (-2%) 446 (+3%) 810
l2_block_building_time_in_ms 11,493 (+1%) 22,548 (+1%) 44,398 (-1%)
l2_block_rollup_simulation_time_in_ms 11,492 (+1%) 22,547 (+1%) 44,398 (-1%)
l2_block_public_tx_process_time_in_ms 9,801 (+1%) 20,833 (+1%) 42,678 (-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 3,013 (+3%) 3,910 (+4%)
node_database_size_in_bytes 12,607,568 16,699,472
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 92.2 (-5%) 378 (-3%) 21,474 44,898 N/A
private-kernel-inner 170 (-3%) 702 (+2%) 72,411 45,020 N/A
private-kernel-reset-tiny 320 (+4%) 698 (-2%) 65,240 44,886 N/A
private-kernel-tail 168 131 (-5%) 50,608 52,921 N/A
base-parity 5.57 N/A 160 96.0 N/A
root-parity 35.0 N/A 73,948 96.0 N/A
base-rollup ⚠️ 3,122 (+19%) N/A 189,195 664 N/A
block-root-rollup 41.1 N/A 58,205 2,448 N/A
public-kernel-setup 85.4 (+1%) N/A 105,085 71,222 N/A
public-kernel-app-logic 97.9 (+1%) N/A 104,898 71,222 N/A
public-kernel-tail 858 N/A 390,582 16,414 N/A
private-kernel-reset-small 308 N/A 66,341 45,629 N/A
private-kernel-tail-to-public ⚠️ 1,079 (-22%) 594 (-1%) 455,400 1,825 N/A
public-kernel-teardown 83.7 N/A 105,349 71,222 N/A
merge-rollup 20.2 (+1%) N/A 38,174 664 N/A
undefined N/A N/A N/A N/A 82,212

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 343 (-1%)
ContractInstanceDeployer:deploy 1,408 11,731 18.3 (-2%)
MultiCallEntrypoint:entrypoint 1,920 11,731 406 (-1%)
FeeJuice:deploy 1,376 11,731 386 (-3%)
SchnorrAccount:constructor 1,312 11,731 72.8 (-6%)
SchnorrAccount:entrypoint 2,336 11,731 383 (-1%)
FeeJuice:claim 1,344 11,731 39.1 (-1%)
Token:privately_mint_private_note 1,280 11,731 99.6
FPC:fee_entrypoint_public 1,344 11,731 25.7 (-2%)
Token:transfer 1,312 11,731 221 (-9%)
Benchmarking:create_note 1,344 11,731 86.0
SchnorrAccount:verify_private_authwit 1,280 11,731 27.7 (-12%)
Token:unshield 1,376 11,731 520 (-4%)
FPC:fee_entrypoint_private 1,376 11,731 696 (-2%)

AVM Simulation

Time to simulate various public functions in the AVM.

Function time_ms bytecode_size_in_bytes
FeeJuice:_increase_public_balance 49.4 (-4%) 8,174
FeeJuice:set_portal 11.6 (-23%) 4,055
Token:constructor 87.1 (+5%) 29,082
FPC:constructor 55.6 (-1%) 18,940
FeeJuice:check_balance 38.6 (-2%) 5,978
Token:mint_public ⚠️ 301 (+474%) 12,704
Token:assert_minter_and_mint 478 (-1%) 8,467
AuthRegistry:set_authorized ⚠️ 49.2 (+31%) 4,194
FPC:prepare_fee 246 (+10%) 6,747
Token:transfer_public 36.1 (+25%) 39,863
FPC:pay_refund 54.6 (+2%) 9,398
Benchmarking:increment_balance 1,227 7,263
Token:_increase_public_balance 50.5 (+19%) 8,686
FPC:pay_refund_with_shielded_rebate 62.4 9,881

Public DB Access

Time to access various public DBs.

Function time_ms
get-nullifier-index 0.153 (-6%)

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.18 3.82 (-1%) 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.113 (+1%) 0.107 (-1%) N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 11.1 (-1%) 18.0 (+3%) 31.0 (+1%) 59.8 114 (+1%)
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.106 (-1%) 0.104 (+2%) 0.100 0.103 0.102 (+1%)
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 14.4 (-1%) 25.7 44.0 (+1%) 83.1 (+1%) 160 (-1%)
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 108 207 355 691 1,363
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.111 0.104 (+1%) 0.106 0.103 0.102 (-1%)
batch_insert_into_indexed_tree_40_depth_ms N/A N/A 16.5 (+1%) N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A 132 (+1%) N/A N/A N/A N/A
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A 0.106 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,838 668,997

Transaction size based on fee payment method

| Metric | |
| - | |

@sklppy88 sklppy88 force-pushed the ek/fix/4781/transaction-simulation-should-be-validated branch from 71e587c to 2a464b1 Compare August 8, 2024 11:36
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from 684caac to 2574895 Compare August 8, 2024 11:36
@sklppy88 sklppy88 force-pushed the ek/fix/4781/transaction-simulation-should-be-validated branch 2 times, most recently from ea59527 to 2f4d23a Compare August 8, 2024 15:03
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch 3 times, most recently from 36e2089 to 991a16d Compare August 8, 2024 15:59
@sklppy88 sklppy88 changed the title fix: making sent tx's fail at validation, rather than at being dropped by the p2p node fix: making sent tx's fail at validation, rather than waiting for the non inclusion of the tx at a block Aug 9, 2024
@sklppy88 sklppy88 requested a review from nventuro August 9, 2024 15:49
@sklppy88 sklppy88 marked this pull request as ready for review August 9, 2024 15:49
Base automatically changed from ek/fix/4781/transaction-simulation-should-be-validated to ek/fix/4781/breaking-private-voting-test-by-expecting-simulation-to-fail August 9, 2024 17:27
sklppy88 added a commit that referenced this pull request Aug 9, 2024
This PR fixes the outdated error messages brought on by #7841.

Please see that PR for more context.
@sklppy88 sklppy88 force-pushed the ek/fix/4781/breaking-private-voting-test-by-expecting-simulation-to-fail branch from e3794ed to 595b0ad Compare August 12, 2024 20:30
sklppy88 added a commit that referenced this pull request Aug 12, 2024
This PR fixes the outdated error messages brought on by #7841.

Please see that PR for more context.
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from d13b336 to ee7cb6b Compare August 12, 2024 20:30
@sklppy88 sklppy88 force-pushed the ek/fix/4781/breaking-private-voting-test-by-expecting-simulation-to-fail branch from 33c9509 to 1f3fce3 Compare August 12, 2024 21:34
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from ee7cb6b to 9936978 Compare August 12, 2024 21:34
sklppy88 added a commit that referenced this pull request Aug 12, 2024
This PR fixes the outdated error messages brought on by #7841.

Please see that PR for more context.
@sklppy88 sklppy88 force-pushed the ek/fix/4781/breaking-private-voting-test-by-expecting-simulation-to-fail branch 2 times, most recently from 4add105 to 0741b46 Compare August 12, 2024 22:02
sklppy88 added a commit that referenced this pull request Aug 12, 2024
This PR fixes the outdated error messages brought on by #7841.

Please see that PR for more context.
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from 9936978 to d00810d Compare August 12, 2024 22:13
sklppy88 added a commit that referenced this pull request Aug 27, 2024
This PR fixes the outdated error messages brought on by #7841.

Please see that PR for more context.
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from f51e8b8 to 50017f4 Compare August 27, 2024 18:48
@sklppy88 sklppy88 force-pushed the ek/fix/4781/adding-tx-validation-tests-to-node branch from 2563301 to da8276c Compare August 27, 2024 20:24
sklppy88 added a commit that referenced this pull request Aug 27, 2024
This PR fixes the outdated error messages brought on by #7841.

Please see that PR for more context.
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from 50017f4 to 752ca9c Compare August 27, 2024 20:24
@sklppy88 sklppy88 force-pushed the ek/fix/4781/adding-tx-validation-tests-to-node branch from da8276c to 501d079 Compare August 28, 2024 06:33
sklppy88 added a commit that referenced this pull request Aug 28, 2024
This PR fixes the outdated error messages brought on by #7841.

Please see that PR for more context.
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from 752ca9c to dfee9c2 Compare August 28, 2024 06:34
Base automatically changed from ek/fix/4781/adding-tx-validation-tests-to-node to ek/fix/4781/adding-double-spend-validator-to-node August 28, 2024 08:52
@sklppy88 sklppy88 force-pushed the ek/fix/4781/adding-double-spend-validator-to-node branch from 501d079 to c006b33 Compare August 28, 2024 10:49
sklppy88 added a commit that referenced this pull request Aug 28, 2024
This PR fixes the outdated error messages brought on by #7841.

Please see that PR for more context.
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from dfee9c2 to 178f2d9 Compare August 28, 2024 10:49
@sklppy88 sklppy88 force-pushed the ek/fix/4781/adding-double-spend-validator-to-node branch from c006b33 to 6d1ef00 Compare August 28, 2024 12:20
sklppy88 added a commit that referenced this pull request Aug 28, 2024
This PR fixes the outdated error messages brought on by #7841.

Please see that PR for more context.
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from 178f2d9 to 36f87a2 Compare August 28, 2024 12:20
@sklppy88 sklppy88 force-pushed the ek/fix/4781/adding-double-spend-validator-to-node branch from 6d1ef00 to 9f14a97 Compare August 28, 2024 20:47
sklppy88 added a commit that referenced this pull request Aug 28, 2024
This PR fixes the outdated error messages brought on by #7841.

Please see that PR for more context.
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from 36f87a2 to 47f47d1 Compare August 28, 2024 20:47
@sklppy88 sklppy88 force-pushed the ek/fix/4781/adding-double-spend-validator-to-node branch from 9f14a97 to 159fe3b Compare August 29, 2024 19:21
sklppy88 added a commit that referenced this pull request Aug 29, 2024
This PR fixes the outdated error messages brought on by #7841.

Please see that PR for more context.
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from 47f47d1 to 24f43be Compare August 29, 2024 19:21
Base automatically changed from ek/fix/4781/adding-double-spend-validator-to-node to master August 30, 2024 11:09
sklppy88 added a commit that referenced this pull request Aug 30, 2024
This PR fixes the outdated error messages brought on by #7841.

Please see that PR for more context.
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from 24f43be to 403c62c Compare August 30, 2024 12:43
sklppy88 and others added 2 commits August 31, 2024 13:54
This PR fixes the outdated error messages brought on by #7841.

Please see that PR for more context.
@sklppy88 sklppy88 force-pushed the ek/fix/4781/sent-transactions-should-also-fail-early-if-invalid branch from 403c62c to b094dbe Compare August 31, 2024 13:54
Comment on lines +213 to +214
await expect(contract.methods.emit_nullifier(nullifier).send().wait()).rejects.toThrow(
'The simulated transaction is unable to be added to state and is invalid.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to have the validators pass further context to the error, e.g. in this case explain that it's due to a duplicated nullifier?

@sklppy88 sklppy88 marked this pull request as draft September 26, 2024 05:36
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