From e1d6df1e5d7364d016361724962af7a6abfc4bd5 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 19 Feb 2021 20:39:18 +0200 Subject: [PATCH] Continue using the V1 Slashing DB by default --- beacon_chain/conf.nim | 14 +++++++++----- beacon_chain/nimbus_beacon_node.nim | 29 ++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/beacon_chain/conf.nim b/beacon_chain/conf.nim index 0597f8b96..3a6ea0731 100644 --- a/beacon_chain/conf.nim +++ b/beacon_chain/conf.nim @@ -51,6 +51,11 @@ type enabled # Always enabled disabled # Always disabled + SlashingDbKind* {.pure.} = enum + v1 + v2 + both + BeaconNodeConf* = object logLevel* {. defaultValue: "INFO" @@ -120,12 +125,11 @@ type desc: "Subscribe to all attestation subnet topics when gossiping" name: "subscribe-all-subnets" }: bool - # Can we use a set[enum]? - testDualSlashingProtectionDBs* {. + slashingDbKind* {. hidden - defaultValue: false - desc: "Use the the 2 slashing protection implementation at the same time to ensure no regression." - name: "slashing-test-dual-db" }: bool + defaultValue: SlashingDbKind.v1 + desc: "The slashing DB flavour to use (v1, v2 or both)" + name: "slashing-db-kind" }: SlashingDbKind case cmd* {. command diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 90876595d..43eba1e6e 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -320,7 +320,26 @@ proc init*(T: type BeaconNode, topics &= getAttestationTopic(enrForkId.forkDigest, subnet) topics) - if conf.testDualSlashingProtectionDBs: + case conf.slashingDbKind + of SlashingDbKind.v1: + info "Loading slashing protection database", path = conf.validatorsDir() + res.attachedValidators = ValidatorPool.init( + SlashingProtectionDB.init( + chainDag.headState.data.data.genesis_validators_root, + conf.validatorsDir(), "slashing_protection", + modes = {kCompleteArchiveV1}, + disagreementBehavior = kChooseV1 + ) + ) + of SlashingDbKind.v2: + info "Loading slashing protection database (v2)", path = conf.validatorsDir() + res.attachedValidators = ValidatorPool.init( + SlashingProtectionDB.init( + chainDag.headState.data.data.genesis_validators_root, + conf.validatorsDir(), "slashing_protection" + ) + ) + of SlashingDbKind.both: info "Loading slashing protection database (dual DB mode)", path = conf.validatorsDir() res.attachedValidators = ValidatorPool.init( SlashingProtectionDB.init( @@ -330,14 +349,6 @@ proc init*(T: type BeaconNode, disagreementBehavior = kChooseV2 ) ) - else: - info "Loading slashing protection database", path = conf.validatorsDir() - res.attachedValidators = ValidatorPool.init( - SlashingProtectionDB.init( - chainDag.headState.data.data.genesis_validators_root, - conf.validatorsDir(), "slashing_protection" - ) - ) proc getWallTime(): BeaconTime = res.beaconClock.now()