-
Notifications
You must be signed in to change notification settings - Fork 235
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!: Use circuit builders #895
Conversation
Gets rid of the composers class that wrapped a circuit constructor and a composer helper. This entailed various improvements such as a refactor of the stdlib verifier tests. Cleanup such a renaming of classes and moving of files will come in another PR. Corresponding PR in the core circuits library is AztecProtocol/aztec-packages#895.
.l1_to_l2_messages_tree_root = 3000, | ||
.private_kernel_vk_tree_root = 4000, | ||
} }; | ||
// CombinedHistoricTreeRoots<NT> const historic_tree_roots = { .private_historic_tree_roots = { |
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.
Should we remove instead?
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.
Probably? I haven't looked into the history or discussed with core circuits team yet.
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.
Yeah I didn't see it was a draft, my bad
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.
I ended up making an issue to look at this and two other unused variables in the same test file, and I reference that issue in TODOs in the code.
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 overall (although now I realize its a draft)
Weird stuff is happening
{ | ||
static_assert((std::is_same<NativeTypes, NCT>::value)); | ||
|
||
// Capture the composer: | ||
auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); }; | ||
// Capture the circuit builder: |
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.
FYI, I think this this comment and this lambda are repeated 30 times!
@@ -91,7 +91,7 @@ std::shared_ptr<NT::VK> fake_vk() | |||
{ | |||
std::map<std::string, NT::bn254_point> commitments; | |||
commitments["FAKE"] = *new NT::bn254_point(NT::fq(0), NT::fq(0)); | |||
NT::VKData vk_data = { .composer_type = proof_system::ComposerType::TURBO, | |||
NT::VKData vk_data = { .circuit_type = static_cast<uint32_t>(proof_system::CircuitType::TURBO), |
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.
enum ComposerType
became enum class CircuitType : uint32_t
and so we need to do explicit casting sometimes.
CT::AggregationObject result = verify_proof<CT::bn254, CT::recursive_inner_verifier_settings>( | ||
composer, vk, recursive_manifest, proof, previous_aggregation_output); | ||
CT::AggregationObject result = | ||
verify_proof<plonk::flavor::Ultra>(builder, vk, proof, previous_aggregation_output); |
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.
This function was added to Barretenberg to avoid the circuits library from having to know about a manifest. In general, we should insulate the circuits library from details of proof construction (such as a manifest). I'm not sure that the flavor is the "right" thing, but it's an improvement, and doing it this way let me expose MUCH less in barretenberg.hpp.
STANDARD = 0, | ||
TURBO = 1, | ||
PLOOKUP = 2, | ||
STANDARD_HONK = 3, |
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.
There is no difference between a standard Honk circuit and a standard Plonk circuit! This was a hack we introduced, iirc, in order to make the stdlib tests run with Honk.
PreviousKernelData<NT> const& previous_kernel, | ||
std::array<NT::fr, READ_REQUESTS_LENGTH> const& read_requests, | ||
std::array<MembershipWitness<NT, PRIVATE_DATA_TREE_HEIGHT>, READ_REQUESTS_LENGTH> const& | ||
read_request_membership_witnesses); | ||
|
||
CircuitResult<KernelCircuitPublicInputs<NT>> native_private_kernel_circuit_ordering_rr_dummy( | ||
CircuitResult<KernelCircuitPublicInputs<NT> > native_private_kernel_circuit_ordering_rr_dummy( |
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.
nit but is this an unwanted space?
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.
Fixed
{ | ||
// compute P0, P1 for private function proof | ||
CT::AggregationObject aggregation_object = Aggregator::aggregate( | ||
&composer, private_inputs.private_call.vk, private_inputs.private_call.proof, num_private_call_public_inputs); | ||
CT::AggregationObject aggregation_object = |
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.
This is nice, aggregate
shouldn't have to know what the number of public inputs of the private call is.
std::conditional_t<std::same_as<Composer, plonk::TurboPlonkComposer>, | ||
stdlib::recursion::recursive_turbo_verifier_settings<bn254>, | ||
stdlib::recursion::recursive_ultra_verifier_settings<bn254>>; | ||
using recursive_inner_verifier_settings = stdlib::recursion::recursive_ultra_verifier_settings<bn254>; |
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.
Is his because we don't expect turbo to be used as inner circuit builder anymore? If so, makes sense.
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.
Well, Luke's previous PR fixed the inner circuit type to Ultra (indeed, Aggregate::aggregate
now uses a fixed flavor), so it wouldn't even work to toggle the inner type. In general this recursion stuff needs a rework, so I thought I'd pare it down to make it simpler for when we do that work. In fact, I see now this alias is not in use anywhere, so I think I'll remove it.
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, just left a couple of minor comments. Thanks @codygunton.
This reverts commit bef4f57.
Changing test description to reference Schnorr not Ecdsa leads to weird build error.
@@ -113,7 +113,7 @@ value: 0xd05 | |||
" | |||
`; | |||
|
|||
exports[`structs/kernel serializes and prints EcdsaSignature 1`] = `"{ 0101010101010101010101010101010101010101010101010101010101010101, 0101010101010101010101010101010101010101010101010101010101010101, 0 }"`; |
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.
As discussed with @PhilWindle, this final value in the snapshot here should not exist because the signature tested is not an ECDSA signature as the naming suggests--it was switched in some places to a Schnorr signature. I complete this switch by changing the definition of abis__test_roundtrip_serialize_signature
to use a Schnorr signature and updated the snapshot accordingly.
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.
BTW, I tried to rename the test and ran into a weird error:
FAIL structs/kernel/index.test.ts
● Test suite failed to run
ReferenceError: exports is not defined
1 | import { expectSerializeToMatchSnapshot } from '../../tests/expectSerialize.js';
> 2 | import { makeSchnorrSignature } from '../../tests/factories.js';
| ^
3 | import {
4 | makePreviousKernelData,
5 | makePrivateKernelInputsInner,
at structs/kernel/index.test.ts:2:23
Gets rid of the composers class that wrapped a circuit constructor and a composer helper. This entailed various improvements such as a refactor of the stdlib verifier tests. Cleanup such a renaming of classes and moving of files will come in another PR. Corresponding PR in the core circuits library is #895.
Gets rid of the composers class that wrapped a circuit constructor and a composer helper. This entailed various improvements such as a refactor of the stdlib verifier tests. Cleanup such a renaming of classes and moving of files will come in another PR. Corresponding PR in the core circuits library is #895.
Gets rid of the composers class that wrapped a circuit constructor and a composer helper. This entailed various improvements such as a refactor of the stdlib verifier tests. Cleanup such a renaming of classes and moving of files will come in another PR. Corresponding PR in the core circuits library is #895.
Description
This PR is 'just' bulk cleanup to reflect changes in Barretenberg. These are the main changes.
Composer
is renamed toBuilder
orCircuitBuilder
composer
is renamed tobuilder
. In some contextscircuit
also makes sense and it might be preferable.ComposerType
was renamed toCircuitType
and this is changed accordingly, along with renamingcomposer_type
tocircuit_type
.DummyComposer
and dummy_composer.hpp.Aggregator::aggregate
function now calls a more encapsulated recursive verifier function.Some unexpected compiler errors around unused variables came up. I'm not sure how to proceed. I made an issue (#914) recording this in the hopes that we can merge with todos referencing that issue.
I left some additional notes as comments on lines of code.
Checklist: