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

refactor: add PublicCallStackItem and remove side_effect_counter from call_context #5177

Closed
wants to merge 6 commits into from

Conversation

alexghr
Copy link
Contributor

@alexghr alexghr commented Mar 12, 2024

Stacked on top of #5156

@alexghr alexghr force-pushed the alexg/fix/public-callstack-item branch from 727e673 to 124afeb Compare March 13, 2024 01:47
@alexghr alexghr force-pushed the alexg/fix/public-callstack-item branch from 124afeb to 266cbd8 Compare March 13, 2024 11:19
@alexghr alexghr changed the base branch from master to alexg/fix/phase-mgr March 13, 2024 11:21
@alexghr alexghr force-pushed the alexg/fix/public-callstack-item branch from 266cbd8 to ec36d02 Compare March 13, 2024 11:24
@alexghr alexghr changed the base branch from alexg/fix/phase-mgr to master March 13, 2024 11:24
@alexghr alexghr changed the base branch from master to alexg/fix/phase-mgr March 13, 2024 11:25
Copy link
Contributor

github-actions bot commented Mar 13, 2024

Changes to circuit sizes

Generated at commit: 0b1e1220bde0a8573a166bd2fd7ae77f1adb39e5, compared to commit: 6977e8166b5c27685458a6e04e840b45a77d4765

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_init -1 ✅ -0.00% -2 ✅ -0.00%
private_kernel_inner -1 ✅ -0.00% -312 ✅ -0.06%
public_kernel_teardown -4 ✅ -0.01% -315 ✅ -0.17%
public_kernel_setup -4 ✅ -0.01% -315 ✅ -0.17%
public_kernel_app_logic -11 ✅ -0.02% -603 ✅ -0.19%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
private_kernel_init 48,685 (-1) -0.00% 350,742 (-2) -0.00%
private_kernel_inner 95,968 (-1) -0.00% 521,696 (-312) -0.06%
public_kernel_teardown 29,353 (-4) -0.01% 181,733 (-315) -0.17%
public_kernel_setup 27,607 (-4) -0.01% 179,986 (-315) -0.17%
public_kernel_app_logic 55,524 (-11) -0.02% 313,913 (-603) -0.19%

@alexghr alexghr marked this pull request as ready for review March 13, 2024 15:08
Base automatically changed from alexg/fix/phase-mgr to master March 13, 2024 15:55
@alexghr alexghr force-pushed the alexg/fix/public-callstack-item branch 4 times, most recently from f86091a to cfd2290 Compare March 14, 2024 08:41
@AztecBot
Copy link
Collaborator

AztecBot commented Mar 14, 2024

Benchmark results

Metrics with a significant change:

  • note_successful_decrypting_time_in_ms (8): 236 (+23%)
  • note_trial_decrypting_time_in_ms (32): 82.4 (+156%)
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 1b2cf58a 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 5,668 18,820 36,356
l1_rollup_calldata_gas 66,280 239,068 469,100
l1_rollup_execution_gas 647,378 929,426 1,305,280
l2_block_processing_time_in_ms 1,340 (+4%) 4,759 (+3%) 9,277 (-2%)
note_successful_decrypting_time_in_ms ⚠️ 236 (+23%) 564 (+9%) 969 (-6%)
note_trial_decrypting_time_in_ms 39.7 (-60%) ⚠️ 82.4 (+156%) 98.6 (+71%)
l2_block_building_time_in_ms 18,837 (+3%) 68,269 (-1%) 135,302
l2_block_rollup_simulation_time_in_ms 8,191 (+1%) 28,740 (+1%) 56,347
l2_block_public_tx_process_time_in_ms 10,624 (+5%) 39,469 (-1%) 78,856 (-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 13,703 (-6%) 27,817 (-4%)
note_history_successful_decrypting_time_in_ms 1,266 (-1%) 2,423 (-2%)
note_history_trial_decrypting_time_in_ms 93.0 (-9%) 115 (-35%)
node_database_size_in_bytes 19,083,344 35,684,432
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 279 (-3%) 44,362 28,244
private-kernel-ordering 213 (-2%) 52,868 14,326
base-parity 1,799 (-1%) 128 311
base-rollup 714 165,787 925
root-parity 1,556 (-2%) 1,244 311
root-rollup 62.8 4,487 789
private-kernel-inner 637 (-3%) 73,767 28,244
public-kernel-app-logic 441 (-4%) 35,256 28,215
public-kernel-tail 172 (-2%) 40,926 28,215
merge-rollup 8.30 (-1%) 2,696 925

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 9.98 (-1%) 15.9 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.581 0.493 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 45.7 (-3%) 72.1 231 444 (-1%) 877 (+1%) 1,714 (+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.469 (-3%) 0.445 0.420 0.415 0.415 0.411 (+1%) N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 53.6 (-1%) 107 336 (-1%) 658 (-1%) 1,309 (+1%) 2,595 N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 104 207 691 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.478 (-1%) 0.482 0.456 (-1%) 0.454 0.453 (+1%) 0.452 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.0 (-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.534 (-1%)

Miscellaneous

Transaction sizes based on how many contract classes are registered in the tx.

Metric 0 registered classes
tx_size_in_bytes 22,008

Transaction processing duration by data writes.

Metric 0 new note hashes 1 new note hashes
tx_pxe_processing_time_ms 3,215 (-3%) 1,737 (-2%)
Metric 0 public data writes 1 public data writes
tx_sequencer_processing_time_ms 11.0 1,235 (-3%)

@@ -80,7 +80,7 @@ library Constants {
uint256 internal constant INITIALIZATION_SLOT_SEPARATOR = 1000_000_000;
uint256 internal constant INITIAL_L2_BLOCK_NUM = 1;
uint256 internal constant BLOB_SIZE_IN_BYTES = 126976;
uint256 internal constant MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 15000;
uint256 internal constant MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 20000;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Returning a PublicCallStackItem from the oracle increases the bytecode size for contracts. Some contracts went over the limit (e.g. the lending e2e)

assert(item.public_inputs.call_context.is_static_call == is_static_call);

// this blows up contract deployments
// self.public_call_stack_hashes.push(item.hash());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Enabling this line blows up contract bytecode even more (e.g. lending contract goes from ~16k fields to >25k)

@alexghr alexghr force-pushed the alexg/fix/public-callstack-item branch from 6da453f to 9f1dd8f Compare March 18, 2024 10:28
@alexghr alexghr changed the title refactor: remove side_effect_counter from call_context refactor: add PublicCallStackItem and remove side_effect_counter from call_context Mar 18, 2024
@alexghr alexghr force-pushed the alexg/fix/public-callstack-item branch from 3c7fc5b to 7bb4af9 Compare March 18, 2024 15:20
@fcarreiro fcarreiro removed their request for review March 18, 2024 17:11
@alexghr alexghr force-pushed the alexg/fix/public-callstack-item branch from e005a97 to c0347ae Compare March 18, 2024 19:49
@alexghr alexghr force-pushed the alexg/fix/public-callstack-item branch from da1b125 to 5cf8f02 Compare March 18, 2024 20:24
@alexghr
Copy link
Contributor Author

alexghr commented Mar 19, 2024

I fixed all of the conflicts and used a smaller struct to pass information back to Noir from public_execution_context when calling public function to reduce the size of the generated bytecode.

@alexghr
Copy link
Contributor Author

alexghr commented Mar 31, 2024

I'll close this PR as it's quite old now and will be covered by the avm

@alexghr alexghr closed this Mar 31, 2024
@alexghr alexghr deleted the alexg/fix/public-callstack-item branch April 2, 2024 09:45
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