validate mainnet specs against all forks (#11625)
* ethcore/res: move test specifications in test-specs subdirectory * ethcore/spec: update paths for test machines * scripts/actions: validate mainnet specs against all forks * fix unexpected end of macro invocation * scripts/actions: remove first empty line Co-Authored-By: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
parent
4b5e9ddfa6
commit
2a3b321a34
@ -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")) }
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
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)]
|
||||
|
@ -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 "*** 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
|
||||
|
Loading…
Reference in New Issue
Block a user