Skip to content

Commit

Permalink
fix: post-merge aztec3-temporary (#432)
Browse files Browse the repository at this point in the history
* fix: post-merge aztec3-temporary

* tests and fixes

* tests and fixes

* Fix generator amounts

* Fix generator counts in native

* Update

* Point to aztec3-temporary

---------

Co-authored-by: dbanks12 <david@aztecprotocol.com>
  • Loading branch information
ludamad and dbanks12 authored May 4, 2023
1 parent fd2604f commit 1081179
Show file tree
Hide file tree
Showing 31 changed files with 238 additions and 32 deletions.
6 changes: 6 additions & 0 deletions circuits/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "wasm32")
set(BENCHMARKS OFF)
set(DISABLE_TBB 1)
add_compile_definitions(_WASI_EMULATED_PROCESS_CLOCKS=1)
# TODO resolve how we can all get on the same generator counts
# Wasm (currently) takes less generators
set(CMAKE_BBERG_CXX_FLAGS "-DBARRETENBERG_CRYPTO_GENERATOR_PARAMETERS_HACK=64,32,16,64")
else()
# Native can take more generators
set(CMAKE_BBERG_CXX_FLAGS "-DBARRETENBERG_CRYPTO_GENERATOR_PARAMETERS_HACK=2048,32,128,2048")
endif()

set(CMAKE_C_STANDARD 11)
Expand Down
2 changes: 1 addition & 1 deletion circuits/cpp/barretenberg
Submodule barretenberg updated 129 files
21 changes: 18 additions & 3 deletions circuits/cpp/cmake/barretenberg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,31 @@ endif()
# "Enabling this option forces the build step to always be run. This can be the easiest way to robustly
# ensure that the external project's own build dependencies are evaluated rather than relying on the
# default success timestamp-based method." - https://cmake.org/cmake/help/latest/module/ExternalProject.html

ExternalProject_Add(Barretenberg
SOURCE_DIR ${BBERG_DIR}
BUILD_IN_SOURCE TRUE
BUILD_ALWAYS TRUE
UPDATE_COMMAND ""
INSTALL_COMMAND ""
CONFIGURE_COMMAND ${CMAKE_COMMAND} --preset ${CMAKE_BBERG_PRESET} -DSERIALIZE_CANARY=${SERIALIZE_CANARY} -DENABLE_ASAN=${ENABLE_ASAN} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
BUILD_COMMAND ${CMAKE_COMMAND} --build --preset ${CMAKE_BBERG_PRESET} ${BBERG_TARGETS}
CONFIGURE_COMMAND
${CMAKE_COMMAND}
--preset ${CMAKE_BBERG_PRESET}
-DCMAKE_CXX_FLAGS=${CMAKE_BBERG_CXX_FLAGS}
-DSERIALIZE_CANARY=${SERIALIZE_CANARY}
-DMULTITHREADING=${MULTITHREADING}
-DENABLE_ASAN=${ENABLE_ASAN}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
BUILD_COMMAND
${CMAKE_COMMAND}
--build
--preset ${CMAKE_BBERG_PRESET}
${BBERG_TARGETS}
# byproducts needed by ninja generator (not needed by make)
BUILD_BYPRODUCTS ${BBERG_BUILD_DIR}/lib/libbarretenberg.a ${BBERG_BUILD_DIR}/lib/libenv.a)
BUILD_BYPRODUCTS
${BBERG_BUILD_DIR}/lib/libbarretenberg.a
${BBERG_BUILD_DIR}/lib/libenv.a
)

include_directories(${BBERG_DIR}/src)

Expand Down
18 changes: 18 additions & 0 deletions circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
#include "rollup/root/root_rollup_inputs.hpp"
#include "rollup/root/root_rollup_public_inputs.hpp"

#include "aztec3/circuits/abis/combined_accumulated_data.hpp"
#include "aztec3/circuits/abis/function_data.hpp"
#include "aztec3/circuits/abis/function_leaf_preimage.hpp"
#include "aztec3/circuits/abis/new_contract_data.hpp"
#include "aztec3/circuits/abis/signed_tx_request.hpp"
#include <aztec3/circuits/hash.hpp>
#include <aztec3/constants.hpp>
#include <aztec3/utils/array.hpp>
#include <aztec3/utils/types/native_types.hpp>

#include "barretenberg/crypto/ecdsa/ecdsa.hpp"
#include "barretenberg/srs/reference_string/mem_reference_string.hpp"
#include <barretenberg/crypto/keccak/keccak.hpp>
#include <barretenberg/stdlib/merkle_tree/membership.hpp>
Expand Down Expand Up @@ -414,6 +417,21 @@ WASM_EXPORT const char* abis__test_roundtrip_reserialize_root_rollup_public_inpu
return as_serialized_output<aztec3::circuits::abis::RootRollupPublicInputs<NT>>(rollup_inputs_buf, size);
}

