Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanks12 committed Apr 29, 2023
1 parent b5614ec commit 369494f
Show file tree
Hide file tree
Showing 44 changed files with 170 additions and 178 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#pragma once
#include "aztec3/circuits/abis/append_only_tree_snapshot.hpp"
#include <aztec3/circuits/abis/rollup/merge/previous_rollup_data.hpp>
#include <aztec3/utils/types/native_types.hpp>
#include <aztec3/utils/types/circuit_types.hpp>
#include <aztec3/utils/types/convert.hpp>
#include <aztec3/utils/types/native_types.hpp>

#include <type_traits>

namespace aztec3::circuits::abis {
Expand Down Expand Up @@ -37,4 +38,4 @@ template <typename NCT> std::ostream& operator<<(std::ostream& os, MergeRollupIn
return os << "previous_rollup_data: " << obj.previous_rollup_data << "\n";
};

} // namespace aztec3::circuits::abis
} // namespace aztec3::circuits::abis
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
#include "aztec3/circuits/abis/membership_witness.hpp"
#include "aztec3/circuits/abis/rollup/base/base_or_merge_rollup_public_inputs.hpp"
#include "aztec3/constants.hpp"
#include <aztec3/utils/types/native_types.hpp>
#include <aztec3/utils/types/circuit_types.hpp>
#include <aztec3/utils/types/convert.hpp>
#include <aztec3/utils/types/native_types.hpp>

#include <type_traits>

namespace aztec3::circuits::abis {
Expand Down Expand Up @@ -56,4 +57,4 @@ template <typename NCT> std::ostream& operator<<(std::ostream& os, PreviousRollu
<< "vk_sibling_path: " << obj.vk_sibling_path << "\n";
};

} // namespace aztec3::circuits::abis
} // namespace aztec3::circuits::abis
17 changes: 8 additions & 9 deletions circuits/cpp/src/aztec3/circuits/apps/l1_call.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

#include "l1_function_interface.hpp"

#include <barretenberg/stdlib/primitives/witness/witness.hpp>
#include <aztec3/utils/types/native_types.hpp>
#include <aztec3/utils/types/circuit_types.hpp>
#include <aztec3/utils/types/convert.hpp>
#include <aztec3/utils/types/native_types.hpp>

#include <barretenberg/stdlib/primitives/witness/witness.hpp>

namespace aztec3::circuits::apps {

Expand All @@ -20,19 +21,17 @@ template <typename Composer> class L1Call {
L1FunctionInterface& l1_function;
std::vector<fr> args;
fr hash_of_argument_encodings = 0;
fr partial_l1_call_stack_item = 0; // keccak(function_selector, hash_of_argument_encodings)
fr partial_l1_call_stack_item = 0; // keccak(function_selector, hash_of_argument_encodings)

L1Call(L1FunctionInterface const& l1_function, std::vector<fr> const& args)
: l1_function(l1_function)
, args(args)
L1Call(L1FunctionInterface const& l1_function, std::vector<fr> const& args) : l1_function(l1_function), args(args)
{
/// TODO: in reality, we'll need to use keccak hash here, as this will need to be replecated on-chain.
if (args.size() == 0) {
hash_of_argument_encodings = 0;
} else {
hash_of_argument_encodings = args[0]; // lazy stub for a hash!
hash_of_argument_encodings = args[0]; // lazy stub for a hash!
}
partial_l1_call_stack_item = function_selector; // lazy stub for a hash!
partial_l1_call_stack_item = function_selector; // lazy stub for a hash!
}

bool operator==(L1Call<NCT> const&) const = default;
Expand Down Expand Up @@ -81,4 +80,4 @@ template <typename NCT> std::ostream& operator<<(std::ostream& os, L1Call<NCT> c
<< "partial_l1_call_stack_item: " << l1_call.partial_l1_call_stack_item << "\n";
}

} // namespace aztec3::circuits::apps
} // namespace aztec3::circuits::apps
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ using aztec3::circuits::abis::OptionalPrivateCircuitPublicInputs;
OptionalPrivateCircuitPublicInputs<NT> constructor(FunctionExecutionContext& exec_ctx,
std::array<NT::fr, ARGS_LENGTH> const& args);

} // namespace aztec3::circuits::apps::test_apps::basic_contract_deployment
} // namespace aztec3::circuits::apps::test_apps::basic_contract_deployment
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#pragma once

