diff --git a/README.md b/README.md index 0137a907d..0afd36f3c 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/beacon_chain/spec/beaconstate.nim b/beacon_chain/spec/beaconstate.nim index 87197de4b..8afde80da 100644 --- a/beacon_chain/spec/beaconstate.nim +++ b/beacon_chain/spec/beaconstate.nim @@ -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. diff --git a/beacon_chain/spec/datatypes.nim b/beacon_chain/spec/datatypes.nim index 131b0841c..d5c6989be 100644 --- a/beacon_chain/spec/datatypes.nim +++ b/beacon_chain/spec/datatypes.nim @@ -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 diff --git a/beacon_chain/spec/presets/mainnet.nim b/beacon_chain/spec/presets/mainnet.nim index 6df48e3ad..472406100 100644 --- a/beacon_chain/spec/presets/mainnet.nim +++ b/beacon_chain/spec/presets/mainnet.nim @@ -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 diff --git a/beacon_chain/spec/presets/minimal.nim b/beacon_chain/spec/presets/minimal.nim index 6a4bc73cc..af9554adf 100644 --- a/beacon_chain/spec/presets/minimal.nim +++ b/beacon_chain/spec/presets/minimal.nim @@ -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 diff --git a/beacon_chain/spec/state_transition_block.nim b/beacon_chain/spec/state_transition_block.nim index 25e47fe62..9ad7af410 100644 --- a/beacon_chain/spec/state_transition_block.nim +++ b/beacon_chain/spec/state_transition_block.nim @@ -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" diff --git a/tests/all_tests.nim b/tests/all_tests.nim index 427798b0a..6bea80d1d 100644 --- a/tests/all_tests.nim +++ b/tests/all_tests.nim @@ -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 diff --git a/tests/mocking/merkle_minimal.nim b/tests/mocking/merkle_minimal.nim index ca9db2ac2..0e350ed66 100644 --- a/tests/mocking/merkle_minimal.nim +++ b/tests/mocking/merkle_minimal.nim @@ -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" diff --git a/tests/official/fixtures b/tests/official/fixtures index 0e0b698ee..0a5165400 160000 --- a/tests/official/fixtures +++ b/tests/official/fixtures @@ -1 +1 @@ -Subproject commit 0e0b698ee70e3782a2716cda4a928b9ae18ad494 +Subproject commit 0a51654000c7066fa2d89105044367a748ae5db0 diff --git a/tests/official/fixtures_utils.nim b/tests/official/fixtures_utils.nim index a157e1f9a..f93df928e 100644 --- a/tests/official/fixtures_utils.nim +++ b/tests/official/fixtures_utils.nim @@ -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: diff --git a/tests/official/test_fixture_ssz_consensus_objects.nim b/tests/official/test_fixture_ssz_consensus_objects.nim index a8cb2e0cd..9224cf5de 100644 --- a/tests/official/test_fixture_ssz_consensus_objects.nim +++ b/tests/official/test_fixture_ssz_consensus_objects.nim @@ -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 diff --git a/tests/official/test_fixture_ssz_generic_types.nim b/tests/official/test_fixture_ssz_generic_types.nim index d0957d9b2..92d26b0e7 100644 --- a/tests/official/test_fixture_ssz_generic_types.nim +++ b/tests/official/test_fixture_ssz_generic_types.nim @@ -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 diff --git a/tests/spec_block_processing/test_process_attestation.nim b/tests/spec_block_processing/test_process_attestation.nim index b762d4d5f..7da59ae96 100644 --- a/tests/spec_block_processing/test_process_attestation.nim +++ b/tests/spec_block_processing/test_process_attestation.nim @@ -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 diff --git a/tests/spec_block_processing/test_process_deposits.nim b/tests/spec_block_processing/test_process_deposits.nim index b521671f7..e22aefa86 100644 --- a/tests/spec_block_processing/test_process_deposits.nim +++ b/tests/spec_block_processing/test_process_deposits.nim @@ -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.}