From e464dbca29268e35abb258d7373b63ac4803e303 Mon Sep 17 00:00:00 2001 From: /raw PONG _GHMoaCXLT <58883403+q9f@users.noreply.github.com> Date: Sat, 11 Apr 2020 15:16:50 +0200 Subject: [PATCH 1/5] ethcore/res: move test specifications in test-specs subdirectory --- ethcore/res/ethereum/{ => test-specs}/berlin_test.json | 0 ethcore/res/ethereum/{ => test-specs}/byzantium_test.json | 0 ethcore/res/ethereum/{ => test-specs}/constantinople_test.json | 0 ethcore/res/ethereum/{ => test-specs}/eip150_test.json | 0 ethcore/res/ethereum/{ => test-specs}/eip161_test.json | 0 ethcore/res/ethereum/{ => test-specs}/eip210_test.json | 0 ethcore/res/ethereum/{ => test-specs}/frontier_like_test.json | 0 ethcore/res/ethereum/{ => test-specs}/frontier_test.json | 0 ethcore/res/ethereum/{ => test-specs}/homestead_test.json | 0 ethcore/res/ethereum/{ => test-specs}/istanbul_test.json | 0 ethcore/res/ethereum/{ => test-specs}/kovan_wasm_test.json | 0 ethcore/res/ethereum/{ => test-specs}/mcip3_test.json | 0 ethcore/res/ethereum/{ => test-specs}/st_peters_test.json | 0 ethcore/res/ethereum/{ => test-specs}/transition_test.json | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename ethcore/res/ethereum/{ => test-specs}/berlin_test.json (100%) rename ethcore/res/ethereum/{ => test-specs}/byzantium_test.json (100%) rename ethcore/res/ethereum/{ => test-specs}/constantinople_test.json (100%) rename ethcore/res/ethereum/{ => test-specs}/eip150_test.json (100%) rename ethcore/res/ethereum/{ => test-specs}/eip161_test.json (100%) rename ethcore/res/ethereum/{ => test-specs}/eip210_test.json (100%) rename ethcore/res/ethereum/{ => test-specs}/frontier_like_test.json (100%) rename ethcore/res/ethereum/{ => test-specs}/frontier_test.json (100%) rename ethcore/res/ethereum/{ => test-specs}/homestead_test.json (100%) rename ethcore/res/ethereum/{ => test-specs}/istanbul_test.json (100%) rename ethcore/res/ethereum/{ => test-specs}/kovan_wasm_test.json (100%) rename ethcore/res/ethereum/{ => test-specs}/mcip3_test.json (100%) rename ethcore/res/ethereum/{ => test-specs}/st_peters_test.json (100%) rename ethcore/res/ethereum/{ => test-specs}/transition_test.json (100%) diff --git a/ethcore/res/ethereum/berlin_test.json b/ethcore/res/ethereum/test-specs/berlin_test.json similarity index 100% rename from ethcore/res/ethereum/berlin_test.json rename to ethcore/res/ethereum/test-specs/berlin_test.json diff --git a/ethcore/res/ethereum/byzantium_test.json b/ethcore/res/ethereum/test-specs/byzantium_test.json similarity index 100% rename from ethcore/res/ethereum/byzantium_test.json rename to ethcore/res/ethereum/test-specs/byzantium_test.json diff --git a/ethcore/res/ethereum/constantinople_test.json b/ethcore/res/ethereum/test-specs/constantinople_test.json similarity index 100% rename from ethcore/res/ethereum/constantinople_test.json rename to ethcore/res/ethereum/test-specs/constantinople_test.json diff --git a/ethcore/res/ethereum/eip150_test.json b/ethcore/res/ethereum/test-specs/eip150_test.json similarity index 100% rename from ethcore/res/ethereum/eip150_test.json rename to ethcore/res/ethereum/test-specs/eip150_test.json diff --git a/ethcore/res/ethereum/eip161_test.json b/ethcore/res/ethereum/test-specs/eip161_test.json similarity index 100% rename from ethcore/res/ethereum/eip161_test.json rename to ethcore/res/ethereum/test-specs/eip161_test.json diff --git a/ethcore/res/ethereum/eip210_test.json b/ethcore/res/ethereum/test-specs/eip210_test.json similarity index 100% rename from ethcore/res/ethereum/eip210_test.json rename to ethcore/res/ethereum/test-specs/eip210_test.json diff --git a/ethcore/res/ethereum/frontier_like_test.json b/ethcore/res/ethereum/test-specs/frontier_like_test.json similarity index 100% rename from ethcore/res/ethereum/frontier_like_test.json rename to ethcore/res/ethereum/test-specs/frontier_like_test.json diff --git a/ethcore/res/ethereum/frontier_test.json b/ethcore/res/ethereum/test-specs/frontier_test.json similarity index 100% rename from ethcore/res/ethereum/frontier_test.json rename to ethcore/res/ethereum/test-specs/frontier_test.json diff --git a/ethcore/res/ethereum/homestead_test.json b/ethcore/res/ethereum/test-specs/homestead_test.json similarity index 100% rename from ethcore/res/ethereum/homestead_test.json rename to ethcore/res/ethereum/test-specs/homestead_test.json diff --git a/ethcore/res/ethereum/istanbul_test.json b/ethcore/res/ethereum/test-specs/istanbul_test.json similarity index 100% rename from ethcore/res/ethereum/istanbul_test.json rename to ethcore/res/ethereum/test-specs/istanbul_test.json diff --git a/ethcore/res/ethereum/kovan_wasm_test.json b/ethcore/res/ethereum/test-specs/kovan_wasm_test.json similarity index 100% rename from ethcore/res/ethereum/kovan_wasm_test.json rename to ethcore/res/ethereum/test-specs/kovan_wasm_test.json diff --git a/ethcore/res/ethereum/mcip3_test.json b/ethcore/res/ethereum/test-specs/mcip3_test.json similarity index 100% rename from ethcore/res/ethereum/mcip3_test.json rename to ethcore/res/ethereum/test-specs/mcip3_test.json diff --git a/ethcore/res/ethereum/st_peters_test.json b/ethcore/res/ethereum/test-specs/st_peters_test.json similarity index 100% rename from ethcore/res/ethereum/st_peters_test.json rename to ethcore/res/ethereum/test-specs/st_peters_test.json diff --git a/ethcore/res/ethereum/transition_test.json b/ethcore/res/ethereum/test-specs/transition_test.json similarity index 100% rename from ethcore/res/ethereum/transition_test.json rename to ethcore/res/ethereum/test-specs/transition_test.json From 4501e0d5c8fbcf98dc41b540e46a8a98ca6f1d3b Mon Sep 17 00:00:00 2001 From: /raw PONG _GHMoaCXLT <58883403+q9f@users.noreply.github.com> Date: Sat, 11 Apr 2020 15:17:50 +0200 Subject: [PATCH 2/5] ethcore/spec: update paths for test machines --- ethcore/machine/src/test_helpers.rs | 20 ++++---- ethcore/spec/src/chain.rs | 79 ++++++++++++++++++----------- 2 files changed, 58 insertions(+), 41 deletions(-) diff --git a/ethcore/machine/src/test_helpers.rs b/ethcore/machine/src/test_helpers.rs index fd8793b50e6..e781c3513a3 100644 --- a/ethcore/machine/src/test_helpers.rs +++ b/ethcore/machine/src/test_helpers.rs @@ -35,31 +35,31 @@ pub fn load_machine(reader: &[u8]) -> Machine { } /// Create a new Foundation Frontier-era chain spec as though it never changes to Homestead. -pub fn new_frontier_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/frontier_test.json")) } +pub fn new_frontier_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/frontier_test.json")) } /// Create a new Foundation Homestead-era chain spec as though it never changed from Frontier. -pub fn new_homestead_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/homestead_test.json")) } +pub fn new_homestead_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/homestead_test.json")) } /// Create a new Foundation Homestead-EIP210-era chain spec as though it never changed from Homestead/Frontier. -pub fn new_eip210_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/eip210_test.json")) } +pub fn new_eip210_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/eip210_test.json")) } /// Create a new Foundation Byzantium era spec. -pub fn new_byzantium_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/byzantium_test.json")) } +pub fn new_byzantium_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/byzantium_test.json")) } /// Create a new Foundation Constantinople era spec. -pub fn new_constantinople_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/constantinople_test.json")) } +pub fn new_constantinople_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/constantinople_test.json")) } /// Create a new Foundation St. Peter's (Contantinople Fix) era spec. -pub fn new_constantinople_fix_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/st_peters_test.json")) } +pub fn new_constantinople_fix_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/st_peters_test.json")) } /// Create a new Foundation Istanbul era spec. -pub fn new_istanbul_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/istanbul_test.json")) } +pub fn new_istanbul_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/istanbul_test.json")) } /// Create a new Foundation Berlin era spec. -pub fn new_berlin_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/berlin_test.json")) } +pub fn new_berlin_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/berlin_test.json")) } /// Create a new Musicoin-MCIP3-era spec. -pub fn new_mcip3_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/mcip3_test.json")) } +pub fn new_mcip3_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/mcip3_test.json")) } /// Create new Kovan spec with wasm activated at certain block -pub fn new_kovan_wasm_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/kovan_wasm_test.json")) } +pub fn new_kovan_wasm_test_machine() -> Machine { load_machine(include_bytes!("../../res/ethereum/test-specs/kovan_wasm_test.json")) } diff --git a/ethcore/spec/src/chain.rs b/ethcore/spec/src/chain.rs index 3c53e437461..a81c2a2de1c 100644 --- a/ethcore/spec/src/chain.rs +++ b/ethcore/spec/src/chain.rs @@ -45,6 +45,20 @@ macro_rules! bundle_test_spec { } } +macro_rules! bundle_custom_spec { + ($($path: expr => $name: ident), *) => { + $( + /// Bundled test spec + pub fn $name() -> crate::spec::Spec { + crate::spec::Spec::load( + &::std::env::temp_dir(), + include_bytes!(concat!("../../res/", $path, ".json")) as &[u8] + ).expect(concat!("Chain spec ", $path, " is invalid.")) + } + )* + } +} + macro_rules! bundle_test_machine { ($($path: expr => $name: ident), *) => { $( @@ -62,8 +76,10 @@ bundle_release_spec! { "ethereum/callisto" => new_callisto, "ethereum/classic" => new_classic, "ethereum/ellaism" => new_ellaism, - "ethereum/evantestcore" => new_evantestcore, + "ethereum/ethercore" => new_ethercore, "ethereum/evancore" => new_evancore, + "ethereum/evantestcore" => new_evantestcore, + "ethereum/ewc" => new_ewc, "ethereum/expanse" => new_expanse, "ethereum/foundation" => new_foundation, "ethereum/goerli" => new_goerli, @@ -73,57 +89,58 @@ bundle_release_spec! { "ethereum/mordor" => new_mordor, "ethereum/musicoin" => new_musicoin, "ethereum/poacore" => new_poanet, - "ethereum/xdai" => new_xdai, - "ethereum/ethercore" => new_ethercore, "ethereum/poasokol" => new_sokol, "ethereum/rinkeby" => new_rinkeby, "ethereum/ropsten" => new_ropsten, "ethereum/volta" => new_volta, - "ethereum/ewc" => new_ewc + "ethereum/xdai" => new_xdai, } bundle_test_spec! { + "ethereum/test-specs/berlin_test" => new_berlin_test, + "ethereum/test-specs/byzantium_test" => new_byzantium_test, + "ethereum/test-specs/constantinople_test" => new_constantinople_test, + "ethereum/test-specs/eip150_test" => new_eip150_test, + "ethereum/test-specs/eip161_test" => new_eip161_test, + "ethereum/test-specs/eip210_test" => new_eip210_test, + "ethereum/test-specs/frontier_like_test" => new_mainnet_like, + "ethereum/test-specs/frontier_test" => new_frontier_test, + "ethereum/test-specs/homestead_test" => new_homestead_test, + "ethereum/test-specs/istanbul_test" => new_istanbul_test, + "ethereum/test-specs/kovan_wasm_test" => new_kovan_wasm_test, + "ethereum/test-specs/mcip3_test" => new_mcip3_test, + "ethereum/test-specs/st_peters_test" => new_constantinople_fix_test, + "ethereum/test-specs/transition_test" => new_transition_test, +} + +bundle_custom_spec! { "authority_round" => new_test_round, "authority_round_block_reward_contract" => new_test_round_block_reward_contract, "authority_round_empty_steps" => new_test_round_empty_steps, "authority_round_randomness_contract" => new_test_round_randomness_contract, "constructor" => new_test_constructor, - "ethereum/byzantium_test" => new_byzantium_test, - "ethereum/constantinople_test" => new_constantinople_test, - "ethereum/istanbul_test" => new_istanbul_test, - "ethereum/berlin_test" => new_berlin_test, - "ethereum/eip150_test" => new_eip150_test, - "ethereum/eip161_test" => new_eip161_test, - "ethereum/eip210_test" => new_eip210_test, - "ethereum/frontier_like_test" => new_mainnet_like, - "ethereum/frontier_test" => new_frontier_test, - "ethereum/homestead_test" => new_homestead_test, - "ethereum/kovan_wasm_test" => new_kovan_wasm_test, - "ethereum/mcip3_test" => new_mcip3_test, - "ethereum/mordor" => new_mordor_test, - "ethereum/ropsten" => new_ropsten_test, - "ethereum/st_peters_test" => new_constantinople_fix_test, - "ethereum/transition_test" => new_transition_test, "instant_seal" => new_instant, "null" => new_null, "null_morden" => new_test, - "null_morden_with_reward" => new_test_with_reward, "null_morden_with_finality" => new_test_with_finality, + "null_morden_with_reward" => new_test_with_reward, "validator_contract" => new_validator_contract, "validator_multi" => new_validator_multi, - "validator_safe_contract" => new_validator_safe_contract + "validator_safe_contract" => new_validator_safe_contract, } bundle_test_machine! { - "ethereum/byzantium_test" => new_byzantium_test_machine, - "ethereum/constantinople_test" => new_constantinople_test_machine, - "ethereum/istanbul_test" => new_istanbul_test_machine, - "ethereum/berlin_test" => new_berlin_test_machine, - "ethereum/eip210_test" => new_eip210_test_machine, - "ethereum/frontier_test" => new_frontier_test_machine, - "ethereum/homestead_test" => new_homestead_test_machine, - "ethereum/kovan_wasm_test" => new_kovan_wasm_test_machine, - "null_morden" => new_test_machine + "null_morden" => new_test_machine, + "ethereum/test-specs/berlin_test" => new_berlin_test_machine, + "ethereum/test-specs/byzantium_test" => new_byzantium_test_machine, + "ethereum/test-specs/constantinople_test" => new_constantinople_test_machine, + "ethereum/test-specs/eip210_test" => new_eip210_test_machine, + "ethereum/test-specs/frontier_test" => new_frontier_test_machine, + "ethereum/test-specs/homestead_test" => new_homestead_test_machine, + "ethereum/test-specs/istanbul_test" => new_istanbul_test_machine, + "ethereum/test-specs/kovan_wasm_test" => new_kovan_wasm_test_machine, + "ethereum/test-specs/mcip3_test" => new_mcip3_test_machine, + "ethereum/test-specs/st_peters_test" => new_constantinople_fix_test_machine, } #[cfg(test)] From 9925743e9be55a78f172f2a793322a024d77ee1f Mon Sep 17 00:00:00 2001 From: /raw PONG _GHMoaCXLT <58883403+q9f@users.noreply.github.com> Date: Sat, 11 Apr 2020 15:19:17 +0200 Subject: [PATCH 3/5] scripts/actions: validate mainnet specs against all forks --- scripts/actions/validate-chainspecs.sh | 30 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/scripts/actions/validate-chainspecs.sh b/scripts/actions/validate-chainspecs.sh index bf88b74c08c..d0e8079a7ec 100755 --- a/scripts/actions/validate-chainspecs.sh +++ b/scripts/actions/validate-chainspecs.sh @@ -1,27 +1,37 @@ #!/bin/bash set -e # fail on any error set -u # treat unset variables as error -echo "________Running validate_chainspecs.sh________" - +echo -e "\n*** Running \`validate_chainspecs.sh\`" ERR=0 - -echo "________Validate chainspecs________" time cargo build --release -p chainspec --verbose --color=always +echo -e "\n*** Validating custom chain specifications:" for spec in ethcore/res/*.json; do if ! ./target/release/chainspec "$spec"; then ERR=1; fi done +echo -e "\n*** Validating test-chain specifications:" +for spec in ethcore/res/ethereum/test-specs/*.json; do + if ! ./target/release/chainspec "$spec"; then ERR=1; fi +done + +echo -e "\n*** Validating ethereum chain specifications:" for spec in ethcore/res/ethereum/*.json; do if ! ./target/release/chainspec "$spec"; then ERR=1; fi done -echo "________Mainnet contains Istanbul EIPs________" -for eip in $(grep --only-matching "eip.*Transition" ethcore/res/ethereum/istanbul_test.json); do - if ! grep -q $eip ethcore/res/ethereum/foundation.json; then - echo "ERROR: $eip is missing in the foundation json spec" - ERR=1 - fi +echo -e "\n*** Checking mainnet EIPs against test specifications:" +for spec in "ethcore/res/ethereum/foundation.json" "ethcore/res/ethereum/classic.json"; do + for fork in "frontier" "homestead" "byzantium" "constantinople" "st_peters" "istanbul"; do + for eip in $(grep --only-matching "eip.*Transition" ethcore/res/ethereum/test-specs/${fork}_test.json); do + if ! grep -q $eip $spec; then + echo "ERROR: $fork $eip is missing in the $spec" + ERR=1 + else + echo "$spec contains $fork $eip" + fi + done + done done exit $ERR From 1f6b32945fd4f1dddb9c4af33d70602c1812142e Mon Sep 17 00:00:00 2001 From: /raw PONG _GHMoaCXLT <58883403+q9f@users.noreply.github.com> Date: Sat, 11 Apr 2020 17:47:45 +0200 Subject: [PATCH 4/5] fix unexpected end of macro invocation --- ethcore/spec/src/chain.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ethcore/spec/src/chain.rs b/ethcore/spec/src/chain.rs index a81c2a2de1c..32385f31065 100644 --- a/ethcore/spec/src/chain.rs +++ b/ethcore/spec/src/chain.rs @@ -93,7 +93,7 @@ bundle_release_spec! { "ethereum/rinkeby" => new_rinkeby, "ethereum/ropsten" => new_ropsten, "ethereum/volta" => new_volta, - "ethereum/xdai" => new_xdai, + "ethereum/xdai" => new_xdai } bundle_test_spec! { @@ -110,7 +110,7 @@ bundle_test_spec! { "ethereum/test-specs/kovan_wasm_test" => new_kovan_wasm_test, "ethereum/test-specs/mcip3_test" => new_mcip3_test, "ethereum/test-specs/st_peters_test" => new_constantinople_fix_test, - "ethereum/test-specs/transition_test" => new_transition_test, + "ethereum/test-specs/transition_test" => new_transition_test } bundle_custom_spec! { @@ -126,7 +126,7 @@ bundle_custom_spec! { "null_morden_with_reward" => new_test_with_reward, "validator_contract" => new_validator_contract, "validator_multi" => new_validator_multi, - "validator_safe_contract" => new_validator_safe_contract, + "validator_safe_contract" => new_validator_safe_contract } bundle_test_machine! { @@ -140,7 +140,7 @@ bundle_test_machine! { "ethereum/test-specs/istanbul_test" => new_istanbul_test_machine, "ethereum/test-specs/kovan_wasm_test" => new_kovan_wasm_test_machine, "ethereum/test-specs/mcip3_test" => new_mcip3_test_machine, - "ethereum/test-specs/st_peters_test" => new_constantinople_fix_test_machine, + "ethereum/test-specs/st_peters_test" => new_constantinople_fix_test_machine } #[cfg(test)] From 371ba639b48d35c2a6f5ac851a5acad646006593 Mon Sep 17 00:00:00 2001 From: Raw Pong Ghmoa <58883403+q9f@users.noreply.github.com> Date: Tue, 14 Apr 2020 20:00:02 +0200 Subject: [PATCH 5/5] scripts/actions: remove first empty line Co-Authored-By: Niklas Adolfsson --- scripts/actions/validate-chainspecs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/actions/validate-chainspecs.sh b/scripts/actions/validate-chainspecs.sh index d0e8079a7ec..45680edd3f1 100755 --- a/scripts/actions/validate-chainspecs.sh +++ b/scripts/actions/validate-chainspecs.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e # fail on any error set -u # treat unset variables as error -echo -e "\n*** Running \`validate_chainspecs.sh\`" +echo -e "*** Running \`validate_chainspecs.sh\`" ERR=0 time cargo build --release -p chainspec --verbose --color=always