2019-09-03 03:12:09 +00:00
|
|
|
# beacon_chain
|
|
|
|
# Copyright (c) 2018-Present Status Research & Development GmbH
|
|
|
|
# Licensed and distributed under either of
|
2019-11-25 15:30:02 +00:00
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
2019-09-03 03:12:09 +00:00
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2019-11-14 10:47:55 +00:00
|
|
|
{.used.}
|
|
|
|
|
2019-09-03 03:12:09 +00:00
|
|
|
import
|
|
|
|
# Standard library
|
2021-04-28 16:41:02 +00:00
|
|
|
os, strutils,
|
2019-09-03 03:12:09 +00:00
|
|
|
# Beacon chain internals
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
../../../beacon_chain/spec/[presets, state_transition_epoch],
|
2021-05-30 20:23:10 +00:00
|
|
|
../../../beacon_chain/spec/[datatypes/altair, beaconstate],
|
2019-09-03 03:12:09 +00:00
|
|
|
# Test utilities
|
2021-05-28 20:32:26 +00:00
|
|
|
../../testutil,
|
|
|
|
../fixtures_utils,
|
|
|
|
../test_fixture_rewards,
|
|
|
|
../../helpers/debug_state
|
2019-09-03 03:12:09 +00:00
|
|
|
|
2021-05-28 20:32:26 +00:00
|
|
|
from ../../../beacon_chain/spec/beaconstate import process_registry_updates
|
2019-09-03 03:12:09 +00:00
|
|
|
# XXX: move to state_transition_epoch?
|
|
|
|
|
2021-05-30 20:23:10 +00:00
|
|
|
template runSuite(
|
|
|
|
suiteDir, testName: string, transitionProc: untyped{ident},
|
|
|
|
useCache, useTAB: static bool = false): untyped =
|
2021-05-28 20:32:26 +00:00
|
|
|
suite "Official - Altair - Epoch Processing - " & testName & preset():
|
2021-04-28 16:41:02 +00:00
|
|
|
doAssert dirExists(suiteDir)
|
2021-07-05 18:40:09 +00:00
|
|
|
for testDir in walkDirRec(suiteDir, yieldFilter = {pcDir}, checkDir = true):
|
2021-04-28 16:41:02 +00:00
|
|
|
|
|
|
|
let unitTestName = testDir.rsplit(DirSep, 1)[1]
|
|
|
|
test testName & " - " & unitTestName & preset():
|
|
|
|
# BeaconState objects are stored on the heap to avoid stack overflow
|
2021-05-24 08:42:40 +00:00
|
|
|
var preState = newClone(parseTest(testDir/"pre.ssz_snappy", SSZ, BeaconState))
|
|
|
|
let postState = newClone(parseTest(testDir/"post.ssz_snappy", SSZ, BeaconState))
|
2021-04-28 16:41:02 +00:00
|
|
|
|
2021-05-30 20:23:10 +00:00
|
|
|
doAssert not (useCache and useTAB)
|
2021-04-28 16:41:02 +00:00
|
|
|
when useCache:
|
|
|
|
var cache = StateCache()
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
when compiles(transitionProc(defaultRuntimeConfig, preState[], cache)):
|
|
|
|
transitionProc(defaultRuntimeConfig, preState[], cache)
|
|
|
|
else:
|
|
|
|
transitionProc(preState[], cache)
|
2021-05-30 20:23:10 +00:00
|
|
|
elif useTAB:
|
|
|
|
var cache = StateCache()
|
|
|
|
let total_active_balance = preState[].get_total_active_balance(cache)
|
|
|
|
transitionProc(preState[], total_active_balance)
|
2021-04-28 16:41:02 +00:00
|
|
|
else:
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
when compiles(transitionProc(preState[])):
|
|
|
|
transitionProc(preState[])
|
|
|
|
else:
|
|
|
|
transitionProc(defaultRuntimeConfig, preState[])
|
2021-04-28 16:41:02 +00:00
|
|
|
|
|
|
|
reportDiff(preState, postState)
|
2019-09-03 03:12:09 +00:00
|
|
|
|
|
|
|
# Justification & Finalization
|
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
2021-05-28 15:25:58 +00:00
|
|
|
const JustificationFinalizationDir = SszTestsDir/const_preset/"altair"/"epoch_processing"/"justification_and_finalization"/"pyspec_tests"
|
2021-05-30 20:23:10 +00:00
|
|
|
runSuite(JustificationFinalizationDir, "Justification & Finalization", process_justification_and_finalization, useCache = false, useTAB = true)
|
|
|
|
|
|
|
|
# Inactivity updates
|
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
|
|
|
const InactivityDir = SszTestsDir/const_preset/"altair"/"epoch_processing"/"inactivity_updates"/"pyspec_tests"
|
|
|
|
runSuite(InactivityDir, "Inactivity", process_inactivity_updates, useCache = false)
|
2019-09-03 03:12:09 +00:00
|
|
|
|
|
|
|
# Rewards & Penalties
|
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
2020-08-17 01:09:27 +00:00
|
|
|
# in test_fixture_rewards
|
2019-09-03 03:12:09 +00:00
|
|
|
|
|
|
|
# Registry updates
|
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
2021-05-28 15:25:58 +00:00
|
|
|
const RegistryUpdatesDir = SszTestsDir/const_preset/"altair"/"epoch_processing"/"registry_updates"/"pyspec_tests"
|
2020-06-03 05:42:08 +00:00
|
|
|
runSuite(RegistryUpdatesDir, "Registry updates", process_registry_updates, useCache = true)
|
2019-09-03 03:12:09 +00:00
|
|
|
|
|
|
|
# Slashings
|
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
2021-05-28 15:25:58 +00:00
|
|
|
const SlashingsDir = SszTestsDir/const_preset/"altair"/"epoch_processing"/"slashings"/"pyspec_tests"
|
2021-05-30 20:23:10 +00:00
|
|
|
runSuite(SlashingsDir, "Slashings", process_slashings, useCache = false, useTAB = true)
|
2019-09-03 03:12:09 +00:00
|
|
|
|
2021-05-30 20:23:10 +00:00
|
|
|
# Eth1 data reset
|
2019-09-05 10:27:26 +00:00
|
|
|
# ---------------------------------------------------------------
|
2019-09-03 03:12:09 +00:00
|
|
|
|
2021-05-28 15:25:58 +00:00
|
|
|
const Eth1DataResetDir = SszTestsDir/const_preset/"altair"/"epoch_processing"/"eth1_data_reset/"/"pyspec_tests"
|
2021-05-24 08:42:40 +00:00
|
|
|
runSuite(Eth1DataResetDir, "Eth1 data reset", process_eth1_data_reset, useCache = false)
|
|
|
|
|
2021-05-30 20:23:10 +00:00
|
|
|
# Effective balance updates
|
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
2021-05-28 15:25:58 +00:00
|
|
|
const EffectiveBalanceUpdatesDir = SszTestsDir/const_preset/"altair"/"epoch_processing"/"effective_balance_updates"/"pyspec_tests"
|
2021-05-24 08:42:40 +00:00
|
|
|
runSuite(EffectiveBalanceUpdatesDir, "Effective balance updates", process_effective_balance_updates, useCache = false)
|
|
|
|
|
2021-05-30 20:23:10 +00:00
|
|
|
# Slashings reset
|
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
2021-05-28 15:25:58 +00:00
|
|
|
const SlashingsResetDir = SszTestsDir/const_preset/"altair"/"epoch_processing"/"slashings_reset"/"pyspec_tests"
|
2021-05-24 08:42:40 +00:00
|
|
|
runSuite(SlashingsResetDir, "Slashings reset", process_slashings_reset, useCache = false)
|
|
|
|
|
2021-05-30 20:23:10 +00:00
|
|
|
# RANDAO mixes reset
|
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
2021-05-28 15:25:58 +00:00
|
|
|
const RandaoMixesResetDir = SszTestsDir/const_preset/"altair"/"epoch_processing"/"randao_mixes_reset"/"pyspec_tests"
|
2021-05-24 08:42:40 +00:00
|
|
|
runSuite(RandaoMixesResetDir, "RANDAO mixes reset", process_randao_mixes_reset, useCache = false)
|
|
|
|
|
2021-05-30 20:23:10 +00:00
|
|
|
# Historical roots update
|
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
2021-05-28 15:25:58 +00:00
|
|
|
const HistoricalRootsUpdateDir = SszTestsDir/const_preset/"altair"/"epoch_processing"/"historical_roots_update"/"pyspec_tests"
|
2021-05-24 08:42:40 +00:00
|
|
|
runSuite(HistoricalRootsUpdateDir, "Historical roots update", process_historical_roots_update, useCache = false)
|
|
|
|
|
2021-05-30 20:23:10 +00:00
|
|
|
# Participation flag updates
|
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
|
|
|
const ParticipationFlagDir = SszTestsDir/const_preset/"altair"/"epoch_processing"/"participation_flag_updates"/"pyspec_tests"
|
|
|
|
runSuite(ParticipationFlagDir, "Participation flag updates", process_participation_flag_updates, useCache = false)
|
|
|
|
|
|
|
|
# Sync committee updates
|
|
|
|
# ---------------------------------------------------------------
|
|
|
|
|
|
|
|
const SyncCommitteeDir = SszTestsDir/const_preset/"altair"/"epoch_processing"/"sync_committee_updates"/"pyspec_tests"
|
|
|
|
runSuite(SyncCommitteeDir, "Sync committee updates", process_sync_committee_updates, useCache = false)
|