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

Add recursive version of get_storage circuit #311

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 13 additions & 8 deletions ethereum/circuits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions ethereum/circuits/get_storage_recursive/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "get_storage_recursive"
type = "bin"
compiler_version = ">=0.30.0"

[dependencies]
ethereum = { path = "../lib" }
3 changes: 3 additions & 0 deletions ethereum/circuits/get_storage_recursive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Recursive get_storage

Recursive version of [get_storage](../get_storage/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's explain what this recursive version is and why we need it

11 changes: 11 additions & 0 deletions ethereum/circuits/get_storage_recursive/src/main.nr
Original file line number Diff line number Diff line change
@@ -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)
}
Loading