remove option to select Capella fork choice algo (#6478)

* remove option to select Capella fork choice algo

With Deneb having run stable for quite a while now, it's time to remove
the option to select the prior fork choice algo from Capella.

* also remove usage from test
This commit is contained in:
Etan Kissling 2024-08-07 16:48:05 +02:00 committed by GitHub
parent 32fe62f084
commit 3375875e05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 17 additions and 60 deletions

View File

@ -32,8 +32,6 @@ import
from std/os import getHomeDir, parentDir, `/`
from std/strutils import parseBiggestUInt, replace
from fork_choice/fork_choice_types
import ForkChoiceVersion
from consensus_object_pools/block_pools_types_light_client
import LightClientDataImportMode
@ -676,12 +674,6 @@ type
desc: "Bandwidth estimate for the node (bits per second)"
name: "debug-bandwidth-estimate" .}: Option[Natural]
forkChoiceVersion* {.
hidden
desc: "Forkchoice version to use. " &
"Must be one of: stable"
name: "debug-forkchoice-version" .}: Option[ForkChoiceVersion]
of BNStartUpCmd.wallets:
case walletsCmd* {.command.}: WalletsCmd
of WalletsCmd.create:

View File

@ -104,7 +104,6 @@ declareGauge attestation_pool_block_attestation_packing_time,
proc init*(T: type AttestationPool, dag: ChainDAGRef,
quarantine: ref Quarantine,
forkChoiceVersion = ForkChoiceVersion.Stable,
onAttestation: OnPhase0AttestationCallback = nil,
onElectraAttestation: OnElectraAttestationCallback = nil): T =
## Initialize an AttestationPool from the dag `headState`
@ -113,7 +112,7 @@ proc init*(T: type AttestationPool, dag: ChainDAGRef,
let finalizedEpochRef = dag.getFinalizedEpochRef()
var forkChoice = ForkChoice.init(
finalizedEpochRef, dag.finalizedHead.blck, forkChoiceVersion)
finalizedEpochRef, dag.finalizedHead.blck)
# Feed fork choice with unfinalized history - during startup, block pool only
# keeps track of a single history so we just need to follow it

View File

