mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
ci: add eth chain test. Set prevrandao after merge (#621)
* Small changes * feat: Add eth chain test to ci. Set prevrandao after merge * Update .github/workflows/ci.yml Co-authored-by: Bjerg <onbjerg@users.noreply.github.com> * move env Co-authored-by: Bjerg <onbjerg@users.noreply.github.com>
This commit is contained in:
29
.github/workflows/ci.yml
vendored
29
.github/workflows/ci.yml
vendored
@ -55,6 +55,35 @@ jobs:
|
|||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
files: lcov.info
|
files: lcov.info
|
||||||
flags: unit-tests
|
flags: unit-tests
|
||||||
|
eth-blockchain:
|
||||||
|
name: Ethereum blockchain Tests (Stable)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
RUST_LOG: info,sync=error
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Checkout ethereum/tests
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
repository: ethereum/tests
|
||||||
|
path: ethtests
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Install toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- uses: Swatinem/rust-cache@v1
|
||||||
|
with:
|
||||||
|
cache-on-failure: true
|
||||||
|
|
||||||
|
- name: Run Ethereum tests
|
||||||
|
run: cargo run --release -- test-chain ethtests/BlockchainTests/GeneralStateTests/
|
||||||
|
|
||||||
fuzz:
|
fuzz:
|
||||||
# Skip the Fuzzing Jobs until we make them run fast and reliably. Currently they will
|
# Skip the Fuzzing Jobs until we make them run fast and reliably. Currently they will
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use crate::util;
|
use crate::util;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use eyre::eyre;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
/// Models for parsing JSON blockchain tests
|
/// Models for parsing JSON blockchain tests
|
||||||
@ -45,6 +46,10 @@ impl Command {
|
|||||||
|
|
||||||
info!("\nPASSED {num_of_passed}/{} tests\n", num_of_passed + num_of_failed);
|
info!("\nPASSED {num_of_passed}/{} tests\n", num_of_passed + num_of_failed);
|
||||||
|
|
||||||
Ok(())
|
if num_of_failed != 0 {
|
||||||
|
Err(eyre!("Failed {num_of_failed} tests"))
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,7 +63,8 @@ pub fn should_skip(path: &Path) -> bool {
|
|||||||
path.file_name() == Some(OsStr::new("Call50000_sha256.json")) ||
|
path.file_name() == Some(OsStr::new("Call50000_sha256.json")) ||
|
||||||
path.file_name() == Some(OsStr::new("static_Call50000_sha256.json")) ||
|
path.file_name() == Some(OsStr::new("static_Call50000_sha256.json")) ||
|
||||||
path.file_name() == Some(OsStr::new("loopMul.json")) ||
|
path.file_name() == Some(OsStr::new("loopMul.json")) ||
|
||||||
path.file_name() == Some(OsStr::new("CALLBlake2f_MaxRounds.json"))
|
path.file_name() == Some(OsStr::new("CALLBlake2f_MaxRounds.json")) ||
|
||||||
|
path.file_name() == Some(OsStr::new("shiftCombinations.json"))
|
||||||
{
|
{
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -79,12 +80,14 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<()> {
|
|||||||
if should_skip(path) {
|
if should_skip(path) {
|
||||||
return Ok(())
|
return Ok(())
|
||||||
}
|
}
|
||||||
|
info!("Executing test from path: {path:?}");
|
||||||
|
|
||||||
for (name, suite) in suites.0 {
|
for (name, suite) in suites.0 {
|
||||||
if matches!(
|
if matches!(
|
||||||
suite.network,
|
suite.network,
|
||||||
ForkSpec::ByzantiumToConstantinopleAt5 |
|
ForkSpec::ByzantiumToConstantinopleAt5 |
|
||||||
ForkSpec::Constantinople |
|
ForkSpec::Constantinople |
|
||||||
|
ForkSpec::ConstantinopleFix |
|
||||||
ForkSpec::MergeEOF |
|
ForkSpec::MergeEOF |
|
||||||
ForkSpec::MergeMeterInitCode |
|
ForkSpec::MergeMeterInitCode |
|
||||||
ForkSpec::MergePush0,
|
ForkSpec::MergePush0,
|
||||||
@ -96,7 +99,7 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<()> {
|
|||||||
|
|
||||||
let pre_state = suite.pre.0;
|
let pre_state = suite.pre.0;
|
||||||
|
|
||||||
debug!("Executing test: {name} for spec: {:?}", suite.network);
|
debug!("Executing {:?} spec: {:?}", name, suite.network);
|
||||||
|
|
||||||
let spec_upgrades: SpecUpgrades = suite.network.into();
|
let spec_upgrades: SpecUpgrades = suite.network.into();
|
||||||
// if paris aka merge is not activated we dont have block rewards;
|
// if paris aka merge is not activated we dont have block rewards;
|
||||||
|
|||||||
@ -77,11 +77,11 @@ impl SpecUpgrades {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// New homestead enabled spec
|
/// New frontier enabled spec
|
||||||
pub fn new_homestead_activated() -> Self {
|
pub fn new_frontier_activated() -> Self {
|
||||||
Self {
|
Self {
|
||||||
homestead: 0,
|
frontier: 0,
|
||||||
frontier: u64::MAX,
|
homestead: u64::MAX,
|
||||||
tangerine_whistle: u64::MAX,
|
tangerine_whistle: u64::MAX,
|
||||||
spurious_dragon: u64::MAX,
|
spurious_dragon: u64::MAX,
|
||||||
byzantium: u64::MAX,
|
byzantium: u64::MAX,
|
||||||
@ -95,8 +95,8 @@ impl SpecUpgrades {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// New homestead enabled spec
|
/// New homestead enabled spec
|
||||||
pub fn new_frontier_activated() -> Self {
|
pub fn new_homestead_activated() -> Self {
|
||||||
Self { frontier: 0, ..Self::new_ethereum() }
|
Self { homestead: 0, ..Self::new_frontier_activated() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// New tangerine enabled spec
|
/// New tangerine enabled spec
|
||||||
|
|||||||
@ -13,7 +13,7 @@ use reth_primitives::{
|
|||||||
use reth_provider::StateProvider;
|
use reth_provider::StateProvider;
|
||||||
use revm::{
|
use revm::{
|
||||||
db::AccountState, Account as RevmAccount, AccountInfo, AnalysisKind, Bytecode, Database,
|
db::AccountState, Account as RevmAccount, AccountInfo, AnalysisKind, Bytecode, Database,
|
||||||
Return, B160, EVM, U256 as evmU256,
|
Return, SpecId, B160, EVM, U256 as evmU256,
|
||||||
};
|
};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
@ -312,12 +312,13 @@ pub fn execute<DB: StateProvider>(
|
|||||||
let mut evm = EVM::new();
|
let mut evm = EVM::new();
|
||||||
evm.database(db);
|
evm.database(db);
|
||||||
|
|
||||||
|
let spec_id = config.spec_upgrades.revm_spec(header.number);
|
||||||
evm.env.cfg.chain_id = evmU256::from_limbs(config.chain_id.0);
|
evm.env.cfg.chain_id = evmU256::from_limbs(config.chain_id.0);
|
||||||
evm.env.cfg.spec_id = config.spec_upgrades.revm_spec(header.number);
|
evm.env.cfg.spec_id = config.spec_upgrades.revm_spec(header.number);
|
||||||
evm.env.cfg.perf_all_precompiles_have_balance = false;
|
evm.env.cfg.perf_all_precompiles_have_balance = false;
|
||||||
evm.env.cfg.perf_analyse_created_bytecodes = AnalysisKind::Raw;
|
evm.env.cfg.perf_analyse_created_bytecodes = AnalysisKind::Raw;
|
||||||
|
|
||||||
revm_wrap::fill_block_env(&mut evm.env.block, header);
|
revm_wrap::fill_block_env(&mut evm.env.block, header, spec_id >= SpecId::MERGE);
|
||||||
let mut cumulative_gas_used = 0;
|
let mut cumulative_gas_used = 0;
|
||||||
// output of verification
|
// output of verification
|
||||||
let mut changesets = Vec::with_capacity(transactions.len());
|
let mut changesets = Vec::with_capacity(transactions.len());
|
||||||
|
|||||||
@ -67,11 +67,17 @@ impl<DB: StateProvider> DatabaseRef for State<DB> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Fill block environment from Block.
|
/// Fill block environment from Block.
|
||||||
pub fn fill_block_env(block_env: &mut BlockEnv, header: &Header) {
|
pub fn fill_block_env(block_env: &mut BlockEnv, header: &Header, after_merge: bool) {
|
||||||
block_env.number = evmU256::from(header.number);
|
block_env.number = evmU256::from(header.number);
|
||||||
block_env.coinbase = B160(header.beneficiary.0);
|
block_env.coinbase = B160(header.beneficiary.0);
|
||||||
block_env.timestamp = evmU256::from(header.timestamp);
|
block_env.timestamp = evmU256::from(header.timestamp);
|
||||||
block_env.difficulty = evmU256::from_limbs(header.difficulty.0);
|
if after_merge {
|
||||||
|
block_env.prevrandao = Some(B256(header.mix_hash.0));
|
||||||
|
block_env.difficulty = evmU256::ZERO;
|
||||||
|
} else {
|
||||||
|
block_env.difficulty = evmU256::from_limbs(header.difficulty.0);
|
||||||
|
block_env.prevrandao = None;
|
||||||
|
}
|
||||||
block_env.basefee = evmU256::from(header.base_fee_per_gas.unwrap_or_default());
|
block_env.basefee = evmU256::from(header.base_fee_per_gas.unwrap_or_default());
|
||||||
block_env.gas_limit = evmU256::from(header.gas_limit);
|
block_env.gas_limit = evmU256::from(header.gas_limit);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user