rename initialize_beacon_state{_from_eth1,}; suppress warnings when doppelganger detection disabled

This commit is contained in:
Dustin Brody 2021-04-26 21:41:35 +02:00 committed by zah
parent 18da0f8928
commit 7f42d38219
10 changed files with 18 additions and 23 deletions

View File

@ -35,7 +35,7 @@ OK: 9/9 Fail: 0/9 Skip: 0/9
OK: 1/1 Fail: 0/1 Skip: 0/1 OK: 1/1 Fail: 0/1 Skip: 0/1
## Beacon state [Preset: mainnet] ## Beacon state [Preset: mainnet]
```diff ```diff
+ Smoke test initialize_beacon_state_from_eth1 [Preset: mainnet] OK + Smoke test initialize_beacon_state [Preset: mainnet] OK
``` ```
OK: 1/1 Fail: 0/1 Skip: 0/1 OK: 1/1 Fail: 0/1 Skip: 0/1
## Block pool processing [Preset: mainnet] ## Block pool processing [Preset: mainnet]

View File

@ -195,7 +195,7 @@ when hasGenesisDetection:
var deposits = m.allGenesisDepositsUpTo(eth1Block.voteData.deposit_count) var deposits = m.allGenesisDepositsUpTo(eth1Block.voteData.deposit_count)
result = initialize_beacon_state_from_eth1( result = initialize_beacon_state(
m.preset, m.preset,
eth1Block.voteData.block_hash, eth1Block.voteData.block_hash,
eth1Block.timestamp.uint64, eth1Block.timestamp.uint64,

View File

@ -33,9 +33,6 @@ declareCounter beacon_proposer_slashings_received,
declareCounter beacon_voluntary_exits_received, declareCounter beacon_voluntary_exits_received,
"Number of beacon chain voluntary exits received by this peer" "Number of beacon chain voluntary exits received by this peer"
declareCounter doppelganger_detection_activated,
"Number of times doppelganger detection was activated"
const delayBuckets = [2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, Inf] const delayBuckets = [2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, Inf]
declareHistogram beacon_attestation_delay, declareHistogram beacon_attestation_delay,
@ -176,16 +173,14 @@ proc checkForPotentialDoppelganger(
tgtBlck, attestationData.target.epoch) tgtBlck, attestationData.target.epoch)
for validatorIndex in attesterIndices: for validatorIndex in attesterIndices:
let validatorPubkey = epochRef.validator_keys[validatorIndex] let validatorPubkey = epochRef.validator_keys[validatorIndex]
if self.validatorPool[].getValidator(validatorPubkey) != if self.doppelgangerDetectionEnabled and
default(AttachedValidator): self.validatorPool[].getValidator(validatorPubkey) !=
warn "Duplicate validator detected; would be slashed", default(AttachedValidator):
warn "We believe you are currently running another instance of the same validator. We've disconnected you from the network as this presents a significant slashing risk. Possible next steps are (a) making sure you've disconnected your validator from your old machine before restarting the client; and (b) running the client again with the gossip-slashing-protection option disabled, only if you are absolutely sure this is the only instance of your validator running, and reporting the issue at https://github.com/status-im/nimbus-eth2/issues.",
validatorIndex, validatorIndex,
validatorPubkey, validatorPubkey,
attestationSlot = attestationData.slot attestationSlot = attestationData.slot
doppelganger_detection_activated.inc() quit QuitFailure
if self.doppelgangerDetectionEnabled:
warn "We believe you are currently running another instance of the same validator. We've disconnected you from the network as this presents a significant slashing risk. Possible next steps are (a) making sure you've disconnected your validator from your old machine before restarting the client; and (b) running the client again with the gossip-slashing-protection option disabled, only if you are absolutely sure this is the only instance of your validator running, and reporting the issue at https://github.com/status-im/nimbus-eth2/issues."
quit QuitFailure
{.pop.} # async can raise anything {.pop.} # async can raise anything

View File

@ -1748,7 +1748,7 @@ proc doCreateTestnet(config: BeaconNodeConf, rng: var BrHmacDrbgContext) {.raise
else: (waitFor getEth1BlockHash(config.web3Urls[0], blockId("latest"))).asEth2Digest else: (waitFor getEth1BlockHash(config.web3Urls[0], blockId("latest"))).asEth2Digest
runtimePreset = getRuntimePresetForNetwork(config.eth2Network) runtimePreset = getRuntimePresetForNetwork(config.eth2Network)
var var
initialState = initialize_beacon_state_from_eth1( initialState = initialize_beacon_state(
runtimePreset, eth1Hash, startTime, deposits, {skipBlsValidation}) runtimePreset, eth1Hash, startTime, deposits, {skipBlsValidation})
# https://github.com/ethereum/eth2.0-pm/tree/6e41fcf383ebeb5125938850d8e9b4e9888389b4/interop/mocked_start#create-genesis-state # https://github.com/ethereum/eth2.0-pm/tree/6e41fcf383ebeb5125938850d8e9b4e9888389b4/interop/mocked_start#create-genesis-state

View File

@ -240,7 +240,7 @@ func genesis_time_from_eth1_timestamp*(preset: RuntimePreset, eth1_timestamp: ui
eth1_timestamp + preset.GENESIS_DELAY eth1_timestamp + preset.GENESIS_DELAY
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#genesis # https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#genesis
proc initialize_beacon_state_from_eth1*( proc initialize_beacon_state*(
preset: RuntimePreset, preset: RuntimePreset,
eth1_block_hash: Eth2Digest, eth1_block_hash: Eth2Digest,
eth1_timestamp: uint64, eth1_timestamp: uint64,
@ -335,7 +335,7 @@ proc initialize_hashed_beacon_state_from_eth1*(
eth1_timestamp: uint64, eth1_timestamp: uint64,
deposits: openArray[DepositData], deposits: openArray[DepositData],
flags: UpdateFlags = {}): HashedBeaconState = flags: UpdateFlags = {}): HashedBeaconState =
let genesisState = initialize_beacon_state_from_eth1( let genesisState = initialize_beacon_state(
preset, eth1_block_hash, eth1_timestamp, deposits, flags) preset, eth1_block_hash, eth1_timestamp, deposits, flags)
HashedBeaconState(data: genesisState[], root: hash_tree_root(genesisState[])) HashedBeaconState(data: genesisState[], root: hash_tree_root(genesisState[]))

View File

@ -102,7 +102,7 @@ proc loadGenesis*(validators: Natural, validate: bool):
let contractSnapshot = DepositContractSnapshot( let contractSnapshot = DepositContractSnapshot(
depositContractState: merkleizer.toDepositContractState) depositContractState: merkleizer.toDepositContractState)
res.data = initialize_beacon_state_from_eth1( res.data = initialize_beacon_state(
defaultRuntimePreset, defaultRuntimePreset,
Eth2Digest(), Eth2Digest(),
0, 0,

View File

@ -221,7 +221,7 @@ suiteReport "Beacon chain DB" & preset():
db = BeaconChainDB.new(defaultRuntimePreset, "", inMemory = true) db = BeaconChainDB.new(defaultRuntimePreset, "", inMemory = true)
let let
state = initialize_beacon_state_from_eth1( state = initialize_beacon_state(
defaultRuntimePreset, eth1BlockHash, 0, defaultRuntimePreset, eth1BlockHash, 0,
makeInitialDeposits(SLOTS_PER_EPOCH), {skipBlsValidation}) makeInitialDeposits(SLOTS_PER_EPOCH), {skipBlsValidation})
root = hash_tree_root(state[]) root = hash_tree_root(state[])

View File

@ -1,5 +1,5 @@
# beacon_chain # beacon_chain
# Copyright (c) 2018-2020 Status Research & Development GmbH # Copyright (c) 2018-2021 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * 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). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@ -13,7 +13,7 @@ import
../beacon_chain/spec/[beaconstate, datatypes, digest, presets] ../beacon_chain/spec/[beaconstate, datatypes, digest, presets]
suiteReport "Beacon state" & preset(): suiteReport "Beacon state" & preset():
timedTest "Smoke test initialize_beacon_state_from_eth1" & preset(): timedTest "Smoke test initialize_beacon_state" & preset():
let state = initialize_beacon_state_from_eth1( let state = initialize_beacon_state(
defaultRuntimePreset, Eth2Digest(), 0, makeInitialDeposits(SLOTS_PER_EPOCH, {}), {}) defaultRuntimePreset, Eth2Digest(), 0, makeInitialDeposits(SLOTS_PER_EPOCH, {}), {})
check: state.validators.lenu64 == SLOTS_PER_EPOCH check: state.validators.lenu64 == SLOTS_PER_EPOCH

View File

@ -150,7 +150,7 @@ suiteReport "Interop":
const genesis_time = 1570500000 const genesis_time = 1570500000
var var
initialState = initialize_beacon_state_from_eth1( initialState = initialize_beacon_state(
defaultRuntimePreset, eth1BlockHash, genesis_time, deposits, {}) defaultRuntimePreset, eth1BlockHash, genesis_time, deposits, {})
# https://github.com/ethereum/eth2.0-pm/tree/6e41fcf383ebeb5125938850d8e9b4e9888389b4/interop/mocked_start#create-genesis-state # https://github.com/ethereum/eth2.0-pm/tree/6e41fcf383ebeb5125938850d8e9b4e9888389b4/interop/mocked_start#create-genesis-state

View File

@ -1,5 +1,5 @@
# beacon_chain # beacon_chain
# Copyright (c) 2018-2019 Status Research & Development GmbH # Copyright (c) 2018-2021 Status Research & Development GmbH
# Licensed and distributed under either of # Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * 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). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@ -97,7 +97,7 @@ proc makeTestDB*(tailState: var BeaconState, tailBlock: SignedBeaconBlock): Beac
proc makeTestDB*(validators: Natural): BeaconChainDB = proc makeTestDB*(validators: Natural): BeaconChainDB =
let let
genState = initialize_beacon_state_from_eth1( genState = initialize_beacon_state(
defaultRuntimePreset, defaultRuntimePreset,
Eth2Digest(), Eth2Digest(),
0, 0,