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

Update circuits structs for public functions #304

Merged
merged 26 commits into from
Apr 20, 2023
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b31a2fb
WIP
PhilWindle Apr 19, 2023
6398255
Add public data to base rollup inputs
spalladino Apr 19, 2023
f41c404
Add public data tree snapshots to base and merge rollup public inputs
spalladino Apr 19, 2023
a25b19a
Fixed build
PhilWindle Apr 19, 2023
ae2e2fc
Merge branch 'pw/public-kernel' of github.com:AztecProtocol/aztec3-pa…
PhilWindle Apr 19, 2023
53b2fa6
Build fixed
PhilWindle Apr 19, 2023
0047940
Merge branch 'master' into pw/public-kernel
PhilWindle Apr 19, 2023
14dbb80
New kernel circuit input types
PhilWindle Apr 19, 2023
535e6c2
Update base rollup inputs and public inputs in ts
spalladino Apr 19, 2023
f28a629
Rename PrivateKernelPublicInputs to include both kernel circuits
spalladino Apr 19, 2023
9b5d9b8
Fix factory method
spalladino Apr 19, 2023
14ba682
Add missing callContext to public circuit public inputs serialization
spalladino Apr 19, 2023
e470001
Update ts structs to match changes in cpp
spalladino Apr 19, 2023
031fe84
Move makeEmpty helper functions to static methods
spalladino Apr 19, 2023
819e475
Update test snapshot
spalladino Apr 19, 2023
8951507
Update kernel serialization test
spalladino Apr 19, 2023
93755dd
Rename some factory and empty methods
spalladino Apr 19, 2023
f07ca69
Fix base rollup inputs created from circuit block builder
spalladino Apr 19, 2023
44b0e12
Fix the most annoying bug ever
spalladino Apr 19, 2023
df143f6
Vertical whitespace
spalladino Apr 19, 2023
7021deb
Update snapshots
spalladino Apr 19, 2023
4c7f676
Update hash constructor snapshot
spalladino Apr 19, 2023
86ef125
Restructure circuits.js structs
spalladino Apr 19, 2023
6f48308
Merge remote-tracking branch 'origin/master' into pw/public-kernel
spalladino Apr 20, 2023
f981818
Rename old to historic in new structs
spalladino Apr 20, 2023
b7d3300
Merge remote-tracking branch 'origin/master' into pw/public-kernel
spalladino Apr 20, 2023
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
Next Next commit
WIP
PhilWindle committed Apr 19, 2023
commit b31a2fb3ebee3a2dfb48ff9c2a626cd2701379ea
2 changes: 1 addition & 1 deletion circuits/cpp/src/aztec3/circuits/abis/.test.cpp
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
#include "index.hpp"
#include <barretenberg/stdlib/types/types.hpp>

#include "private_kernel/previous_kernel_data.hpp"
#include "previous_kernel_data.hpp"
#include "private_kernel/private_inputs.hpp"

namespace aztec3::circuits::abis {
19 changes: 9 additions & 10 deletions circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
#include "barretenberg/srs/reference_string/mem_reference_string.hpp"
#include "aztec3/circuits/abis/function_data.hpp"
#include "aztec3/circuits/abis/function_leaf_preimage.hpp"
#include "aztec3/circuits/abis/private_kernel/new_contract_data.hpp"
#include "aztec3/circuits/abis/new_contract_data.hpp"
#include "private_circuit_public_inputs.hpp"
#include "tx_request.hpp"
#include "tx_context.hpp"
@@ -12,9 +12,9 @@
#include "rollup/base/base_or_merge_rollup_public_inputs.hpp"
#include "rollup/root/root_rollup_public_inputs.hpp"
#include "rollup/root/root_rollup_inputs.hpp"
#include "private_kernel/previous_kernel_data.hpp"
#include "previous_kernel_data.hpp"
#include "private_kernel/private_inputs.hpp"
#include "private_kernel/public_inputs.hpp"
#include "kernel_circuit_public_inputs.hpp"

#include <aztec3/circuits/hash.hpp>
#include <aztec3/constants.hpp>
@@ -31,9 +31,9 @@ using aztec3::circuits::compute_constructor_hash;
using aztec3::circuits::compute_contract_address;
using aztec3::circuits::abis::FunctionData;
using aztec3::circuits::abis::FunctionLeafPreimage;
using aztec3::circuits::abis::NewContractData;
using aztec3::circuits::abis::TxContext;
using aztec3::circuits::abis::TxRequest;
using aztec3::circuits::abis::private_kernel::NewContractData;
using NT = aztec3::utils::types::NativeTypes;

// Cbind helper functions
@@ -403,7 +403,7 @@ WASM_EXPORT const char* abis__test_roundtrip_serialize_base_rollup_inputs(uint8_
WASM_EXPORT const char* abis__test_roundtrip_serialize_previous_kernel_data(uint8_t const* kernel_data_buf,
uint32_t* size)
{
return as_string_output<aztec3::circuits::abis::private_kernel::PreviousKernelData<NT>>(kernel_data_buf, size);
return as_string_output<aztec3::circuits::abis::PreviousKernelData<NT>>(kernel_data_buf, size);
}

WASM_EXPORT const char* abis__test_roundtrip_serialize_base_or_merge_rollup_public_inputs(
@@ -441,17 +441,16 @@ WASM_EXPORT const char* abis__test_roundtrip_serialize_private_kernel_inputs(uin
return as_string_output<aztec3::circuits::abis::private_kernel::PrivateInputs<NT>>(input, size);
}

WASM_EXPORT const char* abis__test_roundtrip_serialize_private_kernel_public_inputs(uint8_t const* input,
WASM_EXPORT const char* abis__test_roundtrip_serialize_kernel_circuit_public_inputs(uint8_t const* input,
uint32_t* size)
{
return as_string_output<aztec3::circuits::abis::private_kernel::PublicInputs<NT>>(input, size);
return as_string_output<aztec3::circuits::abis::KernelCircuitPublicInputs<NT>>(input, size);
}


WASM_EXPORT const char* abis__test_roundtrip_serialize_function_leaf_preimage(uint8_t const* function_leaf_preimage_buf, uint32_t* size)
WASM_EXPORT const char* abis__test_roundtrip_serialize_function_leaf_preimage(uint8_t const* function_leaf_preimage_buf,
uint32_t* size)
{
return as_string_output<aztec3::circuits::abis::FunctionLeafPreimage<NT>>(function_leaf_preimage_buf, size);
}


} // extern "C"
4 changes: 2 additions & 2 deletions circuits/cpp/src/aztec3/circuits/abis/c_bind.test.cpp
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

#include "tx_request.hpp"
#include "function_leaf_preimage.hpp"
#include "aztec3/circuits/abis/private_kernel/new_contract_data.hpp"
#include "aztec3/circuits/abis/new_contract_data.hpp"

#include <barretenberg/stdlib/merkle_tree/membership.hpp>
#include <barretenberg/numeric/random/engine.hpp>
@@ -13,7 +13,7 @@
namespace {

using NT = aztec3::utils::types::NativeTypes;
using aztec3::circuits::abis::private_kernel::NewContractData;
using aztec3::circuits::abis::NewContractData;

auto& engine = numeric::random::get_debug_engine();

30 changes: 11 additions & 19 deletions circuits/cpp/src/aztec3/circuits/abis/call_stack_item.hpp
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
#include "function_data.hpp"
#include "private_circuit_public_inputs.hpp"
#include "public_circuit_public_inputs.hpp"
#include "kernel_circuit_public_inputs.hpp"

#include <barretenberg/stdlib/primitives/witness/witness.hpp>
#include <aztec3/utils/types/circuit_types.hpp>
@@ -15,28 +16,19 @@ using aztec3::utils::types::NativeTypes;
using std::conditional;
using std::is_same;

enum class CallType {
Public,
Private,
};

template <typename NCT, CallType call_type> struct CallStackItem {
template <typename NCT, typename PrivatePublic> struct CallStackItem {
typedef typename NCT::address address;
typedef typename NCT::boolean boolean;
typedef typename NCT::fr fr;

template <typename T>
using PublicInputs = typename std::
conditional<call_type == CallType::Public, PublicCircuitPublicInputs<T>, PrivateCircuitPublicInputs<T>>::type;

// This is the _actual_ contract address relating to where this function's code resides in the
// contract tree. Regardless of whether this is a call or delegatecall, this
// `contract_address` _does not change_. Amongst other things, it's used as a lookup for
// getting the correct code from the tree. There is a separate `storage_contract_address`
// within a CallStackItem which varies depending on whether this is a call or delegatecall.
address contract_address = 0;
FunctionData<NCT> function_data{};
PublicInputs<NCT> public_inputs{};
typename PrivatePublic::AppCircuitPublicInputs public_inputs{};

boolean operator==(CallContext<NCT> const& other) const
{
@@ -45,14 +37,14 @@ template <typename NCT, CallType call_type> struct CallStackItem {
};

template <typename Composer>
CallStackItem<CircuitTypes<Composer>, call_type> to_circuit_type(Composer& composer) const
CallStackItem<CircuitTypes<Composer>, PrivatePublic> to_circuit_type(Composer& composer) const
{
static_assert((std::is_same<NativeTypes, NCT>::value));

// Capture the composer:
auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(composer, e); };

CallStackItem<CircuitTypes<Composer>, call_type> call_stack_item = {
CallStackItem<CircuitTypes<Composer>, PrivatePublic> call_stack_item = {
to_ct(contract_address),
function_data.to_circuit_type(composer),
public_inputs.to_circuit_type(composer),
@@ -75,8 +67,8 @@ template <typename NCT, CallType call_type> struct CallStackItem {
}
}; // namespace aztec3::circuits::abis

template <typename NCT, CallType call_type>
void read(uint8_t const*& it, CallStackItem<NCT, call_type>& call_stack_item)
template <typename NCT, typename PrivatePublic>
void read(uint8_t const*& it, CallStackItem<NCT, PrivatePublic>& call_stack_item)
{
using serialize::read;

@@ -85,8 +77,8 @@ void read(uint8_t const*& it, CallStackItem<NCT, call_type>& call_stack_item)
read(it, call_stack_item.public_inputs);
};

template <typename NCT, CallType call_type>
void write(std::vector<uint8_t>& buf, CallStackItem<NCT, call_type> const& call_stack_item)
template <typename NCT, typename PrivatePublic>
void write(std::vector<uint8_t>& buf, CallStackItem<NCT, PrivatePublic> const& call_stack_item)
{
using serialize::write;

@@ -95,8 +87,8 @@ void write(std::vector<uint8_t>& buf, CallStackItem<NCT, call_type> const& call_
write(buf, call_stack_item.public_inputs);
};

template <typename NCT, CallType call_type>
std::ostream& operator<<(std::ostream& os, CallStackItem<NCT, call_type> const& call_stack_item)
template <typename NCT, typename PrivatePublic>
std::ostream& operator<<(std::ostream& os, CallStackItem<NCT, PrivatePublic> const& call_stack_item)
{
return os << "contract_address: " << call_stack_item.contract_address << "\n"
<< "function_data: " << call_stack_item.function_data << "\n"
Loading