test update (#429)

support for 9.0.1 ethereum tests
This commit is contained in:
Dusan Stanivukovic 2021-06-10 15:01:48 +02:00 committed by GitHub
parent 5e7086d54c
commit b928380b64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 307 additions and 17 deletions

View File

@ -0,0 +1,212 @@
{
"name": "BerlinToLondonAt5 (test)",
"engine": {
"Ethash": {
"params": {
"minimumDifficulty": "0x020000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x1BC16D674EC80000",
"homesteadTransition": "0x0",
"eip100bTransition": "0x0",
"difficultyBombDelays": {
"0": 5000000
}
}
}
},
"params": {
"gasLimitBoundDivisor": "0x0400",
"registrar": "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
"accountStartNonce": "0x00",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID": "0x1",
"maxCodeSize": 24576,
"maxCodeSizeTransition": "0x0",
"eip150Transition": "0x0",
"eip160Transition": "0x0",
"eip161abcTransition": "0x0",
"eip161dTransition": "0x0",
"eip140Transition": "0x0",
"eip211Transition": "0x0",
"eip214Transition": "0x0",
"eip155Transition": "0x0",
"eip658Transition": "0x0",
"eip145Transition": "0x0",
"eip1014Transition": "0x0",
"eip1052Transition": "0x0",
"eip1283Transition": "0x0",
"eip1283DisableTransition": "0x0",
"eip1283ReenableTransition": "0x0",
"eip1344Transition": "0x0",
"eip1706Transition": "0x0",
"eip1884Transition": "0x0",
"eip2028Transition": "0x0",
"eip2929Transition": "0x0",
"eip2930Transition": "0x0",
"eip1559Transition": "0x5",
"eip3198Transition": "0x5",
"eip3541Transition": "0x5",
"eip3529Transition": "0x5",
"eip1559BaseFeeMaxChangeDenominator": "0x8",
"eip1559ElasticityMultiplier": "0x2",
"eip1559BaseFeeInitialValue": "0x3B9ACA00"
},
"genesis": {
"seal": {
"ethereum": {
"nonce": "0x0000000000000042",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
},
"difficulty": "0x400000000",
"author": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
"gasLimit": "0x1388"
},
"accounts": {
"0000000000000000000000000000000000000001": {
"balance": "1",
"builtin": {
"name": "ecrecover",
"pricing": {
"linear": {
"base": 3000,
"word": 0
}
}
}
},
"0000000000000000000000000000000000000002": {
"balance": "1",
"builtin": {
"name": "sha256",
"pricing": {
"linear": {
"base": 60,
"word": 12
}
}
}
},
"0000000000000000000000000000000000000003": {
"balance": "1",
"builtin": {
"name": "ripemd160",
"pricing": {
"linear": {
"base": 600,
"word": 120
}
}
}
},
"0000000000000000000000000000000000000004": {
"balance": "1",
"builtin": {
"name": "identity",
"pricing": {
"linear": {
"base": 15,
"word": 3
}
}
}
},
"0000000000000000000000000000000000000005": {
"builtin": {
"name": "modexp",
"activate_at": "0x00",
"pricing": {
"0": {
"price": {
"modexp2565": {}
}
}
}
}
},
"0000000000000000000000000000000000000006": {
"builtin": {
"name": "alt_bn128_add",
"pricing": {
"0": {
"price": {
"alt_bn128_const_operations": {
"price": 500
}
}
},
"0": {
"info": "EIP 1108 transition",
"price": {
"alt_bn128_const_operations": {
"price": 150
}
}
}
}
}
},
"0000000000000000000000000000000000000007": {
"builtin": {
"name": "alt_bn128_mul",
"pricing": {
"0": {
"price": {
"alt_bn128_const_operations": {
"price": 40000
}
}
},
"0": {
"info": "EIP 1108 transition",
"price": {
"alt_bn128_const_operations": {
"price": 6000
}
}
}
}
}
},
"0000000000000000000000000000000000000008": {
"builtin": {
"name": "alt_bn128_pairing",
"pricing": {
"0": {
"price": {
"alt_bn128_pairing": {
"base": 100000,
"pair": 80000
}
}
},
"0": {
"info": "EIP 1108 transition",
"price": {
"alt_bn128_pairing": {
"base": 45000,
"pair": 34000
}
}
}
}
}
},
"0000000000000000000000000000000000000009": {
"builtin": {
"name": "blake2_f",
"activate_at": "0x00",
"pricing": {
"blake2_f": {
"gas_per_round": 1
}
}
}
}
}
}

@ -1 +1 @@
Subproject commit 8a81997b22475f1dd90f0d01128c43b18f8877b2 Subproject commit fa0ab110f3f45d1f6786f978ea596a18ecbe8275

View File

@ -108,6 +108,7 @@ impl<'a> EvmTestClient<'a> {
} }
ForkSpec::Berlin => Some(ethereum::new_berlin_test()), ForkSpec::Berlin => Some(ethereum::new_berlin_test()),
ForkSpec::London => Some(ethereum::new_london_test()), ForkSpec::London => Some(ethereum::new_london_test()),
ForkSpec::BerlinToLondonAt5 => Some(ethereum::new_berlin_to_london_test()),
ForkSpec::FrontierToHomesteadAt5 ForkSpec::FrontierToHomesteadAt5
| ForkSpec::HomesteadToDaoAt5 | ForkSpec::HomesteadToDaoAt5
| ForkSpec::HomesteadToEIP150At5 | ForkSpec::HomesteadToEIP150At5

View File

@ -282,6 +282,14 @@ pub fn new_london_test() -> Spec {
) )
} }
/// Create a new BerlinToLondonAt5 era spec.
pub fn new_berlin_to_london_test() -> Spec {
load(
None,
include_bytes!("../../res/chainspec/test/berlin_to_londonat5_test.json"),
)
}
/// Create a new Musicoin-MCIP3-era spec. /// Create a new Musicoin-MCIP3-era spec.
pub fn new_mcip3_test() -> Spec { pub fn new_mcip3_test() -> Spec {
load( load(

View File

@ -134,8 +134,24 @@ pub fn is_same_block(ref_block: &Block, block: &Unverified) -> bool {
TypedTxId::Legacy TypedTxId::Legacy
}; };
is_ok = is_ok is_ok = is_ok
&& {
match ref_tx.gas_price {
Some(gas_price) => {
test_exp(tx.tx().gas_price == gas_price.0, "Tx gas price")
}
None => {
test_exp(
tx.tx().gas_price == ref_tx.max_fee_per_gas.unwrap_or_default().0,
"Tx max fee per gas",
) && test_exp(
tx.max_priority_fee_per_gas()
== ref_tx.max_priority_fee_per_gas.unwrap_or_default().0,
"Tx max priority fee per gas",
)
}
}
}
&& test_exp(tx.tx().nonce == ref_tx.nonce.0, "Tx nonce") && test_exp(tx.tx().nonce == ref_tx.nonce.0, "Tx nonce")
&& test_exp(tx.tx().gas_price == ref_tx.gas_price.0, "Tx gas price")
&& test_exp(tx.tx().gas == ref_tx.gas_limit.0, "Tx gas") && test_exp(tx.tx().gas == ref_tx.gas_limit.0, "Tx gas")
&& test_exp(tx.tx().value == ref_tx.value.0, "Tx value") && test_exp(tx.tx().value == ref_tx.value.0, "Tx value")
&& test_exp(tx.tx().data == ref_tx.data.0, "Tx data") && test_exp(tx.tx().data == ref_tx.data.0, "Tx data")

View File

@ -16,7 +16,7 @@
use super::{test_common::*, HookType}; use super::{test_common::*, HookType};
use client::{EvmTestClient, EvmTestError, TransactErr, TransactSuccess}; use client::{EvmTestClient, EvmTestError, TransactErr, TransactSuccess};
use ethjson; use ethjson::{self, spec::ForkSpec};
use pod_state::PodState; use pod_state::PodState;
use std::path::Path; use std::path::Path;
use trace; use trace;
@ -77,6 +77,14 @@ pub fn json_state_test<H: FnMut(&str, HookType)>(
} }
}; };
//hardcode base fee for part of the london tests, that miss base fee field in env
let mut test_env = env.clone();
if spec_name >= ForkSpec::London {
if test_env.base_fee.is_none() {
test_env.base_fee = Some(0x0a.into());
}
}
for (i, state) in states.into_iter().enumerate() { for (i, state) in states.into_iter().enumerate() {
let info = format!( let info = format!(
"TestState/{}/{:?}/{}/trie", "TestState/{}/{:?}/{}/trie",
@ -94,7 +102,7 @@ pub fn json_state_test<H: FnMut(&str, HookType)>(
let result = || -> Result<_, EvmTestError> { let result = || -> Result<_, EvmTestError> {
Ok(EvmTestClient::from_pod_state(&spec, pre.clone())?.transact( Ok(EvmTestClient::from_pod_state(&spec, pre.clone())?.transact(
&env, &test_env,
transaction, transaction,
trace::NoopTracer, trace::NoopTracer,
trace::NoopVMTracer, trace::NoopVMTracer,

View File

@ -27,7 +27,7 @@ pub struct Transaction {
pub transaction_type: Option<Uint>, pub transaction_type: Option<Uint>,
pub data: Bytes, pub data: Bytes,
pub gas_limit: Uint, pub gas_limit: Uint,
pub gas_price: Uint, pub gas_price: Option<Uint>,
pub nonce: Uint, pub nonce: Uint,
pub r: Uint, pub r: Uint,
pub s: Uint, pub s: Uint,
@ -35,6 +35,8 @@ pub struct Transaction {
pub value: Uint, pub value: Uint,
pub chain_id: Option<Uint>, pub chain_id: Option<Uint>,
pub access_list: Option<AccessList>, pub access_list: Option<AccessList>,
pub max_fee_per_gas: Option<Uint>,
pub max_priority_fee_per_gas: Option<Uint>,
pub hash: Option<H256>, pub hash: Option<H256>,
} }

View File

@ -39,6 +39,7 @@ pub enum ForkSpec {
ByzantiumToConstantinopleFixAt5, ByzantiumToConstantinopleFixAt5,
Berlin, Berlin,
London, London,
BerlinToLondonAt5,
} }
/// Spec deserialization. /// Spec deserialization.

View File

@ -27,7 +27,7 @@ use crate::{
}; };
use common_types::transaction::{ use common_types::transaction::{
AccessListTx, Action, SignedTransaction, Transaction, TypedTransaction, AccessListTx, Action, EIP1559TransactionTx, SignedTransaction, Transaction, TypedTransaction,
}; };
use serde_json::{self, Error}; use serde_json::{self, Error};
@ -84,7 +84,7 @@ pub struct MultiTransaction {
/// Gas limit set. /// Gas limit set.
pub gas_limit: Vec<Uint>, pub gas_limit: Vec<Uint>,
/// Gas price. /// Gas price.
pub gas_price: Uint, pub gas_price: Option<Uint>,
/// Nonce. /// Nonce.
pub nonce: Uint, pub nonce: Uint,
/// Secret key. /// Secret key.
@ -94,6 +94,10 @@ pub struct MultiTransaction {
pub to: MaybeEmpty<Address>, pub to: MaybeEmpty<Address>,
/// Value set. /// Value set.
pub value: Vec<Uint>, pub value: Vec<Uint>,
/// Max fee per gas.
pub max_fee_per_gas: Option<Uint>,
/// Max priority fee per gas.
pub max_priority_fee_per_gas: Option<Uint>,
} }
fn sign_with_secret(tx: TypedTransaction, secret: Option<Secret>) -> SignedTransaction { fn sign_with_secret(tx: TypedTransaction, secret: Option<Secret>) -> SignedTransaction {
@ -113,7 +117,10 @@ impl MultiTransaction {
let to: Option<Address> = self.to.clone().into(); let to: Option<Address> = self.to.clone().into();
let transaction = Transaction { let transaction = Transaction {
nonce: self.nonce.clone().into(), nonce: self.nonce.clone().into(),
gas_price: self.gas_price.clone().into(), gas_price: match self.gas_price {
Some(x) => x.into(),
None => self.max_fee_per_gas.unwrap().into(),
},
gas: self.gas_limit[indexes.gas as usize].clone().into(), gas: self.gas_limit[indexes.gas as usize].clone().into(),
action: match to { action: match to {
Some(to) => Action::Call(to.into()), Some(to) => Action::Call(to.into()),
@ -126,7 +133,7 @@ impl MultiTransaction {
if let Some(access_lists) = self.access_lists.as_ref() { if let Some(access_lists) = self.access_lists.as_ref() {
if access_lists.len() > indexes.data as usize { if access_lists.len() > indexes.data as usize {
if let Some(access_list) = access_lists[indexes.data as usize].clone() { if let Some(access_list) = access_lists[indexes.data as usize].clone() {
//access list type of transaction //access list exist
let access_list = access_list let access_list = access_list
.into_iter() .into_iter()
@ -138,19 +145,50 @@ impl MultiTransaction {
}) })
.collect(); .collect();
let tx = TypedTransaction::AccessList(AccessListTx { let al_tx = AccessListTx {
transaction, transaction,
access_list, access_list,
}); };
match self.gas_price {
Some(_) => {
let tx = TypedTransaction::AccessList(al_tx);
return sign_with_secret(tx, secret);
}
None => {
let tx = TypedTransaction::EIP1559Transaction(EIP1559TransactionTx {
transaction: al_tx,
max_priority_fee_per_gas: self
.max_priority_fee_per_gas
.unwrap()
.into(),
});
return sign_with_secret(tx, secret); return sign_with_secret(tx, secret);
} }
} }
} }
}
};
match self.gas_price {
Some(_) => {
let tx = TypedTransaction::Legacy(transaction); let tx = TypedTransaction::Legacy(transaction);
sign_with_secret(tx, secret) sign_with_secret(tx, secret)
} }
None => {
let al_tx = AccessListTx {
transaction,
access_list: common_types::transaction::AccessList::default(),
};
let tx = TypedTransaction::EIP1559Transaction(EIP1559TransactionTx {
transaction: al_tx,
max_priority_fee_per_gas: self.max_priority_fee_per_gas.unwrap().into(),
});
sign_with_secret(tx, secret)
}
}
}
} }
/// State test indexes deserialization. /// State test indexes deserialization.

View File

@ -32,7 +32,7 @@ pub struct Transaction {
/// Gas limit. /// Gas limit.
pub gas_limit: Uint, pub gas_limit: Uint,
/// Gas price. /// Gas price.
pub gas_price: Uint, pub gas_price: Option<Uint>,
/// Nonce. /// Nonce.
pub nonce: Uint, pub nonce: Uint,
/// Secret key. /// Secret key.
@ -42,6 +42,10 @@ pub struct Transaction {
pub to: MaybeEmpty<Address>, pub to: MaybeEmpty<Address>,
/// Value. /// Value.
pub value: Uint, pub value: Uint,
/// Max fee per gas.
pub max_fee_per_gas: Option<Uint>,
/// Max priority fee per gas.
pub max_priority_fee_per_gas: Option<Uint>,
} }
#[cfg(test)] #[cfg(test)]

View File

@ -36,7 +36,7 @@ pub struct Env {
#[serde(rename = "currentTimestamp")] #[serde(rename = "currentTimestamp")]
pub timestamp: Uint, pub timestamp: Uint,
/// Block base fee. /// Block base fee.
#[serde(rename = "currentBlockBaseFee")] #[serde(rename = "currentBaseFee")]
pub base_fee: Option<Uint>, pub base_fee: Option<Uint>,
} }