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: adding aztec node tx validation tests #8220

Conversation

sklppy88
Copy link
Contributor

@sklppy88 sklppy88 commented Aug 27, 2024

This PR adds some tests on the aztec node for the validation of txs as requested by @nventuro on the previous PR in the stack.

Copy link
Contributor Author

sklppy88 commented Aug 27, 2024

@sklppy88 sklppy88 changed the title init fix: adding aztec node validation tests Aug 27, 2024
@sklppy88 sklppy88 changed the title fix: adding aztec node validation tests fix: adding aztec node tx validation tests Aug 27, 2024
@sklppy88 sklppy88 changed the title fix: adding aztec node tx validation tests fix: adding aztec node tx validation tests Aug 27, 2024
@sklppy88 sklppy88 force-pushed the ek/fix/4781/adding-tx-validation-tests-to-node branch from 3415327 to 2563301 Compare August 27, 2024 17:11
@sklppy88 sklppy88 marked this pull request as ready for review August 27, 2024 18:25
@sklppy88 sklppy88 requested a review from nventuro August 27, 2024 18:25
@AztecBot
Copy link
Collaborator

AztecBot commented Aug 27, 2024

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,759 1,564 709 761 778
proof_construction_time_sha256_30_ms 11,540 (+1%) 3,095 1,380 1,441 1,467 (+1%)
proof_construction_time_sha256_100_ms 44,105 11,849 5,447 5,393 5,806 (+1%)
proof_construction_time_poseidon_hash_ms 78.0 34.0 34.0 58.0 87.0 (-1%)
proof_construction_time_poseidon_hash_30_ms 1,529 421 202 225 271 (+1%)
proof_construction_time_poseidon_hash_100_ms 5,643 1,516 677 (+1%) 730 (-2%) 742

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,938 177,952
l1_rollup_execution_gas 843,053 1,576,619 3,361,689
l2_block_processing_time_in_ms 247 (-4%) 443 (+1%) 806 (-4%)
l2_block_building_time_in_ms 11,531 (+2%) 22,467 (+2%) 45,060 (+1%)
l2_block_rollup_simulation_time_in_ms 11,530 (+2%) 22,467 (+2%) 45,060 (+1%)
l2_block_public_tx_process_time_in_ms 9,796 (+1%) 20,649 (+2%) 43,158 (+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,977 (+2%) 3,864 (+1%)
node_database_size_in_bytes 12,644,432 16,715,856
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 99.3 (+8%) 398 21,735 44,860 N/A
private-kernel-inner 179 (+2%) 705 (-1%) 72,544 45,007 N/A
private-kernel-reset-tiny 321 (+3%) 718 65,593 44,846 N/A
private-kernel-tail 170 (+2%) 136 (-2%) 50,644 52,257 N/A
base-parity 5.70 (+2%) N/A 160 96.0 N/A
root-parity 35.7 (+1%) N/A 73,948 96.0 N/A
base-rollup 3,456 N/A 189,136 664 N/A
block-root-rollup 42.6 (+3%) N/A 58,205 2,448 N/A
public-kernel-setup 86.2 (+1%) N/A 105,085 71,222 N/A
public-kernel-app-logic 98.2 (+2%) N/A 104,911 71,222 N/A
public-kernel-tail 870 (+1%) N/A 390,582 16,414 N/A
private-kernel-reset-small 314 (+1%) N/A 66,341 45,629 N/A
private-kernel-tail-to-public 672 (+1%) 615 455,400 1,825 N/A
public-kernel-teardown 84.5 (+1%) N/A 105,349 71,222 N/A
merge-rollup 20.8 (+2%) N/A 38,174 664 N/A
undefined N/A N/A N/A N/A 76,895 (-2%)

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 344 (+1%)
ContractInstanceDeployer:deploy 1,408 11,731 18.4
MultiCallEntrypoint:entrypoint 1,920 11,731 407 (+1%)
FeeJuice:deploy 1,376 11,731 389
SchnorrAccount:constructor 1,312 11,731 74.1 (+1%)
SchnorrAccount:entrypoint 2,304 11,731 409 (+3%)
Token:privately_mint_private_note 1,280 11,731 105 (+1%)
FPC:fee_entrypoint_public 1,344 11,731 25.8 (-1%)
Token:transfer 1,312 11,731 237 (+4%)
Benchmarking:create_note 1,344 11,731 89.3 (+2%)
SchnorrAccount:verify_private_authwit 1,280 11,731 28.2 (+3%)
Token:unshield 1,376 11,731 530 (+1%)
FPC:fee_entrypoint_private 1,376 11,731 753 (+2%)

AVM Simulation

Time to simulate various public functions in the AVM.

Function time_ms bytecode_size_in_bytes
FeeJuice:_increase_public_balance 55.3 7,101
FeeJuice:set_portal 10.9 (+13%) 2,128
Token:constructor 79.8 (+1%) 25,285
FPC:constructor 57.0 (+8%) 17,853
FeeJuice:mint_public 43.5 (+11%) 5,415
Token:mint_public 44.7 (+1%) 10,101
Token:assert_minter_and_mint 66.8 (+2%) 6,844
AuthRegistry:set_authorized 39.9 (-17%) 3,969
FPC:prepare_fee 235 6,747
Token:transfer_public 19.7 (-28%) 38,126
FPC:pay_refund 50.5 (-5%) 9,398
Benchmarking:increment_balance 1,229 (+3%) 6,179
Token:_increase_public_balance 39.4 (-3%) 7,705
FPC:pay_refund_with_shielded_rebate 62.1 (+3%) 9,881

Public DB Access

Time to access various public DBs.

Function time_ms
get-nullifier-index 0.157 (+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.18 (+1%) 3.87 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.114 (+1%) 0.110 N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 11.4 (+3%) 17.6 (-2%) 30.3 59.0 113 (-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.109 (+2%) 0.102 (-2%) 0.0988 0.101 0.101 (-1%)
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 14.4 (+1%) 25.4 43.2 82.2 161 (-1%)
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.109 (+1%) 0.102 0.104 0.102 (+1%) 0.100 (-2%)
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 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,779 668,997

Transaction size based on fee payment method

| Metric | |
| - | |

@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
Comment on lines +147 to +151
it('tests that the node correctly validates chain id', async () => {
const tx = mockTxForRollup(0x10000);
tx.data.constants.txContext.chainId = chainId;

const mockedGlobalVariables = new GlobalVariables(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised by all of this, did we have no tests for the node validations at all?

fix: fixing private voting by correctly throwing an error if simulation fails (#7840)

This PR makes a simulation of a tx fail, if the tx cannot be included in
a block and added to the state.

e.g. If a simulation produces duplicate nullifiers, or nullifiers that
already exist in a state tree, the results of this simulation should not
be returned, but should warn users that the transaction simulated is
impossible to actually be added to a block due to being an invalid
transaction.

The method for achieving the above is that a new API on the node was
created, used for validating the correctness of the metadata and
side-effects produced by a transaction. A transaction is deemed valid if
and only if the transaction can be added to a block that can be used to
advance state.

Note: this update does not make this validation necessary, and defaults
to offline simulation. Offline simulation is previous non-validated
behavior, and is potentially useful if we ever move to a model where a
node is optional to a pxe.

Another note just for reference: there is weirdness in e2e_prover, that
fails the proof validation.

Resolves #4781.

Apply suggestions from code review

Co-authored-by: Nicolás Venturo <[email protected]>
@sklppy88 sklppy88 force-pushed the ek/fix/4781/adding-double-spend-validator-to-node branch from ffb3fe1 to 30d2493 Compare August 28, 2024 06:33
@sklppy88 sklppy88 force-pushed the ek/fix/4781/adding-tx-validation-tests-to-node branch from da8276c to 501d079 Compare August 28, 2024 06:34
@sklppy88 sklppy88 merged commit 501d079 into ek/fix/4781/adding-double-spend-validator-to-node Aug 28, 2024
34 of 37 checks passed
@sklppy88 sklppy88 deleted the ek/fix/4781/adding-tx-validation-tests-to-node branch August 28, 2024 08:52
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