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

chore!: cleanup recursion interface #3528

Merged
merged 18 commits into from
Dec 18, 2023
Merged

Conversation

kevaundray
Copy link
Contributor

@kevaundray kevaundray commented Dec 3, 2023

This PR aims to fix some of the long-standing issues with the recursion interface, in particular:

  • Users needing to manually handle the aggregation objects

  • asking users to pass the barretenberg proofs as inputs, and the public inputs.

  • The first is fixed by removing the notion of aggregation objects from the Noir program and defining it as a "proof system public input".

  • The second is fixed by defining a proof as only containing the proof elements and public inputs separately. (There is a PR up to do this more extensively, but it was temporarily shelved as we applied the changes more upstream to see what broke, after the recursion changes are made, I think we can merge that PR).

There are a few other things that I'd like to address but may be left for another PR (due to them being significant breaking changes):

  • Users need to convert their proof and VK from bytes to packed fields. We currently have a 30K budget in terms of gates so it should be possible to do this conversion in circuit. The benefits of this is that proofs no longer look

  • is_recursive can be added as a circuit definition, removing the need for the is_recursive flag

Checklist:

Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge.

  • If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag.
  • I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code.
  • Every change is related to the PR description.
  • I have linked this pull request to relevant issues (if any exist).

@kevaundray
Copy link
Contributor Author

This seems to be failing tests because the recursion tests don't actually set the inner public inputs, this was never flagged up before because we were using the values in the proof

@kevaundray kevaundray marked this pull request as ready for review December 4, 2023 00:30
@kevaundray
Copy link
Contributor Author

One last thing to note, is the fact that this PR does not allow one to pass a proof with an aggregation object to a std::verify_proof anymore. What we'd need to do is add the prepend the aggregation object to the proof since its a "proof system public input".

Before doing this, we should clarify the possible usecases, that would require nested aggregation object and the usecases that would only require threading the output aggregation object

@AztecBot
Copy link
Collaborator

AztecBot commented Dec 4, 2023

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.

Values are compared against data from master at commit a60b71a5 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 128 txs
l1_rollup_calldata_size_in_bytes 45,444 179,588 716,132
l1_rollup_calldata_gas 223,008 868,148 3,447,992
l1_rollup_execution_gas 842,095 3,595,256 22,203,654
l2_block_processing_time_in_ms 1,344 5,112 21,064 (-1%)
note_successful_decrypting_time_in_ms 347 (+1%) 1,042 (-6%) 3,871 (+1%)
note_trial_decrypting_time_in_ms 58.2 (+9%) 38.5 (+3%) 145 (+5%)
l2_block_building_time_in_ms 13,543 53,909 217,167
l2_block_rollup_simulation_time_in_ms 9,981 39,678 (-1%) 160,581
l2_block_public_tx_process_time_in_ms 3,530 14,161 (+2%) 56,348

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 15,430 (-4%) 29,426
note_history_successful_decrypting_time_in_ms 2,507 (-1%) 5,067
note_history_trial_decrypting_time_in_ms 79.0 (-7%) 145 (+4%)
node_database_size_in_bytes 3,920,649 4,260,907
pxe_database_size_in_bytes 29,940 59,499

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 205 (+3%) 43,109 20,441
private-kernel-ordering 114 (-1%) 25,833 9,689
base-rollup 2,053 244,144 881
root-rollup 86.7 (-2%) 4,088 889
private-kernel-inner 259 64,516 20,441
public-kernel-private-input 172 25,203 20,441
public-kernel-non-first-iteration 171 25,245 20,441
merge-rollup 11.2 (-2%) 2,608 881

Miscellaneous

Transaction sizes based on how many contracts are deployed in the tx.

Metric 0 deployed contracts 1 deployed contracts
tx_size_in_bytes 10,323 26,359

Copy link
Contributor

@vezenovm vezenovm left a comment

Choose a reason for hiding this comment

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

LGTM. We have things we need to discuss with regards to nested agg object and the add_recursive_method but this can all be handled in follow-up work as this is a good improvement on the current interface.

@kevaundray kevaundray enabled auto-merge (squash) December 18, 2023 20:34
@kevaundray
Copy link
Contributor Author

We can fixup the nits in a separate PR and add the nested aggregation object

