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: sumcheck part of ECCVM recursive verifier instantiated as an UltraCircuit #6413

Merged
merged 59 commits into from
May 28, 2024

Conversation

maramihali
Copy link
Contributor

@maramihali maramihali commented May 15, 2024

This PR adds the ECCVM recursive verifier up to sumcheck (PCS incoming) with the necessary additional functionality in bigfield. It also removes some unnecessary fields in flavors that are obsolete.

@maramihali maramihali self-assigned this May 17, 2024
@maramihali maramihali added the crypto cryptography label May 17, 2024
@@ -417,7 +417,8 @@ template <typename Flavor> class SumcheckVerifier {
bool checked = false;
//! [Final Verification Step]
if constexpr (IsRecursiveFlavor<Flavor>) {
checked = (full_honk_relation_purported_value == round.target_total_sum).get_value();
full_honk_relation_purported_value.assert_equal(round.target_total_sum);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't have an == operator in bigfield

@@ -9,20 +9,22 @@ namespace bb {
*
* @tparam Builder
*/
template <typename Builder> class VerifierCommitmentKey<stdlib::bn254<Builder>> {
template <typename Curve> class VerifierCommitmentKey {
Copy link
Contributor Author

@maramihali maramihali May 28, 2024

Choose a reason for hiding this comment

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

Getting this to mirror exactly it's native counterpart which is required to construct the vk for the recursive verifier

@Rumata888 Rumata888 self-requested a review May 28, 2024 12:06
@@ -70,6 +72,59 @@ template <typename BuilderType> class ECCVMRecursiveFlavor_ {
using Base::Base;
};

using VerifierCommitmentKey = VerifierCommitmentKey<Curve>;
/**
* @brief The verification key is responsible for storing the the commitments to the precomputed (non-witnessk)
Copy link
Contributor

Choose a reason for hiding this comment

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

typo (witnessk)

* polynomials used by the verifier.
*
* @note Note the discrepancy with what sort of data is stored here vs in the proving key. We may want to
* resolve that, and split out separate PrecomputedPolynom ials/Commitments data for clarity but also for
Copy link
Contributor

Choose a reason for hiding this comment

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

space typo

@@ -75,6 +75,16 @@ template <typename Builder, typename T> class bigfield {
: bigfield(nullptr, uint256_t(native(value)))
{}

// NOLINTNEXTLINE(google-runtime-int) intended behavior
bigfield(const unsigned long value)
: bigfield(nullptr, uint256_t(native(value)))
Copy link
Contributor

Choose a reason for hiding this comment

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

In the unsigned case there is no need to do native

typename G1::element a = generators[0];
typename G1::element b = generators[1];
typename G1::element c = generators[2];
std::shared_ptr<ECCOpQueue> op_queue = std::make_shared<ECCOpQueue>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you change this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make it uniform to the recursive verifier but can revert

explicit ECCVMRecursiveVerifier_(Builder* builder,
const std::shared_ptr<NativeVerificationKey>& native_verifier_key);

bool verify_proof(const HonkProof& proof); // return type?!
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you switch it to stdlib_proof

@maramihali maramihali enabled auto-merge (squash) May 28, 2024 13:08

if (circuit_size != key->circuit_size) {
return false;
for (auto [comm, label] : zip_view(commitments.get_wires(), commitment_labels.get_wires())) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice

@AztecBot
Copy link
Collaborator

AztecBot commented May 28, 2024

Benchmark results

Metrics with a significant change:

  • app_circuit_proving_time_in_ms (Token:transfer): 45,387 (-16%)
  • protocol_circuit_proving_time_in_ms (private-kernel-init): 22,241 (-18%)
  • protocol_circuit_proving_time_in_ms (private-kernel-reset-small): 45,136 (-21%)
  • protocol_circuit_proving_time_in_ms (private-kernel-tail-to-public): 91,417 (-18%)
  • protocol_circuit_proving_time_in_ms (private-kernel-tail): 36,915 (-23%)
  • protocol_circuit_proving_time_in_ms (public-kernel-app-logic): 46,926 (-17%)
  • protocol_circuit_proving_time_in_ms (base-rollup): 73,609 (-21%)
  • protocol_circuit_proving_time_in_ms (root-parity): 44,430 (-17%)
  • protocol_circuit_proving_time_in_ms (public-kernel-tail): 152,638 (-20%)
  • protocol_circuit_proving_time_in_ms (root-rollup): 19,318 (-21%)
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 5,697 1,548 710 776 774

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 1,412 1,412 1,412
l1_rollup_calldata_gas 9,416 (-1%) 9,464 9,428 (-1%)
l1_rollup_execution_gas 616,057 616,105 616,069
l2_block_processing_time_in_ms 1,284 (-1%) 4,792 (-1%) 9,535
l2_block_building_time_in_ms 44,619 (-1%) 177,119 354,030
l2_block_rollup_simulation_time_in_ms 44,453 176,497 352,796
l2_block_public_tx_process_time_in_ms 23,977 100,345 205,176

L2 chain processing

Each column represents the number of blocks on the L2 chain where each block has 16 txs.

Metric 3 blocks 5 blocks
node_history_sync_time_in_ms 9,523 (-1%) 14,749 (+1%)
node_database_size_in_bytes 14,463,056 21,377,104
pxe_database_size_in_bytes 18,071 29,868

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 proving_time_in_ms input_size_in_bytes output_size_in_bytes proof_size_in_bytes num_public_inputs size_in_gates
private-kernel-init 160 (-1%) 3,683 (+3%) ⚠️ 22,241 (-18%) 20,630 64,614 89,536 2,731 1,048,576
private-kernel-inner 623 4,370 (+7%) 42,585 (-15%) 92,318 64,614 89,536 2,731 2,097,152
private-kernel-tail 566 (-1%) 3,131 (+7%) ⚠️ 36,915 (-23%) 96,541 77,498 10,656 266 2,097,152
base-parity 6.55 (+1%) 1,150 (+2%) 2,878 (-2%) 128 64.0 2,208 2.00 131,072
root-parity 49.5 (+1%) 60.9 (-4%) ⚠️ 44,430 (-17%) 27,084 64.0 2,720 18.0 2,097,152
base-rollup 697 (-4%) 2,209 (-7%) ⚠️ 73,609 (-21%) 119,610 756 3,648 47.0 4,194,304
root-rollup 112 (+2%) 65.8 (-17%) ⚠️ 19,318 (-21%) 25,297 620 3,456 41.0 1,048,576
public-kernel-app-logic 522 (-1%) 2,963 (-1%) ⚠️ 46,926 (-17%) 104,941 86,302 114,784 3,520 2,097,152
public-kernel-tail 1,084 22,687 (-5%) ⚠️ 152,638 (-20%) 395,386 7,522 10,656 266 8,388,608
private-kernel-reset-small 589 (-1%) 2,052 (+4%) ⚠️ 45,136 (-21%) 120,733 64,614 89,536 2,731 2,097,152
merge-rollup 28.9 N/A N/A 16,534 756 N/A N/A N/A
public-kernel-setup 626 (-5%) N/A N/A 104,941 86,302 N/A N/A N/A
public-kernel-teardown 578 (+5%) N/A N/A 104,941 86,302 N/A N/A N/A
private-kernel-tail-to-public N/A 8,549 (+4%) ⚠️ 91,417 (-18%) N/A N/A 114,784 3,520 4,194,304

Stats on running time collected for app circuits

Function input_size_in_bytes output_size_in_bytes witness_generation_time_in_ms proof_size_in_bytes proving_time_in_ms size_in_gates num_public_inputs
ContractClassRegisterer:register 1,344 9,944 466 N/A N/A N/A N/A
ContractInstanceDeployer:deploy 1,408 9,944 42.1 (+2%) N/A N/A N/A N/A
MultiCallEntrypoint:entrypoint 1,920 9,944 1,438 (+2%) N/A N/A N/A N/A
SchnorrAccount:constructor 1,312 9,944 990 (+2%) N/A N/A N/A N/A
SchnorrAccount:entrypoint 2,304 9,944 2,091 16,768 50,817 (-14%) 2,097,152 457
Token:privately_mint_private_note 1,280 9,944 1,136 (+4%) N/A N/A N/A N/A
Token:transfer 1,376 9,944 4,038 (+1%) 16,768 ⚠️ 45,387 (-16%) 2,097,152 457
Benchmarking:create_note 1,312 9,944 950 N/A N/A N/A N/A
FPC:fee_entrypoint_public 1,344 9,944 216 (-1%) N/A N/A N/A N/A
SchnorrAccount:spend_private_authwit 1,280 9,944 77.6 (-3%) N/A N/A N/A N/A
Token:unshield 1,376 9,944 3,233 (-3%) N/A N/A N/A N/A
FPC:fee_entrypoint_private 1,376 9,944 3,996 (-3%) N/A N/A N/A N/A

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.5 17.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.609 0.522 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 48.6 76.6 246 480 928 1,843 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.497 0.472 0.446 0.448 0.440 0.440 N/A
batch_insert_into_indexed_tree_20_depth_ms N/A N/A 58.6 113 (-1%) 356 720 (+2%) 1,383 2,752 N/A
batch_insert_into_indexed_tree_20_depth_hash_count N/A N/A 106 208 692 1,363 2,707 5,395 N/A
batch_insert_into_indexed_tree_20_depth_hash_ms N/A N/A 0.507 0.504 (-1%) 0.482 0.494 (+2%) 0.479 0.478 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 62.6
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 107
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.555

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 83,794 665,117

Transaction size based on fee payment method

| Metric | |
| - | |

@maramihali maramihali merged commit afe84a2 into master May 28, 2024
83 checks passed
@maramihali maramihali deleted the mm/eccvm-work branch May 28, 2024 16:54
TomAFrench added a commit that referenced this pull request May 29, 2024
* master:
  feat: prepare circuit output for validation (#6678)
  chore: stop building/publishing `acvm_backend.wasm` (#6584)
  chore: add bench programs (#6566)
  chore: make public data update requests, note hashes, and unencrypted logs readonly in TS (#6658)
  git subrepo push --branch=master noir-projects/aztec-nr
  git_subrepo.sh: Fix parent in .gitrepo file. [skip ci]
  chore: replace relative paths to noir-protocol-circuits
  git subrepo push --branch=master barretenberg
  feat: update honk recursion constraint (#6545)
  feat: Add code-workspace and update build dirs (#6723)
  feat: Sync from noir (#6717)
  feat: folding acir programs (#6685)
  feat: sumcheck part of ECCVM recursive verifier instantiated as an UltraCircuit (#6413)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto cryptography
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants