Skip to content

Commit

Permalink
chore: Enable Ethereum Execution Tests (#122)
Browse files Browse the repository at this point in the history
* Make providers resettable

* Re-add eth execution tests

* Use HashMap::default() instead of new() to also work with newer alloy versions

* run in CI

* fix CI

* fix fmt

* add missing files

* quote version

* fix env name

* fix CI

* add validate

* fix test provider

---------

Co-authored-by: Rami Khalil <the.rami.khalil@gmail.com>
  • Loading branch information
Wollac and hashcashier authored Dec 11, 2024
1 parent cecf5ec commit 2dce795
Show file tree
Hide file tree
Showing 26 changed files with 897 additions and 4,783 deletions.
32 changes: 32 additions & 0 deletions .github/actions/risczero/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: risczero toolchain install
description: Install risczero toolchain

inputs:
version:
description: 'Version of the RISC Zero to install'
required: true
type: string
toolchain-version:
description: 'Version of the RISC Zero toolchains to install'
required: false
default: ''
type: string

runs:
using: composite
steps:
- uses: risc0/cargo-install@v3
with:
crate: cargo-binstall
version: '=1.6'
locked: true

- run: cargo binstall -y --force cargo-risczero@${{ inputs.version }}
shell: bash

- run: cargo risczero install ${{ inputs.toolchain-version != '' && format('--version {0}', inputs.toolchain-version) || '' }}
shell: bash

- name: test risczero
shell: bash
run: cargo risczero --version
45 changes: 30 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,44 @@ permissions:
env:
CARGO_TERM_COLOR: always
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RISC0_VERSION: "1.1.3"
RISC0_TOOLCHAIN_VERSION: "r0.1.81.0"

jobs:
test:
name: test
name: cargo test
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- uses: risc0/risc0/.github/actions/rustup@main
- uses: risc0/risc0/.github/actions/sccache@main
- uses: ./.github/actions/risczero
with:
submodules: recursive
- uses: risc0/risc0/.github/actions/rustup@v1.1.3
- uses: risc0/risc0/.github/actions/sccache@v1.1.3
- uses: risc0/cargo-install@v1
with:
crate: cargo-binstall
- run: cargo binstall -y --force cargo-risczero@1.1.3
- run: cargo risczero install
version: ${{ env.RISC0_VERSION }}
toolchain-version: ${{ env.RISC0_TOOLCHAIN_VERSION }}
- run: cargo test --all-targets -p zeth-core -p zeth-guests -p zeth-preflight -p zeth -p zeth-benchmark -F debug-guest-build
- run: cargo test --all-targets -p zeth-core-ethereum -p zeth-preflight-ethereum -p zeth-ethereum -F debug-guest-build
- run: cargo test --all-targets -p zeth-core-optimism -p zeth-preflight-optimism -p zeth-optimism -F debug-guest-build

ef-tests:
name: Ethereum execution tests
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: risc0/risc0/.github/actions/rustup@main
- uses: risc0/risc0/.github/actions/sccache@main
- uses: ./.github/actions/risczero
with:
version: ${{ env.RISC0_VERSION }}
toolchain-version: ${{ env.RISC0_TOOLCHAIN_VERSION }}
- run: cargo test --all-targets -p zeth-testeth -F ef-tests

clippy:
name: clippy
name: cargo clippy
runs-on: [self-hosted, prod, "${{ matrix.os }}"]
strategy:
fail-fast: false
Expand All @@ -60,20 +75,20 @@ jobs:
steps:
- uses: actions/checkout@v4
- if: matrix.feature == 'cuda'
uses: risc0/risc0/.github/actions/cuda@v1.1.3
- uses: risc0/risc0/.github/actions/rustup@v1.1.3
- uses: risc0/risc0/.github/actions/sccache@v1.1.3
uses: risc0/risc0/.github/actions/cuda@main
- uses: risc0/risc0/.github/actions/rustup@main
- uses: risc0/risc0/.github/actions/sccache@main
- uses: risc0/clippy-action@main
with:
reporter: 'github-pr-check'
fail_on_error: true
clippy_flags: -F $FEATURE --workspace --all-targets -- -Dwarnings

fmt:
name: fmt
name: cargo fmt
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: risc0/risc0/.github/actions/rustup@v1.1.3
- uses: risc0/risc0/.github/actions/rustup@main
- run: cargo fmt --all --check
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "testing/ef-tests/testdata"]
path = testing/ef-tests/testdata
url = https://github.com/ethereum/tests.git
100 changes: 83 additions & 17 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"bin/*",
"crates/*",
"guests",
"testing/ef-tests",
]

# Always optimize; building and running the guest takes much longer without optimization.
Expand Down Expand Up @@ -83,6 +84,7 @@ flate2 = "1.0.34"
pot = "3.0.1"
serde = { version = "1.0.210", features = ["derive"] }
serde_json = { version = "1.0.128", features = ["alloc"] }
serde_with = "3.7.0"
thiserror = "1.0.64"
tiny-keccak = "2.0.2"
tokio = { version = "1.40.0", features = ["full"] }
Expand Down
8 changes: 5 additions & 3 deletions crates/core/src/stateless/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use reth_primitives::revm_primitives::Bytecode;
use reth_primitives::KECCAK_EMPTY;
use reth_revm::db::{AccountState, DbAccount};
use reth_revm::primitives::AccountInfo;
use std::default::Default;

pub trait InitializationStrategy<Driver: CoreDriver, Database> {
fn initialize_database(
Expand Down Expand Up @@ -63,7 +64,8 @@ impl<Driver: CoreDriver> InitializationStrategy<Driver, MemoryDB> for MemoryDbSt
.collect();

// Load account data into db
let mut accounts = HashMap::with_capacity(storage_tries.len());
let mut accounts =
HashMap::with_capacity_and_hasher(storage_tries.len(), Default::default());
for (address, (storage_trie, slots)) in storage_tries {
// consume the slots, as they are no longer needed afterward
let slots = take(slots);
Expand Down Expand Up @@ -93,7 +95,7 @@ impl<Driver: CoreDriver> InitializationStrategy<Driver, MemoryDB> for MemoryDbSt
};

// load storage reads
let mut storage = HashMap::with_capacity(slots.len());
let mut storage = HashMap::with_capacity_and_hasher(slots.len(), Default::default());
for slot in slots {
let value: U256 = storage_trie
.get_rlp(&keccak(slot.to_be_bytes::<32>()))?
Expand All @@ -117,7 +119,7 @@ impl<Driver: CoreDriver> InitializationStrategy<Driver, MemoryDB> for MemoryDbSt

// prepare block hash history
let mut block_hashes: HashMap<U256, B256> =
HashMap::with_capacity(ancestor_headers.len() + 1);
HashMap::with_capacity_and_hasher(ancestor_headers.len() + 1, Default::default());
block_hashes.insert(
U256::from(Driver::block_number(parent_header)),
Driver::header_hash(parent_header),
Expand Down
Loading

0 comments on commit 2dce795

Please sign in to comment.