@kevaundray kevaundray merged commit 839ff73 into master Dec 18, 2023
72 of 74 checks passed
@kevaundray kevaundray deleted the kw/modify-recursion-interface branch December 18, 2023 20:55
@kevaundray kevaundray restored the kw/modify-recursion-interface branch December 18, 2023 21:33
@kevaundray
Copy link
Contributor Author

Will re-merge this into master when #3729 is merged

@vezenovm vezenovm mentioned this pull request Dec 19, 2023
4 tasks
vezenovm added a commit that referenced this pull request Dec 19, 2023
This is a recreation of this PR
(#3528) to handle PR
#3729

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).

---------

Co-authored-by: kevaundray <kevtheappdev@gmail.com>
AztecBot pushed a commit to noir-lang/noir that referenced this pull request Dec 19, 2023
This is a recreation of this PR
(AztecProtocol/aztec-packages#3528) to handle PR
AztecProtocol/aztec-packages#3729

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).

---------

Co-authored-by: kevaundray <kevtheappdev@gmail.com>
AztecBot pushed a commit to AztecProtocol/barretenberg that referenced this pull request Dec 31, 2023
This is a recreation of this PR
(AztecProtocol/aztec-packages#3528) to handle PR
AztecProtocol/aztec-packages#3729

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).

---------

Co-authored-by: kevaundray <kevtheappdev@gmail.com>
sirasistant pushed a commit to noir-lang/noir that referenced this pull request Jan 4, 2024
This is a recreation of this PR
(AztecProtocol/aztec-packages#3528) to handle PR
AztecProtocol/aztec-packages#3729

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).

---------

Co-authored-by: kevaundray <kevtheappdev@gmail.com>
Maddiaa0 pushed a commit that referenced this pull request Jan 8, 2024
This is a recreation of this PR
(#3528) to handle PR
#3729

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).

---------

Co-authored-by: kevaundray <kevtheappdev@gmail.com>
kevaundray pushed a commit that referenced this pull request Feb 19, 2024
This PR adds a test that does a full recursive verification similar to
`TestFullRecursiveComposition` under `recursion_constraint.test.cpp` but
using Noir.

A couple bugs fixes were done to enable the new
`double_verify_nested_proof` test:
- We have an assert in the recursion constraint that checks
`num_public_inputs == RecursionConstraint::AGGREGATION_OBJECT_SIZE` when
generating the dummy transcript for when we do not have valid witness
assignments. If we want to recursively verify a recursive proof that
itself has extra public inputs this assertion makes that impossible (in
fact the cpp test does not use any public inputs for
`TestFullRecursiveComposition` and this may be why this assertion wasn't
hit earlier).
- After moving to a definition of a proof as separate from its public
inputs in (#3528) we
were missing the accurate copy constraints in the case of no valid
witness assignment. In the case of a nested proof the public inputs will
contain an aggregation object for which we expect two accurate G1
points. Otherwise, even with the removed assertion above we will always
hit a "trying to invert 0" error when working without valid witness
assignments.
AztecBot pushed a commit to AztecProtocol/barretenberg that referenced this pull request Feb 20, 2024
This PR adds a test that does a full recursive verification similar to
`TestFullRecursiveComposition` under `recursion_constraint.test.cpp` but
using Noir.

A couple bugs fixes were done to enable the new
`double_verify_nested_proof` test:
- We have an assert in the recursion constraint that checks
`num_public_inputs == RecursionConstraint::AGGREGATION_OBJECT_SIZE` when
generating the dummy transcript for when we do not have valid witness
assignments. If we want to recursively verify a recursive proof that
itself has extra public inputs this assertion makes that impossible (in
fact the cpp test does not use any public inputs for
`TestFullRecursiveComposition` and this may be why this assertion wasn't
hit earlier).
- After moving to a definition of a proof as separate from its public
inputs in (AztecProtocol/aztec-packages#3528) we
were missing the accurate copy constraints in the case of no valid
witness assignment. In the case of a nested proof the public inputs will
contain an aggregation object for which we expect two accurate G1
points. Otherwise, even with the removed assertion above we will always
hit a "trying to invert 0" error when working without valid witness
assignments.
michaelelliot pushed a commit to Swoir/noir_rs that referenced this pull request Feb 28, 2024
This is a recreation of this PR
(AztecProtocol#3528) to handle PR
AztecProtocol#3729

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).

---------

Co-authored-by: kevaundray <kevtheappdev@gmail.com>
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.

None yet

3 participants