mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-01 09:17:52 +00:00
stop download 0.9.1 test vectors; finish 0.9.2 update, primarily via fixing preset constants; remove a couple 0.19.6 shims
This commit is contained in:
parent
f5b8931fad
commit
edfd65fd5d
@ -22,7 +22,7 @@ Nimbus is currently going through interoperability testing with several other be
|
||||
## Related
|
||||
|
||||
* [status-im/nimbus](https://github.com/status-im/nimbus/): main Nimbus repository - start here to learn more about the Nimbus eco-system
|
||||
* [ethereum/eth2.0-specs](https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/specs/core/0_beacon-chain.md): Serenity specification that this project implements
|
||||
* [ethereum/eth2.0-specs](https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md): Serenity specification that this project implements
|
||||
* [ethereum/beacon\_chain](https://github.com/ethereum/beacon_chain): reference implementation from the Ethereum foundation
|
||||
|
||||
You can check where the beacon chain fits in the Ethereum research ecosystem in the [Status Athenaeum](https://github.com/status-im/athenaeum/blob/b465626cc551e361492e56d32517b2cdadd7493f/ethereum_research_records.json#L38).
|
||||
|
@ -46,7 +46,7 @@ func decrease_balance*(
|
||||
else:
|
||||
state.balances[index] - delta
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#deposits
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.4/specs/core/0_beacon-chain.md#deposits
|
||||
func process_deposit*(
|
||||
state: var BeaconState, deposit: Deposit, flags: UpdateFlags = {}): bool =
|
||||
# Process an Eth1 deposit, registering a validator or increasing its balance.
|
||||
|
@ -52,7 +52,7 @@ else:
|
||||
{.fatal: "Preset \"" & const_preset ".nim\" is not supported.".}
|
||||
|
||||
const
|
||||
SPEC_VERSION* = "0.9.1" ## \
|
||||
SPEC_VERSION* = "0.9.2" ## \
|
||||
## Spec version we're aiming to be compatible with, right now
|
||||
## TODO: improve this scheme once we can negotiate versions in protocol
|
||||
|
||||
|
@ -20,7 +20,7 @@ type
|
||||
const
|
||||
# Misc
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/configs/mainnet.yaml#L6
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/mainnet.yaml#L6
|
||||
|
||||
MAX_COMMITTEES_PER_SLOT* {.intdefine.} = 64
|
||||
|
||||
@ -35,24 +35,24 @@ const
|
||||
## with a Verifiable Delay Function (VDF) will improve committee robustness
|
||||
## and lower the safe minimum committee size.)
|
||||
|
||||
MAX_VALIDATORS_PER_COMMITTEE* = 2^12 ##\
|
||||
MAX_VALIDATORS_PER_COMMITTEE* = 2048 ##\
|
||||
## votes
|
||||
|
||||
MIN_PER_EPOCH_CHURN_LIMIT* = 4
|
||||
|
||||
CHURN_LIMIT_QUOTIENT* = 2^16
|
||||
|
||||
SHUFFLE_ROUND_COUNT* = 90
|
||||
MIN_GENESIS_TIME* {.intdefine.} = 1578009600
|
||||
MIN_GENESIS_ACTIVE_VALIDATOR_COUNT* {.intdefine.} = 16384
|
||||
|
||||
# Constants (TODO: not actually configurable)
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/specs/core/0_beacon-chain.md#constants
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#constants
|
||||
BASE_REWARDS_PER_EPOCH* = 4
|
||||
|
||||
DEPOSIT_CONTRACT_TREE_DEPTH* = 32
|
||||
|
||||
# Gwei values
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/configs/mainnet.yaml#L33
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/mainnet.yaml#L50
|
||||
|
||||
MIN_DEPOSIT_AMOUNT* = 2'u64^0 * 10'u64^9 ##\
|
||||
## Minimum amounth of ETH that can be deposited in one call - deposits can
|
||||
@ -69,16 +69,16 @@ const
|
||||
|
||||
# Initial values
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.4/configs/mainnet.yaml#L45
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/mainnet.yaml#L62
|
||||
|
||||
GENESIS_SLOT* = 0.Slot
|
||||
BLS_WITHDRAWAL_PREFIX* = 0'u8
|
||||
|
||||
# Time parameters
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.4/configs/mainnet.yaml#L52
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/mainnet.yaml#L69
|
||||
|
||||
SECONDS_PER_SLOT*{.intdefine.} = 12'u64 # Compile with -d:SECONDS_PER_SLOT=1 for 6x faster slots
|
||||
SECONDS_PER_SLOT*{.intdefine.} = 12'u64 # Compile with -d:SECONDS_PER_SLOT=1 for 12x faster slots
|
||||
## TODO consistent time unit across projects, similar to C++ chrono?
|
||||
|
||||
MIN_ATTESTATION_INCLUSION_DELAY* = 1 ##\
|
||||
@ -127,7 +127,7 @@ const
|
||||
|
||||
# State vector lengths
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/configs/mainnet.yaml#L81
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/mainnet.yaml#L98
|
||||
EPOCHS_PER_HISTORICAL_VECTOR* = 65536
|
||||
EPOCHS_PER_SLASHINGS_VECTOR* = 8192
|
||||
HISTORICAL_ROOTS_LIMIT* = 16777216
|
||||
@ -135,7 +135,7 @@ const
|
||||
|
||||
# Reward and penalty quotients
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/configs/mainnet.yaml#L93
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/mainnet.yaml#L110
|
||||
BASE_REWARD_FACTOR* = 2'u64^6
|
||||
WHISTLEBLOWER_REWARD_QUOTIENT* = 2'u64^9
|
||||
PROPOSER_REWARD_QUOTIENT* = 2'u64^3
|
||||
@ -144,20 +144,17 @@ const
|
||||
|
||||
# Max operations per block
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/configs/mainnet.yaml#L107
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/mainnet.yaml#L124
|
||||
MAX_PROPOSER_SLASHINGS* = 2^4
|
||||
MAX_ATTESTER_SLASHINGS* = 2^0
|
||||
MAX_ATTESTATIONS* = 2^7
|
||||
MAX_DEPOSITS* = 2^4
|
||||
MAX_VOLUNTARY_EXITS* = 2^4
|
||||
|
||||
MIN_GENESIS_TIME* {.intdefine.} = 0
|
||||
MIN_GENESIS_ACTIVE_VALIDATOR_COUNT* {.intdefine.} = 99
|
||||
|
||||
type
|
||||
# Domains
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/specs/core/0_beacon-chain.md#domain-types
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/mainnet.yaml#L138
|
||||
DomainType* {.pure.} = enum
|
||||
DOMAIN_BEACON_PROPOSER = 0
|
||||
DOMAIN_BEACON_ATTESTER = 1
|
||||
|
@ -20,7 +20,7 @@ type
|
||||
const
|
||||
# Misc
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/configs/minimal.yaml#L4
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/minimal.yaml#L4
|
||||
|
||||
# Changed
|
||||
MAX_COMMITTEES_PER_SLOT* = 4
|
||||
@ -47,7 +47,7 @@ const
|
||||
|
||||
# Gwei values
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/configs/minimal.yaml#L32
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/minimal.yaml#L50
|
||||
|
||||
# Unchanged
|
||||
MIN_DEPOSIT_AMOUNT* = 2'u64^0 * 10'u64^9
|
||||
@ -57,7 +57,7 @@ const
|
||||
|
||||
# Initial values
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/configs/minimal.yaml#L44
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/minimal.yaml#L62
|
||||
|
||||
# Unchanged
|
||||
GENESIS_SLOT* = 0.Slot
|
||||
@ -65,7 +65,7 @@ const
|
||||
|
||||
# Time parameters
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.0/configs/minimal.yaml#L51
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/minimal.yaml#L69
|
||||
# Unchanged
|
||||
SECONDS_PER_SLOT*{.intdefine.} = 6'u64
|
||||
|
||||
@ -87,11 +87,13 @@ const
|
||||
MIN_VALIDATOR_WITHDRAWABILITY_DELAY* = 2'u64^8
|
||||
PERSISTENT_COMMITTEE_PERIOD* = 2'u64^11
|
||||
MAX_EPOCHS_PER_CROSSLINK* = 4
|
||||
|
||||
# Changed
|
||||
MIN_EPOCHS_TO_INACTIVITY_PENALTY* = 2'u64^2
|
||||
|
||||
# State vector lengths
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/configs/minimal.yaml#L83
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/minimal.yaml#L101
|
||||
|
||||
# Changed
|
||||
EPOCHS_PER_HISTORICAL_VECTOR* = 64
|
||||
@ -101,7 +103,7 @@ const
|
||||
|
||||
# Reward and penalty quotients
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/configs/minimal.yaml#L95
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/minimal.yaml#L113
|
||||
|
||||
BASE_REWARD_FACTOR* = 2'u64^6
|
||||
WHISTLEBLOWER_REWARD_QUOTIENT* = 2'u64^9
|
||||
@ -111,7 +113,7 @@ const
|
||||
|
||||
# Max operations per block
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.1/configs/minimal.yaml#L109
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/configs/minimal.yaml#L127
|
||||
|
||||
MAX_PROPOSER_SLASHINGS* = 2^4
|
||||
MAX_ATTESTER_SLASHINGS* = 2^0
|
||||
|
@ -269,7 +269,7 @@ proc processAttesterSlashings(state: var BeaconState, blck: BeaconBlock,
|
||||
return false
|
||||
return true
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.6.3/specs/core/0_beacon-chain.md#attestations
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.4/specs/core/0_beacon-chain.md#attestations
|
||||
proc processAttestations*(
|
||||
state: var BeaconState, blck: BeaconBlock, flags: UpdateFlags,
|
||||
stateCache: var StateCache): bool =
|
||||
@ -291,7 +291,7 @@ proc processAttestations*(
|
||||
|
||||
true
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.5.1/specs/core/0_beacon-chain.md#deposits
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.4/specs/core/0_beacon-chain.md#deposits
|
||||
proc processDeposits(state: var BeaconState, blck: BeaconBlock): bool =
|
||||
if not (len(blck.body.deposits) <= MAX_DEPOSITS):
|
||||
notice "processDeposits: too many deposits"
|
||||
|
@ -20,7 +20,9 @@ import # Unit test
|
||||
./test_zero_signature
|
||||
|
||||
import # Refactor state transition unit tests
|
||||
./spec_block_processing/test_genesis,
|
||||
# ./spec_block_processing/test_genesis, # mostly TODOs,
|
||||
# with initGenesisState(...) tested by test_process_deposits(...),
|
||||
# and mainnet hitting pathological/quadratic eth1 deposit behavior
|
||||
./spec_block_processing/test_process_deposits,
|
||||
./spec_block_processing/test_process_attestation,
|
||||
./spec_epoch_processing/test_process_justification_and_finalization
|
||||
|
@ -11,9 +11,7 @@
|
||||
import
|
||||
# Specs
|
||||
../../beacon_chain/spec/[datatypes, digest],
|
||||
../../beacon_chain/ssz,
|
||||
# shims
|
||||
stew/objects
|
||||
../../beacon_chain/ssz
|
||||
|
||||
func round_step_down*(x: Natural, step: static Natural): int {.inline.} =
|
||||
## Round the input to the previous multiple of "step"
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 0e0b698ee70e3782a2716cda4a928b9ae18ad494
|
||||
Subproject commit 0a51654000c7066fa2d89105044367a748ae5db0
|
@ -37,7 +37,7 @@ proc readValue*(r: var JsonReader, a: var seq[byte]) {.inline.} =
|
||||
const
|
||||
FixturesDir* = currentSourcePath.rsplit(DirSep, 1)[0] / "fixtures"
|
||||
JsonTestsDir* = FixturesDir/"json_tests_v0.8.3"
|
||||
SszTestsDir* = FixturesDir/"tests-v0.9.1"
|
||||
SszTestsDir* = FixturesDir/"tests-v0.9.2"
|
||||
|
||||
proc parseTest*(path: string, Format: typedesc[Json or SSZ], T: typedesc): T =
|
||||
try:
|
||||
|
@ -26,7 +26,7 @@ import
|
||||
|
||||
const
|
||||
FixturesDir = currentSourcePath.rsplit(DirSep, 1)[0] / "fixtures"
|
||||
SSZDir = FixturesDir/"tests-v0.9.1"/const_preset/"phase0"/"ssz_static"
|
||||
SSZDir = FixturesDir/"tests-v0.9.2"/const_preset/"phase0"/"ssz_static"
|
||||
|
||||
type
|
||||
SSZHashTreeRoot = object
|
||||
|
@ -23,7 +23,7 @@ import
|
||||
|
||||
const
|
||||
FixturesDir = currentSourcePath.rsplit(DirSep, 1)[0] / "fixtures"
|
||||
SSZDir = FixturesDir/"tests-v0.9.1"/"general"/"phase0"/"ssz_generic"
|
||||
SSZDir = FixturesDir/"tests-v0.9.2"/"general"/"phase0"/"ssz_generic"
|
||||
|
||||
type
|
||||
SSZHashTreeRoot = object
|
||||
|
@ -6,7 +6,7 @@
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
# process_attestation (beaconstate.nim)
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.1/specs/core/0_beacon-chain.md#attestations
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#attestations
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
{.used.}
|
||||
@ -14,8 +14,6 @@
|
||||
import
|
||||
# Standard library
|
||||
unittest,
|
||||
# shims 0.19.6
|
||||
stew/objects, # import default
|
||||
# Specs
|
||||
../../beacon_chain/spec/[beaconstate, datatypes, helpers, validator],
|
||||
# Mock helpers
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
# process_deposit (beaconstate.nim)
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.8.1/specs/core/0_beacon-chain.md#deposits
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.9.2/specs/core/0_beacon-chain.md#deposits
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
{.used.}
|
||||
|
Loading…
x
Reference in New Issue
Block a user