keep proposer boosting permanently enabled (#3565)

This commit is contained in:
tersec 2022-04-12 10:06:30 +00:00 committed by GitHub
parent 039bece917
commit ff6c581273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 24 additions and 44 deletions

View File

@ -493,9 +493,9 @@ type
defaultValue: false defaultValue: false
name: "validator-monitor-totals" }: bool name: "validator-monitor-totals" }: bool
proposerBoosting* {. proposerBoostingNoEffect* {.
hidden hidden
desc: "Enable proposer boosting; temporary option feature gate (debugging; option may be removed without warning)", desc: "No-op stub; may be removed without warning",
defaultValue: false defaultValue: false
name: "proposer-boosting-debug" }: bool name: "proposer-boosting-debug" }: bool

View File

@ -86,17 +86,13 @@ declareGauge attestation_pool_block_attestation_packing_time,
proc init*(T: type AttestationPool, dag: ChainDAGRef, proc init*(T: type AttestationPool, dag: ChainDAGRef,
quarantine: ref Quarantine, quarantine: ref Quarantine,
onAttestation: OnAttestationCallback = nil, onAttestation: OnAttestationCallback = nil): T =
proposerBoosting: bool = false): T =
## Initialize an AttestationPool from the dag `headState` ## Initialize an AttestationPool from the dag `headState`
## The `finalized_root` works around the finalized_checkpoint of the genesis block ## The `finalized_root` works around the finalized_checkpoint of the genesis block
## holding a zero_root. ## holding a zero_root.
let finalizedEpochRef = dag.getFinalizedEpochRef() let finalizedEpochRef = dag.getFinalizedEpochRef()
var forkChoice = ForkChoice.init( var forkChoice = ForkChoice.init(finalizedEpochRef, dag.finalizedHead.blck)
finalizedEpochRef,
dag.finalizedHead.blck,
proposerBoosting)
# Feed fork choice with unfinalized history - during startup, block pool only # Feed fork choice with unfinalized history - during startup, block pool only
# keeps track of a single history so we just need to follow it # keeps track of a single history so we just need to follow it

View File

