From 7b4938c1d2fc6346ba54ede04c08f022e1e36a2a Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 24 May 2024 10:37:54 +0200 Subject: [PATCH 1/2] Add recursive version of get_storage circuit --- Nargo.toml | 1 + ethereum/circuits/get_storage_recursive/Nargo.toml | 7 +++++++ ethereum/circuits/get_storage_recursive/README.md | 3 +++ ethereum/circuits/get_storage_recursive/src/main.nr | 11 +++++++++++ 4 files changed, 22 insertions(+) create mode 100644 ethereum/circuits/get_storage_recursive/Nargo.toml create mode 100644 ethereum/circuits/get_storage_recursive/README.md create mode 100644 ethereum/circuits/get_storage_recursive/src/main.nr diff --git a/Nargo.toml b/Nargo.toml index 3ed4ea25b..1d1920228 100644 --- a/Nargo.toml +++ b/Nargo.toml @@ -3,6 +3,7 @@ members = [ "ethereum/circuits/lib", "ethereum/circuits/get_receipt", "ethereum/circuits/get_storage", + "ethereum/circuits/get_storage_recursive", "ethereum/circuits/get_account", "ethereum/circuits/get_header", "ethereum/circuits/get_transaction", diff --git a/ethereum/circuits/get_storage_recursive/Nargo.toml b/ethereum/circuits/get_storage_recursive/Nargo.toml new file mode 100644 index 000000000..84d77de2a --- /dev/null +++ b/ethereum/circuits/get_storage_recursive/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "get_storage_recursive" +type = "bin" +compiler_version = ">=0.30.0" + +[dependencies] +ethereum = { path = "../lib" } diff --git a/ethereum/circuits/get_storage_recursive/README.md b/ethereum/circuits/get_storage_recursive/README.md new file mode 100644 index 000000000..ae67b4cef --- /dev/null +++ b/ethereum/circuits/get_storage_recursive/README.md @@ -0,0 +1,3 @@ +# Recursive get_storage + +Recursive version of [get_storage](../get_storage/) diff --git a/ethereum/circuits/get_storage_recursive/src/main.nr b/ethereum/circuits/get_storage_recursive/src/main.nr new file mode 100644 index 000000000..20cf916c5 --- /dev/null +++ b/ethereum/circuits/get_storage_recursive/src/main.nr @@ -0,0 +1,11 @@ +use dep::ethereum::{account_with_storage::{get_account_with_storage, StorageWithinBlock}, misc::types::{Address, Bytes32}}; + +#[recursive] +fn main( + chain_id: pub Field, + block_number: pub u64, + address: pub Address, + storage_key: pub Bytes32 +) -> pub StorageWithinBlock<1> { + get_account_with_storage(chain_id, block_number, address, storage_key) +} From 36518833ab0598a072672bb8fc1b5fc417d93f68 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 28 May 2024 09:40:36 +0200 Subject: [PATCH 2/2] Add docs on recursive binaries --- ethereum/circuits/README.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ethereum/circuits/README.md b/ethereum/circuits/README.md index 63bb36ffa..1ec25c00f 100644 --- a/ethereum/circuits/README.md +++ b/ethereum/circuits/README.md @@ -4,14 +4,19 @@ Noir circuits for proving and verifying historical data on the Ethereum blockcha ## Monorepo structure -| Package | Description | Docs | -| ------------------------------- | ------------------------------------------- | ------------------------------- | -| [`lib`](./lib/) | Main library containing oracles & verifiers | [Docs](./lib/README.md) | -| [`get_header`](./get_header/) | Binary crate for generating header proofs | [Docs](./get_header/README.md) | -| [`get_account`](./get_header/) | Binary crate for generating account proofs | [Docs](./get_account/README.md) | -| [`get_storage`](./get_storage/) | Binary crate for generating storage proofs | [Docs](./get_storage/README.md) | -| [`get_receipt`](./get_receipt/) | Binary crate for generating receipt proofs | [Docs](./get_receipt/README.md) | -| [`get_transaction`](./get_transaction/) | Binary crate for generating transaction proofs | [Docs](./get_transaction/README.md) | +| Package | Description | Docs | +| --------------------------------------------------- | ---------------------------------------------------- | ----------------------------------------- | +| [`lib`](./lib/) | Main library containing oracles & verifiers | [Docs](./lib/README.md) | +| [`get_header`](./get_header/) | Binary crate for generating header proofs | [Docs](./get_header/README.md) | +| [`get_account`](./get_header/) | Binary crate for generating account proofs | [Docs](./get_account/README.md) | +| [`get_storage`](./get_storage/) | Binary crate for generating storage proofs | [Docs](./get_storage/README.md) | +| [`get_storage_recursive`](./get_storage_recursive/) | Binary crate for generating recursive storage proofs | [Docs](./get_storage_recursive/README.md) | +| [`get_receipt`](./get_receipt/) | Binary crate for generating receipt proofs | [Docs](./get_receipt/README.md) | +| [`get_transaction`](./get_transaction/) | Binary crate for generating transaction proofs | [Docs](./get_transaction/README.md) | + +### Recursive binaries + +Some binary crates have `_recursive` suffix. This means that their `main` function is decorated with `#[recursive]` attribute. It instructs `nargo` to generate proofs that are possible to verify within another circuit using `std::verify_proof`. Unfortunately - Solidity can only verify normal proofs, so we need both. ## Compile