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: variable_base_scalar_mul blackbox func #6039

Merged
merged 32 commits into from
Apr 30, 2024

Conversation

benesjan
Copy link
Contributor

Currently we only had fixed_base_scalar_mul blackbox function available. With the new key stuff we need variable base as well. This PR is an attempt at implementing that.

Copy link
Contributor Author

benesjan commented Apr 26, 2024

@AztecBot
Copy link
Collaborator

AztecBot commented Apr 26, 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.

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 740 740 740
l1_rollup_calldata_gas 6,680 6,692 6,692
l1_rollup_execution_gas 586,812 586,824 586,824
l2_block_processing_time_in_ms 1,468 (-13%) 5,491 (-3%) 10,584 (-2%)
l2_block_building_time_in_ms 22,630 89,003 178,170
l2_block_rollup_simulation_time_in_ms 22,423 88,253 176,696
l2_block_public_tx_process_time_in_ms 8,961 (-1%) 34,783 69,649 (-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 16,950 (-2%) 32,184 (+1%)
node_database_size_in_bytes 20,762,704 37,445,712
pxe_database_size_in_bytes 29,868 59,425

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 175 (-1%) 46,819 28,822
private-kernel-inner 205 76,734 28,822
private-kernel-ordering 228 (-1%) 53,040 42,751
base-parity 75.8 (+11%) 128 64.0
base-rollup 16,551 111,062 925
root-parity 1,697 (+5%) 27,064 64.0
root-rollup 65.1 (+1%) 11,454 789
public-kernel-app-logic 1,991 54,321 22,677
public-kernel-tail 4,872 159,770 3,898
merge-rollup 6,565 (+1%) 2,696 925
public-kernel-teardown 161 54,321 30,042
public-kernel-setup 220 54,321 30,042

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 11.0 17.9 (+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.7 31.8 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.643 0.551 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 52.4 (+2%) 80.4 (+1%) 262 510 (+2%) 988 1,945 (-1%) N/A
batch_insert_into_append_only_tree_32_depth_hash_count N/A N/A 95.9 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.536 (+2%) 0.496 0.476 0.476 (+2%) 0.468 0.466 N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 61.9 (+2%) 120 378 (+1%) 745 (+1%) 1,470 2,929 N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 105 208 692 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.545 (+2%) 0.539 0.512 0.513 (+1%) 0.508 0.510 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 68.1 (+2%)
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 108
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.599 (+2%)

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 44,613 535,433

Transaction size based on fee payment method

Metric native fee payment method fpc_public fee payment method fpc_private fee payment method
tx_with_fee_size_in_bytes 897 1,145 1,345

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,401 (-1%) 1,005 3,668
Metric 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 893 (+1%) 789 1,418 934 (+1%) 2,183 1,118 (+1%)

@benesjan benesjan changed the base branch from master to 04-26-refactor_create_fixed_base_constraint_cleanup April 26, 2024 09:52
@benesjan benesjan force-pushed the 04-26-feat_variable_base_scalar_mul_blacbox_func branch from 59fa1d8 to 19ffa0e Compare April 26, 2024 09:52
Base automatically changed from 04-26-refactor_create_fixed_base_constraint_cleanup to master April 26, 2024 10:20
@benesjan benesjan force-pushed the 04-26-feat_variable_base_scalar_mul_blacbox_func branch from 19ffa0e to 409d6b7 Compare April 26, 2024 11:34
@benesjan benesjan changed the title feat: variable_base_scalar_mul blacbox func feat: variable_base_scalar_mul blacbox func Apr 26, 2024
@benesjan benesjan force-pushed the 04-26-feat_variable_base_scalar_mul_blacbox_func branch 3 times, most recently from 17cc273 to 2464302 Compare April 26, 2024 14:23
@@ -1,3 +1,4 @@
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/6058): rename this file to something more generic
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will tackle this issue in a separate PR.

@benesjan benesjan force-pushed the 04-26-feat_variable_base_scalar_mul_blacbox_func branch from 2464302 to 1072846 Compare April 26, 2024 14:30
@@ -1,3 +1,4 @@
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/6058): rename this file to something more generic
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will tackle this issue in a separate PR.

@benesjan benesjan changed the title feat: variable_base_scalar_mul blacbox func feat: variable_base_scalar_mul blackbox func Apr 26, 2024
@benesjan benesjan marked this pull request as ready for review April 26, 2024 14:56
@TomAFrench
Copy link
Member

We can follow this up in a separate PR but we may want to instead expose an equivalent to batch_mul rather than a single variable base scalar multiplication. This would make it easier for the backend to use the optimal method when processing these.

@TomAFrench
Copy link
Member

Opened an issue to replace this with an MSM opcode here: noir-lang/noir#4928

@@ -141,12 +161,52 @@ mod grumpkin_fixed_base_scalar_mul {
assert_eq!(
res,
Err(BlackBoxResolutionError::Failed(
BlackBoxFunc::FixedBaseScalarMul,
BlackBoxFunc::VariableBaseScalarMul,
Copy link
Contributor

Choose a reason for hiding this comment

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

This passed? I would expect it to return a FixedBaseScalarMul

Copy link
Contributor Author

@benesjan benesjan Apr 29, 2024

Choose a reason for hiding this comment

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

It actually failed when I just run it locally. So there seems to be some CI issue. Great catch! Who needs a functional CI when you have Maxim 😆
image

@benesjan benesjan force-pushed the 04-26-feat_variable_base_scalar_mul_blacbox_func branch from e4811b5 to 60d5f07 Compare April 29, 2024 06:40
@benesjan benesjan changed the base branch from master to 04-29-fix_test_native.sh_not_running_all_noir_tests April 29, 2024 07:53
@benesjan benesjan force-pushed the 04-26-feat_variable_base_scalar_mul_blacbox_func branch from df898b9 to aa56324 Compare April 29, 2024 07:53
@benesjan benesjan force-pushed the 04-26-feat_variable_base_scalar_mul_blacbox_func branch from bb8be33 to 969c224 Compare April 30, 2024 06:47
@@ -22,7 +22,7 @@ describe('e2e_state_vars', () => {
beforeAll(async () => {
({ teardown, wallet, pxe } = await setup(2));
contract = await DocsExampleContract.deploy(wallet).send().deployed();
}, 30_000);
}, 60_000);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This started failing for me in CI but the code in this PR is not used in this test so it should not lead to slowdown.

Copy link
Member

@TomAFrench TomAFrench left a comment

Choose a reason for hiding this comment

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

LGTM

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.

4 participants