Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Update JSON tests to d4f86ecf4aa7c (#11054)
Browse files Browse the repository at this point in the history
* new ethereum consensus tests, #10908

* Update JSON tests to 725dbc73a

This PR reverts the controversial changes of the previous PR and skips the failing tests.

Maybe I misunderstand the suggested workaround of putting the fix under `#[cfg(test)]` but it seems odd to run different code in production than we run in tests. Instead here I suggest we skip the failing tests with the argument that we do not wish to fix this issue (at least not at this time) because it does not affect us. If I am wrong, and I likely am, I look forward to hearing why and what a better approach to updating the state tests is.

Branched off #10923

ref #10908

* Update json test commit to 1dc9d20e97165708f7db0bbf2d1a87a6b4285827

* Fail with error message

* Handle missing r, s, v params in json tests
Light cleanup of json test runner

* Include the path to the test file

* Handle new `postState` format: string or map
Sort out tests
Missing docs

* WIP

* Include test-helpers from ethjson

* Sort out new paths

* Remove dead code

* Fix warnings stemming from code called only from macros
Skip failing tests in stRevert/ and stTransactionTest/ (too course a filter!)
Docs and light touch refactorings for readability

* Skip all failing tests

* Document the single-test-skipping madness

* Update tests to latest commit on the `develop` branch

* Rename test skipping types to reflect actual purpose

* Switch to skipping individual tests in currents.json
Add some logging to help debug skipping

* Fix rpc test by curve fitting to new json test source file

* Add refs to all issues for fixing failing&skipped json tests

* Sort out the need for Clone for tests

* [json-tests] populate state from genesis pod state (#11083)

* [json-tests] populate state from genesis pod state

* [json-tests] #11075 is resolved as well

* [json-tests] #11076 hopefully too

* [json-tests] #11077 🎉

* [json-tests] fix trailing comma

* Update ethcore/src/json_tests/chain.rs

Co-Authored-By: Andronik Ordian <[email protected]>

* Add issue numbers to TODOs

* Apply @ordians fix for wrong state_root

* Warn on invalid RLP

* Remove the `ci-skip-tests` feature
  • Loading branch information
dvdplm committed Sep 25, 2019
1 parent 7f5ac8b commit d9201aa
Show file tree
Hide file tree
Showing 26 changed files with 447 additions and 275 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ default = ["accounts"]
accounts = ["ethcore-accounts", "parity-rpc/accounts"]
miner-debug = ["ethcore/miner-debug"]
json-tests = ["ethcore/json-tests"]
ci-skip-tests = ["ethcore/ci-skip-tests"]
test-heavy = ["ethcore/test-heavy"]
evm-debug = ["ethcore/evm-debug"]
evm-debug-tests = ["ethcore/evm-debug-tests"]
Expand Down
4 changes: 1 addition & 3 deletions ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,13 @@ evm-debug-tests = ["evm-debug", "evm/evm-debug-tests"]
slow-blocks = []
# Run JSON consensus tests.
json-tests = ["env_logger", "test-helpers", "lazy_static", "machine/test-helpers"]
# Skip JSON consensus tests with pending issues.
ci-skip-tests = []
# Run memory/cpu heavy tests.
test-heavy = []
# Compile test helpers
# note[dvdplm]: "basic-authority/test-helpers" is needed so that `generate_dummy_client_with_spec` works
test-helpers = [
"blooms-db",
"ethjson",
"ethjson/test-helpers",
"ethkey",
"kvdb-memorydb",
"kvdb-rocksdb",
Expand Down
2 changes: 1 addition & 1 deletion ethcore/account-state/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ impl<B: Backend> State<B> {
/// Propagate local cache into shared canonical state cache.
fn propagate_to_global_cache(&mut self) {
let mut addresses = self.cache.borrow_mut();
trace!("Committing cache {:?} entries", addresses.len());
trace!(target: "state", "Committing cache {:?} entries", addresses.len());
for (address, a) in addresses.drain().filter(|&(_, ref a)| a.state == AccountState::Committed || a.state == AccountState::CleanFresh) {
self.db.add_to_account_cache(address, a.account, a.state == AccountState::Committed);
}
Expand Down
2 changes: 1 addition & 1 deletion ethcore/res/ethereum/tests
Submodule tests updated from 725dbc to d4f86e
57 changes: 55 additions & 2 deletions ethcore/res/ethereum/tests-issues/currents.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,57 @@
{
"block": [],
"state": []
"block": [
{
"reference": "Issue https://github.com/paritytech/parity-ethereum/issues/11073 (also see https://github.com/paritytech/parity-ethereum/pull/10923)",
"failing": "stRevertTest",
"subtests": [
"RevertPrecompiledTouch_d0g0v0_Byzantium",
"RevertPrecompiledTouch_d0g0v0_Constantinople",
"RevertPrecompiledTouch_d0g0v0_ConstantinopleFix",
"RevertPrecompiledTouch_d0g0v0_EIP158",
"RevertPrecompiledTouch_d3g0v0_ConstantinopleFix",
"RevertPrecompiledTouchCC_d0g0v0_Byzantium",
"RevertPrecompiledTouchCC_d0g0v0_Constantinople",
"RevertPrecompiledTouchCC_d0g0v0_EIP158",
"RevertPrecompiledTouchDC_d0g0v0_Byzantium",
"RevertPrecompiledTouchDC_d0g0v0_Constantinople",
"RevertPrecompiledTouchDC_d0g0v0_EIP158",
"RevertPrecompiledTouchExactOOG_d7g1v0_ConstantinopleFix",
"RevertPrecompiledTouchExactOOG_d31g1v0_ConstantinopleFix",
"RevertPrecompiledTouch_storage_d3g0v0_ConstantinopleFix",
"RevertPrecompiledTouch_storage_d0g0v0_ConstantinopleFix"
]
}
],
"state": [
{
"reference": "Issue https://github.com/paritytech/parity-ethereum/issues/11078 (also see https://github.com/paritytech/parity-ethereum/pull/10923)",
"failing": "stRevertTest",
"subtests": {
"RevertPrecompiledTouch_storage": {
"subnumbers": ["1", "2"],
"chain": "St. Peter's (test)"
}
}
},
{
"reference": "Issue https://github.com/paritytech/parity-ethereum/issues/11079 (also see https://github.com/paritytech/parity-ethereum/pull/10923)",
"failing": "stRevertTest",
"subtests": {
"RevertPrecompiledTouchExactOOG": {
"subnumbers": ["61", "64"],
"chain": "St. Peter's (test)"
}
}
},
{
"reference": "Issue https://github.com/paritytech/parity-ethereum/issues/11080 (also see https://github.com/paritytech/parity-ethereum/pull/10923)",
"failing": "stRevertTest",
"subtests": {
"RevertPrecompiledTouch": {
"subnumbers": ["1", "2"],
"chain": "St. Peter's (test)"
}
}
}
]
}
1 change: 1 addition & 0 deletions ethcore/spec/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use keccak_hash::KECCAK_NULL_RLP;
use crate::seal::Seal;

/// Genesis components.
#[derive(Debug)]
pub struct Genesis {
/// Seal.
pub seal: Seal,
Expand Down
5 changes: 5 additions & 0 deletions ethcore/spec/src/seal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use ethereum_types::{H64, H256, H520};
use ethjson;

/// Classic ethereum seal.
#[derive(Debug)]
pub struct Ethereum {
/// Seal nonce.
pub nonce: H64,
Expand All @@ -37,6 +38,7 @@ impl Into<Generic> for Ethereum {
}

/// AuthorityRound seal.
#[derive(Debug)]
pub struct AuthorityRound {
/// Seal step.
pub step: usize,
Expand All @@ -45,6 +47,7 @@ pub struct AuthorityRound {
}

/// Tendermint seal.
#[derive(Debug)]
pub struct Tendermint {
/// Seal round.
pub round: usize,
Expand Down Expand Up @@ -73,9 +76,11 @@ impl Into<Generic> for Tendermint {
}
}

#[derive(Debug)]
pub struct Generic(pub Vec<u8>);

/// Genesis seal type.
#[derive(Debug)]
pub enum Seal {
/// Classic ethereum seal.
Ethereum(Ethereum),
Expand Down
90 changes: 45 additions & 45 deletions ethcore/spec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ use crate::{
seal::Generic as GenericSeal,
};




/// Runtime parameters for the spec that are related to how the software should run the chain,
/// rather than integral properties of the chain itself.
pub struct SpecParams<'a> {
Expand Down Expand Up @@ -134,53 +131,56 @@ fn run_constructors<T: Backend>(
let start_nonce = engine.account_start_nonce(0);

let mut state = State::from_existing(db, root, start_nonce, factories.clone())?;

// Execute contract constructors.
let env_info = EnvInfo {
number: 0,
author,
timestamp,
difficulty,
last_hashes: Default::default(),
gas_used: U256::zero(),
gas_limit: U256::max_value(),
};

let from = Address::zero();
for &(ref address, ref constructor) in constructors.iter() {
trace!(target: "spec", "run_constructors: Creating a contract at {}.", address);
trace!(target: "spec", " .. root before = {}", state.root());
let params = ActionParams {
code_address: address.clone(),
code_hash: Some(keccak(constructor)),
code_version: U256::zero(),
address: address.clone(),
sender: from.clone(),
origin: from.clone(),
gas: U256::max_value(),
gas_price: Default::default(),
value: ActionValue::Transfer(Default::default()),
code: Some(Arc::new(constructor.clone())),
data: None,
call_type: CallType::None,
params_type: ParamsType::Embedded,
if constructors.is_empty() {
state.populate_from(genesis_state.clone());
let _ = state.commit()?;
} else {
// Execute contract constructors.
let env_info = EnvInfo {
number: 0,
author,
timestamp,
difficulty,
last_hashes: Default::default(),
gas_used: U256::zero(),
gas_limit: U256::max_value(),
};

let mut substate = Substate::new();
let from = Address::zero();
for &(ref address, ref constructor) in constructors.iter() {
trace!(target: "spec", "run_constructors: Creating a contract at {}.", address);
trace!(target: "spec", " .. root before = {}", state.root());
let params = ActionParams {
code_address: address.clone(),
code_hash: Some(keccak(constructor)),
code_version: U256::zero(),
address: address.clone(),
sender: from.clone(),
origin: from.clone(),
gas: U256::max_value(),
gas_price: Default::default(),
value: ActionValue::Transfer(Default::default()),
code: Some(Arc::new(constructor.clone())),
data: None,
call_type: CallType::None,
params_type: ParamsType::Embedded,
};

let mut substate = Substate::new();

{
let machine = engine.machine();
let schedule = machine.schedule(env_info.number);
let mut exec = Executive::new(&mut state, &env_info, &machine, &schedule);
// failing create is not a bug
if let Err(e) = exec.create(params, &mut substate, &mut NoopTracer, &mut NoopVMTracer) {
warn!(target: "spec", "Genesis constructor execution at {} failed: {}.", address, e);
{
let machine = engine.machine();
let schedule = machine.schedule(env_info.number);
let mut exec = Executive::new(&mut state, &env_info, &machine, &schedule);
// failing create is not a bug
if let Err(e) = exec.create(params, &mut substate, &mut NoopTracer, &mut NoopVMTracer) {
warn!(target: "spec", "Genesis constructor execution at {} failed: {}.", address, e);
}
}
}

let _ = state.commit()?;
let _ = state.commit()?;
}
}

Ok(state.drop())
}

Expand Down Expand Up @@ -219,7 +219,7 @@ pub struct Spec {
pub hardcoded_sync: Option<SpecHardcodedSync>,
/// Contract constructors to be executed on genesis.
pub constructors: Vec<(Address, Bytes)>,
/// May be prepopulated if we know this in advance.
/// May be pre-populated if we know this in advance.
pub state_root: H256,
/// Genesis state as plain old data.
pub genesis_state: PodState,
Expand Down
Loading

0 comments on commit d9201aa

Please sign in to comment.