Skip to content

Commit

Permalink
feat: bridge l1 assets to l2 acvm (#578)
Browse files Browse the repository at this point in the history
* inbox and message box contracts

* outbox

* address PR comments

* add registry

* s/keccak/sha and optimise insert()

* chore: move reused test mnemonic into a fixtures file

* e2e mock solidity contracts checkpoint

* feat: draft noir circuit to consume l1 message

* rename l1_token -> non native

fix: rename

* feat: add pedersen generator for l1 to l2 message secret

* feat: create interfaces

* feat: scaffold test

* feat: initial sol token contract tests

* feat: add getL1ToL2Message oracle call

* feat: consume dummy cross chain message test

* temp

* fix: merge remedy

* fix: yarn prepare

* fix: merge update contracts

* feat: scaffold e2e as far as possible, include contentHash in acvm

* fix: jsdoc l1_to_l2_message

* fix: forge fmt

* fix: formatting acir sim

* refactor : remove naked modulus declarations

* fix: post merge solidity cleanup

* fix: convert msgKey to a field element as it will always be one

* chore(fmt): forge fmt baby

* fix type

* nit: check for emitted event

* fix: post merge

* fix: we please the linter

* fix: bruh

* fix: refactor contract to be initialisable, fix too issue

* refactor(nr): emit_data -> debug_log

* nits

* fix: post merge spring cleaning

* feat: keccak(message[0:4]) in messages

* fix: i stg mr format

* add .skip to unfinished e2e test

---------

Co-authored-by: Rahul Kothari <rahul.kothari.201@gmail.com>
Co-authored-by: cheethas <addaboy@gmail.com>
  • Loading branch information
3 people authored May 18, 2023
1 parent a1da7f3 commit a19c36e
Show file tree
Hide file tree
Showing 49 changed files with 1,941 additions and 73 deletions.
179 changes: 138 additions & 41 deletions build_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,67 @@
"circuits-wasm-linux-clang": {
"buildDir": "circuits/cpp",
"dockerfile": "dockerfiles/Dockerfile.wasm-linux-clang",
"rebuildPatterns": ["^circuits/"],
"rebuildPatterns": [
"^circuits/"
],
"dependencies": []
},
"circuits-wasm-linux-clang-assert": {
"buildDir": "circuits/cpp",
"dockerfile": "dockerfiles/Dockerfile.wasm-linux-clang-assert",
"rebuildPatterns": ["^circuits/"],
"rebuildPatterns": [
"^circuits/"
],
"dependencies": []
},
"circuits-x86_64-linux-clang-tidy": {
"buildDir": "circuits/cpp",
"dockerfile": "dockerfiles/Dockerfile.x86_64-linux-clang-tidy",
"rebuildPatterns": ["^circuits/"],
"rebuildPatterns": [
"^circuits/"
],
"dependencies": []
},
"circuits-x86_64-linux-clang": {
"buildDir": "circuits/cpp",
"dockerfile": "dockerfiles/Dockerfile.x86_64-linux-clang",
"rebuildPatterns": ["^circuits/"],
"rebuildPatterns": [
"^circuits/"
],
"dependencies": []
},
"circuits-x86_64-linux-clang-assert": {
"buildDir": "circuits/cpp",
"dockerfile": "dockerfiles/Dockerfile.x86_64-linux-clang-assert",
"rebuildPatterns": ["^circuits/"],
"rebuildPatterns": [
"^circuits/"
],
"dependencies": []
},
"circuits-x86_64-linux-gcc": {
"buildDir": "circuits/cpp",
"dockerfile": "dockerfiles/Dockerfile.x86_64-linux-gcc",
"rebuildPatterns": ["^circuits/"],
"rebuildPatterns": [
"^circuits/"
],
"dependencies": []
},
"l1-contracts": {
"buildDir": "l1-contracts",
"dockerfile": "Dockerfile",
"rebuildPatterns": ["^l1-contracts/"],
"rebuildPatterns": [
"^l1-contracts/"
],
"dependencies": []
},
"l1-artifacts": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/l1-artifacts",
"dockerfile": "l1-artifacts/Dockerfile",
"rebuildPatterns": ["^l1-contracts/", "^yarn-project/l1-artifacts/"],
"rebuildPatterns": [
"^l1-contracts/",
"^yarn-project/l1-artifacts/"
],
"dependencies": []
},
"yarn-project-base": {
Expand All @@ -58,13 +75,18 @@
"^yarn-project/yarn-project-base/",
"^yarn-project/yarn.lock"
],
"dependencies": ["circuits-wasm-linux-clang", "l1-contracts"]
"dependencies": [
"circuits-wasm-linux-clang",
"l1-contracts"
]
},
"acir-simulator": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/acir-simulator",
"dockerfile": "acir-simulator/Dockerfile",
"rebuildPatterns": ["^yarn-project/acir-simulator/"],
"rebuildPatterns": [
"^yarn-project/acir-simulator/"
],
"dependencies": [
"barretenberg.js",
"circuits.js",
Expand All @@ -78,21 +100,33 @@
"buildDir": "yarn-project",
"projectDir": "yarn-project/archiver",
"dockerfile": "archiver/Dockerfile",
"rebuildPatterns": ["^yarn-project/archiver/"],
"dependencies": ["foundation", "l1-artifacts", "types"]
"rebuildPatterns": [
"^yarn-project/archiver/"
],
"dependencies": [
"foundation",
"l1-artifacts",
"types"
]
},
"aztec-cli": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/aztec-cli",
"dockerfile": "aztec-cli/Dockerfile",
"rebuildPatterns": ["^yarn-project/aztec-cli/"],
"dependencies": ["foundation"]
"rebuildPatterns": [
"^yarn-project/aztec-cli/"
],
"dependencies": [
"foundation"
]
},
"aztec-rpc": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/aztec-rpc",
"dockerfile": "aztec-rpc/Dockerfile",
"rebuildPatterns": ["^yarn-project/aztec-rpc/"],
"rebuildPatterns": [
"^yarn-project/aztec-rpc/"
],
"dependencies": [
"acir-simulator",
"aztec-node",
Expand All @@ -108,28 +142,48 @@
"buildDir": "yarn-project",
"projectDir": "yarn-project/aztec.js",
"dockerfile": "aztec.js/Dockerfile",
"rebuildPatterns": ["^yarn-project/aztec.js/"],
"dependencies": ["aztec-rpc", "circuits.js", "foundation", "noir-contracts"]
"rebuildPatterns": [
"^yarn-project/aztec.js/"
],
"dependencies": [
"aztec-rpc",
"circuits.js",
"foundation",
"noir-contracts"
]
},
"barretenberg.js": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/barretenberg.js",
"dockerfile": "barretenberg.js/Dockerfile",
"rebuildPatterns": ["^yarn-project/barretenberg.js/"],
"dependencies": ["foundation", "yarn-project-base"]
"rebuildPatterns": [
"^yarn-project/barretenberg.js/"
],
"dependencies": [
"foundation",
"yarn-project-base"
]
},
"circuits.js": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/circuits.js",
"dockerfile": "circuits.js/Dockerfile",
"rebuildPatterns": ["^yarn-project/circuits.js/"],
"dependencies": ["barretenberg.js", "foundation", "yarn-project-base"]
"rebuildPatterns": [
"^yarn-project/circuits.js/"
],
"dependencies": [
"barretenberg.js",
"foundation",
"yarn-project-base"
]
},
"end-to-end": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/end-to-end",
"dockerfile": "end-to-end/Dockerfile",
"rebuildPatterns": ["^yarn-project/end-to-end/"],
"rebuildPatterns": [
"^yarn-project/end-to-end/"
],
"dependencies": [
"aztec-node",
"aztec.js",
Expand All @@ -145,56 +199,89 @@
"buildDir": "yarn-project",
"projectDir": "yarn-project/foundation",
"dockerfile": "foundation/Dockerfile",
"rebuildPatterns": ["^yarn-project/foundation/"],
"rebuildPatterns": [
"^yarn-project/foundation/"
],
"dependencies": []
},
"key-store": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/key-store",
"dockerfile": "key-store/Dockerfile",
"rebuildPatterns": ["^yarn-project/key-store/"],
"dependencies": ["barretenberg.js", "circuits.js", "foundation"]
"rebuildPatterns": [
"^yarn-project/key-store/"
],
"dependencies": [
"barretenberg.js",
"circuits.js",
"foundation"
]
},
"merkle-tree": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/merkle-tree",
"dockerfile": "merkle-tree/Dockerfile",
"rebuildPatterns": ["^yarn-project/merkle-tree/"],
"dependencies": ["barretenberg.js", "foundation"]
"rebuildPatterns": [
"^yarn-project/merkle-tree/"
],
"dependencies": [
"barretenberg.js",
"foundation"
]
},
"noir-contracts": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/noir-contracts",
"dockerfile": "noir-contracts/Dockerfile",
"rebuildPatterns": ["^yarn-project/noir-contracts/"],
"dependencies": ["foundation"]
"rebuildPatterns": [
"^yarn-project/noir-contracts/"
],
"dependencies": [
"foundation"
]
},
"noir-compiler": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/noir-compiler",
"dockerfile": "noir-compiler/Dockerfile",
"rebuildPatterns": ["^yarn-project/noir-compiler/"],
"dependencies": ["foundation"]
"rebuildPatterns": [
"^yarn-project/noir-compiler/"
],
"dependencies": [
"foundation"
]
},
"p2p": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/p2p",
"dockerfile": "p2p/Dockerfile",
"rebuildPatterns": ["^yarn-project/p2p/"],
"dependencies": ["circuits.js", "foundation", "types"]
"rebuildPatterns": [
"^yarn-project/p2p/"
],
"dependencies": [
"circuits.js",
"foundation",
"types"
]
},
"prover-client": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/prover-client",
"dockerfile": "prover-client/Dockerfile",
"rebuildPatterns": ["^yarn-project/prover-client/"],
"dependencies": ["foundation"]
"rebuildPatterns": [
"^yarn-project/prover-client/"
],
"dependencies": [
"foundation"
]
},
"aztec-node": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/aztec-node",
"dockerfile": "aztec-node/Dockerfile",
"rebuildPatterns": ["^yarn-project/aztec-node/"],
"rebuildPatterns": [
"^yarn-project/aztec-node/"
],
"dependencies": [
"archiver",
"barretenberg.js",
Expand All @@ -211,7 +298,9 @@
"buildDir": "yarn-project",
"projectDir": "yarn-project/sequencer-client",
"dockerfile": "sequencer-client/Dockerfile",
"rebuildPatterns": ["^yarn-project/sequencer-client/"],
"rebuildPatterns": [
"^yarn-project/sequencer-client/"
],
"dependencies": [
"acir-simulator",
"circuits.js",
Expand All @@ -227,14 +316,22 @@
"buildDir": "yarn-project",
"projectDir": "yarn-project/types",
"dockerfile": "types/Dockerfile",
"rebuildPatterns": ["^yarn-project/types/"],
"dependencies": ["circuits.js", "foundation", "l1-artifacts"]
"rebuildPatterns": [
"^yarn-project/types/"
],
"dependencies": [
"circuits.js",
"foundation",
"l1-artifacts"
]
},
"world-state": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/world-state",
"dockerfile": "world-state/Dockerfile",
"rebuildPatterns": ["^yarn-project/world-state/"],
"rebuildPatterns": [
"^yarn-project/world-state/"
],
"dependencies": [
"barretenberg.js",
"circuits.js",
Expand All @@ -243,4 +340,4 @@
"types"
]
}
}
}
17 changes: 17 additions & 0 deletions circuits/cpp/src/aztec3/circuits/abis/c_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "barretenberg/crypto/ecdsa/ecdsa.hpp"
#include "barretenberg/srs/reference_string/mem_reference_string.hpp"
#include "barretenberg/stdlib/commitment/pedersen/pedersen_plookup.hpp"
#include <barretenberg/crypto/keccak/keccak.hpp>
#include <barretenberg/stdlib/merkle_tree/membership.hpp>