@ -51,19 +51,14 @@ logScope:
func init*(T: type ForkChoiceBackend, func init*(T: type ForkChoiceBackend,
justifiedCheckpoint: Checkpoint, justifiedCheckpoint: Checkpoint,
finalizedCheckpoint: Checkpoint, finalizedCheckpoint: Checkpoint): T =
useProposerBoosting: bool): T = T(proto_array: ProtoArray.init(
T(
proto_array: ProtoArray.init(
justifiedCheckpoint, justifiedCheckpoint,
finalizedCheckpoint), finalizedCheckpoint))
proposer_boosting: useProposerBoosting
)
proc init*(T: type ForkChoice, proc init*(T: type ForkChoice,
epochRef: EpochRef, epochRef: EpochRef,
blck: BlockRef, blck: BlockRef): T =
proposerBoosting: bool): T =
## Initialize a fork choice context for a finalized state - in the finalized ## Initialize a fork choice context for a finalized state - in the finalized
## state, the justified and finalized checkpoints are the same, so only one ## state, the justified and finalized checkpoints are the same, so only one
## is used here ## is used here
@ -80,7 +75,7 @@ proc init*(T: type ForkChoice,
ForkChoice( ForkChoice(
backend: ForkChoiceBackend.init( backend: ForkChoiceBackend.init(
best_justified, finalized, proposerBoosting), best_justified, finalized),
checkpoints: Checkpoints( checkpoints: Checkpoints(
justified: justified, justified: justified,
finalized: finalized, finalized: finalized,
@ -413,7 +408,7 @@ func find_head*(
# Apply score changes # Apply score changes
? self.proto_array.applyScoreChanges( ? self.proto_array.applyScoreChanges(
deltas, justifiedCheckpoint, finalizedCheckpoint, deltas, justifiedCheckpoint, finalizedCheckpoint,
justified_state_balances, proposer_boost_root, self.proposer_boosting justified_state_balances, proposer_boost_root
) )
self.balances = justified_state_balances self.balances = justified_state_balances

View File

@ -130,7 +130,6 @@ type
proto_array*: ProtoArray proto_array*: ProtoArray
votes*: seq[VoteTracker] votes*: seq[VoteTracker]
balances*: seq[Gwei] balances*: seq[Gwei]
proposer_boosting*: bool
QueuedAttestation* = object QueuedAttestation* = object
slot*: Slot slot*: Slot

View File

@ -130,8 +130,7 @@ func applyScoreChanges*(self: var ProtoArray,
justifiedCheckpoint: Checkpoint, justifiedCheckpoint: Checkpoint,
finalizedCheckpoint: Checkpoint, finalizedCheckpoint: Checkpoint,
newBalances: openArray[Gwei], newBalances: openArray[Gwei],
proposerBoostRoot: Eth2Digest, proposerBoostRoot: Eth2Digest): FcResult[void] =
useProposerBoost: bool): FcResult[void] =
## Iterate backwards through the array, touching all nodes and their parents ## Iterate backwards through the array, touching all nodes and their parents
## and potentially the best-child of each parent. ## and potentially the best-child of each parent.
# #
@ -146,9 +145,6 @@ func applyScoreChanges*(self: var ProtoArray,
# updating if the current node should become the best-child # updating if the current node should become the best-child
# 4. If required, update the parent's best-descendant with the current node # 4. If required, update the parent's best-descendant with the current node
# or its best-descendant # or its best-descendant
#
# useProposerBoost is temporary, until it can be either permanently enabled
# or is removed from the Eth2 spec.
doAssert self.indices.len == self.nodes.len # By construction doAssert self.indices.len == self.nodes.len # By construction
if deltas.len != self.indices.len: if deltas.len != self.indices.len:
return err ForkChoiceError( return err ForkChoiceError(
@ -176,8 +172,7 @@ func applyScoreChanges*(self: var ProtoArray,
# If we find the node for which the proposer boost was previously applied, # If we find the node for which the proposer boost was previously applied,
# decrease the delta by the previous score amount. # decrease the delta by the previous score amount.
if useProposerBoost and if (not self.previousProposerBoostRoot.isZero) and
(not self.previousProposerBoostRoot.isZero) and
self.previousProposerBoostRoot == node.root: self.previousProposerBoostRoot == node.root:
if nodeDelta < 0 and if nodeDelta < 0 and
nodeDelta - low(Delta) < self.previousProposerBoostScore: nodeDelta - low(Delta) < self.previousProposerBoostScore:
@ -190,8 +185,7 @@ func applyScoreChanges*(self: var ProtoArray,
# the delta by the new score amount. # the delta by the new score amount.
# #
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/fork-choice.md#get_latest_attesting_balance # https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/fork-choice.md#get_latest_attesting_balance
if useProposerBoost and (not proposerBoostRoot.isZero) and if (not proposerBoostRoot.isZero) and proposerBoostRoot == node.root:
proposerBoostRoot == node.root:
proposerBoostScore = calculateProposerBoost(newBalances) proposerBoostScore = calculateProposerBoost(newBalances)
if nodeDelta >= 0 and if nodeDelta >= 0 and
high(Delta) - nodeDelta < self.previousProposerBoostScore: high(Delta) - nodeDelta < self.previousProposerBoostScore:
@ -245,7 +239,6 @@ func applyScoreChanges*(self: var ProtoArray,
deltas[parentPhysicalIdx] += nodeDelta deltas[parentPhysicalIdx] += nodeDelta
# After applying all deltas, update the `previous_proposer_boost`. # After applying all deltas, update the `previous_proposer_boost`.
if useProposerBoost:
self.previousProposerBoostRoot = proposerBoostRoot self.previousProposerBoostRoot = proposerBoostRoot
self.previousProposerBoostScore = proposerBoostScore self.previousProposerBoostScore = proposerBoostScore

View File

@ -249,8 +249,7 @@ proc initFullNode(
quarantine = newClone( quarantine = newClone(
Quarantine.init()) Quarantine.init())
attestationPool = newClone( attestationPool = newClone(
AttestationPool.init( AttestationPool.init(dag, quarantine, onAttestationReceived))
dag, quarantine, onAttestationReceived, config.proposerBoosting))
syncCommitteeMsgPool = newClone( syncCommitteeMsgPool = newClone(
SyncCommitteeMsgPool.init(rng, onSyncContribution)) SyncCommitteeMsgPool.init(rng, onSyncContribution))
exitPool = newClone( exitPool = newClone(

View File

@ -100,7 +100,6 @@ proc initialLoad(
fkChoice = newClone(ForkChoice.init( fkChoice = newClone(ForkChoice.init(
dag.getFinalizedEpochRef(), dag.getFinalizedEpochRef(),
dag.finalizedHead.blck, dag.finalizedHead.blck,
true
)) ))
(dag, fkChoice) (dag, fkChoice)

View File

@ -14,8 +14,7 @@ func setup_finality_01(): tuple[fork_choice: ForkChoiceBackend, ops: seq[Operati
# Initialize the fork choice context # Initialize the fork choice context
result.fork_choice = ForkChoiceBackend.init( result.fork_choice = ForkChoiceBackend.init(
justifiedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(0)), justifiedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(0)),
finalizedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(0)), finalizedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(0))
true # use proposer boosting, though the proposer boost root not set
) )
# ---------------------------------- # ----------------------------------

View File

@ -14,8 +14,7 @@ func setup_finality_02(): tuple[fork_choice: ForkChoiceBackend, ops: seq[Operati
# Initialize the fork choice context # Initialize the fork choice context
result.fork_choice = ForkChoiceBackend.init( result.fork_choice = ForkChoiceBackend.init(
justifiedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1)), justifiedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1)),
finalizedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1)), finalizedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1))
true # use proposer boosting, though the proposer boost root not set
) )
# ---------------------------------- # ----------------------------------

View File

@ -15,8 +15,7 @@ func setup_no_votes(): tuple[fork_choice: ForkChoiceBackend, ops: seq[Operation]
# We start with epoch 0 fully finalized to avoid epoch 0 special cases. # We start with epoch 0 fully finalized to avoid epoch 0 special cases.
result.fork_choice = ForkChoiceBackend.init( result.fork_choice = ForkChoiceBackend.init(
justifiedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1)), justifiedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1)),
finalizedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1)), finalizedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1))
true # use proposer boosting, though the proposer boost root not set
) )
# ---------------------------------- # ----------------------------------