#include "init.hpp"

#include "contract.hpp"
#include "init.hpp"

#include <aztec3/circuits/apps/contract.hpp>
#include <aztec3/circuits/apps/function_declaration.hpp>
Expand All @@ -21,4 +20,4 @@ inline Contract init_contract()
return contract;
}

} // namespace aztec3::circuits::apps::test_apps::basic_contract_deployment
} // namespace aztec3::circuits::apps::test_apps::basic_contract_deployment
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ inline Contract init_contract()
return contract;
}

} // namespace aztec3::circuits::apps::test_apps::escrow
} // namespace aztec3::circuits::apps::test_apps::escrow
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ OptionalPrivateCircuitPublicInputs<NT> deposit(FunctionExecutionContext& exec_ct
// TODO: or, we'll be collecting this data in the exec_ctx.
};

} // namespace aztec3::circuits::apps::test_apps::escrow
} // namespace aztec3::circuits::apps::test_apps::escrow
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ using aztec3::circuits::abis::OptionalPrivateCircuitPublicInputs;
OptionalPrivateCircuitPublicInputs<NT> deposit(FunctionExecutionContext& exec_ctx,
std::array<NT::fr, ARGS_LENGTH> const& args);

} // namespace aztec3::circuits::apps::test_apps::escrow
} // namespace aztec3::circuits::apps::test_apps::escrow
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "init.hpp"
#include "contract.hpp"
#include "deposit.hpp"
#include "init.hpp"
#include "transfer.hpp"
#include "withdraw.hpp"
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ OptionalPrivateCircuitPublicInputs<NT> transfer(FunctionExecutionContext& exec_c
NT::boolean const& _reveal_msg_sender_to_recipient,
NT::fr const& _fee);

} // namespace aztec3::circuits::apps::test_apps::escrow
} // namespace aztec3::circuits::apps::test_apps::escrow
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ OptionalPrivateCircuitPublicInputs<NT> withdraw(FunctionExecutionContext& exec_c
NT::fr const& _l1_withdrawal_address,
NT::fr const& _fee);

} // namespace aztec3::circuits::apps::test_apps::escrow
} // namespace aztec3::circuits::apps::test_apps::escrow
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

// #include <aztec3/circuits/apps/function_execution_context.hpp>

#include <gtest/gtest.h>
#include <barretenberg/common/test.hpp>

#include <gtest/gtest.h>

namespace aztec3::circuits::apps::test_apps::private_to_private_function_call {

class private_to_private_function_call_tests : public ::testing::Test {};

TEST(private_to_private_function_call_tests, circuit_private_to_private_function_call)
{

C fn1_composer = C("../barretenberg/cpp/srs_db/ignition");
DB db;

Expand All @@ -24,7 +24,7 @@ TEST(private_to_private_function_call_tests, circuit_private_to_private_function
uint256_t(0x01071e9a23e0f7edULL, 0x5d77b35d1830fa3eULL, 0xc6ba3660bb1f0c0bULL, 0x2ef9f7f09867fd6eULL);

const FunctionData<NT> function_data{
.function_selector = 1, // TODO: deduce this from the contract, somehow.
.function_selector = 1, // TODO: deduce this from the contract, somehow.
.is_private = true,
.is_constructor = false,
};
Expand Down Expand Up @@ -62,4 +62,4 @@ TEST(private_to_private_function_call_tests, circuit_private_to_private_function
info("n: ", fn1_composer.num_gates);
}

} // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call
} // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ inline Contract init_contract_2()
return contract_2;
}

} // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call
} // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "function_1_1.hpp"
#include "function_2_1.hpp"

#include "contract.hpp"
#include "function_2_1.hpp"

#include <aztec3/circuits/apps/function_execution_context.hpp>

Expand Down Expand Up @@ -85,4 +85,4 @@ void function_1_1(FunctionExecutionContext& exec_ctx, std::array<NT::fr, ARGS_LE
exec_ctx.finalise();
};

} // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call
} // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ namespace aztec3::circuits::apps::test_apps::private_to_private_function_call {

void function_1_1(FunctionExecutionContext& exec_ctx, std::array<NT::fr, ARGS_LENGTH> const& _args);

} // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call
} // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ using aztec3::circuits::abis::OptionalPrivateCircuitPublicInputs;