WASM_EXPORT const char* abis__test_roundtrip_serialize_combined_accumulated_data(uint8_t const* input, uint32_t* size)
{
return as_string_output<aztec3::circuits::abis::CombinedAccumulatedData<NT>>(input, size);
}

WASM_EXPORT const char* abis__test_roundtrip_serialize_signature(uint8_t const* input, uint32_t* size)
{
return as_string_output<NT::ecdsa_signature>(input, size);
}

WASM_EXPORT const char* abis__test_roundtrip_serialize_signed_tx_request(uint8_t const* input, uint32_t* size)
{
return as_string_output<aztec3::circuits::abis::SignedTxRequest<NT>>(input, size);
}

WASM_EXPORT const char* abis__test_roundtrip_serialize_private_kernel_inputs(uint8_t const* input, uint32_t* size)
{
return as_string_output<aztec3::circuits::abis::private_kernel::PrivateInputs<NT>>(input, size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ KernelCircuitPublicInputs<NT> native_public_kernel_circuit_public_previous_kerne
// validate the kernel execution common to all invocation circumstances
common_validate_kernel_execution(composer, public_kernel_inputs);

// vallidate our public call hash
// validate our public call hash
validate_this_public_call_hash(composer, public_kernel_inputs, public_inputs);

// update the public end state of the circuit
Expand Down
3 changes: 3 additions & 0 deletions circuits/cpp/src/aztec3/utils/dummy_composer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class DummyComposer {
void do_assert(bool const& assertion, std::string const& msg, CircuitErrorCode error_code)
{
if (!assertion) {
#ifdef __wasm__
info("Error(", error_code, "): ", msg);
#endif
failure_msgs.push_back(CircuitError{ error_code, msg });
}
}
Expand Down
4 changes: 2 additions & 2 deletions circuits/cpp/src/aztec3/utils/types/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ template <typename Composer> typename NT::ecdsa_signature to_nt(typename CT<Comp
std::copy(r_bytes.begin(), r_bytes.end(), r_array.begin());
std::copy(s_bytes.begin(), s_bytes.end(), s_array.begin());

return NT::ecdsa_signature{ r_array, s_array };
return NT::ecdsa_signature{ r_array, s_array, e.v };
};

template <typename Composer>
Expand Down Expand Up @@ -252,4 +252,4 @@ template <typename Composer, std::size_t SIZE> std::array<std::optional<typename
return map(arr, ref_to_nt);
};

} // namespace aztec3::utils::types
} // namespace aztec3::utils::types
2 changes: 1 addition & 1 deletion yarn-project/acir-simulator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T prettier -w ./src",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
"test": "DEBUG=wasm NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
},
"inherits": [
"../package.common.json"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/archiver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T prettier -w ./src",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests",
"test": "DEBUG=wasm NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests",
"start": "node ./dest",
"start:dev": "tsc-watch -p tsconfig.json --onSuccess 'yarn start'",
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T prettier -w ./src",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
"test": "DEBUG=wasm NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
},
"inherits": [
"../package.common.json"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T prettier -w ./src",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
"test": "DEBUG=wasm NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
},
"inherits": [
"../package.common.json"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-rpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T prettier -w ./src",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
"test": "DEBUG=wasm NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
},
"inherits": [
"../package.common.json"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T prettier -w ./src",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
"test": "DEBUG=wasm NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
},
"inherits": [
"../package.common.json"
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/barretenberg.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T prettier -w ./src",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests",
"test": "DEBUG=wasm NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests",
"test-debug": "NODE_NO_WARNINGS=1 node --inspect-brk --experimental-vm-modules $(yarn bin jest) --no-cache --passWithNoTests --runInBand"
},
"inherits": [
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T prettier -w ./src",
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
"test": "DEBUG=wasm NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests"
},
"inherits": [
"../package.common.json"
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/circuits.js/src/kernel/public_kernel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { makePublicKernelInputsNoKernelInput, makePublicKernelInputsWithEmptyOut
describe('kernel/public_kernel', () => {
it('simulates public kernel circuit with previous public kernel', async function () {
const input = makePublicKernelInputsWithEmptyOutput();
// Fix validity
input.publicCallData.callStackItem.functionData.isConstructor = false;
input.publicCallData.callStackItem.functionData.isPrivate = false;
input.previousKernel.publicInputs.isPrivateKernel = false;
const result = await simulatePublicKernelCircuit(input);
expect(result).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,147 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`structs/kernel serializes and prints CombinedAccumulatedData 1`] = `
"aggregation_object:
P0: { 0x1, 0x2 }
P1: { 0x101, 0x102 }
public_inputs: [
0x3
0x4
0x5
0x6
]
proof_witness_indices: [ 7 8 9 10 11 12 ]
has_data: 0
private_call_count: 0xd
public_call_count: 0xe
new_commitments:
[ 0x101 0x102 0x103 0x104 ]
new_nullifiers:
[ 0x201 0x202 0x203 0x204 ]
private_call_stack:
[ 0x301 0x302 0x303 0x304 0x305 0x306 0x307 0x308 ]
public_call_stack:
[ 0x401 0x402 0x403 0x404 0x405 0x406 0x407 0x408 ]
new_l2_to_l1_msgs:
[ 0x501 0x502 0x503 0x504 ]
new_contracts:
[ contract_address: 0x601
portal_contract_address: 0x202020202020202020202020202020202020202
function_tree_root: 0x603
]
optionally_revealed_data:
[ call_stack_item_hash: 0x701
function_data:
function_selector: 702
is_private: 1
is_constructor: 1
emitted_events:
[ 0x801 0x802 0x803 0x804 ]
vk_hash: 0x703
portal_contract_address: 0x404040404040404040404040404040404040404
pay_fee_from_l1: 1
pay_fee_from_public_l2: 0
called_from_l1: 1
called_from_public_l2: 0
call_stack_item_hash: 0x702
function_data:
function_selector: 703
is_private: 1
is_constructor: 1
emitted_events:
[ 0x802 0x803 0x804 0x805 ]
vk_hash: 0x704
portal_contract_address: 0x505050505050505050505050505050505050505
pay_fee_from_l1: 1
pay_fee_from_public_l2: 0
called_from_l1: 1
called_from_public_l2: 0
call_stack_item_hash: 0x703
function_data:
function_selector: 704
is_private: 1
is_constructor: 1
emitted_events:
[ 0x803 0x804 0x805 0x806 ]
vk_hash: 0x705
portal_contract_address: 0x606060606060606060606060606060606060606
pay_fee_from_l1: 1
pay_fee_from_public_l2: 0
called_from_l1: 1
called_from_public_l2: 0
call_stack_item_hash: 0x704
function_data:
function_selector: 705
is_private: 1
is_constructor: 1
emitted_events:
[ 0x804 0x805 0x806 0x807 ]
vk_hash: 0x706
portal_contract_address: 0x707070707070707070707070707070707070707
pay_fee_from_l1: 1
pay_fee_from_public_l2: 0
called_from_l1: 1
called_from_public_l2: 0
]
state_transitions:
[ leaf_index: 0x801
old_value: 0x802
new_value: 0x803
leaf_index: 0x802
old_value: 0x803
new_value: 0x804
leaf_index: 0x803
old_value: 0x804
new_value: 0x805
leaf_index: 0x804
old_value: 0x805
new_value: 0x806
]
state_reads:
[ leaf_index: 0x901
value: 0x902
leaf_index: 0x902
value: 0x903
leaf_index: 0x903
value: 0x904
leaf_index: 0x904
value: 0x905
]
"
`;

exports[`structs/kernel serializes and prints EcdsaSignature 1`] = `"{ 0101010101010101010101010101010101010101010101010101010101010101, 0202020202020202020202020202020202020202020202020202020202020202, 3 }"`;

exports[`structs/kernel serializes and prints SignedTxRequest 1`] = `
"tx_request:
from: 0x1
to: 0x11
function_data: function_selector: 257
is_private: 1
is_constructor: 1
args: [ 0x201 0x202 0x203 0x204 0x205 0x206 0x207 0x208 ]
nonce: 0x301
tx_context: is_fee_payment_tx: 0
is_rebate_payment_tx: 0
is_contract_deployment_tx: 1
contract_deployment_data:
constructor_vk_hash: 0x401
function_tree_root: 0x402
contract_address_salt: 0x403
portal_contract_address: 0x404040404040404040404040404040404040404
chain_id: 0x501
signature: { 0101010101010101010101010101010101010101010101010101010101010101, 0202020202020202020202020202020202020202020202020202020202020202, 3 }
"
`;

exports[`structs/kernel serializes and prints previous_kernel_data 1`] = `
"public_inputs: end:
aggregation_object:
Expand Down Expand Up @@ -171,7 +313,7 @@ portal_contract_address: 0x404040404040404040404040404040404040404
chain_id: 0x501
signature: { 0101010101010101010101010101010101010101010101010101010101010101, 0202020202020202020202020202020202020202020202020202020202020202 }
signature: { 0101010101010101010101010101010101010101010101010101010101010101, 0202020202020202020202020202020202020202020202020202020202020202, 3 }
previous_kernel:
public_inputs: end:
Expand Down Expand Up @@ -1044,7 +1186,7 @@ portal_contract_address: 0x404040404040404040404040404040404040404
chain_id: 0x501
signature: { 0101010101010101010101010101010101010101010101010101010101010101, 0202020202020202020202020202020202020202020202020202020202020202 }
signature: { 0101010101010101010101010101010101010101010101010101010101010101, 0202020202020202020202020202020202020202020202020202020202020202, 3 }
public_call:
call_stack_item:
Expand Down
Loading

0 comments on commit 1081179

Please sign in to comment.