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
name: "validator-monitor-totals" }: bool
proposerBoosting* {.
proposerBoostingNoEffect* {.
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
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,
quarantine: ref Quarantine,
onAttestation: OnAttestationCallback = nil,
proposerBoosting: bool = false): T =
onAttestation: OnAttestationCallback = nil): T =
## Initialize an AttestationPool from the dag `headState`
## The `finalized_root` works around the finalized_checkpoint of the genesis block
## holding a zero_root.
let finalizedEpochRef = dag.getFinalizedEpochRef()
var forkChoice = ForkChoice.init(
finalizedEpochRef,
dag.finalizedHead.blck,
proposerBoosting)
var forkChoice = ForkChoice.init(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

@ -51,19 +51,14 @@ logScope:
func init*(T: type ForkChoiceBackend,
justifiedCheckpoint: Checkpoint,
finalizedCheckpoint: Checkpoint,
useProposerBoosting: bool): T =
T(
proto_array: ProtoArray.init(
finalizedCheckpoint: Checkpoint): T =
T(proto_array: ProtoArray.init(
justifiedCheckpoint,
finalizedCheckpoint),
proposer_boosting: useProposerBoosting
)
finalizedCheckpoint))
proc init*(T: type ForkChoice,
epochRef: EpochRef,
blck: BlockRef,
proposerBoosting: bool): T =
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
@ -80,7 +75,7 @@ proc init*(T: type ForkChoice,
ForkChoice(
backend: ForkChoiceBackend.init(
best_justified, finalized, proposerBoosting),
best_justified, finalized),
checkpoints: Checkpoints(
justified: justified,
finalized: finalized,
@ -413,7 +408,7 @@ func find_head*(
# Apply score changes
? self.proto_array.applyScoreChanges(
deltas, justifiedCheckpoint, finalizedCheckpoint,
justified_state_balances, proposer_boost_root, self.proposer_boosting
justified_state_balances, proposer_boost_root
)
self.balances = justified_state_balances

View File

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

View File

@ -130,8 +130,7 @@ func applyScoreChanges*(self: var ProtoArray,
justifiedCheckpoint: Checkpoint,
finalizedCheckpoint: Checkpoint,
newBalances: openArray[Gwei],
proposerBoostRoot: Eth2Digest,
useProposerBoost: bool): FcResult[void] =
proposerBoostRoot: Eth2Digest): FcResult[void] =
## Iterate backwards through the array, touching all nodes and their parents
## 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
# 4. If required, update the parent's best-descendant with the current node
# 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
if deltas.len != self.indices.len:
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,
# decrease the delta by the previous score amount.
if useProposerBoost and
(not self.previousProposerBoostRoot.isZero) and
if (not self.previousProposerBoostRoot.isZero) and
self.previousProposerBoostRoot == node.root:
if nodeDelta < 0 and
nodeDelta - low(Delta) < self.previousProposerBoostScore:
@ -190,8 +185,7 @@ func applyScoreChanges*(self: var ProtoArray,
# 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
if useProposerBoost and (not proposerBoostRoot.isZero) and
proposerBoostRoot == node.root:
if (not proposerBoostRoot.isZero) and proposerBoostRoot == node.root:
proposerBoostScore = calculateProposerBoost(newBalances)
if nodeDelta >= 0 and
high(Delta) - nodeDelta < self.previousProposerBoostScore:
@ -245,9 +239,8 @@ func applyScoreChanges*(self: var ProtoArray,
deltas[parentPhysicalIdx] += nodeDelta
# After applying all deltas, update the `previous_proposer_boost`.
if useProposerBoost:
self.previousProposerBoostRoot = proposerBoostRoot
self.previousProposerBoostScore = proposerBoostScore
self.previousProposerBoostRoot = proposerBoostRoot
self.previousProposerBoostScore = proposerBoostScore
for nodePhysicalIdx in countdown(self.nodes.len - 1, 0):
if node.root.isZero:

View File

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

View File

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

View File

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

View File

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

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.
result.fork_choice = ForkChoiceBackend.init(
justifiedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1)),
finalizedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1)),
true # use proposer boosting, though the proposer boost root not set
finalizedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1))
)
# ----------------------------------

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.
result.fork_choice = ForkChoiceBackend.init(
justifiedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1)),
finalizedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1)),
true # use proposer boosting, though the proposer boost root not set
finalizedCheckpoint = Checkpoint(root: GenesisRoot, epoch: Epoch(1))
)
# ----------------------------------

View File

@ -448,6 +448,8 @@ suite "Attestation pool processing" & preset():
check:
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
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]
@ -457,7 +459,8 @@ suite "Attestation pool processing" & preset():
epochRef: EpochRef):
# Callback add to fork choice if valid
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(
state[], getStateField(state[], slot) - 1, 1.CommitteeIndex,