void function_2_1(FunctionExecutionContext& exec_ctx, std::array<NT::fr, ARGS_LENGTH> const& _args);

} // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call
} // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "init.hpp"
#include "contract.hpp"
#include "function_1_1.hpp"
#include "function_2_1.hpp"
#include "function_2_1.hpp"
#include "init.hpp"
4 changes: 2 additions & 2 deletions circuits/cpp/src/aztec3/circuits/kernel/private/index.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include "init.hpp"
#include "private_kernel_circuit.hpp"
#include "native_private_kernel_circuit.hpp"
#include "native_private_kernel_circuit.hpp"
#include "private_kernel_circuit.hpp"
13 changes: 5 additions & 8 deletions circuits/cpp/src/aztec3/circuits/kernel/private/init.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#pragma once
#include <aztec3/oracle/oracle.hpp>
#include <aztec3/circuits/apps/oracle_wrapper.hpp>
#include <aztec3/circuits/abis/private_kernel/private_inputs.hpp>
#include <aztec3/circuits/apps/function_execution_context.hpp>

#include <aztec3/circuits/apps/oracle_wrapper.hpp>
#include <aztec3/circuits/recursion/aggregator.hpp>

#include <aztec3/circuits/abis/private_kernel/private_inputs.hpp>

#include <aztec3/utils/types/convert.hpp>
#include <aztec3/oracle/oracle.hpp>
#include <aztec3/utils/types/circuit_types.hpp>
#include <aztec3/utils/types/convert.hpp>
#include <aztec3/utils/types/native_types.hpp>

namespace aztec3::circuits::kernel::private_kernel {
Expand All @@ -28,4 +25,4 @@ using OracleWrapper = aztec3::circuits::apps::OracleWrapperInterface<Composer>;

using FunctionExecutionContext = aztec3::circuits::apps::FunctionExecutionContext<Composer>;

} // namespace aztec3::circuits::kernel::private_kernel
} // namespace aztec3::circuits::kernel::private_kernel
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "init.hpp"

#include <aztec3/circuits/abis/private_kernel/private_inputs.hpp>
#include <aztec3/circuits/abis/kernel_circuit_public_inputs.hpp>
#include <aztec3/circuits/abis/private_kernel/private_inputs.hpp>
#include <aztec3/utils/dummy_composer.hpp>

namespace aztec3::circuits::kernel::private_kernel {
Expand All @@ -17,4 +17,4 @@ using DummyComposer = aztec3::utils::DummyComposer;
KernelCircuitPublicInputs<NT> native_private_kernel_circuit(DummyComposer& composer,
PrivateInputs<NT> const& _private_inputs);

} // namespace aztec3::circuits::kernel::private_kernel
} // namespace aztec3::circuits::kernel::private_kernel
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "init.hpp"

#include <aztec3/circuits/abis/private_kernel/private_inputs.hpp>
#include <aztec3/circuits/abis/kernel_circuit_public_inputs.hpp>
#include <aztec3/circuits/abis/private_kernel/private_inputs.hpp>

namespace aztec3::circuits::kernel::private_kernel {

Expand All @@ -13,4 +13,4 @@ using aztec3::circuits::abis::private_kernel::PrivateInputs;
KernelCircuitPublicInputs<NT> private_kernel_circuit(Composer& composer, PrivateInputs<NT> const& _private_inputs);
KernelCircuitPublicInputs<NT> private_kernel_native(PrivateInputs<NT> const& private_inputs);

} // namespace aztec3::circuits::kernel::private_kernel
} // namespace aztec3::circuits::kernel::private_kernel
4 changes: 2 additions & 2 deletions circuits/cpp/src/aztec3/circuits/kernel/private/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace {
using NT = aztec3::utils::types::NativeTypes;
using aztec3::circuits::abis::PreviousKernelData;
} // namespace
} // namespace

namespace aztec3::circuits::kernel::private_kernel::utils {

PreviousKernelData<NT> dummy_previous_kernel(bool real_vk_proof = false);

} // namespace aztec3::circuits::kernel::private_kernel::utils
} // namespace aztec3::circuits::kernel::private_kernel::utils
5 changes: 3 additions & 2 deletions circuits/cpp/src/aztec3/circuits/kernel/public/common.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "init.hpp"
#include "common.hpp"

