Skip to content

Commit

Permalink
Merge branch 'master' into sync-noir
Browse files Browse the repository at this point in the history
* master: (29 commits)
  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)
  feat: Constant Honk proof sizes (#6954)
  feat: add outgoing keys support to getEvents (#7239)
  feat: Sync from noir (#7223)
  feat!: split storage access oracles (#7237)
  feat: add new lenses for encryted notes (#7238)
  feat(avm): calldata gadget preliminaries (#7227)
  fix(docs): Historical reference library updates (#7166)
  chore: avoid building contracts when producing gates report (#7136)
  ...
  • Loading branch information
TomAFrench committed Jul 1, 2024
2 parents 076533a + 3e6d88e commit e9cbb84
Show file tree
Hide file tree
Showing 227 changed files with 2,433 additions and 1,643 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,
}
10 changes: 5 additions & 5 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 @@ -926,7 +926,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 +992,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
3 changes: 3 additions & 0 deletions barretenberg/cpp/pil/avm/main.pil
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ 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;
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
68 changes: 39 additions & 29 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,18 +741,15 @@ bool avm_verify(const std::filesystem::path& proof_path, const std::filesystem::
#endif

/**
* @brief Creates a proof for an ACIR circuit
*
* Communication:
* - stdout: The proof is written to stdout as a byte array
* - Filesystem: The proof is written to the path specified by outputPath
* @brief Create a Honk a prover from program bytecode and an optional witness
*
* @param bytecodePath Path to the file containing the serialized circuit
* @param witnessPath Path to the file containing the serialized witness
* @param outputPath Path to write the proof to
* @tparam Flavor
* @param bytecodePath
* @param witnessPath
* @return UltraProver_<Flavor>
*/
template <IsUltraFlavor Flavor>
void prove_honk(const std::string& bytecodePath, const std::string& witnessPath, const std::string& outputPath)
template <typename Flavor>
UltraProver_<Flavor> compute_valid_prover(const std::string& bytecodePath, const std::string& witnessPath)
{
using Builder = Flavor::CircuitBuilder;
using Prover = UltraProver_<Flavor>;
Expand All @@ -762,16 +759,40 @@ void prove_honk(const std::string& bytecodePath, const std::string& witnessPath,
honk_recursion = true;
}
auto constraint_system = get_constraint_system(bytecodePath, honk_recursion);
auto witness = get_witness(witnessPath);
acir_format::WitnessVector witness = {};
if (!witnessPath.empty()) {
witness = get_witness(witnessPath);
}

auto builder = acir_format::create_circuit<Builder>(constraint_system, 0, witness, honk_recursion);

auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials();
size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates);
init_bn254_crs(srs_size);

// Construct Honk proof
Prover prover{ builder };
return prover;
}

/**
* @brief Creates a proof for an ACIR circuit
*
* Communication:
* - stdout: The proof is written to stdout as a byte array
* - Filesystem: The proof is written to the path specified by outputPath
*
* @param bytecodePath Path to the file containing the serialized circuit
* @param witnessPath Path to the file containing the serialized witness
* @param outputPath Path to write the proof to
*/
template <IsUltraFlavor Flavor>
void prove_honk(const std::string& bytecodePath, const std::string& witnessPath, const std::string& outputPath)
{
// using Builder = Flavor::CircuitBuilder;
using Prover = UltraProver_<Flavor>;

// Construct Honk proof
Prover prover = compute_valid_prover<Flavor>(bytecodePath, witnessPath);
auto proof = prover.construct_proof();

if (outputPath == "-") {
Expand Down Expand Up @@ -807,10 +828,9 @@ template <IsUltraFlavor Flavor> bool verify_honk(const std::string& proof_path,
auto g2_data = get_bn254_g2_data(CRS_PATH);
srs::init_crs_factory({}, g2_data);
auto proof = from_buffer<std::vector<bb::fr>>(read_file(proof_path));
auto verification_key = std::make_shared<VerificationKey>(from_buffer<VerificationKey>(read_file(vk_path)));
verification_key->pcs_verification_key = std::make_shared<VerifierCommitmentKey>();

Verifier verifier{ verification_key };
auto vk = std::make_shared<VerificationKey>(from_buffer<VerificationKey>(read_file(vk_path)));
vk->pcs_verification_key = std::make_shared<VerifierCommitmentKey>();
Verifier verifier{ vk };

bool verified = verifier.verify_proof(proof);

Expand All @@ -830,22 +850,12 @@ template <IsUltraFlavor Flavor> bool verify_honk(const std::string& proof_path,
*/
template <IsUltraFlavor Flavor> void write_vk_honk(const std::string& bytecodePath, const std::string& outputPath)
{
using Builder = Flavor::CircuitBuilder;
using Prover = UltraProver_<Flavor>;
using ProverInstance = ProverInstance_<Flavor>;
using VerificationKey = Flavor::VerificationKey;

bool honk_recursion = false;
if constexpr (IsAnyOf<Flavor, UltraFlavor>) {
honk_recursion = true;
}
auto constraint_system = get_constraint_system(bytecodePath, honk_recursion);
auto builder = acir_format::create_circuit<Builder>(constraint_system, 0, {}, honk_recursion);

auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials();
size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates);
init_bn254_crs(srs_size);

ProverInstance prover_inst(builder);
Prover prover = compute_valid_prover<Flavor>(bytecodePath, "");
ProverInstance& prover_inst = *prover.instance;
VerificationKey vk(
prover_inst.proving_key); // uses a partial form of the proving key which only has precomputed entities

Expand Down

This file was deleted.

Loading

0 comments on commit e9cbb84

Please sign in to comment.