Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into mm/remove-instance
Browse files Browse the repository at this point in the history
  • Loading branch information
maramihali committed Mar 4, 2024
2 parents abb67f1 + 6b861bb commit 38107b1
Show file tree
Hide file tree
Showing 495 changed files with 10,170 additions and 7,089 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ jobs:
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_inclusion_proofs_contract.test.ts
aztec_manifest_key: end-to-end

e2e-pending-commitments-contract:
e2e-pending-note-hashes-contract:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
Expand All @@ -902,7 +902,7 @@ jobs:
- *setup_env
- run:
name: "Test"
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_pending_commitments_contract.test.ts
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_pending_note_hashes_contract.test.ts
aztec_manifest_key: end-to-end

e2e-ordering:
Expand Down Expand Up @@ -1493,7 +1493,7 @@ workflows:
- e2e-account-contracts: *e2e_test
- e2e-escrow-contract: *e2e_test
- e2e-inclusion-proofs-contract: *e2e_test
- e2e-pending-commitments-contract: *e2e_test
- e2e-pending-note-hashes-contract: *e2e_test
- e2e-ordering: *e2e_test
- e2e-counter: *e2e_test
- e2e-private-voting: *e2e_test
Expand Down Expand Up @@ -1539,7 +1539,7 @@ workflows:
- e2e-account-contracts
- e2e-escrow-contract
- e2e-inclusion-proofs-contract
- e2e-pending-commitments-contract
- e2e-pending-note-hashes-contract
- e2e-ordering
- e2e-counter
- e2e-private-voting
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/mirror_noir_subrepo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Push to branch
run: |
set -xue # print commands
SUBREPO_PATH=noir
SUBREPO_PATH=noir/noir-repo
BRANCH=aztec-packages
if [[ "$PR_URL" == "" ]]; then
# if no staging branch, we can overwrite
Expand All @@ -73,7 +73,7 @@ jobs:
# otherwise we first reset our staging branch
STAGING_BRANCH=$BRANCH-staging
fi
BASE_NOIR_COMMIT=`git config --file=noir/noir-repo/.gitrepo subrepo.commit`
BASE_NOIR_COMMIT=`git config --file=$SUBREPO_PATH/.gitrepo subrepo.commit`
COMMIT=$(git rev-parse HEAD)
COMMIT_MESSAGE=$(git log -1 --pretty=format:%B)
Expand All @@ -91,7 +91,7 @@ jobs:
}
# force_sync_staging: Push to our aztec-packages staging branch.
function force_sync_staging() {
echo "$COMMIT" > noir/noir-repo/.aztec-sync-commit && git add noir/noir-repo/.aztec-sync-commit
echo "$COMMIT" > $SUBREPO_PATH/.aztec-sync-commit && git add $SUBREPO_PATH/.aztec-sync-commit
# make a new commit with our previous message
git commit -am "$COMMIT_MESSAGE"
# Now push to it with subrepo with computed commit messages
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/mirror_repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ jobs:
nargo_files="$(find $SUBREPO_PATH -name 'Nargo.toml' | xargs grep --files-with-matches 'noir-protocol-circuits')"
# match lines like this:
# protocol_types = { path = "../../noir-protocol-circuits/src/crates/types" }
# protocol_types = { path = "../../noir-protocol-circuits/crates/types" }
# and replace with
# protocol_types = { git="https://github.com/aztecprotocol/aztec-packages", tag="aztec-packages-v0.16.9", directory="noir-projects/noir-protocol-circuits/src/crates/types" }
# protocol_types = { git="https://github.com/aztecprotocol/aztec-packages", tag="aztec-packages-v0.16.9", directory="noir-projects/noir-protocol-circuits/crates/types" }
for nargo_file in $nargo_files; do
sed --regexp-extended --in-place \
"s;path\s*=\s*\".*noir-protocol-circuits(.*)\";git=\"$monorepo_url\", tag=\"$monorepo_tag\", directory=\"$monorepo_protocol_circuits_path\1\";" \
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/protocol-circuits-gate-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ jobs:
run: nargo --version

- name: Generate gates report
working-directory: ./noir-projects/noir-protocol-circuits/src
working-directory: ./noir-projects/noir-protocol-circuits
run: |
nargo info --json > protocol_circuits_report.json
mv protocol_circuits_report.json ../../../protocol_circuits_report.json
nargo info --json --silence-warnings > protocol_circuits_report.json
mv protocol_circuits_report.json ../../protocol_circuits_report.json
env:
NARGO_BACKEND_PATH: ../../../barretenberg/cpp/build/bin/bb
NARGO_BACKEND_PATH: ../../barretenberg/cpp/build/bin/bb

- name: Compare gates reports
id: gates_diff
Expand Down
41 changes: 41 additions & 0 deletions avm-transpiler/src/transpile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ fn handle_foreign_call(
inputs: &Vec<ValueOrArray>,
) {
match function.as_str() {
"avmOpcodeNoteHashExists" => handle_note_hash_exists(avm_instrs, destinations, inputs),
"emitNoteHash" | "emitNullifier" => handle_emit_note_hash_or_nullifier(
function.as_str() == "emitNullifier",
avm_instrs,
Expand All @@ -255,6 +256,46 @@ fn handle_foreign_call(
}
}

/// Handle an AVM NOTEHASHEXISTS instruction
/// Adds the new instruction to the avm instructions list.
fn handle_note_hash_exists(
avm_instrs: &mut Vec<AvmInstruction>,
destinations: &Vec<ValueOrArray>,
inputs: &Vec<ValueOrArray>,
) {
let (note_hash_offset_operand, leaf_index_offset_operand) = match &inputs[..] {
[
ValueOrArray::MemoryAddress(nh_offset),
ValueOrArray::MemoryAddress(li_offset)
] => (nh_offset.to_usize() as u32, li_offset.to_usize() as u32),
_ => panic!(
"Transpiler expects ForeignCall::NOTEHASHEXISTS to have 2 inputs of type MemoryAddress, got {:?}", inputs
),
};
let exists_offset_operand = match &destinations[..] {
[ValueOrArray::MemoryAddress(offset)] => offset.to_usize() as u32,
_ => panic!(
"Transpiler expects ForeignCall::NOTEHASHEXISTS to have 1 output of type MemoryAddress, got {:?}", destinations
),
};
avm_instrs.push(AvmInstruction {
opcode: AvmOpcode::NOTEHASHEXISTS,
indirect: Some(ALL_DIRECT),
operands: vec![
AvmOperand::U32 {
value: note_hash_offset_operand,
},
AvmOperand::U32 {
value: leaf_index_offset_operand,
},
AvmOperand::U32 {
value: exists_offset_operand,
},
],
..Default::default()
});
}

/// Handle an AVM EMITNOTEHASH or EMITNULLIFIER instruction
/// (an emitNoteHash or emitNullifier brillig foreign call was encountered)
/// Adds the new instruction to the avm instructions list.
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 = e26973fa4884d59fe7fde6a98ce1e74cd9d0a0f0
parent = 035cff451ca2171e08279b9d36b23f38b840efea
commit = a3c713311e45192f775bef06080a6a13e7ab5603
parent = e6ce08f6d74db76a45e5dea69d5b7531ca99c769
method = merge
cmdver = 0.4.6
22 changes: 11 additions & 11 deletions barretenberg/cpp/scripts/bb-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@ IMAGE_URI=$(calculate_image_uri $REPOSITORY)
retry docker pull $IMAGE_URI

TESTS=(
client_ivc_tests
flavor_tests
relations_tests
transcript_tests
commitment_schemes_tests
sumcheck_tests
eccvm_tests
translator_vm_tests
protogalaxy_tests
ultra_honk_tests
goblin_tests
client_ivc_tests
dsl_tests
crypto_aes128_tests
crypto_blake2s_tests
crypto_blake3s_tests
Expand All @@ -22,23 +32,13 @@ TESTS=(
crypto_poseidon2_tests
crypto_schnorr_tests
crypto_sha256_tests
dsl_tests
ecc_tests
eccvm_tests
flavor_tests
goblin_tests
join_split_example_proofs_inner_proof_data_tests
join_split_example_proofs_notes_tests
numeric_tests
plonk_tests
polynomials_tests
protogalaxy_tests
relations_tests
srs_tests
sumcheck_tests
transcript_tests
translator_vm_tests
ultra_honk_tests
vm_tests
)
TESTS_STR="${TESTS[@]}"
Expand Down
22 changes: 22 additions & 0 deletions barretenberg/cpp/scripts/ultra_honk_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set -eu

# Move above script dir.
cd $(dirname $0)/..

cmake --preset clang16
cmake --build --preset clang16

cd build/

./bin/flavor_tests
./bin/relations_tests
./bin/transcript_tests
./bin/commitment_schemes_tests
./bin/sumcheck_tests
./bin/eccvm_tests
./bin/translator_vm_tests
./bin/protogalaxy_tests
./bin/ultra_honk_tests
./bin/goblin_tests
./bin/client_ivc_tests
./bin/stdlib_recursion_tests
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@

namespace bb {

constexpr size_t COMMITMENT_TEST_NUM_POINTS = 4096;

template <class CK> inline std::shared_ptr<CK> CreateCommitmentKey();

template <> inline std::shared_ptr<CommitmentKey<curve::BN254>> CreateCommitmentKey<CommitmentKey<curve::BN254>>()
{
srs::init_crs_factory("../srs_db/ignition");
constexpr size_t n = 4096;
return std::make_shared<CommitmentKey<curve::BN254>>(n);
return std::make_shared<CommitmentKey<curve::BN254>>(COMMITMENT_TEST_NUM_POINTS);
}
// For IPA
template <> inline std::shared_ptr<CommitmentKey<curve::Grumpkin>> CreateCommitmentKey<CommitmentKey<curve::Grumpkin>>()
{
srs::init_grumpkin_crs_factory("../srs_db/grumpkin");
constexpr size_t n = 4096;
return std::make_shared<CommitmentKey<curve::Grumpkin>>(n);
return std::make_shared<CommitmentKey<curve::Grumpkin>>(COMMITMENT_TEST_NUM_POINTS);
}

template <typename CK> inline std::shared_ptr<CK> CreateCommitmentKey()
Expand All @@ -39,20 +39,16 @@ template <>
inline std::shared_ptr<VerifierCommitmentKey<curve::BN254>> CreateVerifierCommitmentKey<
VerifierCommitmentKey<curve::BN254>>()
{
constexpr size_t n = 4096;
std::shared_ptr<bb::srs::factories::CrsFactory<curve::BN254>> crs_factory(
new bb::srs::factories::FileCrsFactory<curve::BN254>("../srs_db/ignition", 4096));
return std::make_shared<VerifierCommitmentKey<curve::BN254>>(n, crs_factory);
return std::make_shared<VerifierCommitmentKey<curve::BN254>>();
}
// For IPA
template <>
inline std::shared_ptr<VerifierCommitmentKey<curve::Grumpkin>> CreateVerifierCommitmentKey<
VerifierCommitmentKey<curve::Grumpkin>>()
{
constexpr size_t n = 4096;
std::shared_ptr<bb::srs::factories::CrsFactory<curve::Grumpkin>> crs_factory(
new bb::srs::factories::FileCrsFactory<curve::Grumpkin>("../srs_db/grumpkin", 4096));
return std::make_shared<VerifierCommitmentKey<curve::Grumpkin>>(n, crs_factory);
auto crs_factory = std::make_shared<srs::factories::FileCrsFactory<curve::Grumpkin>>("../srs_db/grumpkin",
COMMITMENT_TEST_NUM_POINTS);
return std::make_shared<VerifierCommitmentKey<curve::Grumpkin>>(COMMITMENT_TEST_NUM_POINTS, crs_factory);
}
template <typename VK> inline std::shared_ptr<VK> CreateVerifierCommitmentKey()
// requires std::default_initializable<VK>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
#include "barretenberg/numeric/bitop/pow.hpp"
#include "barretenberg/polynomials/polynomial.hpp"
#include "barretenberg/polynomials/polynomial_arithmetic.hpp"
#include "barretenberg/srs/factories/crs_factory.hpp"
#include "barretenberg/srs/factories/file_crs_factory.hpp"
#include "barretenberg/srs/global_crs.hpp"

#include <cstddef>
#include <memory>
Expand All @@ -35,19 +34,13 @@ template <> class VerifierCommitmentKey<curve::BN254> {
using Commitment = typename Curve::AffineElement;

public:
VerifierCommitmentKey() = delete;
std::shared_ptr<bb::srs::factories::VerifierCrs<Curve>> srs;

/**
* @brief Construct a new Kate Verification Key object from existing SRS
*
* @param num_points
* @param srs verifier G2 point
*/
VerifierCommitmentKey(
[[maybe_unused]] size_t num_points, // TODO(https://github.com/AztecProtocol/barretenberg/issues/874)
std::shared_ptr<bb::srs::factories::CrsFactory<Curve>> crs_factory)
: srs(crs_factory->get_verifier_crs())
{}
VerifierCommitmentKey()
{
srs::init_crs_factory("../srs_db/ignition");
srs = srs::get_crs_factory<Curve>()->get_verifier_crs();
};

/**
* @brief verifies a pairing equation over 2 points using the verifier SRS
Expand All @@ -65,8 +58,6 @@ template <> class VerifierCommitmentKey<curve::BN254> {

return (result == Curve::TargetField::one());
}

std::shared_ptr<bb::srs::factories::VerifierCrs<Curve>> srs;
};

/**
Expand All @@ -89,7 +80,7 @@ template <> class VerifierCommitmentKey<curve::Grumpkin> {
* @param num_points specifies the length of the SRS
* @param path is the location to the SRS file
*/
VerifierCommitmentKey(size_t num_points, std::shared_ptr<bb::srs::factories::CrsFactory<Curve>> crs_factory)
VerifierCommitmentKey(size_t num_points, const std::shared_ptr<bb::srs::factories::CrsFactory<Curve>>& crs_factory)
: pippenger_runtime_state(num_points)
, srs(crs_factory->get_verifier_crs(num_points))

Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ template <typename CycleGroup_T, typename Curve_T, typename PCS_T> class ECCVMBa
* resolve that, and split out separate PrecomputedPolynomials/Commitments data for clarity but also for
* portability of our circuits.
*/
using VerificationKey = VerificationKey_<PrecomputedEntities<Commitment>>;
using VerificationKey = VerificationKey_<PrecomputedEntities<Commitment>, VerifierCommitmentKey>;

/**
* @brief A container for polynomials produced after the first round of sumcheck.
Expand Down
8 changes: 7 additions & 1 deletion barretenberg/cpp/src/barretenberg/flavor/flavor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#include "barretenberg/polynomials/univariate.hpp"
#include "barretenberg/proof_system/types/circuit_type.hpp"
#include <array>
#include <barretenberg/srs/global_crs.hpp>
#include <concepts>
#include <vector>

Expand Down Expand Up @@ -142,20 +143,25 @@ class ProvingKey_ : public PrecomputedPolynomials, public WitnessPolynomials {
*
* @tparam PrecomputedEntities An instance of PrecomputedEntities_ with affine_element data type and handle type.
*/
template <typename PrecomputedCommitments> class VerificationKey_ : public PrecomputedCommitments {
template <typename PrecomputedCommitments, typename VerifierCommitmentKey>
class VerificationKey_ : public PrecomputedCommitments {
public:
std::shared_ptr<VerifierCommitmentKey> pcs_verification_key;

VerificationKey_() = default;
VerificationKey_(const size_t circuit_size, const size_t num_public_inputs)
{
this->circuit_size = circuit_size;
this->log_circuit_size = numeric::get_msb(circuit_size);
this->num_public_inputs = num_public_inputs;
};

template <typename ProvingKeyPtr> VerificationKey_(const ProvingKeyPtr& proving_key)
{
this->circuit_size = proving_key->circuit_size;
this->log_circuit_size = numeric::get_msb(this->circuit_size);
this->num_public_inputs = proving_key->num_public_inputs;
this->pcs_verification_key = std::make_shared<VerifierCommitmentKey>();

for (auto [polynomial, commitment] : zip_view(proving_key->get_precomputed_polynomials(), this->get_all())) {
commitment = proving_key->commitment_key->commit(polynomial);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ class AvmFlavor {
RefArray<Polynomial, 0> get_table_column_wires() { return {}; };
};

using VerificationKey = VerificationKey_<PrecomputedEntities<Commitment>>;
using VerificationKey = VerificationKey_<PrecomputedEntities<Commitment>, VerifierCommitmentKey>;

using FoldedPolynomials = AllEntities<std::vector<FF>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class ToyFlavor {
RefArray<Polynomial, 0> get_table_column_wires() { return {}; };
};

using VerificationKey = VerificationKey_<PrecomputedEntities<Commitment>>;
using VerificationKey = VerificationKey_<PrecomputedEntities<Commitment>, VerifierCommitmentKey>;

using FoldedPolynomials = AllEntities<std::vector<FF>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ class GoblinTranslatorFlavor {
* resolve that, and split out separate PrecomputedPolynomials/Commitments data for clarity but also for
* portability of our circuits.
*/
using VerificationKey = VerificationKey_<PrecomputedEntities<Commitment>>;
using VerificationKey = VerificationKey_<PrecomputedEntities<Commitment>, VerifierCommitmentKey>;

/**
* @brief A field element for each entity of the flavor. These entities represent the prover polynomials
Expand Down
Loading

0 comments on commit 38107b1

Please sign in to comment.