@ -49,13 +49,11 @@ func compute_deltas(
logScope: topics = "fork_choice"
func init*(
T: type ForkChoiceBackend, checkpoints: FinalityCheckpoints,
version: ForkChoiceVersion): T =
T(proto_array: ProtoArray.init(checkpoints, version))
T: type ForkChoiceBackend, checkpoints: FinalityCheckpoints): T =
T(proto_array: ProtoArray.init(checkpoints))
proc init*(
T: type ForkChoice, epochRef: EpochRef, blck: BlockRef,
version: ForkChoiceVersion): T =
T: type ForkChoice, epochRef: EpochRef, blck: BlockRef): T =
## Initialize a fork choice context for a finalized state - in the finalized
## state, the justified and finalized checkpoints are the same, so only one
## is used here
@ -67,10 +65,8 @@ proc init*(
backend: ForkChoiceBackend.init(
FinalityCheckpoints(
justified: checkpoint,
finalized: checkpoint),
version),
finalized: checkpoint)),
checkpoints: Checkpoints(
version: version,
justified: BalanceCheckpoint(
checkpoint: checkpoint,
total_active_balance: epochRef.total_active_balance,

View File

@ -29,14 +29,6 @@ import
# ----------------------------------------------------------------------
type
ForkChoiceVersion* {.pure.} = enum
## Controls which version of fork choice to run.
Stable = "stable"
## Use current version from stable Ethereum consensus specifications
Pr3431 = "pr3431"
## https://github.com/ethereum/consensus-specs/pull/3431
## https://github.com/ethereum/consensus-specs/issues/3466
fcKind* = enum
## Fork Choice Error Kinds
fcFinalizedNodeUnknown
@ -96,7 +88,6 @@ type
## Subtracted from logical index to get the physical index
ProtoArray* = object
version*: ForkChoiceVersion
currentEpoch*: Epoch
checkpoints*: FinalityCheckpoints
nodes*: ProtoNodes
@ -121,7 +112,6 @@ type
balances*: seq[Gwei]
Checkpoints* = object
version*: ForkChoiceVersion
time*: BeaconTime
justified*: BalanceCheckpoint
finalized*: Checkpoint

View File

@ -90,8 +90,7 @@ func nodeLeadsToViableHead(
# ----------------------------------------------------------------------
func init*(
T: type ProtoArray, checkpoints: FinalityCheckpoints,
version: ForkChoiceVersion): T =
T: type ProtoArray, checkpoints: FinalityCheckpoints): T =
let node = ProtoNode(
bid: BlockId(
slot: checkpoints.finalized.epoch.start_slot,
@ -103,8 +102,7 @@ func init*(
bestChild: none(int),
bestDescendant: none(int))
T(version: version,
checkpoints: checkpoints,
T(checkpoints: checkpoints,
nodes: ProtoNodes(buf: @[node], offset: 0),
indices: {node.bid.root: 0}.toTable())
@ -536,23 +534,10 @@ func nodeIsViableForHead(
node.checkpoints.justified.epoch == self.checkpoints.justified.epoch
if not correctJustified:
case self.version
of ForkChoiceVersion.Stable:
# If the previous epoch is justified, the block should be pulled-up.
# In this case, check that unrealized justification is higher than the
# store and that the voting source is not more than two epochs ago
if self.isPreviousEpochJustified and
node.bid.slot.epoch == self.currentEpoch:
let unrealized =
self.currentEpochTips.getOrDefault(nodeIdx, node.checkpoints)
correctJustified =
unrealized.justified.epoch >= self.checkpoints.justified.epoch and
node.checkpoints.justified.epoch + 2 >= self.currentEpoch
of ForkChoiceVersion.Pr3431:
# The voting source should be either at the same height as the store's
# justified checkpoint or not more than two epochs ago
correctJustified =
node.checkpoints.justified.epoch + 2 >= self.currentEpoch
# The voting source should be either at the same height as the store's
# justified checkpoint or not more than two epochs ago
correctJustified =
node.checkpoints.justified.epoch + 2 >= self.currentEpoch
return
if not correctJustified:
@ -565,7 +550,7 @@ func nodeIsViableForHead(
true
else:
# Check that this node is not going to be pruned
let
let
finalizedEpoch = self.checkpoints.finalized.epoch
finalizedSlot = finalizedEpoch.start_slot
var ancestor = some node

View File

@ -385,7 +385,7 @@ proc initFullNode(
quarantine = newClone(
Quarantine.init())
attestationPool = newClone(AttestationPool.init(
dag, quarantine, config.forkChoiceVersion.get, onAttestationReceived))
dag, quarantine, onAttestationReceived))
syncCommitteeMsgPool = newClone(
SyncCommitteeMsgPool.init(rng, dag.cfg, onSyncContribution))
lightClientPool = newClone(
@ -2249,8 +2249,6 @@ proc doRunBeaconNode(config: var BeaconNodeConf, rng: ref HmacDrbgContext) {.rai
# works
for node in metadata.bootstrapNodes:
config.bootstrapNodes.add node
if config.forkChoiceVersion.isNone:
config.forkChoiceVersion = some(ForkChoiceVersion.Pr3431)
## Ctrl+C handling
proc controlCHandler() {.noconv.} =

View File

@ -90,8 +90,7 @@ proc installDebugApiHandlers*(router: var RestRouter, node: BeaconNode) =
var response = GetForkChoiceResponse(
justified_checkpoint: forkChoice.checkpoints.justified.checkpoint,
finalized_checkpoint: forkChoice.checkpoints.finalized,
extra_data: RestExtraData(
version: some($forkChoice.backend.proto_array.version)))
extra_data: RestExtraData())
for item in forkChoice.backend.proto_array:
let

View File

@ -601,7 +601,7 @@ type
extra_data*: Option[RestNodeExtraData]
RestExtraData* = object
version*: Option[string]
discard
GetForkChoiceResponse* = object
justified_checkpoint*: Checkpoint

View File

@ -90,8 +90,7 @@ proc initialLoad(
dag = ChainDAGRef.init(
forkedState[].kind.genesisTestRuntimeConfig, db, validatorMonitor, {})
fkChoice = newClone(ForkChoice.init(
dag.getFinalizedEpochRef(), dag.finalizedHead.blck,
ForkChoiceVersion.Pr3431))
dag.getFinalizedEpochRef(), dag.finalizedHead.blck))
(dag, fkChoice)

View File

@ -298,8 +298,7 @@ proc startBeaconNode(basePort: int) {.raises: [CatchableError].} =
"--keymanager-port=" & $(basePort + PortKind.KeymanagerBN.ord),
"--keymanager-token-file=" & tokenFilePath,
"--suggested-fee-recipient=" & $defaultFeeRecipient,
"--doppelganger-detection=off",
"--debug-forkchoice-version=stable"], it))
"--doppelganger-detection=off"], it))
except Exception as exc: # TODO fix confutils exceptions
raiseAssert exc.msg