Skip to content

Commit

Permalink
feat: simpler ci test (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwen01 authored Oct 3, 2024
1 parent b845322 commit acc65ae
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 15 deletions.
29 changes: 27 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ jobs:
RUST_BACKTRACE: full
RUST_LOG: info


test-e2e:
name: Test
name: Test e2es
runs-on: ["runs-on", "runner=32cpu-linux-x64", "run-id=${{ github.run_id }}"]
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
Expand All @@ -70,6 +69,32 @@ jobs:
run: |
SP1_DEV=1 RUST_LOG=info cargo test -p sp1-cc-host-executor --release -- --nocapture
test-uniswap-forge:
name: Test uniswap forge
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run Forge build
run: |
cd examples/uniswap/contracts
forge --version
forge build --sizes
id: build

- name: Run Forge tests
run: |
cd examples/uniswap/contracts
forge test -vvv
id: test




1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ rsp-mpt = { git = "https://github.com/succinctlabs/rsp" , rev = "3647076"}
# reth
reth-primitives = { git = "https://github.com/sp1-patches/reth", tag = "rsp-20240830", default-features = false, features = [
"alloy-compat",
"optimism",
"std",
] }
reth-codecs = { git = "https://github.com/sp1-patches/reth", tag = "rsp-20240830", default-features = false }
Expand All @@ -75,10 +74,8 @@ reth-ethereum-consensus = { git = "https://github.com/sp1-patches/reth", tag = "

# revm
revm = { version = "14.0.0", features = [
"optimism",
"std",
"serde",
"kzg-rs",
], default-features = false }
revm-primitives = { version = "9.0.0", features = [
"std",
Expand All @@ -89,7 +86,6 @@ revm-primitives = { version = "9.0.0", features = [
alloy-primitives = "0.8"
alloy-provider = { version = "0.3", default-features = false, features = [
"reqwest",
"reqwest-rustls-tls",
] }
alloy-rpc-types = { version = "0.3", default-features = false, features = [
"eth",
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,12 @@ Then, from the root directory of the repository, run

where `[example]` is one of the following
* `uniswap`
* Fetches the price of the UNI / WETH pair on Uniswap V3.
* Outputs a file called [plonk-fixture.json](examples/uniswap/contracts/src/fixtures/plonk-fixture.json), which contains everything you need to verify the proof on chain.
* To see an example of on-chain verification, take a look at the [contracts](./examples/uniswap/contracts/) directory.
* On chain verification requires generating a plonk or groth16 proof, which requires significant computational resources. We recommend using the [SP1 Prover network](https://docs.succinct.xyz/generating-proofs/prover-network.html).
* Fetches the price of the UNI / WETH pair on Uniswap V3. By default, this does not generate a proof.
* Running `RUST_LOG=info cargo run --bin [example] --release -- --prove` will generate a plonk proof. This requires
significant computational resources, so we recommend using the [SP1 Prover network]
(https://docs.succinct.xyz/generating-proofs/prover-network.html).
* Outputs a file called [plonk-fixture.json](examples/uniswap/contracts/src/fixtures/plonk-fixture.json), which contains everything you need to verify the proof on chain.
* To see an example of on-chain verification, take a look at the [contracts](./examples/uniswap/contracts/) directory.
* `multiplexer`
* Calls a contract that fetches the prices of many different collateral assets.
* The source code of this contract is found [here](./examples/multiplexer/ZkOracleHelper.sol).
Expand Down
6 changes: 2 additions & 4 deletions examples/multiplexer/client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ sp1_zkvm::entrypoint!(main);

use alloy_primitives::{address, Address};
use alloy_sol_macro::sol;
use alloy_sol_types::{SolCall, SolValue};
use alloy_sol_types::SolValue;
use bincode;
use sp1_cc_client_executor::{
io::EVMStateSketch, ClientExecutor, ContractInput, ContractPublicValues,
};
use sp1_cc_client_executor::{io::EVMStateSketch, ClientExecutor, ContractInput};

sol! {
/// Interface to the multiplexer contract. It gets the prices of many tokens, including
Expand Down
2 changes: 1 addition & 1 deletion examples/uniswap/client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sp1_zkvm::entrypoint!(main);

use alloy_primitives::{address, Address};
use alloy_sol_macro::sol;
use alloy_sol_types::{SolCall, SolValue};
use alloy_sol_types::SolValue;
use bincode;
use sp1_cc_client_executor::{io::EVMStateSketch, ClientExecutor, ContractInput};
sol! {
Expand Down
1 change: 1 addition & 0 deletions examples/uniswap/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ eyre.workspace = true
bincode.workspace = true
serde.workspace = true
serde_json.workspace = true
clap = { version = "4.0", features = ["derive"] }

# sp1
sp1-sdk = { git = "https://github.com/succinctlabs/sp1", branch = "yuwen/fs-test"}
Expand Down
17 changes: 17 additions & 0 deletions examples/uniswap/host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use alloy_provider::ReqwestProvider;
use alloy_rpc_types::BlockNumberOrTag;
use alloy_sol_macro::sol;
use alloy_sol_types::{SolCall, SolValue};
use clap::Parser;
use serde::{Deserialize, Serialize};
use sp1_cc_client_executor::{ContractInput, ContractPublicValues};
use sp1_cc_host_executor::HostExecutor;
Expand Down Expand Up @@ -38,6 +39,14 @@ struct SP1CCProofFixture {
proof: String,
}

/// The arguments for the command.
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct Args {
#[clap(long, default_value = "false")]
prove: bool,
}

/// Generate a `SP1CCProofFixture`, and save it as a json file.
///
/// This is useful for verifying the proof of contract call execution on chain.
Expand All @@ -62,6 +71,9 @@ async fn main() -> eyre::Result<()> {
// Setup logging.
utils::setup_logger();

// Parse the command line arguments.
let args = Args::parse();

// Which block transactions are executed on.
let block_number = BlockNumberOrTag::Number(20600000);

Expand Down Expand Up @@ -102,6 +114,11 @@ async fn main() -> eyre::Result<()> {
let (_, report) = client.execute(ELF, stdin.clone()).run().unwrap();
println!("executed program with {} cycles", report.total_instruction_count());

// If the prove flag is not set, we return here.
if !args.prove {
return Ok(());
}

// Generate the proof for the given program and input.
let (pk, vk) = client.setup(ELF);
let proof = client.prove(&pk, stdin).plonk().run().unwrap();
Expand Down

0 comments on commit acc65ae

Please sign in to comment.