Skip to content
Closed
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
4 changes: 4 additions & 0 deletions circuits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ You can choose which tests will run via a gtest filter. This one below runs only
./scripts/run_tests_local wasm aztec3_circuits_abis_tests -*.circuit*
```

> _Note:_ To log wasm output from within TS that uses them, you can use before running your `yarn test`
```
export DEBUG='wasm'
```
---

Here's a list of the tests currently available (conveniently combined with the command to build, then execute them on `x86_64`, for easy copy-pasta):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ template <typename NCT> struct CombinedAccumulatedData {
zero_array<fr, KERNEL_PRIVATE_CALL_STACK_LENGTH>();
std::array<fr, KERNEL_PUBLIC_CALL_STACK_LENGTH> public_call_stack =
zero_array<fr, KERNEL_PUBLIC_CALL_STACK_LENGTH>();
std::array<fr, KERNEL_L1_MSG_STACK_LENGTH> l1_msg_stack = zero_array<fr, KERNEL_L1_MSG_STACK_LENGTH>();
std::array<fr, KERNEL_NEW_L2_TO_L1_MSGS_LENGTH> new_l2_to_l1_msgs =
zero_array<fr, KERNEL_NEW_L2_TO_L1_MSGS_LENGTH>();

std::array<NewContractData<NCT>, KERNEL_NEW_CONTRACTS_LENGTH> new_contracts{};

Expand All @@ -50,7 +51,7 @@ template <typename NCT> struct CombinedAccumulatedData {
return aggregation_object == other.aggregation_object && private_call_count == other.private_call_count &&
public_call_count == other.public_call_count && new_commitments == other.new_commitments &&
new_nullifiers == other.new_nullifiers && private_call_stack == other.private_call_stack &&
public_call_stack == other.public_call_stack && l1_msg_stack == other.l1_msg_stack &&
public_call_stack == other.public_call_stack && new_l2_to_l1_msgs == other.new_l2_to_l1_msgs &&
new_contracts == other.new_contracts && optionally_revealed_data == other.optionally_revealed_data &&
state_transitions == other.state_transitions && state_reads == other.state_reads;
};
Expand Down Expand Up @@ -82,7 +83,7 @@ template <typename NCT> struct CombinedAccumulatedData {

to_ct(private_call_stack),
to_ct(public_call_stack),
to_ct(l1_msg_stack),
to_ct(new_l2_to_l1_msgs),

map(new_contracts, to_circuit_type),
map(optionally_revealed_data, to_circuit_type),
Expand Down Expand Up @@ -116,7 +117,7 @@ template <typename NCT> struct CombinedAccumulatedData {

to_nt(private_call_stack),
to_nt(public_call_stack),
to_nt(l1_msg_stack),
to_nt(new_l2_to_l1_msgs),

map(new_contracts, to_native_type),
map(optionally_revealed_data, to_native_type),
Expand All @@ -140,7 +141,7 @@ template <typename NCT> struct CombinedAccumulatedData {

set_array_public(private_call_stack);
set_array_public(public_call_stack);
set_array_public(l1_msg_stack);
set_array_public(new_l2_to_l1_msgs);

set_array_public(new_contracts);
set_array_public(optionally_revealed_data);
Expand Down Expand Up @@ -200,7 +201,7 @@ template <typename NCT> void read(uint8_t const*& it, CombinedAccumulatedData<NC
read(it, accum_data.new_nullifiers);
read(it, accum_data.private_call_stack);
read(it, accum_data.public_call_stack);
read(it, accum_data.l1_msg_stack);
read(it, accum_data.new_l2_to_l1_msgs);
read(it, accum_data.new_contracts);
read(it, accum_data.optionally_revealed_data);
read(it, accum_data.state_transitions);
Expand All @@ -218,7 +219,7 @@ template <typename NCT> void write(std::vector<uint8_t>& buf, CombinedAccumulate
write(buf, accum_data.new_nullifiers);
write(buf, accum_data.private_call_stack);
write(buf, accum_data.public_call_stack);
write(buf, accum_data.l1_msg_stack);
write(buf, accum_data.new_l2_to_l1_msgs);
write(buf, accum_data.new_contracts);
write(buf, accum_data.optionally_revealed_data);
write(buf, accum_data.state_transitions);
Expand All @@ -239,8 +240,8 @@ template <typename NCT> std::ostream& operator<<(std::ostream& os, CombinedAccum
<< accum_data.private_call_stack << "\n"
<< "public_call_stack:\n"
<< accum_data.public_call_stack << "\n"
<< "l1_msg_stack:\n"
<< accum_data.l1_msg_stack << "\n"
<< "new_l2_to_l1_msgs:\n"
<< accum_data.new_l2_to_l1_msgs << "\n"
<< "new_contracts:\n"
<< accum_data.new_contracts << "\n"
<< "optionally_revealed_data:\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ template <typename NCT> class PrivateCircuitPublicInputs {

std::array<fr, PRIVATE_CALL_STACK_LENGTH> private_call_stack = zero_array<fr, PRIVATE_CALL_STACK_LENGTH>();
std::array<fr, PUBLIC_CALL_STACK_LENGTH> public_call_stack = zero_array<fr, PUBLIC_CALL_STACK_LENGTH>();
std::array<fr, L1_MSG_STACK_LENGTH> l1_msg_stack = zero_array<fr, L1_MSG_STACK_LENGTH>();
std::array<fr, NEW_L2_TO_L1_MSGS_LENGTH> new_l2_to_l1_msgs = zero_array<fr, NEW_L2_TO_L1_MSGS_LENGTH>();

fr historic_private_data_tree_root = 0;
fr historic_nullifier_tree_root = 0;
Expand All @@ -49,7 +49,7 @@ template <typename NCT> class PrivateCircuitPublicInputs {
return call_context == other.call_context && args == other.args && return_values == other.return_values &&
emitted_events == other.emitted_events && new_commitments == other.new_commitments &&
new_nullifiers == other.new_nullifiers && private_call_stack == other.private_call_stack &&
public_call_stack == other.public_call_stack && l1_msg_stack == other.l1_msg_stack &&
public_call_stack == other.public_call_stack && new_l2_to_l1_msgs == other.new_l2_to_l1_msgs &&
historic_private_data_tree_root == other.historic_private_data_tree_root &&
historic_nullifier_tree_root == other.historic_nullifier_tree_root &&
historic_contract_tree_root == other.historic_contract_tree_root &&
Expand Down Expand Up @@ -78,7 +78,7 @@ template <typename NCT> class PrivateCircuitPublicInputs {

to_ct(private_call_stack),
to_ct(public_call_stack),
to_ct(l1_msg_stack),
to_ct(new_l2_to_l1_msgs),

to_ct(historic_private_data_tree_root),
to_ct(historic_nullifier_tree_root),
Expand Down Expand Up @@ -109,7 +109,7 @@ template <typename NCT> class PrivateCircuitPublicInputs {

to_nt(private_call_stack),
to_nt(public_call_stack),
to_nt(l1_msg_stack),
to_nt(new_l2_to_l1_msgs),

to_nt(historic_private_data_tree_root),
to_nt(historic_nullifier_tree_root),
Expand Down Expand Up @@ -139,7 +139,7 @@ template <typename NCT> class PrivateCircuitPublicInputs {

spread_arr_into_vec(private_call_stack, inputs);
spread_arr_into_vec(public_call_stack, inputs);
spread_arr_into_vec(l1_msg_stack, inputs);
spread_arr_into_vec(new_l2_to_l1_msgs, inputs);

inputs.push_back(historic_private_data_tree_root);
inputs.push_back(historic_nullifier_tree_root);
Expand Down Expand Up @@ -170,7 +170,7 @@ template <typename NCT> void read(uint8_t const*& it, PrivateCircuitPublicInputs
read(it, pis.new_nullifiers);
read(it, pis.private_call_stack);
read(it, pis.public_call_stack);
read(it, pis.l1_msg_stack);
read(it, pis.new_l2_to_l1_msgs);
read(it, pis.historic_private_data_tree_root);
read(it, pis.historic_nullifier_tree_root);
read(it, pis.historic_contract_tree_root);
Expand All @@ -192,7 +192,7 @@ void write(std::vector<uint8_t>& buf, PrivateCircuitPublicInputs<NCT> const& pri
write(buf, pis.new_nullifiers);
write(buf, pis.private_call_stack);
write(buf, pis.public_call_stack);
write(buf, pis.l1_msg_stack);
write(buf, pis.new_l2_to_l1_msgs);
write(buf, pis.historic_private_data_tree_root);
write(buf, pis.historic_nullifier_tree_root);
write(buf, pis.historic_contract_tree_root);
Expand All @@ -213,7 +213,7 @@ std::ostream& operator<<(std::ostream& os, PrivateCircuitPublicInputs<NCT> const
<< "new_nullifiers: " << pis.new_nullifiers << "\n"
<< "private_call_stack: " << pis.private_call_stack << "\n"
<< "public_call_stack: " << pis.public_call_stack << "\n"
<< "l1_msg_stack: " << pis.l1_msg_stack << "\n"
<< "new_l2_to_l1_msgs: " << pis.new_l2_to_l1_msgs << "\n"
<< "historic_private_data_tree_root: " << pis.historic_private_data_tree_root << "\n"
<< "historic_nullifier_tree_root: " << pis.historic_nullifier_tree_root << "\n"
<< "contract_deployment_data: " << pis.contract_deployment_data << "\n"
Expand Down Expand Up @@ -241,7 +241,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {

std::array<opt_fr, PRIVATE_CALL_STACK_LENGTH> private_call_stack;
std::array<opt_fr, PUBLIC_CALL_STACK_LENGTH> public_call_stack;
std::array<opt_fr, L1_MSG_STACK_LENGTH> l1_msg_stack;
std::array<opt_fr, NEW_L2_TO_L1_MSGS_LENGTH> new_l2_to_l1_msgs;

opt_fr historic_private_data_tree_root;
opt_fr historic_nullifier_tree_root;
Expand All @@ -263,7 +263,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {

std::array<opt_fr, PRIVATE_CALL_STACK_LENGTH> const& private_call_stack,
std::array<opt_fr, PUBLIC_CALL_STACK_LENGTH> const& public_call_stack,
std::array<opt_fr, L1_MSG_STACK_LENGTH> const& l1_msg_stack,
std::array<opt_fr, NEW_L2_TO_L1_MSGS_LENGTH> const& new_l2_to_l1_msgs,

opt_fr const& historic_private_data_tree_root,
opt_fr const& historic_nullifier_tree_root,
Expand All @@ -278,7 +278,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {
, new_nullifiers(new_nullifiers)
, private_call_stack(private_call_stack)
, public_call_stack(public_call_stack)
, l1_msg_stack(l1_msg_stack)
, new_l2_to_l1_msgs(new_l2_to_l1_msgs)
, historic_private_data_tree_root(historic_private_data_tree_root)
, historic_nullifier_tree_root(historic_nullifier_tree_root)
, historic_contract_tree_root(historic_contract_tree_root)
Expand All @@ -303,7 +303,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {

new_inputs.private_call_stack.fill(std::nullopt);
new_inputs.public_call_stack.fill(std::nullopt);
new_inputs.l1_msg_stack.fill(std::nullopt);
new_inputs.new_l2_to_l1_msgs.fill(std::nullopt);

new_inputs.historic_private_data_tree_root = std::nullopt;
new_inputs.historic_nullifier_tree_root = std::nullopt;
Expand Down Expand Up @@ -350,7 +350,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {

make_unused_array_elements_zero(composer, private_call_stack);
make_unused_array_elements_zero(composer, public_call_stack);
make_unused_array_elements_zero(composer, l1_msg_stack);
make_unused_array_elements_zero(composer, new_l2_to_l1_msgs);

make_unused_element_zero(composer, historic_private_data_tree_root);
make_unused_element_zero(composer, historic_nullifier_tree_root);
Expand Down Expand Up @@ -381,7 +381,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {

set_array_public(private_call_stack);
set_array_public(public_call_stack);
set_array_public(l1_msg_stack);
set_array_public(new_l2_to_l1_msgs);

(*historic_private_data_tree_root).set_public();
(*historic_nullifier_tree_root).set_public();
Expand Down Expand Up @@ -414,7 +414,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {

to_ct(private_call_stack),
to_ct(public_call_stack),
to_ct(l1_msg_stack),
to_ct(new_l2_to_l1_msgs),

to_ct(historic_private_data_tree_root),
to_ct(historic_nullifier_tree_root),
Expand Down Expand Up @@ -448,7 +448,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {

to_nt(private_call_stack),
to_nt(public_call_stack),
to_nt(l1_msg_stack),
to_nt(new_l2_to_l1_msgs),

to_nt(historic_private_data_tree_root),
to_nt(historic_nullifier_tree_root),
Expand Down Expand Up @@ -483,7 +483,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {

spread_arr_opt_into_vec(private_call_stack, inputs);
spread_arr_opt_into_vec(public_call_stack, inputs);
spread_arr_opt_into_vec(l1_msg_stack, inputs);
spread_arr_opt_into_vec(new_l2_to_l1_msgs, inputs);

inputs.push_back(*historic_private_data_tree_root);
inputs.push_back(*historic_nullifier_tree_root);
Expand Down Expand Up @@ -512,7 +512,7 @@ template <typename NCT> class OptionalPrivateCircuitPublicInputs {

.private_call_stack = map(private_call_stack, get_value),
.public_call_stack = map(public_call_stack, get_value),
.l1_msg_stack = map(l1_msg_stack, get_value),
.new_l2_to_l1_msgs = map(new_l2_to_l1_msgs, get_value),

.historic_private_data_tree_root = historic_private_data_tree_root.value(),
.historic_nullifier_tree_root = historic_nullifier_tree_root.value(),
Expand Down Expand Up @@ -604,7 +604,7 @@ void read(uint8_t const*& it, OptionalPrivateCircuitPublicInputs<NCT>& private_c
read(it, pis.new_nullifiers);
read(it, pis.private_call_stack);
read(it, pis.public_call_stack);
read(it, pis.l1_msg_stack);
read(it, pis.new_l2_to_l1_msgs);
read(it, pis.historic_private_data_tree_root);
read(it, pis.historic_nullifier_tree_root);
read(it, pis.historic_contract_tree_root);
Expand All @@ -626,7 +626,7 @@ void write(std::vector<uint8_t>& buf, OptionalPrivateCircuitPublicInputs<NCT> co
write(buf, pis.new_nullifiers);
write(buf, pis.private_call_stack);
write(buf, pis.public_call_stack);
write(buf, pis.l1_msg_stack);
write(buf, pis.new_l2_to_l1_msgs);
write(buf, pis.historic_private_data_tree_root);
write(buf, pis.historic_nullifier_tree_root);
write(buf, pis.historic_contract_tree_root);
Expand All @@ -646,7 +646,7 @@ std::ostream& operator<<(std::ostream& os, OptionalPrivateCircuitPublicInputs<NC
<< "new_nullifiers: " << pis.new_nullifiers << "\n"
<< "private_call_stack: " << pis.private_call_stack << "\n"
<< "public_call_stack: " << pis.public_call_stack << "\n"
<< "l1_msg_stack: " << pis.l1_msg_stack << "\n"
<< "new_l2_to_l1_msgs: " << pis.new_l2_to_l1_msgs << "\n"
<< "historic_private_data_tree_root: " << pis.historic_private_data_tree_root << "\n"
<< "historic_nullifier_tree_root: " << pis.historic_nullifier_tree_root << "\n"
<< "historic_nullifier_tree_root: " << pis.historic_nullifier_tree_root << "\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

// // std::array<fr, CONTRACT_DEPLOYMENT_CALL_STACK_LENGTH> contract_deployment_call_stack;

// std::array<CallContext<NCT>, L1_MSG_STACK_LENGTH> l1_call_contexts;
// std::array<fr, L1_MSG_STACK_LENGTH> l1_counterparts; // TODO: this is probably wrong.
// std::array<CallContext<NCT>, NEW_L2_TO_L1_MSGS_LENGTH> l1_call_contexts;
// std::array<fr, NEW_L2_TO_L1_MSGS_LENGTH> l1_counterparts; // TODO: this is probably wrong.

// template <typename Composer>
// CallContextReconciliationData<CircuitTypes<Composer>> to_circuit_type(Composer& composer) const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ template <typename NCT> struct PublicCircuitPublicInputs {
std::array<StateRead<NCT>, STATE_READS_LENGTH> state_reads{};

std::array<fr, PUBLIC_CALL_STACK_LENGTH> public_call_stack = zero_array<fr, PUBLIC_CALL_STACK_LENGTH>();
std::array<fr, L1_MSG_STACK_LENGTH> l1_msg_stack = zero_array<fr, L1_MSG_STACK_LENGTH>();
std::array<fr, NEW_L2_TO_L1_MSGS_LENGTH> new_l2_to_l1_msgs = zero_array<fr, NEW_L2_TO_L1_MSGS_LENGTH>();

fr historic_public_data_tree_root = 0;

Expand All @@ -44,7 +44,7 @@ template <typename NCT> struct PublicCircuitPublicInputs {
return call_context == other.call_context && args == other.args && return_values == other.return_values &&
emitted_events == other.emitted_events && state_transitions == other.state_transitions &&
state_reads == other.state_reads && public_call_stack == other.public_call_stack &&
l1_msg_stack == other.l1_msg_stack &&
new_l2_to_l1_msgs == other.new_l2_to_l1_msgs &&
historic_public_data_tree_root == other.historic_public_data_tree_root &&
prover_address == other.prover_address;
};
Expand All @@ -70,7 +70,7 @@ template <typename NCT> struct PublicCircuitPublicInputs {
.state_reads = map(state_reads, to_circuit_type),

.public_call_stack = to_ct(public_call_stack),
.l1_msg_stack = to_ct(l1_msg_stack),
.new_l2_to_l1_msgs = to_ct(new_l2_to_l1_msgs),

.historic_public_data_tree_root = to_ct(historic_public_data_tree_root),

Expand Down Expand Up @@ -99,7 +99,7 @@ template <typename NCT> struct PublicCircuitPublicInputs {
spread_arr_into_vec(map(state_reads, to_hashes), inputs);

spread_arr_into_vec(public_call_stack, inputs);
spread_arr_into_vec(l1_msg_stack, inputs);
spread_arr_into_vec(new_l2_to_l1_msgs, inputs);

inputs.push_back(historic_public_data_tree_root);

Expand Down Expand Up @@ -127,7 +127,7 @@ template <typename NCT> void read(uint8_t const*& it, PublicCircuitPublicInputs<
read(it, pis.state_reads);

read(it, pis.public_call_stack);
read(it, pis.l1_msg_stack);
read(it, pis.new_l2_to_l1_msgs);

read(it, pis.historic_public_data_tree_root);

Expand All @@ -150,7 +150,7 @@ void write(std::vector<uint8_t>& buf, PublicCircuitPublicInputs<NCT> const& publ
write(buf, pis.state_reads);

write(buf, pis.public_call_stack);
write(buf, pis.l1_msg_stack);
write(buf, pis.new_l2_to_l1_msgs);

write(buf, pis.historic_public_data_tree_root);

Expand All @@ -171,7 +171,7 @@ std::ostream& operator<<(std::ostream& os, PublicCircuitPublicInputs<NCT> const&
<< "state_reads: " << pis.state_reads << "\n"

<< "public_call_stack: " << pis.public_call_stack << "\n"
<< "l1_msg_stack: " << pis.l1_msg_stack << "\n"
<< "new_l2_to_l1_msgs: " << pis.new_l2_to_l1_msgs << "\n"

<< "historic_public_data_tree_root: " << pis.historic_public_data_tree_root << "\n"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ template <typename NCT> void write(std::vector<uint8_t>& buf, RootRollupInputs<N
template <typename NCT> std::ostream& operator<<(std::ostream& os, RootRollupInputs<NCT> const& obj)
{
return os << "previous_rollup_data: " << obj.previous_rollup_data << "\n"
<< "new_historic_private_data_tree_roots: " << obj.new_historic_private_data_tree_root_sibling_path
<< "\n"
<< "new_historic_contract_tree_roots: " << obj.new_historic_contract_tree_root_sibling_path << "\n";
<< "new_historic_private_data_tree_root_sibling_path: "
<< obj.new_historic_private_data_tree_root_sibling_path << "\n"
<< "new_historic_contract_tree_root_sibling_path: " << obj.new_historic_contract_tree_root_sibling_path
<< "\n";
}

} // namespace aztec3::circuits::abis
Loading