View File

@ -15,8 +15,7 @@ func setup_votes(): tuple[fork_choice: ForkChoiceBackend, ops: seq[Operation]] =
# We start with epoch 0 fully finalized to avoid epoch 0 special cases. # We start with epoch 0 fully finalized to avoid epoch 0 special cases.
result.fork_choice = ForkChoiceBackend.init( result.fork_choice = ForkChoiceBackend.init(
justifiedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1)), justifiedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1)),
finalizedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1)), finalizedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1))
true # use proposer boosting, though the proposer boost root not set
) )
# ---------------------------------- # ----------------------------------

View File

@ -448,6 +448,8 @@ suite "Attestation pool processing" & preset():
check: check:
head == b10Add[] head == b10Add[]
# Add a block too late to be timely enough to be proposer-boosted, which
# would otherwise cause it to be selected as head
let let
b11 = makeTestBlock(state[], cache, b11 = makeTestBlock(state[], cache,
graffiti = GraffitiBytes [1'u8, 0, 0, 0 ,0 ,0 ,0 ,0 ,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] graffiti = GraffitiBytes [1'u8, 0, 0, 0 ,0 ,0 ,0 ,0 ,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
@ -457,7 +459,8 @@ suite "Attestation pool processing" & preset():
epochRef: EpochRef): epochRef: EpochRef):
# Callback add to fork choice if valid # Callback add to fork choice if valid
pool[].addForkChoice( pool[].addForkChoice(
epochRef, blckRef, signedBlock.message, blckRef.slot.start_beacon_time) epochRef, blckRef, signedBlock.message,
blckRef.slot.start_beacon_time + SECONDS_PER_SLOT.int64.seconds)
bc1 = get_beacon_committee( bc1 = get_beacon_committee(
state[], getStateField(state[], slot) - 1, 1.CommitteeIndex, state[], getStateField(state[], slot) - 1, 1.CommitteeIndex,