Expand Down Expand Up @@ -376,6 +377,22 @@ WASM_EXPORT void abis__compute_call_stack_item_hash(uint8_t const* call_stack_it
NT::fr::serialize_to_buffer(get_call_stack_item_hash(call_stack_item), output);
}

/**
* @brief Computes the hash of a message secret for use in l1 -> l2 messaging
*
* @param secret
* @param output
*/
WASM_EXPORT void abis__compute_message_secret_hash(uint8_t const* secret, uint8_t* output)
{
NT::fr message_secret;
read(secret, message_secret);
// TODO(sean): This is not using the generator correctly and is unsafe, update
auto secret_hash = crypto::pedersen_commitment::compress_native(
{ aztec3::GeneratorIndex::L1_TO_L2_MESSAGE_SECRET, message_secret });
NT::fr::serialize_to_buffer(secret_hash, output);
}

/* Typescript test helpers that call as_string_output() to stress serialization.
* Each of these take an object buffer, and a string size pointer.
* They return a string pointer (to be bbfree'd) and write to the string size pointer. */
Expand Down
1 change: 1 addition & 0 deletions circuits/cpp/src/aztec3/circuits/abis/c_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ WASM_EXPORT void abis__compute_contract_address(uint8_t const* deployer_address_
uint8_t const* constructor_hash_buf,
uint8_t* output);

WASM_EXPORT void abis__compute_message_secret_hash(uint8_t const* secret, uint8_t* output);
WASM_EXPORT void abis__compute_contract_leaf(uint8_t const* contract_leaf_preimage_buf, uint8_t* output);

WASM_EXPORT void abis__compute_transaction_hash(uint8_t const* signed_tx_request_buf, uint8_t* output);
Expand Down
1 change: 1 addition & 0 deletions circuits/cpp/src/aztec3/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ enum GeneratorIndex {
PUBLIC_LEAF_INDEX,
PUBLIC_DATA_LEAF,
SIGNED_TX_REQUEST,
L1_TO_L2_MESSAGE_SECRET
};

enum StorageSlotGeneratorIndex {
Expand Down
1 change: 1 addition & 0 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ contract Rollup is Decoder {

MockVerifier public immutable VERIFIER;
IRegistry public immutable REGISTRY;

bytes32 public rollupStateHash;

constructor(IRegistry _registry) {
Expand Down
Loading

0 comments on commit a19c36e

Please sign in to comment.