Skip to content

Commit

Permalink
is_dao_worthy_recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
akonior committed Jun 7, 2024
1 parent abc25de commit c800523
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 2 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/circuits_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,20 @@ jobs:
toolchain: nightly-2024-05-22

- name: Compile Circuit
run: nargo compile --workspace --deny-warnings
run: |
nargo compile --package get_header --deny-warnings
nargo compile --package get_account --deny-warnings
nargo compile --package get_storage --deny-warnings
nargo compile --package get_storage_recursive --deny-warnings
nargo compile --package get_receipt --deny-warnings
nargo compile --package get_transaction --deny-warnings
nargo compile --package get_log --deny-warnings
nargo compile --package is_dao_worthy --deny-warnings
nargo compile --package is_ape_owner --deny-warnings
# We cannot use the `--deny-warnings` option in `is_dao_worthy_recursive` because the `verify_proof` method generates warning
# that are actually informational messages from the compiler and cannot be ignored.
nargo compile --package is_dao_worthy_recursive
- name: Start Oracle Server
working-directory: ethereum/oracles
Expand All @@ -54,6 +67,18 @@ jobs:
nargo prove --package is_dao_worthy --oracle-resolver=http://localhost:5555
nargo prove --package is_ape_owner --oracle-resolver=http://localhost:5555
- name: Generate verification key for recursive proof
working-directory: ethereum/oracles
run: |
# To generate the verification key, the following file is required: ~/.nargo/backends/acvm-backend-barretenberg/backend_binary.
# This file is automatically installed during the execution of the `nargo prove` command in previous step.
yarn generate-get-storage-vk
- name: Generate Recursive Proof
run: |
export NARGO_FOREIGN_CALL_TIMEOUT=100000 # miliseconds
nargo prove --package is_dao_worthy_recursive --oracle-resolver=http://localhost:5555
- name: Verify Proof
run: |
nargo verify --package get_header
Expand Down
1 change: 1 addition & 0 deletions Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"ethereum/circuits/get_log",
"vlayer/ethereum/circuits/lib",
"vlayer/examples/circuits/is_dao_worthy",
"vlayer/examples/circuits/is_dao_worthy_recursive",
"vlayer/examples/circuits/is_ape_owner",
"vlayer/examples/circuits/is_crypto_punk_owner",
]
Expand Down
2 changes: 1 addition & 1 deletion vlayer/examples/circuits/is_dao_worthy/Verifier.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
block_number = "0x000000000000000000000000000000000000000000000000000000000121eac0"
block_number = 19000000
8 changes: 8 additions & 0 deletions vlayer/examples/circuits/is_dao_worthy_recursive/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "is_dao_worthy_recursive"
type = "bin"
compiler_version = ">=0.30.0"

[dependencies]
ethereum = { path = "../../../../ethereum/circuits/lib" }
token = { path = "../../../ethereum/circuits/lib" }
4 changes: 4 additions & 0 deletions vlayer/examples/circuits/is_dao_worthy_recursive/Prover.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
block_number = 19000000

# Circle address
wallet_address = [ 0x55, 0xfe, 0x00, 0x2a, 0xef, 0xf0, 0x2f, 0x77, 0x36, 0x4d, 0xe3, 0x39, 0xa1, 0x29, 0x29, 0x23, 0xa1, 0x58, 0x44, 0xb8 ]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
block_number = 19000000
13 changes: 13 additions & 0 deletions vlayer/examples/circuits/is_dao_worthy_recursive/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use dep::ethereum::misc::types::Address;
use dep::token::token_list::mainnet::USDC;

mod main_test;

global MIN_BALANCE = U128::from_integer(100_000_000_000); // $100k

fn main(wallet_address: Address, block_number: pub u64) {
let wallet_balance = USDC.get_balance_recursive(wallet_address, block_number);
let is_balance_greater_or_equal = MIN_BALANCE <= wallet_balance;

assert(is_balance_greater_or_equal, "Insufficient USDC balance");
}
27 changes: 27 additions & 0 deletions vlayer/examples/circuits/is_dao_worthy_recursive/src/main_test.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
mod is_dao_worthy_main {
use dep::std::test::OracleMock;
use dep::ethereum::fixtures::mainnet::{
paris::usdc_circle::header::{hash, block_header_partial as paris_block_header_partial, block_header_rlp as paris_block_header_rlp},
paris::usdc_circle::account::account, paris::usdc_circle::storage::values,
paris::usdc_circle::state_proof::proof_input_serialized as state_proof_input_serialized,
paris::usdc_circle::storage_proof::proofs_serialized
};
use dep::ethereum::{account_with_storage_recursive::RecursiveProof, account_with_storage::StorageWithinBlock};
use crate::main;

#[test]
fn success_greater_then() {
let result = StorageWithinBlock { block_hash: hash, account, values };
let recursive_proof = RecursiveProof { key_hash: 1, verification_key: [0; 114], proof: [0; 93] };

let _ = OracleMock::mock("get_storage_recursive").returns((result.serialize(), recursive_proof));
let _ = OracleMock::mock("get_header").returns((paris_block_header_partial, paris_block_header_rlp));
let _ = OracleMock::mock("get_proof").returns((account, state_proof_input_serialized, proofs_serialized[0]));

let block_number = 19_000_000;
let circle_address = [
0x55, 0xfe, 0x00, 0x2a, 0xef, 0xf0, 0x2f, 0x77, 0x36, 0x4d, 0xe3, 0x39, 0xa1, 0x29, 0x29, 0x23, 0xa1, 0x58, 0x44, 0xb8
];
main(circle_address, block_number);
}
}

0 comments on commit c800523

Please sign in to comment.