Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): Testing guide and getPrivateStorage method #1992

Merged
merged 14 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,17 @@ jobs:
command: ./scripts/cond_run_script end-to-end $JOB_NAME ./scripts/run_tests_local guides/writing_an_account_contract.test.ts
working_directory: yarn-project/end-to-end

guides-dapp-testing:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Test"
command: cond_spot_run_tests end-to-end guides/dapp_testing.test.ts docker-compose-e2e-sandbox.yml

e2e-canary-test:
docker:
- image: aztecprotocol/alpine-build-image
Expand Down Expand Up @@ -1407,6 +1418,7 @@ workflows:
- e2e-browser-sandbox: *e2e_test
- aztec-rpc-sandbox: *e2e_test
- guides-writing-an-account-contract: *e2e_test
- guides-dapp-testing: *e2e_test

- e2e-end:
requires:
Expand Down Expand Up @@ -1437,6 +1449,7 @@ workflows:
- e2e-canary-test
- aztec-rpc-sandbox
- guides-writing-an-account-contract
- guides-dapp-testing
<<: *defaults

- deploy-dockerhub:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ __extension__ using uint128_t = unsigned __int128;
// NOLINTBEGIN(cppcoreguidelines-pro-type-reinterpret-cast, cert-dcl58-cpp)
// clang-format on

template <typename T> concept IntegralOrEnum = std::integral<T> || std::is_enum_v<T>;
template <typename T>
concept IntegralOrEnum = std::integral<T> || std::is_enum_v<T>;

namespace serialize {
// Forward declare derived msgpack methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,8 +874,8 @@ template <typename FF> class UltraCircuitBuilder_ : public CircuitBuilderBase<ar

size_t total = count + romcount + ramcount + rangecount + num_ecc_op_gates;
std::cout << "gates = " << total << " (arith " << count << ", rom " << romcount << ", ram " << ramcount
<< ", range " << rangecount << ", non native field gates " << nnfcount << ", goblin ecc op gates " << num_ecc_op_gates
<< "), pubinp = " << this->public_inputs.size() << std::endl;
<< ", range " << rangecount << ", non native field gates " << nnfcount << ", goblin ecc op gates "
<< num_ecc_op_gates << "), pubinp = " << this->public_inputs.size() << std::endl;
}
// /**
// * @brief Get the final number of gates in a circuit, which consists of the sum of:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ template <typename Curve> class stdlib_biggroup_goblin : public testing::Test {
/**
* @brief Test goblin-style batch mul
* @details Check that 1) Goblin-style batch mul returns correct value, and 2) resulting circuit is correct
*
*
*/
static void test_goblin_style_batch_mul()
{
const bool goblin_flag = true; // used to indicate goblin-style in batch_mul
const size_t num_points = 5;
Builder builder;

std::vector<affine_element> points;
std::vector<fr> scalars;
for (size_t i = 0; i < num_points; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ std::array<typename Flavor::GroupElement, 2> UltraRecursiveVerifier_<Flavor, gob

std::optional sumcheck_output = sumcheck.verify(relation_parameters, transcript);

info("Sumcheck: num gates = ", builder->get_num_gates() - prev_num_gates, ", (total = ", builder->get_num_gates(), ")");
info("Sumcheck: num gates = ",
builder->get_num_gates() - prev_num_gates,
", (total = ",
builder->get_num_gates(),
")");
prev_num_gates = builder->get_num_gates();

// If Sumcheck does not return an output, sumcheck verification has failed
Expand All @@ -124,7 +128,11 @@ std::array<typename Flavor::GroupElement, 2> UltraRecursiveVerifier_<Flavor, gob
++evaluation_idx;
}

info("Batched eval: num gates = ", builder->get_num_gates() - prev_num_gates, ", (total = ", builder->get_num_gates(), ")");
info("Batched eval: num gates = ",
builder->get_num_gates() - prev_num_gates,
", (total = ",
builder->get_num_gates(),
")");
prev_num_gates = builder->get_num_gates();

// Compute batched commitments needed for input to Gemini.
Expand All @@ -150,13 +158,21 @@ std::array<typename Flavor::GroupElement, 2> UltraRecursiveVerifier_<Flavor, gob
auto batched_commitment_unshifted =
GroupElement::template batch_mul<goblin_flag>(commitments.get_unshifted(), scalars_unshifted);

info("Batch mul (unshifted): num gates = ", builder->get_num_gates() - prev_num_gates, ", (total = ", builder->get_num_gates(), ")");
info("Batch mul (unshifted): num gates = ",
builder->get_num_gates() - prev_num_gates,
", (total = ",
builder->get_num_gates(),
")");
prev_num_gates = builder->get_num_gates();

auto batched_commitment_to_be_shifted =
GroupElement::template batch_mul<goblin_flag>(commitments.get_to_be_shifted(), scalars_to_be_shifted);

info("Batch mul (to-be-shited): num gates = ", builder->get_num_gates() - prev_num_gates, ", (total = ", builder->get_num_gates(), ")");
info("Batch mul (to-be-shited): num gates = ",
builder->get_num_gates() - prev_num_gates,
", (total = ",
builder->get_num_gates(),
")");
prev_num_gates = builder->get_num_gates();

// Produce a Gemini claim consisting of:
Expand All @@ -168,13 +184,21 @@ std::array<typename Flavor::GroupElement, 2> UltraRecursiveVerifier_<Flavor, gob
batched_commitment_to_be_shifted,
transcript);

info("Gemini: num gates = ", builder->get_num_gates() - prev_num_gates, ", (total = ", builder->get_num_gates(), ")");
info("Gemini: num gates = ",
builder->get_num_gates() - prev_num_gates,
", (total = ",
builder->get_num_gates(),
")");
prev_num_gates = builder->get_num_gates();

// Produce a Shplonk claim: commitment [Q] - [Q_z], evaluation zero (at random challenge z)
auto shplonk_claim = Shplonk::reduce_verification(pcs_verification_key, gemini_claim, transcript);

info("Shplonk: num gates = ", builder->get_num_gates() - prev_num_gates, ", (total = ", builder->get_num_gates(), ")");
info("Shplonk: num gates = ",
builder->get_num_gates() - prev_num_gates,
", (total = ",
builder->get_num_gates(),
")");
prev_num_gates = builder->get_num_gates();

// Constuct the inputs to the final KZG pairing check
Expand Down
9 changes: 4 additions & 5 deletions circuits/cpp/src/aztec3/circuits/kernel/private/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,10 @@ void common_update_end_values(DummyBuilder& builder,
std::array<NT::fr, MAX_NEW_NULLIFIERS_PER_CALL> siloed_nullified_commitments{};
for (size_t i = 0; i < MAX_NEW_NULLIFIERS_PER_CALL; ++i) {
siloed_nullified_commitments[i] =
nullified_commitments[i] == fr(0)
? fr(0) // don't silo when empty
: nullified_commitments[i] == fr(EMPTY_NULLIFIED_COMMITMENT)
? fr(EMPTY_NULLIFIED_COMMITMENT) // don't silo when empty
: silo_commitment<NT>(storage_contract_address, nullified_commitments[i]);
nullified_commitments[i] == fr(0) ? fr(0) // don't silo when empty
: nullified_commitments[i] == fr(EMPTY_NULLIFIED_COMMITMENT)
? fr(EMPTY_NULLIFIED_COMMITMENT) // don't silo when empty
: silo_commitment<NT>(storage_contract_address, nullified_commitments[i]);
}

push_array_to_array(
Expand Down
Loading