Conversation
| multiplicative_constant = 1; | ||
| witness_index = IS_CONSTANT; | ||
| // context -> stored_value = value.witness; | ||
| } else { |
There was a problem hiding this comment.
Hmm why is this if constexpr needed?
There was a problem hiding this comment.
Normally values of field elements are stored in the variables array of a given circuit builder. The index in that array is called a "real variable index". In order to avoid redundantly storing variable values, a witness object wraps an index idx and the corresponding variable value is accessed as in variables[real_variable_index[idx]]. I'm trying out a model where we do away with the variables array altogether, but just have a witness wrap a value. Therefore to initialize a field element from a witness I need to supply the witness info not through providing a witness index, but a witness value itself. The right way to do that is through setting the additive_constant, since 'normalizing' the field element would put the same value there. That said, I'm not sure this is the best approach.
There was a problem hiding this comment.
But if you're just talking about the constexpr then I think we could avoid code generation by just defining the function for the particular template parameter CircuitSimulatorBN254. We will also have a CircuitSimulatorGrumpkin though... anyway, experimenting.
| @@ -0,0 +1,113 @@ | |||
| #pragma once | |||
There was a problem hiding this comment.
TODO: share code with CircuitConstructorBase
| template <typename T> | ||
| concept IsHonkFlavor = IsAnyOf<T, honk::flavor::Standard, honk::flavor::Ultra, honk::flavor::StandardGrumpkin, honk::flavor::UltraGrumpkin>; | ||
|
|
||
| // WORKTODO: move? smart way of not referring to instances? |
There was a problem hiding this comment.
We will probably want a CircuitSimulatorGrumpkin
| @@ -1,13 +1,14 @@ | |||
| #include "barretenberg/crypto/blake2s/blake2s.hpp" | |||
| #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" | |||
| #include "barretenberg/proof_system/circuit_builder/circuit_simulator.hpp" | |||
| #include "barretenberg/stdlib/primitives/point/point.hpp" | ||
| #include "barretenberg/stdlib/primitives/witness/witness.hpp" | ||
|
|
||
| // TODO: This does not belong in barretenberg. |
There was a problem hiding this comment.
The notion of an "address" I mean... just a side note.
| const bool_t lhs = *this; | ||
| ComposerContext* ctx = lhs.get_context() ? lhs.get_context() : rhs.get_context(); | ||
|
|
||
| if (lhs.is_constant() && rhs.is_constant()) { |
There was a problem hiding this comment.
We want to put the composer in a failing state without changing existing code. We can't reuse the "both are witnesses" code because the assert_equal that takes in values (ant not witness indices) only exists on the simulator.
|
|
||
| if (byte.is_constant()) { | ||
| field_t<Composer> low(context, low_value); | ||
| field_t<Composer> high(context, high_value); |
There was a problem hiding this comment.
CIRCUIT BUG: we were not correctly setting bits in the constant case.
| EXPECT_EQ(out[0], uint8_t(0)); | ||
| EXPECT_EQ(out[1], uint8_t(7)); | ||
| EXPECT_EQ(out[3], uint8_t(5)); | ||
| EXPECT_EQ(out[1], uint8_t(7)); // start with 0000'0010, want 0000'0111, get 0000'0110 |
| uint32_t put_constant_variable([[maybe_unused]] const barretenberg::fr& variable) { return 1028; } | ||
| void set_public_input([[maybe_unused]] const uint32_t witness_index) | ||
| { | ||
| // WORKTODO Public input logic? |
There was a problem hiding this comment.
Haven't thought through potential subtleties with set_public_input or fix_witness.
| // return 0; // WORKTODO: return part of `in` for debugging purposes? | ||
| // } | ||
|
|
||
| inline uint32_t add_variable([[maybe_unused]] const barretenberg::fr index) const { return 1028; } |
There was a problem hiding this comment.
1028 = 0x404, recognizable when printing if something went wrong in the simulation.
| size_t get_num_constant_gates() { return 1028; }; | ||
| // maybe this shouldn't be implemented? | ||
|
|
||
| bool create_range_constraint(FF const& elt, |
There was a problem hiding this comment.
My goal is to preserve the composer interface when I can, but without tracking witness indices. In this case I decided to change the interface (input is a field element elt rather than a witness index). One way to unify interfaces would be to pass around witness_t's rather than indices, since this is a container for both an index and a vale. But this would undermine the optimization of tracking witness indices.
| return { 1028 }; | ||
| }; | ||
|
|
||
| void assert_equal(FF left, FF right, std::string const& msg) |
There was a problem hiding this comment.
Another departure of the form "witness index becomes a value".
| * to max_cache_size_ polynomials. This saves on many expensive copies of large amounts of memory to the external | ||
| * store. Smaller polynomials get swapped out, but they're also much cheaper to read/write. | ||
| * The default ctor sets the cache size to 70. | ||
| * The default ctor sets the cache size to 40. |
There was a problem hiding this comment.
Unrelated: I should have changed this in a PR earlier this week.
| @@ -2,5 +2,5 @@ | |||
|
|
|||
| namespace proof_system::merkle { | |||
| // TODO(Cody) Get rid of this? | |||
There was a problem hiding this comment.
IMO the various enum's that track types should go away.
| EXPECT_EQ(result, true); | ||
|
|
||
| auto gates_after = composer.get_num_gates(); | ||
| EXPECT_EQ(gates_after - gates_before, 6UL); |
There was a problem hiding this comment.
These tests that function like benchmarks should break, since we don't track gates, but they aren't testing circuit logic, so I felt comfortable deleting them.
d720a1a to
3d70094
Compare
|
Subsumed by AztecProtocol/aztec-packages#1195, which @maramihali took over the line |
Description
Please provide a paragraph or two giving a summary of the change, including relevant motivation and context.
Checklist:
@briefdescribing the intended functionality.includedirectives have been added.