update to spec v0.11.2 to keep compatible with Schlesi (#1036)

* update to spec v0.11.2 to keep compatible with Schlesi

* update spec/state_transition_epoch spec references to v0.11.2

* bump other spec refs
This commit is contained in:
tersec 2020-05-18 23:05:27 +00:00 committed by GitHub
parent 398166369b
commit 8432932c11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 38 additions and 48 deletions

View File

@ -130,7 +130,6 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ HYSTERESIS_UPWARD_MULTIPLIER 5 [Preset: mainnet] OK
+ INACTIVITY_PENALTY_QUOTIENT 33554432 [Preset: mainnet] OK
+ INITIAL_ACTIVE_SHARDS 64 [Preset: mainnet] OK
+ INITIAL_GASPRICE 10 [Preset: mainnet] OK
+ LIGHT_CLIENT_COMMITTEE_PERIOD 256 [Preset: mainnet] OK
+ LIGHT_CLIENT_COMMITTEE_SIZE 128 [Preset: mainnet] OK
+ MAX_ATTESTATIONS 128 [Preset: mainnet] OK
@ -155,7 +154,7 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ MIN_ATTESTATION_INCLUSION_DELAY 1 [Preset: mainnet] OK
+ MIN_DEPOSIT_AMOUNT 1000000000 [Preset: mainnet] OK
+ MIN_EPOCHS_TO_INACTIVITY_PENALTY 4 [Preset: mainnet] OK
+ MIN_GASPRICE 32 [Preset: mainnet] OK
+ MIN_GASPRICE 8 [Preset: mainnet] OK
+ MIN_GENESIS_ACTIVE_VALIDATOR_COUNT 16384 [Preset: mainnet] OK
+ MIN_GENESIS_DELAY 86400 [Preset: mainnet] OK
+ MIN_GENESIS_TIME 1578009600 [Preset: mainnet] OK
@ -184,7 +183,7 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ VALIDATOR_REGISTRY_LIMIT 1099511627776 [Preset: mainnet] OK
+ WHISTLEBLOWER_REWARD_QUOTIENT 512 [Preset: mainnet] OK
```
OK: 84/87 Fail: 3/87 Skip: 0/87
OK: 83/86 Fail: 3/86 Skip: 0/86
## PeerPool testing suite
```diff
+ Access peers by key test OK
@ -253,4 +252,4 @@ OK: 4/4 Fail: 0/4 Skip: 0/4
OK: 8/8 Fail: 0/8 Skip: 0/8
---TOTAL---
OK: 156/159 Fail: 3/159 Skip: 0/159
OK: 155/158 Fail: 3/158 Skip: 0/158

View File

@ -136,7 +136,6 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ HYSTERESIS_UPWARD_MULTIPLIER 5 [Preset: minimal] OK
+ INACTIVITY_PENALTY_QUOTIENT 33554432 [Preset: minimal] OK
+ INITIAL_ACTIVE_SHARDS 4 [Preset: minimal] OK
+ INITIAL_GASPRICE 10 [Preset: minimal] OK
+ LIGHT_CLIENT_COMMITTEE_PERIOD 256 [Preset: minimal] OK
+ LIGHT_CLIENT_COMMITTEE_SIZE 128 [Preset: minimal] OK
+ MAX_ATTESTATIONS 128 [Preset: minimal] OK
@ -161,7 +160,7 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ MIN_ATTESTATION_INCLUSION_DELAY 1 [Preset: minimal] OK
+ MIN_DEPOSIT_AMOUNT 1000000000 [Preset: minimal] OK
+ MIN_EPOCHS_TO_INACTIVITY_PENALTY 4 [Preset: minimal] OK
+ MIN_GASPRICE 32 [Preset: minimal] OK
+ MIN_GASPRICE 8 [Preset: minimal] OK
+ MIN_GENESIS_ACTIVE_VALIDATOR_COUNT 64 [Preset: minimal] OK
+ MIN_GENESIS_DELAY 300 [Preset: minimal] OK
+ MIN_GENESIS_TIME 1578009600 [Preset: minimal] OK
@ -190,7 +189,7 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ VALIDATOR_REGISTRY_LIMIT 1099511627776 [Preset: minimal] OK
+ WHISTLEBLOWER_REWARD_QUOTIENT 512 [Preset: minimal] OK
```
OK: 84/87 Fail: 3/87 Skip: 0/87
OK: 83/86 Fail: 3/86 Skip: 0/86
## PeerPool testing suite
```diff
+ Access peers by key test OK
@ -259,4 +258,4 @@ OK: 4/4 Fail: 0/4 Skip: 0/4
OK: 8/8 Fail: 0/8 Skip: 0/8
---TOTAL---
OK: 158/161 Fail: 3/161 Skip: 0/161
OK: 157/160 Fail: 3/160 Skip: 0/160

View File

@ -16,7 +16,7 @@ Nimbus beacon chain is a research implementation of the beacon chain component o
## Related
* [status-im/nimbus](https://github.com/status-im/nimbus/): Nimbus for Ethereum 1
* [ethereum/eth2.0-specs](https://github.com/ethereum/eth2.0-specs/tree/v0.11.1#phase-0): Serenity specification that this project implements
* [ethereum/eth2.0-specs](https://github.com/ethereum/eth2.0-specs/tree/v0.11.2#phase-0): Serenity specification that this project implements
You can check where the beacon chain fits in the Ethereum ecosystem our Two-Point-Oh series: https://our.status.im/tag/two-point-oh/

View File

@ -392,22 +392,17 @@ proc process_registry_updates*(state: var BeaconState) {.nbench.}=
validator.activation_epoch =
compute_activation_exit_epoch(get_current_epoch(state))
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
proc is_valid_indexed_attestation*(
state: BeaconState, indexed_attestation: IndexedAttestation,
flags: UpdateFlags): bool =
## Check if ``indexed_attestation`` has valid indices and signature.
# Check if ``indexed_attestation`` has sorted and unique indices and a valid
# aggregate signature.
# TODO: this is noSideEffect besides logging
# https://github.com/status-im/nim-chronicles/issues/62
let indices = indexed_attestation.attesting_indices
# Verify max number of indices
if not (len(indices) <= MAX_VALIDATORS_PER_COMMITTEE):
notice "indexed attestation: validator index beyond max validators per committee"
return false
# Verify indices are sorted and unique
let indices = indexed_attestation.attesting_indices
if indices != sorted(toHashSet(indices).toSeq, system.cmp):
notice "indexed attestation: indices not sorted"
return false

View File

@ -62,7 +62,7 @@ else:
loadCustomPreset const_preset
const
SPEC_VERSION* = "0.11.1" ## \
SPEC_VERSION* = "0.11.2" ## \
## Spec version we're aiming to be compatible with, right now
GENESIS_SLOT* = Slot(0)

View File

@ -22,7 +22,7 @@ type
# (other candidate is nativesockets.Domain)
Domain = datatypes.Domain
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#integer_squareroot
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#integer_squareroot
func integer_squareroot*(n: SomeInteger): SomeInteger =
# Return the largest integer ``x`` such that ``x**2 <= n``.
doAssert n >= 0'u64

View File

@ -45,7 +45,6 @@ type
HYSTERESIS_UPWARD_MULTIPLIER
INACTIVITY_PENALTY_QUOTIENT
INITIAL_ACTIVE_SHARDS
INITIAL_GASPRICE
JUSTIFICATION_BITS_LENGTH
LIGHT_CLIENT_COMMITTEE_PERIOD
LIGHT_CLIENT_COMMITTEE_SIZE

View File

@ -172,7 +172,6 @@ const
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.0/configs/mainnet.yaml#L161
PHASE_1_FORK_VERSION* = 1
INITIAL_ACTIVE_SHARDS* = 64
INITIAL_GASPRICE* = 10
# Phase 1: General
# ---------------------------------------------------------------
@ -187,7 +186,7 @@ const
TARGET_SHARD_BLOCK_SIZE* = 196608
MAX_SHARD_BLOCKS_PER_ATTESTATION* = 12
MAX_GASPRICE* = 16384 # Gwei
MIN_GASPRICE* = 32 # Gwei
MIN_GASPRICE* = 8 # Gwei
GASPRICE_ADJUSTMENT_COEFFICIENT* = 8
# Phase 1: Custody game

View File

@ -151,7 +151,6 @@ const
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.0/configs/minimal.yaml#L161
PHASE_1_FORK_VERSION* = 16777217
INITIAL_ACTIVE_SHARDS* = 4
INITIAL_GASPRICE* = 10
# Phase 1: General
# ---------------------------------------------------------------
@ -166,7 +165,7 @@ const
TARGET_SHARD_BLOCK_SIZE* = 196608
MAX_SHARD_BLOCKS_PER_ATTESTATION* = 12
MAX_GASPRICE* = 16384 # Gwei
MIN_GASPRICE* = 32 # Gwei
MIN_GASPRICE* = 8 # Gwei
GASPRICE_ADJUSTMENT_COEFFICIENT* = 8
# Phase 1 - Custody game

View File

@ -66,7 +66,7 @@ declareGauge beacon_current_epoch, "Current epoch"
# Spec
# --------------------------------------------------------
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#get_total_active_balance
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#get_total_active_balance
func get_total_active_balance*(state: BeaconState): Gwei =
# Return the combined effective balance of the active validators.
# Note: ``get_total_balance`` returns ``EFFECTIVE_BALANCE_INCREMENT`` Gwei
@ -76,7 +76,7 @@ func get_total_active_balance*(state: BeaconState): Gwei =
state,
get_active_validator_indices(state, get_current_epoch(state)))
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#helper-functions-1
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#helper-functions-1
func get_matching_source_attestations(state: BeaconState, epoch: Epoch):
seq[PendingAttestation] =
doAssert epoch in [get_current_epoch(state), get_previous_epoch(state)]
@ -149,11 +149,11 @@ proc process_justification_and_finalization*(state: var BeaconState,
## matter -- in the next epoch, they'll be 2 epochs old, when BeaconState
## tracks current_epoch_attestations and previous_epoch_attestations only
## per
## https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#attestations
## https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#attestations
## and `get_matching_source_attestations(...)` via
## https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#helper-functions-1
## https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#helper-functions-1
## and
## https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#final-updates
## https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#final-updates
## after which the state.previous_epoch_attestations is replaced.
trace "Non-attesting indices in previous epoch",
missing_all_validators=
@ -242,7 +242,7 @@ proc process_justification_and_finalization*(state: var BeaconState,
checkpoint = shortLog(state.finalized_checkpoint),
cat = "finalization"
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#rewards-and-penalties-1
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#rewards-and-penalties-1
func get_base_reward(state: BeaconState, index: ValidatorIndex,
total_balance: auto): Gwei =
# Spec function recalculates total_balance every time, which creates an
@ -251,7 +251,7 @@ func get_base_reward(state: BeaconState, index: ValidatorIndex,
effective_balance * BASE_REWARD_FACTOR div
integer_squareroot(total_balance) div BASE_REWARDS_PER_EPOCH
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#rewards-and-penalties-1
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#rewards-and-penalties-1
func get_attestation_deltas(state: BeaconState, stateCache: var StateCache):
tuple[a: seq[Gwei], b: seq[Gwei]] {.nbench.}=
let
@ -376,7 +376,7 @@ func process_slashings*(state: var BeaconState) {.nbench.}=
let penalty = penalty_numerator div total_balance * increment
decrease_balance(state, index.ValidatorIndex, penalty)
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#final-updates
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#final-updates
func process_final_updates*(state: var BeaconState) {.nbench.}=
let
current_epoch = get_current_epoch(state)
@ -413,7 +413,7 @@ func process_final_updates*(state: var BeaconState) {.nbench.}=
if next_epoch mod (SLOTS_PER_HISTORICAL_ROOT div SLOTS_PER_EPOCH).uint64 == 0:
# Equivalent to hash_tree_root(foo: HistoricalBatch), but without using
# significant additional stack or heap.
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#historicalbatch
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#historicalbatch
# In response to https://github.com/status-im/nim-beacon-chain/issues/921
state.historical_roots.add hash_tree_root(
[hash_tree_root(state.block_roots), hash_tree_root(state.state_roots)])
@ -422,7 +422,7 @@ func process_final_updates*(state: var BeaconState) {.nbench.}=
state.previous_epoch_attestations = state.current_epoch_attestations
state.current_epoch_attestations = @[]
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#epoch-processing
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#epoch-processing
proc process_epoch*(state: var BeaconState, updateFlags: UpdateFlags)
{.nbench.} =
let currentEpoch = get_current_epoch(state)
@ -431,7 +431,7 @@ proc process_epoch*(state: var BeaconState, updateFlags: UpdateFlags)
var per_epoch_cache = get_empty_per_epoch_cache()
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#justification-and-finalization
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#justification-and-finalization
process_justification_and_finalization(state, per_epoch_cache, updateFlags)
# state.slot hasn't been incremented yet.
@ -441,10 +441,10 @@ proc process_epoch*(state: var BeaconState, updateFlags: UpdateFlags)
# the finalization rules triggered.
doAssert state.finalized_checkpoint.epoch + 3 >= currentEpoch
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#rewards-and-penalties-1
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#rewards-and-penalties-1
process_rewards_and_penalties(state, per_epoch_cache)
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#registry-updates
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#registry-updates
# Don't rely on caching here.
process_registry_updates(state)
@ -452,10 +452,10 @@ proc process_epoch*(state: var BeaconState, updateFlags: UpdateFlags)
## get_active_validator_indices(...) usually changes.
clear(per_epoch_cache.beacon_committee_cache)
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#slashings
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#slashings
process_slashings(state)
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#final-updates
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#final-updates
process_final_updates(state)
# Once per epoch metrics

View File

@ -40,7 +40,7 @@ type
const
FixturesDir* = currentSourcePath.rsplit(DirSep, 1)[0] / ".." / ".." / "vendor" / "nim-eth2-scenarios"
SszTestsDir* = FixturesDir/"tests-v0.11.1"
SszTestsDir* = FixturesDir/"tests-v0.11.2"
proc parseTest*(path: string, Format: typedesc[Json or SSZ], T: typedesc): T =
try:

View File

@ -19,7 +19,7 @@ import
const
SpecDir = currentSourcePath.rsplit(DirSep, 1)[0] /
".."/".."/"beacon_chain"/"spec"
Config = FixturesDir/"tests-v0.11.1"/const_preset/"config.yaml"
Config = SszTestsDir/const_preset/"config.yaml"
type
CheckedType = SomeInteger or Slot or Epoch

View File

@ -25,7 +25,7 @@ import
# ----------------------------------------------------------------
const
SSZDir = FixturesDir/"tests-v0.11.1"/const_preset/"phase0"/"ssz_static"
SSZDir = SszTestsDir/const_preset/"phase0"/"ssz_static"
type
SSZHashTreeRoot = object

View File

@ -23,7 +23,7 @@ import
# ------------------------------------------------------------------------
const
SSZDir = FixturesDir/"tests-v0.11.1"/"general"/"phase0"/"ssz_generic"
SSZDir = SszTestsDir/"general"/"phase0"/"ssz_generic"
type
SSZHashTreeRoot = object

View File

@ -1,12 +1,12 @@
# beacon_chain
# Copyright (c) 2018-2019 Status Research & Development GmbH
# Copyright (c) 2018-2020 Status Research & Development GmbH
# Licensed and distributed under either of
# * 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).
# 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.11.1/specs/phase0/beacon-chain.md#attestations
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#attestations
# ---------------------------------------------------------------
{.used.}

View File

@ -7,7 +7,7 @@
# process_deposit (beaconstate.nim)
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#deposits
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.2/specs/phase0/beacon-chain.md#deposits
# ---------------------------------------------------------------
{.used.}

@ -1 +1 @@
Subproject commit 5326d824b1d91ea273095172512eb309f32e0c82
Subproject commit 0e390c80735c39f3f0375007f158f23dec0f7b0a