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(SimulateTx): Decoded Return values for public and private function calls #5551

Closed
wants to merge 49 commits into from

Conversation

LHerskind
Copy link
Contributor

@LHerskind LHerskind commented Apr 3, 2024

Went into a bit of merging hell here, so only the last commit is really the important one that have the diffs for this pr - eb46d88.

The pr changes slightly how the artifact is used to construct the FunctionArtifact as part of the contract_artifact.ts such that it includes the returnTypes from BEFORE the macros have been applied. This is possible using @Thunkar's additions to the abi 😎.

The private and public execution is altered to return the flattened values directly, and the simulate in the contract_function_interaction.ts will then use the changes to the artifact to decode the values before returning to the user.

Compared to the old approach where I was looking to return decoded from the simulation, this is more straightforward as we don't need to handle additional plumbing to get the artifacts into the public execution, and keeps the decoding on the user side of things. Also makes it easier to follow the paths.


The solution is currently only returning the return values of the last enqueued public call as part of the application logic.

This was done as it is: 1) unclear what is actually the expected, 2) there will only be one in most cases where using it as a read.

The main case where there could be multiple public calls that you want to get the return values for would be for using the multi-call structure, where we wish to get the return values for every single one. Making the multi-call work is still a TODO.

Note that something like a multicall can be implemented with just a single enqueued public call if done as a contract, so that can be done interim, but longer term it would be quite interesting to be able to use the batch directly without needing a multi-call contract to be deployed at all.

The native multi-calls are also an issue for the private functions. This solution is therefore mainly for having the ability to read without unconstrained, multi-calls can come later.

@LHerskind LHerskind marked this pull request as draft April 3, 2024 14:23
@AztecBot
Copy link
Collaborator

AztecBot commented Apr 3, 2024

Docs Preview

Hey there! 👋 You can check your preview at https://660d6bf24d6f1ffc9e9d9ad7--aztec-docs-dev.netlify.app

@AztecBot
Copy link
Collaborator

AztecBot commented Apr 3, 2024

Benchmark results

Metrics with a significant change:

  • note_successful_decrypting_time_in_ms (8): 256 (+23%)
  • note_trial_decrypting_time_in_ms (8): 56.5 (+364%)
  • note_trial_decrypting_time_in_ms (32): 111 (+118%)
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 0249737e 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 64 txs
l1_rollup_calldata_size_in_bytes 676 676 676
l1_rollup_calldata_gas 6,424 6,412 6,424
l1_rollup_execution_gas 585,757 585,745 585,757
l2_block_processing_time_in_ms 1,325 4,760 9,341 (+2%)
note_successful_decrypting_time_in_ms ⚠️ 256 (+23%) 602 (+11%) 1,050 (+7%)
note_trial_decrypting_time_in_ms ⚠️ 56.5 (+364%) ⚠️ 111 (+118%) 69.9 (-30%)
l2_block_building_time_in_ms 11,489 41,928 82,861
l2_block_rollup_simulation_time_in_ms 7,474 26,157 51,303
l2_block_public_tx_process_time_in_ms 3,993 15,720 (+1%) 31,458 (+1%)

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,248 (-1%) 27,311 (+1%)
note_history_successful_decrypting_time_in_ms 1,319 (+1%) 2,478 (+1%)
note_history_trial_decrypting_time_in_ms 63.2 (-38%) 116 (+1%)
node_database_size_in_bytes 18,632,784 35,016,784
pxe_database_size_in_bytes 29,859 59,414

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 182 (-1%) 44,379 28,214
private-kernel-ordering 169 52,880 14,296
base-parity 3,563 (+3%) 128 311
root-parity 1,251 (-4%) 1,244 311
base-rollup 15,004 165,760 861
root-rollup 49.7 4,359 725
private-kernel-inner 226 73,795 28,214
public-kernel-app-logic 95.7 35,252 28,217
public-kernel-tail 137 40,928 28,217
merge-rollup 8.57 (-7%) 2,568 861
public-kernel-teardown 91.9 (-1%) 35,252 28,217
public-kernel-setup 90.8 (-1%) 35,252 28,217

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 512 leaves 1024 leaves 2048 leaves 4096 leaves 32 leaves
batch_insert_into_append_only_tree_16_depth_ms 10.2 (+2%) 16.1 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_count 16.8 31.6 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_16_depth_hash_ms 0.592 (+2%) 0.495 N/A N/A N/A N/A N/A N/A N/A
batch_insert_into_append_only_tree_32_depth_ms N/A N/A 46.4 (-3%) 72.4 (+1%) 234 (+1%) 448 876 (+1%) 1,748 (+1%) N/A
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 96.0 159 543 1,055 2,079 4,127 N/A
batch_insert_into_append_only_tree_32_depth_hash_ms N/A N/A 0.476 (-3%) 0.446 (+1%) 0.426 (+1%) 0.418 0.416 0.418 (+2%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 55.3 (+2%) 108 (+1%) 343 (+1%) 670 (+1%) 1,324 (+1%) 2,629 N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 105 207 691 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.482 0.485 0.467 (+1%) 0.459 (+1%) 0.458 (+1%) 0.458 (+1%) N/A
batch_insert_into_indexed_tree_40_depth_ms N/A N/A N/A N/A N/A N/A N/A N/A 61.7 (+1%)
batch_insert_into_indexed_tree_40_depth_hash_count N/A N/A N/A N/A N/A N/A N/A N/A 109
batch_insert_into_indexed_tree_40_depth_hash_ms N/A N/A N/A N/A N/A N/A N/A N/A 0.538 (+1%)

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 14,968 495,320

Transaction size based on fee payment method

Metric none fee payment method native fee payment method fpc_public fee payment method fpc_private fee payment method
tx_with_fee_size_in_bytes 773 905 1,161 1,377

Transaction processing duration by data writes.

Metric 0 new note hashes 1 new note hashes 2 new note hashes
tx_pxe_processing_time_ms 1,823 (+1%) 1,122 5,611 (+1%)
Metric 0 public data writes 1 public data writes 2 public data writes 3 public data writes 4 public data writes 5 public data writes 8 public data writes
tx_sequencer_processing_time_ms 10.6 (-6%) 488 383 (-1%) 921 (+1%) 577 (+3%) 1,502 555

Thunkar added a commit that referenced this pull request Apr 9, 2024
Leverages the `#[abi(tag)]` feature from
#5386 to output the
aztec functions abi *before* macro transformation, so that values can be
decoded in #5551

---------

Co-authored-by: esau <152162806+sklppy88@users.noreply.github.com>
AztecBot added a commit to noir-lang/noir that referenced this pull request Apr 9, 2024
Leverages the `#[abi(tag)]` feature from
AztecProtocol/aztec-packages#5386 to output the
aztec functions abi *before* macro transformation, so that values can be
decoded in AztecProtocol/aztec-packages#5551

---------

Co-authored-by: esau <152162806+sklppy88@users.noreply.github.com>
@LHerskind
Copy link
Contributor Author

Closing this as I created the cleaner version of it in #5762 now that other things were merged it, seemed easier than cleaning this abomination.

@LHerskind LHerskind closed this Apr 17, 2024
@ludamad ludamad deleted the lh/return_value_abomination branch August 22, 2024 15: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