#include "init.hpp"

namespace aztec3::circuits::kernel::public_kernel {

void common_initialise_end_values(PublicKernelInputs<NT> const& public_kernel_inputs,
Expand Down Expand Up @@ -48,4 +49,4 @@ void validate_this_public_call_hash(DummyComposer& composer,
"calculated public_call_hash does not match provided public_call_hash at the top of the call stack",
CircuitErrorCode::PUBLIC_KERNEL__CALCULATED_PRIVATE_CALL_HASH_AND_PROVIDED_PRIVATE_CALL_HASH_MISMATCH);
};
} // namespace aztec3::circuits::kernel::public_kernel
} // namespace aztec3::circuits::kernel::public_kernel
22 changes: 10 additions & 12 deletions circuits/cpp/src/aztec3/circuits/kernel/public/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

#include "init.hpp"

#include <aztec3/circuits/abis/public_kernel/public_kernel_inputs_no_previous_kernel.hpp>
#include <aztec3/circuits/abis/public_kernel/public_kernel_inputs.hpp>
#include <aztec3/circuits/abis/kernel_circuit_public_inputs.hpp>
#include <aztec3/circuits/abis/public_data_transition.hpp>
#include <aztec3/circuits/abis/public_kernel/public_kernel_inputs.hpp>
#include <aztec3/circuits/abis/public_kernel/public_kernel_inputs_no_previous_kernel.hpp>
#include <aztec3/circuits/abis/state_read.hpp>
#include <aztec3/circuits/abis/state_transition.hpp>
#include <aztec3/circuits/abis/public_data_transition.hpp>
#include <aztec3/utils/dummy_composer.hpp>
#include <aztec3/utils/array.hpp>
#include <aztec3/circuits/hash.hpp>
#include <aztec3/utils/array.hpp>
#include <aztec3/utils/dummy_composer.hpp>

using NT = aztec3::utils::types::NativeTypes;
using aztec3::circuits::abis::KernelCircuitPublicInputs;
Expand Down Expand Up @@ -193,9 +193,8 @@ void common_validate_inputs(DummyComposer& composer, KernelInput const& public_k
* @param public_kernel_inputs The inputs to this iteration of the kernel circuit
* @param circuit_outputs The circuit outputs to be populated
*/
template <typename KernelInput>
void propagate_valid_state_transitions(KernelInput const& public_kernel_inputs,
KernelCircuitPublicInputs<NT>& circuit_outputs)
template <typename KernelInput> void propagate_valid_state_transitions(KernelInput const& public_kernel_inputs,
KernelCircuitPublicInputs<NT>& circuit_outputs)
{
const auto& contract_address = public_kernel_inputs.public_call.call_stack_item.contract_address;
const auto& transitions = public_kernel_inputs.public_call.call_stack_item.public_inputs.state_transitions;
Expand All @@ -219,9 +218,8 @@ void propagate_valid_state_transitions(KernelInput const& public_kernel_inputs,
* @param public_kernel_inputs The inputs to this iteration of the kernel circuit
* @param circuit_outputs The circuit outputs to be populated
*/
template <typename KernelInput>
void propagate_valid_state_reads(KernelInput const& public_kernel_inputs,
KernelCircuitPublicInputs<NT>& circuit_outputs)
template <typename KernelInput> void propagate_valid_state_reads(KernelInput const& public_kernel_inputs,
KernelCircuitPublicInputs<NT>& circuit_outputs)
{
const auto& contract_address = public_kernel_inputs.public_call.call_stack_item.contract_address;
const auto& reads = public_kernel_inputs.public_call.call_stack_item.public_inputs.state_reads;
Expand Down Expand Up @@ -275,4 +273,4 @@ void common_initialise_end_values(PublicKernelInputs<NT> const& public_kernel_in
void validate_this_public_call_hash(DummyComposer& composer,
PublicKernelInputs<NT> const& public_kernel_inputs,
KernelCircuitPublicInputs<NT>& public_inputs);
} // namespace aztec3::circuits::kernel::public_kernel
} // namespace aztec3::circuits::kernel::public_kernel
Loading

0 comments on commit 369494f

Please sign in to comment.