Skip to content

Commit

Permalink
fix: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasRidhuan committed Dec 9, 2024
1 parent 9fd48d8 commit 87d67f4
Show file tree
Hide file tree
Showing 10 changed files with 778 additions and 1,497 deletions.
678 changes: 84 additions & 594 deletions barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp

Large diffs are not rendered by default.

14 changes: 2 additions & 12 deletions barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ template <typename FF> struct AvmFullRow {
RefVector<const FF> as_vector() const;

static std::vector<std::string> names();
static constexpr size_t SIZE = 765;
static constexpr size_t SIZE = 764;
};

template <typename FF> std::ostream& operator<<(std::ostream& os, AvmFullRow<FF> const& row);
Expand Down
240 changes: 26 additions & 214 deletions barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/main.hpp

Large diffs are not rendered by default.

19 changes: 7 additions & 12 deletions barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ std::vector<uint8_t> AvmTraceBuilder::get_bytecode(const FF contract_address, bo

bool exists = true;
if (check_membership && !isCanonical(contract_address)) {
if (bytecode_membership_cache.find(contract_address) != bytecode_membership_cache.end()) {
// If we have already seen the contract address, we can skip the membership check and used the cached
// membership proof
vinfo("Found bytecode for contract address in cache: ", contract_address);
return bytecode_hint.bytecode;
}
const auto contract_address_nullifier = AvmMerkleTreeTraceBuilder::unconstrained_silo_nullifier(
DEPLOYER_CONTRACT_ADDRESS, /*nullifier=*/contract_address);
// nullifier read hint for the contract address
Expand All @@ -185,6 +191,7 @@ std::vector<uint8_t> AvmTraceBuilder::get_bytecode(const FF contract_address, bo
// This was a membership proof!
// Assert that the hint's exists flag matches. The flag isn't really necessary...
ASSERT(bytecode_hint.contract_instance.exists);
bytecode_membership_cache.insert(contract_address);
} else {
// This was a non-membership proof!
// Enforce that the tree access membership checked a low-leaf that skips the contract address nullifier.
Expand Down Expand Up @@ -2863,18 +2870,6 @@ AvmError AvmTraceBuilder::op_emit_note_hash(uint8_t indirect, uint32_t note_hash
row.main_sel_op_emit_note_hash = FF(1);
row.main_op_err = FF(static_cast<uint32_t>(!is_ok(error)));

AppendTreeHint note_hash_write_hint = execution_hints.note_hash_write_hints.at(note_hash_write_counter++);
auto siloed_note_hash =
AvmMerkleTreeTraceBuilder::unconstrained_silo_note_hash(current_ext_call_ctx.contract_address, row.main_ia);
ASSERT(row.main_ia == note_hash_write_hint.leaf_value);
// We first check that the index is currently empty
bool insert_index_is_empty = merkle_tree_trace_builder.perform_note_hash_read(
clk, FF::zero(), note_hash_write_hint.leaf_index, note_hash_write_hint.sibling_path);
ASSERT(insert_index_is_empty);

// Update the root with the new leaf that is appended
merkle_tree_trace_builder.perform_note_hash_append(clk, siloed_note_hash, note_hash_write_hint.sibling_path);

AppendTreeHint note_hash_write_hint = execution_hints.note_hash_write_hints.at(note_hash_write_counter++);
auto siloed_note_hash = AvmMerkleTreeTraceBuilder::unconstrained_silo_note_hash(
current_public_call_request.contract_address, row.main_ia);
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 @@ -48,7 +48,7 @@
#define AVM_ACCUMULATED_DATA_LENGTH 318
#define AVM_CIRCUIT_PUBLIC_INPUTS_LENGTH 1006
#define AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS 86
#define AVM_PROOF_LENGTH_IN_FIELDS 4160
#define AVM_PROOF_LENGTH_IN_FIELDS 4155
#define AVM_PUBLIC_COLUMN_MAX_SIZE 1024
#define AVM_PUBLIC_INPUTS_FLATTENED_SIZE 2915
#define MEM_TAG_FF 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ pub global AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS: u32 = 2 + 21 * 4;
// `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
pub global AVM_PROOF_LENGTH_IN_FIELDS: u32 = 4160;
pub global AVM_PROOF_LENGTH_IN_FIELDS: u32 = 4155;
pub global AVM_PUBLIC_COLUMN_MAX_SIZE: u32 = 1024;
pub global AVM_PUBLIC_INPUTS_FLATTENED_SIZE: u32 =
2 * AVM_PUBLIC_COLUMN_MAX_SIZE + PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH;
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 @@ -220,7 +220,7 @@ export const TUBE_PROOF_LENGTH = 463;
export const HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS = 128;
export const CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS = 143;
export const AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS = 86;
export const AVM_PROOF_LENGTH_IN_FIELDS = 4160;
export const AVM_PROOF_LENGTH_IN_FIELDS = 4155;
export const AVM_PUBLIC_COLUMN_MAX_SIZE = 1024;
export const AVM_PUBLIC_INPUTS_FLATTENED_SIZE = 2915;
export const MEM_TAG_FF = 0;
Expand Down
18 changes: 9 additions & 9 deletions yarn-project/simulator/src/avm/avm_simulator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -864,9 +864,9 @@ describe('AVM simulator: transpiled Noir contracts', () => {
mockGetContractInstance(worldStateDB, contractInstanceWithAddress);
mockGetContractInstance(worldStateDB, contractInstanceWithAddress);
mockGetContractInstance(worldStateDB, contractInstanceWithAddress);
mockNullifierExists(worldStateDB, contractInstanceWithAddress.address.toField());
mockNullifierExists(worldStateDB, contractInstanceWithAddress.address.toField());
mockNullifierExists(worldStateDB, contractInstanceWithAddress.address.toField());
mockNullifierExists(worldStateDB, siloAddress(contractInstanceWithAddress.address));
mockNullifierExists(worldStateDB, siloAddress(contractInstanceWithAddress.address));
mockNullifierExists(worldStateDB, siloAddress(contractInstanceWithAddress.address));

const bytecode = getAvmTestContractBytecode('test_get_contract_instance');

Expand Down Expand Up @@ -935,7 +935,7 @@ describe('AVM simulator: transpiled Noir contracts', () => {
mockGetContractClass(worldStateDB, contractClass);
const contractInstance = makeContractInstanceFromClassId(contractClass.id);
mockGetContractInstance(worldStateDB, contractInstance);
mockNullifierExists(worldStateDB, contractInstance.address.toField());
mockNullifierExists(worldStateDB, siloAddress(contractInstance.address));

const nestedTrace = mock<PublicSideEffectTraceInterface>();
mockTraceFork(trace, nestedTrace);
Expand All @@ -961,7 +961,7 @@ describe('AVM simulator: transpiled Noir contracts', () => {
mockGetContractClass(worldStateDB, contractClass);
const contractInstance = makeContractInstanceFromClassId(contractClass.id);
mockGetContractInstance(worldStateDB, contractInstance);
mockNullifierExists(worldStateDB, contractInstance.address.toField());
mockNullifierExists(worldStateDB, siloAddress(contractInstance.address));

const nestedTrace = mock<PublicSideEffectTraceInterface>();
mockTraceFork(trace, nestedTrace);
Expand Down Expand Up @@ -990,7 +990,7 @@ describe('AVM simulator: transpiled Noir contracts', () => {
mockGetContractClass(worldStateDB, contractClass);
const contractInstance = makeContractInstanceFromClassId(contractClass.id);
mockGetContractInstance(worldStateDB, contractInstance);
mockNullifierExists(worldStateDB, contractInstance.address.toField());
mockNullifierExists(worldStateDB, siloAddress(contractInstance.address));

mockTraceFork(trace);

Expand All @@ -1015,7 +1015,7 @@ describe('AVM simulator: transpiled Noir contracts', () => {
mockGetContractClass(worldStateDB, contractClass);
const contractInstance = makeContractInstanceFromClassId(contractClass.id);
mockGetContractInstance(worldStateDB, contractInstance);
mockNullifierExists(worldStateDB, contractInstance.address.toField());
mockNullifierExists(worldStateDB, siloAddress(contractInstance.address));

const nestedTrace = mock<PublicSideEffectTraceInterface>();
mockTraceFork(trace, nestedTrace);
Expand Down Expand Up @@ -1047,7 +1047,7 @@ describe('AVM simulator: transpiled Noir contracts', () => {
mockGetContractClass(worldStateDB, contractClass);
const contractInstance = makeContractInstanceFromClassId(contractClass.id);
mockGetContractInstance(worldStateDB, contractInstance);
mockNullifierExists(worldStateDB, contractInstance.address.toField());
mockNullifierExists(worldStateDB, siloAddress(contractInstance.address));

mockTraceFork(trace);

Expand All @@ -1072,7 +1072,7 @@ describe('AVM simulator: transpiled Noir contracts', () => {
mockGetContractClass(worldStateDB, contractClass);
const contractInstance = makeContractInstanceFromClassId(contractClass.id);
mockGetContractInstance(worldStateDB, contractInstance);
mockNullifierExists(worldStateDB, contractInstance.address.toField());
mockNullifierExists(worldStateDB, siloAddress(contractInstance.address));

mockTraceFork(trace);

Expand Down
Loading

0 comments on commit 87d67f4

Please sign in to comment.