Skip to content

Commit

Permalink
Fixes after rebase on master
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmon committed Sep 18, 2024
1 parent 14f5243 commit 1e4069f
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 18 deletions.
10 changes: 7 additions & 3 deletions barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,13 @@ class AvmFlavor {
static constexpr size_t NUM_FRS_COM = field_conversion::calc_num_bn254_frs<Commitment>();
static constexpr size_t NUM_FRS_FR = field_conversion::calc_num_bn254_frs<FF>();

static_assert(AVM_PROOF_LENGTH_IN_FIELDS ==
(NUM_WITNESS_ENTITIES + 2) * NUM_FRS_COM + (NUM_ALL_ENTITIES + 1) * NUM_FRS_FR +
CONST_PROOF_SIZE_LOG_N * (NUM_FRS_COM + NUM_FRS_FR * BATCHED_RELATION_PARTIAL_LENGTH),
// After any circuit changes, hover `COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS` in your IDE
// to see its value and then update `AVM_PROOF_LENGTH_IN_FIELDS` in constants.nr.
static constexpr size_t COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS =
(NUM_WITNESS_ENTITIES + 2) * NUM_FRS_COM + (NUM_ALL_ENTITIES + 1) * NUM_FRS_FR +
CONST_PROOF_SIZE_LOG_N * (NUM_FRS_COM + NUM_FRS_FR * BATCHED_RELATION_PARTIAL_LENGTH);

static_assert(AVM_PROOF_LENGTH_IN_FIELDS == COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS,
"\nUnexpected AVM proof length. This might be due to some changes in the\n"
"AVM circuit layout. In this case, modify AVM_PROOF_LENGTH_IN_FIELDS \n"
"in constants.nr accordingly.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ template <typename FF_> class aluImpl {
[[maybe_unused]] const RelationParameters<FF>&,
[[maybe_unused]] const FF& scaling_factor)
{
const auto constants_MEM_TAG_U1 = FF(1);
const auto constants_MEM_TAG_U8 = FF(2);
const auto constants_MEM_TAG_U16 = FF(3);
const auto constants_MEM_TAG_U32 = FF(4);
Expand Down Expand Up @@ -123,12 +124,13 @@ template <typename FF_> class aluImpl {
{
using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>;
auto tmp =
(new_term.alu_in_tag - ((((((new_term.alu_u1_tag + (constants_MEM_TAG_U8 * new_term.alu_u8_tag)) +
(constants_MEM_TAG_U16 * new_term.alu_u16_tag)) +
(constants_MEM_TAG_U32 * new_term.alu_u32_tag)) +
(constants_MEM_TAG_U64 * new_term.alu_u64_tag)) +
(constants_MEM_TAG_U128 * new_term.alu_u128_tag)) +
(constants_MEM_TAG_FF * new_term.alu_ff_tag)));
(new_term.alu_in_tag -
(((((((constants_MEM_TAG_U1 * new_term.alu_u1_tag) + (constants_MEM_TAG_U8 * new_term.alu_u8_tag)) +
(constants_MEM_TAG_U16 * new_term.alu_u16_tag)) +
(constants_MEM_TAG_U32 * new_term.alu_u32_tag)) +
(constants_MEM_TAG_U64 * new_term.alu_u64_tag)) +
(constants_MEM_TAG_U128 * new_term.alu_u128_tag)) +
(constants_MEM_TAG_FF * new_term.alu_ff_tag)));
tmp *= scaling_factor;
std::get<9>(evals) += typename Accumulator::View(tmp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ bool AvmVerifier::verify_proof(const HonkProof& proof,

// Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the
// unrolled protocol.

auto opening_claim = ZeroMorph::verify(circuit_size,
commitments.get_unshifted(),
commitments.get_to_be_shifted(),
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 691
#define PUBLIC_CONTEXT_INPUTS_LENGTH 42
#define AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS 66
#define AVM_PROOF_LENGTH_IN_FIELDS 3802
#define AVM_PROOF_LENGTH_IN_FIELDS 3812
#define MEM_TAG_U1 1
#define MEM_TAG_U8 2
#define MEM_TAG_U16 3
Expand Down
10 changes: 7 additions & 3 deletions bb-pilcom/bb-pil-backend/templates/flavor.hpp.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,13 @@ class {{name}}Flavor {
static constexpr size_t NUM_FRS_COM = field_conversion::calc_num_bn254_frs<Commitment>();
static constexpr size_t NUM_FRS_FR = field_conversion::calc_num_bn254_frs<FF>();

static_assert(AVM_PROOF_LENGTH_IN_FIELDS ==
(NUM_WITNESS_ENTITIES + 2) * NUM_FRS_COM + (NUM_ALL_ENTITIES + 1) * NUM_FRS_FR +
CONST_PROOF_SIZE_LOG_N * (NUM_FRS_COM + NUM_FRS_FR * BATCHED_RELATION_PARTIAL_LENGTH),
// After any circuit changes, hover `COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS` in your IDE
// to see its value and then update `AVM_PROOF_LENGTH_IN_FIELDS` in constants.nr.
static constexpr size_t COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS =
(NUM_WITNESS_ENTITIES + 2) * NUM_FRS_COM + (NUM_ALL_ENTITIES + 1) * NUM_FRS_FR +
CONST_PROOF_SIZE_LOG_N * (NUM_FRS_COM + NUM_FRS_FR * BATCHED_RELATION_PARTIAL_LENGTH);

static_assert(AVM_PROOF_LENGTH_IN_FIELDS == COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS,
"\nUnexpected AVM proof length. This might be due to some changes in the\n"
"AVM circuit layout. In this case, modify AVM_PROOF_LENGTH_IN_FIELDS \n"
"in constants.nr accordingly.");
Expand Down
2 changes: 0 additions & 2 deletions l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ library Constants {
uint256 internal constant L2_GAS_PER_LOG_BYTE = 4;
uint256 internal constant L2_GAS_PER_NOTE_HASH = 32;
uint256 internal constant L2_GAS_PER_NULLIFIER = 64;
uint256 internal constant CANONICAL_KEY_REGISTRY_ADDRESS =
6823425185167517386380694778823032861295161686691976789058601691508103815523;
uint256 internal constant CANONICAL_AUTH_REGISTRY_ADDRESS =
19361441716519463065948254497947932755739298943049449145365332870925554042208;
uint256 internal constant DEPLOYER_CONTRACT_ADDRESS =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ global VERIFICATION_KEY_LENGTH_IN_FIELDS = 128;

// The length is 2 + AvmFlavor::NUM_PRECOMPUTED_ENTITIES * 4
global AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS = 2 + 16 * 4;
global AVM_PROOF_LENGTH_IN_FIELDS = 3802;
// `AVM_PROOF_LENGTH_IN_FIELDS` must be updated when AVM circuit changes.
// To determine latest value, hover `COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS`
// in barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp
global AVM_PROOF_LENGTH_IN_FIELDS = 3812;
/**
* Enumerate the hash_indices which are used for pedersen hashing.
* We start from 1 to avoid the default generators. The generator indices are listed
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export const NESTED_RECURSIVE_PROOF_LENGTH = 439;
export const TUBE_PROOF_LENGTH = 439;
export const VERIFICATION_KEY_LENGTH_IN_FIELDS = 128;
export const AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS = 66;
export const AVM_PROOF_LENGTH_IN_FIELDS = 3802;
export const AVM_PROOF_LENGTH_IN_FIELDS = 3812;
export const MEM_TAG_U1 = 1;
export const MEM_TAG_U8 = 2;
export const MEM_TAG_U16 = 3;
Expand Down

0 comments on commit 1e4069f

Please sign in to comment.