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 }}
|
||||
files: lcov.info
|
||||
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:
|
||||
# Skip the Fuzzing Jobs until we make them run fast and reliably. Currently they will
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
use crate::util;
|
||||
use clap::Parser;
|
||||
use eyre::eyre;
|
||||
use std::path::PathBuf;
|
||||
use tracing::{error, info};
|
||||
/// 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);
|
||||
|
||||
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("static_Call50000_sha256.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
|
||||
}
|
||||
@ -79,12 +80,14 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<()> {
|
||||
if should_skip(path) {
|
||||
return Ok(())
|
||||
}
|
||||
info!("Executing test from path: {path:?}");
|
||||
|
||||
for (name, suite) in suites.0 {
|
||||
if matches!(
|
||||
suite.network,
|
||||
ForkSpec::ByzantiumToConstantinopleAt5 |
|
||||
ForkSpec::Constantinople |
|
||||
ForkSpec::ConstantinopleFix |
|
||||
ForkSpec::MergeEOF |
|
||||
ForkSpec::MergeMeterInitCode |
|
||||
ForkSpec::MergePush0,
|
||||
@ -96,7 +99,7 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<()> {
|
||||
|
||||
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();
|
||||
// if paris aka merge is not activated we dont have block rewards;
|
||||
|
||||
@ -77,11 +77,11 @@ impl SpecUpgrades {
|
||||
}
|
||||
}
|
||||
|
||||
/// New homestead enabled spec
|
||||
pub fn new_homestead_activated() -> Self {
|
||||
/// New frontier enabled spec
|
||||
pub fn new_frontier_activated() -> Self {
|
||||
Self {
|
||||
homestead: 0,
|
||||
frontier: u64::MAX,
|
||||
frontier: 0,
|
||||
homestead: u64::MAX,
|
||||
tangerine_whistle: u64::MAX,
|
||||
spurious_dragon: u64::MAX,
|
||||
byzantium: u64::MAX,
|
||||
@ -95,8 +95,8 @@ impl SpecUpgrades {
|
||||
}
|
||||
|
||||
/// New homestead enabled spec
|
||||
pub fn new_frontier_activated() -> Self {
|
||||
Self { frontier: 0, ..Self::new_ethereum() }
|
||||
pub fn new_homestead_activated() -> Self {
|
||||
Self { homestead: 0, ..Self::new_frontier_activated() }
|
||||
}
|
||||
|
||||
/// New tangerine enabled spec
|
||||
|
||||
@ -13,7 +13,7 @@ use reth_primitives::{
|
||||
use reth_provider::StateProvider;
|
||||
use revm::{
|
||||
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;
|
||||
|
||||
@ -312,12 +312,13 @@ pub fn execute<DB: StateProvider>(
|
||||
let mut evm = EVM::new();
|
||||
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.spec_id = config.spec_upgrades.revm_spec(header.number);
|
||||
evm.env.cfg.perf_all_precompiles_have_balance = false;
|
||||
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;
|
||||
// output of verification
|
||||
let mut changesets = Vec::with_capacity(transactions.len());
|
||||
|
||||
@ -67,11 +67,17 @@ impl<DB: StateProvider> DatabaseRef for State<DB> {
|
||||
}
|
||||
|
||||
/// 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.coinbase = B160(header.beneficiary.0);
|
||||
block_env.timestamp = evmU256::from(header.timestamp);
|
||||
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.gas_limit = evmU256::from(header.gas_limit);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user