Skip to content

Commit

Permalink
Merge branch 'master' into sync-noir
Browse files Browse the repository at this point in the history
* master: (37 commits)
  feat: Sync from noir (#7248)
  chore: remove 4738 ref (#7254)
  refactor: use options.limit as upper limit for note-getter loop (#7253)
  feat: unconstrained variants for event emission (#7251)
  refactor: add log_hash as input in log emission in private context (#7249)
  feat: function selector opcode in AVM (#7244)
  feat: store shared mutable hash (#7169)
  feat: wonky rollups (#7189)
  refactor: gets rid of unencrypted emit in private_context (#7236)
  git subrepo push --branch=master noir-projects/aztec-nr
  git_subrepo.sh: Fix parent in .gitrepo file. [skip ci]
  chore: replace relative paths to noir-protocol-circuits
  git subrepo push --branch=master barretenberg
  fix: reran pil->cpp codegen & encode_and_encrypt_event_with_randomness fix (#7247)
  git subrepo push --branch=master noir-projects/aztec-nr
  git_subrepo.sh: Fix parent in .gitrepo file. [skip ci]
  chore: replace relative paths to noir-protocol-circuits
  git subrepo push --branch=master barretenberg
  feat!: extend storage read oracle to receive address and block number (#7243)
  feat: example of private token transfer event (#7242)
  ...
  • Loading branch information
TomAFrench committed Jul 1, 2024
2 parents 615fd35 + eb9e9f6 commit 9076dca
Show file tree
Hide file tree
Showing 315 changed files with 5,702 additions and 3,557 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/devnet-deploys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on:
push:
branches: [devnet]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
GIT_COMMIT: ${{ github.sha }}
Expand Down Expand Up @@ -56,14 +60,20 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Deploy Bootstrap Nodes
working-directory: ./yarn-project/aztec/terraform/node
- name: Deploy P2P Bootstrap Nodes
working-directory: ./yarn-project/p2p-bootstrap/terraform
run: |
terraform init -input=false -backend-config="key=devnet/aztec-node"
terraform init -input=false -backend-config="key=devnet/p2p-bootstrap"
terraform apply -input=false -auto-approve
- name: Deploy Aztec Nodes
working-directory: ./yarn-project/aztec/terraform/node
run: |
terraform init -input=false -backend-config="key=devnet/aztec-node"
terraform apply -input=false -auto-approve
- name: Deploy Provers
working-directory: ./yarn-project/aztec/terraform/prover
run: |
terraform init -input=false -backend-config="key=devnet/prover"
terraform apply -input=false -auto-approve
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,5 @@
"**/noir/noir-repo/docs/versioned_docs/**": true
},
"cmake.sourceDirectory": "${workspaceFolder}/barretenberg/cpp",
"typescript.tsserver.maxTsServerMemory": 4096,
}
12 changes: 6 additions & 6 deletions avm-transpiler/src/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ pub enum AvmOpcode {
ADDRESS,
STORAGEADDRESS,
SENDER,
FEEPERL2GAS,
FEEPERDAGAS,
FUNCTIONSELECTOR,
TRANSACTIONFEE,
CONTRACTCALLDEPTH,
CHAINID,
VERSION,
BLOCKNUMBER,
TIMESTAMP,
COINBASE,
FEEPERL2GAS,
FEEPERDAGAS,
BLOCKL2GASLIMIT,
BLOCKDAGASLIMIT,
CALLDATACOPY,
Expand Down Expand Up @@ -106,16 +106,16 @@ impl AvmOpcode {
AvmOpcode::ADDRESS => "ADDRESS",
AvmOpcode::STORAGEADDRESS => "STORAGEADDRESS",
AvmOpcode::SENDER => "SENDER",
AvmOpcode::FEEPERL2GAS => "FEEPERL2GAS",
AvmOpcode::FEEPERDAGAS => "FEEPERDAGAS",
AvmOpcode::FUNCTIONSELECTOR => "FUNCTIONSELECTOR",
AvmOpcode::TRANSACTIONFEE => "TRANSACTIONFEE",
AvmOpcode::CONTRACTCALLDEPTH => "CONTRACTCALLDEPTH",
// Execution Environment - Globals
AvmOpcode::CHAINID => "CHAINID",
AvmOpcode::VERSION => "VERSION",
AvmOpcode::BLOCKNUMBER => "BLOCKNUMBER",
AvmOpcode::TIMESTAMP => "TIMESTAMP",
AvmOpcode::COINBASE => "COINBASE",
AvmOpcode::FEEPERL2GAS => "FEEPERL2GAS",
AvmOpcode::FEEPERDAGAS => "FEEPERDAGAS",
AvmOpcode::BLOCKL2GASLIMIT => "BLOCKL2GASLIMIT",
AvmOpcode::BLOCKDAGASLIMIT => "BLOCKDAGASLIMIT",
// Execution Environment - Calldata
Expand Down
19 changes: 9 additions & 10 deletions avm-transpiler/src/transpile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ fn handle_foreign_call(
"avmOpcodeGetContractInstance" => {
handle_get_contract_instance(avm_instrs, destinations, inputs);
}
"storageRead" => handle_storage_read(avm_instrs, destinations, inputs),
"storageWrite" => handle_storage_write(avm_instrs, destinations, inputs),
"avmOpcodeStorageRead" => handle_storage_read(avm_instrs, destinations, inputs),
"avmOpcodeStorageWrite" => handle_storage_write(avm_instrs, destinations, inputs),
"debugLog" => handle_debug_log(avm_instrs, destinations, inputs),
// Getters.
_ if inputs.is_empty() && destinations.len() == 1 => {
Expand Down Expand Up @@ -314,11 +314,9 @@ fn handle_external_call(
ValueOrArray::HeapVector(HeapVector { pointer, size }) => (pointer.0 as u32, size.0 as u32),
_ => panic!("Call instruction's args input should be a HeapVector input"),
};
let temporary_function_selector_offset = match &inputs[4] {
let function_selector_offset = match &inputs[4] {
ValueOrArray::MemoryAddress(offset) => offset.to_usize() as u32,
_ => panic!(
"Call instruction's temporary function selector input should be a basic MemoryAddress",
),
_ => panic!("Call instruction's function selector input should be a basic MemoryAddress",),
};

let ret_offset_maybe = destinations[0];
Expand Down Expand Up @@ -351,7 +349,7 @@ fn handle_external_call(
AvmOperand::U32 { value: ret_offset },
AvmOperand::U32 { value: ret_size },
AvmOperand::U32 { value: success_offset },
AvmOperand::U32 { value: temporary_function_selector_offset },
AvmOperand::U32 { value: function_selector_offset },
],
..Default::default()
});
Expand Down Expand Up @@ -650,6 +648,7 @@ fn handle_getter_instruction(
"avmOpcodeTimestamp" => AvmOpcode::TIMESTAMP,
"avmOpcodeL2GasLeft" => AvmOpcode::L2GASLEFT,
"avmOpcodeDaGasLeft" => AvmOpcode::DAGASLEFT,
"avmOpcodeFunctionSelector" => AvmOpcode::FUNCTIONSELECTOR,
// "callStackDepth" => AvmOpcode::CallStackDepth,
_ => panic!("Transpiler doesn't know how to process ForeignCall function {:?}", function),
};
Expand Down Expand Up @@ -926,7 +925,7 @@ fn handle_storage_write(
inputs: &Vec<ValueOrArray>,
) {
assert!(inputs.len() == 2);
assert!(destinations.len() == 1);
assert!(destinations.len() == 0);

let slot_offset_maybe = inputs[0];
let slot_offset = match slot_offset_maybe {
Expand Down Expand Up @@ -992,8 +991,8 @@ fn handle_storage_read(
inputs: &Vec<ValueOrArray>,
) {
// For the foreign calls we want to handle, we do not want inputs, as they are getters
assert!(inputs.len() == 2); // output, len - but we dont use this len - its for the oracle
assert!(destinations.len() == 1);
assert!(inputs.len() == 1); // storage_slot
assert!(destinations.len() == 1); // return values

let slot_offset_maybe = inputs[0];
let slot_offset = match slot_offset_maybe {
Expand Down
4 changes: 2 additions & 2 deletions barretenberg/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/AztecProtocol/barretenberg
branch = master
commit = 44c9c7e368c0b33a4096a359e7b2b0d45f8bfea1
parent = c5dc0946f4d300df5c6a70026e102de8e69f020b
commit = c0a5796c6a7664918b3b5bd9a76e63ed61f1f2ce
parent = fa15a450408181ffc50946ee56c4ae0fd8c5a61f
method = merge
cmdver = 0.4.6
2 changes: 1 addition & 1 deletion barretenberg/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ barretenberg-acir-tests-bb:
RUN FLOW=prove_and_verify_mega_honk_program ./run_acir_tests.sh
# Fold and verify an ACIR program stack using ClientIvc
RUN FLOW=fold_and_verify_program ./run_acir_tests.sh fold_basic
# Fold and verify an ACIR program stack using ClientIvc, recursively verify as part of the Tube circuit and produce and verify a Honk proof
# Fold and verify an ACIR program stack using ClientIvc, recursively verify as part of the Tube circuit and produce and verify a Honk proof
RUN FLOW=prove_then_verify_tube ./run_acir_tests.sh fold_basic
# Construct and separately verify a UltraHonk proof for a single program that recursively verifies a Honk proof
RUN FLOW=prove_then_verify_ultra_honk ./run_acir_tests.sh verify_honk_proof
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
set -eu
set -eux

VFLAG=${VERBOSE:+-v}
BFLAG="-b ./target/program.json"
Expand Down
5 changes: 3 additions & 2 deletions barretenberg/acir_tests/reset_acir_tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
cd ~/aztec-packages/noir/noir-repo
# Run from barretenberg/acir_tests
cd ../../noir/noir-repo
cargo clean
noirup -p .
cd test_programs && ./rebuild.sh

cd ~/aztec-packages/barretenberg/acir_tests
cd ../../../barretenberg/acir_tests
rm -rf acir_tests
22 changes: 12 additions & 10 deletions barretenberg/cpp/pil/avm/constants.pil
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@

// NOTE: the constants in this file line up to the indexes of values in the
// `PublicKernelInputs.nr` object
// `PublicCircuitPublicInputs` object
namespace constants(256);
// From Public Context Inputs
// From PublicCircuitPublicInputs's CallContext member
pol SENDER_SELECTOR = 0;
// "address" actually does not exist in PublicCircuitPublicInputs,
// so this is just an alias to "storage address" for now
pol ADDRESS_SELECTOR = 1;
pol STORAGE_ADDRESS_SELECTOR = 2;
pol STORAGE_ADDRESS_SELECTOR = 1;
pol FUNCTION_SELECTOR_SELECTOR = 2;

// NOTE: constant expression evaluation does not seem to be supported yet in pil
// pol START_GLOBAL_VARIABLES = CALL_CONTEXT_LENGTH + HEADER_LENGTH = 6 + 23 = 29

// From PublicCircuitPublicInputs's GlobalVariables member
// Global Variables
pol CHAIN_ID_SELECTOR = 29;
pol VERSION_SELECTOR = 30;
pol BLOCK_NUMBER_SELECTOR = 31;
pol TIMESTAMP_SELECTOR = 32;
pol COINBASE_SELECTOR = 33;

pol END_GLOBAL_VARIABLES = 29 + 8; // We only use the first 5 of 8 global variables for now

// Gas
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/6715): This has since moved into the global variables
// Global Variables - fees
pol FEE_PER_DA_GAS_SELECTOR = 35;
pol FEE_PER_L2_GAS_SELECTOR = 36;

pol START_SIDE_EFFECT_COUNTER = 37;
pol END_GLOBAL_VARIABLES = 29 + 8; // We only use the first 5 of 8 global variables for now

// Top-level PublicCircuitPublicInputs members
pol START_SIDE_EFFECT_COUNTER = 37;
pol TRANSACTION_FEE_SELECTOR = 40;

// Other AVM specific constants
pol INTERNAL_CALL_SPACE_ID = 255;

// Lengths of kernel output vectors
// (vectors in PublicCircuitPublicInputs to be processed by kernel)
// Read requests
pol MAX_NULLIFIER_READ_REQUESTS_PER_CALL = 32;
pol MAX_NOTE_HASH_READ_REQUESTS_PER_CALL = 32;
pol MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL = 32;
pol MAX_PUBLIC_DATA_READS_PER_CALL = 32;

// Emitting Data
pol MAX_NEW_NOTE_HASHES_PER_CALL = 16;
pol MAX_NEW_NULLIIFIERS_PER_CALL = 16;
Expand Down
58 changes: 33 additions & 25 deletions barretenberg/cpp/pil/avm/main.pil
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,31 @@ namespace main(256);
pol constant sel_first = [1] + [0]*; // Used mostly to toggle off the first row consisting
// only in first element of shifted polynomials.

//===== PUBLIC COLUMNS=========================================================
pol public calldata;

//===== KERNEL INPUTS =========================================================
// Kernel lookup selector opcodes
pol commit sel_q_kernel_lookup;

// CALL CONTEXT
pol commit sel_op_sender;
// CONTEXT - ENVIRONMENT
pol commit sel_op_address;
pol commit sel_op_storage_address;

// FEES
pol commit sel_op_fee_per_l2_gas;
pol commit sel_op_fee_per_da_gas;
pol commit sel_op_sender;
pol commit sel_op_function_selector;
pol commit sel_op_transaction_fee;
// GLOBALS

// CONTEXT - ENVIRONMENT - GLOBALS
pol commit sel_op_chain_id;
pol commit sel_op_version;
pol commit sel_op_block_number;
pol commit sel_op_coinbase;
pol commit sel_op_timestamp;
// CONTEXT - ENVIRONMENT - GLOBALS - FEES
pol commit sel_op_fee_per_l2_gas;
pol commit sel_op_fee_per_da_gas;

// MACHINE STATE - GAS
// CONTEXT - MACHINE STATE - GAS
pol commit sel_op_l2gasleft;
pol commit sel_op_dagasleft;

Expand Down Expand Up @@ -259,17 +262,18 @@ namespace main(256);
// Relations on type constraints
// TODO: Very likely, we can remove these constraints as the selectors should be derived during
// opcode decomposition.
sel_op_sender * (1 - sel_op_sender) = 0;
sel_op_address * (1 - sel_op_address) = 0;
sel_op_storage_address * (1 - sel_op_storage_address) = 0;
sel_op_sender * (1 - sel_op_sender) = 0;
sel_op_function_selector * (1 - sel_op_function_selector) = 0;
sel_op_transaction_fee * (1 - sel_op_transaction_fee) = 0;
sel_op_chain_id * (1 - sel_op_chain_id) = 0;
sel_op_version * (1 - sel_op_version) = 0;
sel_op_block_number * (1 - sel_op_block_number) = 0;
sel_op_coinbase * (1 - sel_op_coinbase) = 0;
sel_op_timestamp * (1 - sel_op_timestamp) = 0;
sel_op_fee_per_l2_gas * (1 - sel_op_fee_per_l2_gas) = 0;
sel_op_fee_per_da_gas * (1 - sel_op_fee_per_da_gas) = 0;
sel_op_transaction_fee * (1 - sel_op_transaction_fee) = 0;

// MACHINE STATE - GAS
sel_op_l2gasleft * (1 - sel_op_l2gasleft) = 0;
Expand Down Expand Up @@ -407,8 +411,9 @@ namespace main(256);

//===== KERNEL LOOKUPS =======================================================
pol KERNEL_INPUT_SELECTORS = (
sel_op_sender + sel_op_address + sel_op_storage_address + sel_op_chain_id + sel_op_version + sel_op_block_number + sel_op_coinbase +
sel_op_timestamp + sel_op_fee_per_l2_gas + sel_op_fee_per_da_gas + sel_op_transaction_fee
sel_op_address + sel_op_storage_address + sel_op_sender + sel_op_function_selector + sel_op_transaction_fee +
sel_op_chain_id + sel_op_version + sel_op_block_number + sel_op_coinbase + sel_op_timestamp +
sel_op_fee_per_l2_gas + sel_op_fee_per_da_gas
);
// Ensure that only one kernel lookup is active when the kernel_in_offset is active
#[KERNEL_INPUT_ACTIVE_CHECK]
Expand Down Expand Up @@ -565,27 +570,23 @@ namespace main(256);
// We can lookup into a fixed index of this polynomial by including constraints that force the value
// of kernel_in_offset to the value relevant to the given opcode that is active

// CALL CONTEXT
#[SENDER_KERNEL]
sel_op_sender * (kernel.kernel_in_offset - constants.SENDER_SELECTOR) = 0;

// CONTEXT - ENVIRONMENT
#[ADDRESS_KERNEL]
sel_op_address * (kernel.kernel_in_offset - constants.ADDRESS_SELECTOR) = 0;

#[STORAGE_ADDRESS_KERNEL]
sel_op_storage_address * (kernel.kernel_in_offset - constants.STORAGE_ADDRESS_SELECTOR) = 0;

// FEES
#[FEE_DA_GAS_KERNEL]
sel_op_fee_per_da_gas * (kernel.kernel_in_offset - constants.FEE_PER_DA_GAS_SELECTOR) = 0;
#[SENDER_KERNEL]
sel_op_sender * (kernel.kernel_in_offset - constants.SENDER_SELECTOR) = 0;

#[FEE_L2_GAS_KERNEL]
sel_op_fee_per_l2_gas * (kernel.kernel_in_offset - constants.FEE_PER_L2_GAS_SELECTOR) = 0;
#[FUNCTION_SELECTOR_KERNEL]
sel_op_function_selector * (kernel.kernel_in_offset - constants.FUNCTION_SELECTOR_SELECTOR) = 0;

#[FEE_TRANSACTION_FEE_KERNEL]
sel_op_transaction_fee * (kernel.kernel_in_offset - constants.TRANSACTION_FEE_SELECTOR) = 0;

// GLOBALS
// CONTEXT - ENVIRONMENT - GLOBALS
#[CHAIN_ID_KERNEL]
sel_op_chain_id * (kernel.kernel_in_offset - constants.CHAIN_ID_SELECTOR) = 0;

Expand All @@ -595,11 +596,18 @@ namespace main(256);
#[BLOCK_NUMBER_KERNEL]
sel_op_block_number * (kernel.kernel_in_offset - constants.BLOCK_NUMBER_SELECTOR) = 0;

#[TIMESTAMP_KERNEL]
sel_op_timestamp * (kernel.kernel_in_offset - constants.TIMESTAMP_SELECTOR) = 0;

#[COINBASE_KERNEL]
sel_op_coinbase * (kernel.kernel_in_offset - constants.COINBASE_SELECTOR) = 0;

#[TIMESTAMP_KERNEL]
sel_op_timestamp * (kernel.kernel_in_offset - constants.TIMESTAMP_SELECTOR) = 0;
// CONTEXT - ENVIRONMENT - GLOBALS - FEES
#[FEE_DA_GAS_KERNEL]
sel_op_fee_per_da_gas * (kernel.kernel_in_offset - constants.FEE_PER_DA_GAS_SELECTOR) = 0;

#[FEE_L2_GAS_KERNEL]
sel_op_fee_per_l2_gas * (kernel.kernel_in_offset - constants.FEE_PER_L2_GAS_SELECTOR) = 0;

// OUTPUTS LOOKUPS
// Constrain the value of kernel_out_offset to be the correct offset for the operation being performed
Expand Down
1 change: 1 addition & 0 deletions barretenberg/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ add_subdirectory(barretenberg/bb)
add_subdirectory(barretenberg/circuit_checker)
add_subdirectory(barretenberg/client_ivc)
add_subdirectory(barretenberg/commitment_schemes)
add_subdirectory(barretenberg/commitment_schemes_recursion)
add_subdirectory(barretenberg/common)
add_subdirectory(barretenberg/crypto)
add_subdirectory(barretenberg/dsl)
Expand Down
Loading

0 comments on commit 9076dca

Please sign in to comment.