Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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 @@ -52,7 +53,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 @@ -84,7 +85,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 @@ -118,7 +119,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 @@ -142,7 +143,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 @@ -202,7 +203,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 @@ -220,7 +221,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 @@ -241,8 +242,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 @@ -37,7 +37,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 @@ -50,7 +50,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 @@ -79,7 +79,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 @@ -110,7 +110,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 @@ -140,7 +140,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 @@ -171,7 +171,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 @@ -193,7 +193,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 @@ -214,7 +214,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 @@ -242,7 +242,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 @@ -264,7 +264,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 @@ -279,7 +279,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 @@ -34,7 +34,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 @@ -45,7 +45,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 @@ -71,7 +71,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 @@ -100,7 +100,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 @@ -128,7 +128,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 @@ -151,7 +151,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 @@ -172,7 +172,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
7 changes: 0 additions & 7 deletions circuits/cpp/src/aztec3/circuits/apps/contract.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include "function_declaration.hpp"
#include "l1_function_interface.hpp"

#include <aztec3/circuits/abis/function_data.hpp>

Expand Down Expand Up @@ -32,8 +31,6 @@ template <typename NCT> class Contract {

std::map<std::string, FunctionData<NCT>> function_datas;

std::map<std::string, L1FunctionInterface<NCT>> l1_functions;

std::map<std::string, Contract<NCT>> imported_contracts;

explicit Contract<NCT>(std::string const& contract_name) : contract_name(contract_name)
Expand All @@ -58,10 +55,6 @@ template <typename NCT> class Contract {

FunctionData<NCT> get_function_data_by_name(std::string const& name);

void import_l1_function(L1FunctionInterfaceStruct<NCT> const& l1_function_struct);

L1FunctionInterface<NCT>& get_l1_function(std::string const& name);

// TODO: maybe also declare a type at this stage, so the correct type can be checked-for when the StateVar type is
// created within the function.
/**
Expand Down
15 changes: 0 additions & 15 deletions circuits/cpp/src/aztec3/circuits/apps/contract.tpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once
#include "function_execution_context.hpp"
#include "function_declaration.hpp"
#include "l1_function_interface.hpp"

#include <barretenberg/common/container.hpp>

Expand Down Expand Up @@ -63,18 +62,4 @@ template <typename NCT> FunctionData<NCT> Contract<NCT>::get_function_data_by_na
return function_datas[name];
}

template <typename NCT> void Contract<NCT>::import_l1_function(L1FunctionInterfaceStruct<NCT> const& l1_function_struct)
{
L1FunctionInterface<NCT> const l1_function = L1FunctionInterface<NCT>(this, l1_function_struct);
l1_functions.insert(std::make_pair(l1_function_struct.function_name, l1_function));
};

template <typename NCT> L1FunctionInterface<NCT>& Contract<NCT>::get_l1_function(std::string const& name)
{
if (!l1_functions.contains(name)) {
throw_or_abort("L1 function not found. Make sure to import_l1_function()");
}
return l1_functions[name];
}

} // namespace aztec3::circuits::apps
Loading