-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Compute size of Execution proof without needing to compute the proof #2949
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
Conversation
…n_proof_size into a method of Authorization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a method to compute the size of Execution proofs without needing to generate the actual proof, addressing the double-proving workflow issue where storage costs are computed by generating proofs. The key changes include:
- Adding a proof size prediction method for Varuna proofs based on batch sizes
- Implementing an
Authorization::proof_size
method that calculates expected batch sizes and predicts proof size - Adding consistency checks between predicted and actual batch sizes
- Updating existing tests to use VarunaVersion::V2 and verify proof size predictions match actual serialized proof sizes
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
synthesizer/process/src/trace/mod.rs |
Adds consistency check for inclusion batch sizes and makes transitions iterator cloneable |
synthesizer/process/src/tests/test_execute.rs |
Updates tests to use VarunaVersion::V2 and adds proof size validation checks |
synthesizer/process/src/stack/authorization/mod.rs |
Implements proof_size method and number_of_input_records helper for Authorization |
ledger/block/src/transaction/execution/mod.rs |
Makes transitions iterator cloneable to support new functionality |
algorithms/src/snark/varuna/tests.rs |
Adds proof size validation test for Varuna V2 |
algorithms/src/snark/varuna/data_structures/proof.rs |
Implements proof_size function to calculate Varuna proof size without generating proof |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
(converted to draft due to likely conflicts with PR #2948 , fixing soon) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM besides the documentation nits
Co-authored-by: vicsn <victor.s.nicolaas@protonmail.com> Signed-off-by: Antonio Mejías Gil <anmegi.95@gmail.com>
// - batch sizes: (boils down to CanonicalSerialize for [usize]) | ||
// + one u64 for the length (the number of circuits) followed that many usize | ||
// This contains the size information for the vectors in all other fields, | ||
// which are therefore serialised without their length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// - batch sizes: (boils down to CanonicalSerialize for [usize]) | |
// + one u64 for the length (the number of circuits) followed that many usize | |
// This contains the size information for the vectors in all other fields, | |
// which are therefore serialised without their length | |
// - batch sizes: one `usize` for each batch size plus one `u64` for the number of batches. | |
// This contains the size information for all other vectors in the `Proof`, allowing them to be serialized without a length prefix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
impl<N: Network> Eq for Authorization<N> {} | ||
|
||
impl<N: Network> Authorization<N> { | ||
/// Returns the (exact) predicted size of the Varuna proof of an Authorization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Returns the (exact) predicted size of the Varuna proof of an Authorization | |
/// Returns the size of the Varuna proof of an `Authorization` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(function gone in later commits)
/// - `Some(size)` for `VarunaVersion::V2`, where `size` is the size of the proof in bytes. | ||
/// - `None` for `VarunaVersion::V1`. | ||
/// | ||
// The value returned coincides with `Proof<N: Network>::write_le()`, which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// The value returned coincides with `Proof<N: Network>::write_le()`, which | |
// The value returned is equal to the number of bytes returned by `Proof<N: Network>::write_le()`, which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(function gone in later commits)
} | ||
} | ||
|
||
/// Total number of inputs to the passed `Transition`s that are of type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Total number of inputs to the passed `Transition`s that are of type | |
/// Returns the total number of inputs to the passed `Transition`s that are of type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(addressed and also fixed other parts of the same documentation that had become outdated due to the interface change)
synthesizer/process/src/trace/mod.rs
Outdated
Inclusion::prepare_verifier_inputs(global_state_root, inclusion_version, transitions)?; | ||
Inclusion::prepare_verifier_inputs(global_state_root, inclusion_version, transitions.clone())?; | ||
|
||
let expected_n_inclusions = Authorization::number_of_input_records(transitions.clone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might not need the second clone of transitions
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, fixed
Co-authored-by: d0cd <23022326+d0cd@users.noreply.github.com> Signed-off-by: vicsn <victor.s.nicolaas@protonmail.com>
…ase to mint_and_split
Hi @d0cd! Quite a few things have changed in the last commits:
With the above modifications, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me overall!
There are a few minor nits on improving the clarity of comments. Your call on if you think these are worth addressing.
Almost there! Besides fixing the last open comments can you merge in staging? |
I'm still seeing "This branch has conflicts that must be resolved". Can you try: |
Yes! It's taken some effort to merge (staging had quite a few changes on the same functions I touched in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Currently
Execution
storage costs are computed by generating a proof for theAuthorization
and checking its size, which creates an undesirable double-proving workflow (because the storage cost is an input when computing the fee-transaction proof). This PR adds:Authorization::proof_size
method which computes the size of the Varuna proof forself
by calculating the expected batch sizes and then calling the method above.prepare_verifier_inputs
(for futureproofing)VarunaVersion::V2
and the addition to those tests of a proof-size check (i. e. ensuring that the size of the serialized proof, once computed, coincides with the predicted size given theAuthorization
). In the tested cases, the predicted size is an exact match.Since testing has happened only for a limited time of example
Authorization
s available in the code, any issues should be reported when this starts being tested in more complex, real-worldAuthorization
s.