Skip to content

Commit

Permalink
WEB3-112: chore: Steel e2e tests (#228)
Browse files Browse the repository at this point in the history
This PR turns the `erc20-counter` example into an end-to-end test. It
uses a local Ethereum devnet including an execution and consensus client
based on the
[ethpandaops/ethereum-package](https://github.com/ethpandaops/ethereum-package)
Kurtosis package.
In the CI, all contracts are deployed on the devnet before a full proof
is generated and validated with a block and a beacon commitment.

closes #203 
closes WEB3-90

---------

Co-authored-by: Victor Graf <victor@risczero.com>
  • Loading branch information
Wollac and nategraf authored Sep 11, 2024
1 parent 5b09599 commit c8bba7d
Show file tree
Hide file tree
Showing 15 changed files with 269 additions and 235 deletions.
59 changes: 0 additions & 59 deletions .github/workflows/bonsai.yml

This file was deleted.

101 changes: 101 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Testnet

on:
merge_group:
pull_request:
branches: [main, "release-*"]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

# this is needed to gain access via OIDC to the S3 bucket for caching
permissions:
id-token: write
contents: read

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RISC0_TOOLCHAIN_VERSION: r0.1.79.0
RISC0_MONOREPO_REF: "main"

jobs:
e2e-tests:
runs-on: [self-hosted, prod, "${{ matrix.os }}", "${{ matrix.device }}"]
strategy:
matrix:
prover: [bonsai, local]
release:
- ${{ startsWith(github.base_ref, 'release-') || startsWith(github.base_ref, 'refs/heads/release-') }}
# Run on Linux with GPU for faster local proving.
include:
- os: Linux
feature: cuda
device: nvidia_rtx_a5000
# Exclude Bonsai proving on non-release branches.
exclude:
- release: false
prover: bonsai
env:
RUST_BACKTRACE: full
steps:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Use Bonsai for release branches
if: matrix.prover == 'bonsai'
run: |
echo "BONSAI_API_URL=${{ secrets.BONSAI_API_URL }}" >> $GITHUB_ENV
echo "BONSAI_API_KEY=${{ secrets.BONSAI_API_KEY }}" >> $GITHUB_ENV
- if: matrix.feature == 'cuda'
uses: risc0/risc0/.github/actions/cuda@main
- uses: risc0/risc0/.github/actions/rustup@main
- uses: risc0/risc0/.github/actions/sccache@main
with:
key: ${{ matrix.os }}-${{ matrix.feature }}
- uses: risc0/foundry-toolchain@2fe7e70b520f62368a0e3c464f997df07ede420f
- uses: ./.github/actions/cargo-risczero-install
with:
ref: ${{ env.RISC0_MONOREPO_REF }}
toolchain-version: ${{ env.RISC0_TOOLCHAIN_VERSION }}
features: ${{ matrix.feature }}
- name: Setup Kurtosis
run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli
kurtosis analytics disable
echo "$(dirname $(which kurtosis))" >> $GITHUB_PATH
shell: bash
- name: Start local Ethereum testnet
run: |
kurtosis --enclave local-eth-testnet run github.com/ethpandaops/ethereum-package@2e9e5a41784f792a206f1a108c2c96830b2c95ef
echo "ETH_TESTNET_EL_URL=http://$(kurtosis port print local-eth-testnet el-1-geth-lighthouse rpc)" >> $GITHUB_ENV
echo "ETH_TESTNET_CL_URL=$(kurtosis port print local-eth-testnet cl-1-lighthouse-geth http)" >> $GITHUB_ENV
- name: Wait for the local Ethereum testnet to come up
run: while [ $(cast rpc --rpc-url $ETH_TESTNET_EL_URL eth_blockNumber | jq -re) == "0x0" ]; do sleep 5; done
shell: bash
- run: cargo build
working-directory: examples/erc20-counter
- name: Run E2E test (Block Commitment)
run: ./e2e-test.sh
env:
ETH_RPC_URL: ${{ env.ETH_TESTNET_EL_URL }}
ETH_WALLET_ADDRESS: "0x802dCbE1B1A97554B4F50DB5119E37E8e7336417"
ETH_WALLET_PRIVATE_KEY: "0x5d2344259f42259f82d2c140aa66102ba89b57b4883ee441a8b312622bd42491"
working-directory: examples/erc20-counter
- name: Run E2E test (Beacon Commitment)
run: ./e2e-test.sh
env:
ETH_RPC_URL: ${{ env.ETH_TESTNET_EL_URL }}
BEACON_API_URL: ${{ env.ETH_TESTNET_CL_URL }}
ETH_WALLET_ADDRESS: "0x802dCbE1B1A97554B4F50DB5119E37E8e7336417"
ETH_WALLET_PRIVATE_KEY: "0x5d2344259f42259f82d2c140aa66102ba89b57b4883ee441a8b312622bd42491"
working-directory: examples/erc20-counter
- name: Stop local Ethereum testnet
if: always()
run: kurtosis enclave rm -f local-eth-testnet
- run: sccache --show-stats
15 changes: 2 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
merge_group:
pull_request:
branches: [main, "release-*"]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down Expand Up @@ -85,8 +84,6 @@ jobs:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"
- uses: actions/checkout@v4
with:
submodules: recursive
- if: matrix.feature == 'cuda'
uses: risc0/risc0/.github/actions/cuda@main
- uses: risc0/risc0/.github/actions/rustup@main
Expand Down Expand Up @@ -166,6 +163,8 @@ jobs:
- os: Linux
feature: default
device: cpu
env:
RUST_BACKTRACE: full
steps:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"
Expand Down Expand Up @@ -201,17 +200,9 @@ jobs:
with:
submodules: recursive
- uses: risc0/risc0/.github/actions/rustup@main
- uses: risc0/risc0/.github/actions/sccache@main
with:
key: macOS-default
- uses: risc0/foundry-toolchain@2fe7e70b520f62368a0e3c464f997df07ede420f
- uses: ./.github/actions/cargo-risczero-install
with:
ref: ${{ env.RISC0_MONOREPO_REF }}
toolchain-version: ${{ env.RISC0_TOOLCHAIN_VERSION }}
- run: cargo doc --no-deps --workspace
- run: forge doc
#- run: sccache --show-stats

# Run as a separate job because we need to install a different set of tools.
# In particular, it uses nightly Rust and _does not_ install Forge or cargo risczero.
Expand All @@ -221,8 +212,6 @@ jobs:
# This is a workaround from: https://github.com/actions/checkout/issues/590#issuecomment-970586842
- run: "git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :"
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: risc0/risc0/.github/actions/rustup@main
with:
# Building with docs.rs config requires the nightly toolchain.
Expand Down
1 change: 0 additions & 1 deletion examples/erc20-counter/.env

This file was deleted.

29 changes: 22 additions & 7 deletions examples/erc20-counter/apps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,34 @@ Usage: publisher [OPTIONS] --eth-wallet-private-key <ETH_WALLET_PRIVATE_KEY> --e
Options:
--eth-wallet-private-key <ETH_WALLET_PRIVATE_KEY>
Private key [env: ETH_WALLET_PRIVATE_KEY=]
Ethereum private key
[env: ETH_WALLET_PRIVATE_KEY=]
--eth-rpc-url <ETH_RPC_URL>
Ethereum RPC endpoint URL [env: ETH_RPC_URL=]
Ethereum RPC endpoint URL
[env: ETH_RPC_URL=]
--beacon-api-url <BEACON_API_URL>
Beacon API endpoint URL [env: BEACON_API_URL=]
--counter <COUNTER>
Address of the Counter verifier
Optional Beacon API endpoint URL
When provided, Steel uses a beacon block commitment instead of the execution block. This allows proofs to be validated using the EIP-4788 beacon roots contract.
[env: BEACON_API_URL=]
--counter-address <COUNTER_ADDRESS>
Address of the Counter verifier contract
--token-contract <TOKEN_CONTRACT>
Address of the ERC20 token contract [env: TOKEN_CONTRACT=]
Address of the ERC20 token contract
--account <ACCOUNT>
Address to query the token balance of
-h, --help
Print help```
Print help (see a summary with '-h')
```

[publisher]: ./src/bin/publisher.rs
[Counter]: ../contracts/Counter.sol
Loading

0 comments on commit c8bba7d

Please sign in to comment.