mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-17 08:56:45 +00:00
Remove optimistic sync candidate check (#4129)
This commit is contained in:
parent
6ad9b3214d
commit
ab3ac64b19
@ -190,7 +190,7 @@ proc expectValidForkchoiceUpdated(
|
|||||||
from ../consensus_object_pools/attestation_pool import
|
from ../consensus_object_pools/attestation_pool import
|
||||||
addForkChoice, selectOptimisticHead, BeaconHead
|
addForkChoice, selectOptimisticHead, BeaconHead
|
||||||
from ../consensus_object_pools/blockchain_dag import
|
from ../consensus_object_pools/blockchain_dag import
|
||||||
is_optimistic, loadExecutionBlockRoot, markBlockVerified
|
is_optimistic, loadExecutionBlockRoot, markBlockInvalid, markBlockVerified
|
||||||
from ../consensus_object_pools/block_dag import shortLog
|
from ../consensus_object_pools/block_dag import shortLog
|
||||||
from ../consensus_object_pools/spec_cache import get_attesting_indices
|
from ../consensus_object_pools/spec_cache import get_attesting_indices
|
||||||
from ../spec/datatypes/phase0 import TrustedSignedBeaconBlock
|
from ../spec/datatypes/phase0 import TrustedSignedBeaconBlock
|
||||||
@ -481,38 +481,6 @@ proc newExecutionPayload*(
|
|||||||
error "newPayload failed", msg = err.msg
|
error "newPayload failed", msg = err.msg
|
||||||
return Opt.none PayloadExecutionStatus
|
return Opt.none PayloadExecutionStatus
|
||||||
|
|
||||||
from ../consensus_object_pools/blockchain_dag import
|
|
||||||
getBlockRef, loadExecutionBlockRoot, markBlockInvalid
|
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/sync/optimistic.md#helpers
|
|
||||||
proc is_optimistic_candidate_block(
|
|
||||||
self: BlockProcessor, blck: ForkedSignedBeaconBlock): bool =
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/sync/optimistic.md#when-to-optimistically-import-blocks
|
|
||||||
# The current slot (as per the system clock) is at least
|
|
||||||
# `SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY` ahead of the slot of the block being
|
|
||||||
# imported.
|
|
||||||
if blck.slot + self.safeSlotsToImportOptimistically <=
|
|
||||||
self.getBeaconTime().slotOrZero:
|
|
||||||
return true
|
|
||||||
|
|
||||||
# Once merge is finalized, always true; in principle, should be caught by
|
|
||||||
# other checks, but sometimes blocks arrive out of order, triggering some
|
|
||||||
# spurious false negatives because the parent-block-check does not find a
|
|
||||||
# parent block. This can also occur under conditions where EL client RPCs
|
|
||||||
# cause processing delays. Either way, bound this risk to post-merge head
|
|
||||||
# and pre-merge finalization.
|
|
||||||
if not self.consensusManager.dag.loadExecutionBlockRoot(
|
|
||||||
self.consensusManager.dag.finalizedHead.blck).isZero:
|
|
||||||
return true
|
|
||||||
|
|
||||||
let
|
|
||||||
parentRoot = withBlck(blck): blck.message.parent_root
|
|
||||||
parentBlck = self.consensusManager.dag.getBlockRef(parentRoot).valueOr:
|
|
||||||
return false
|
|
||||||
|
|
||||||
# The parent of the block has execution enabled.
|
|
||||||
not self.consensusManager.dag.loadExecutionBlockRoot(parentBlck).isZero
|
|
||||||
|
|
||||||
proc runQueueProcessingLoop*(self: ref BlockProcessor) {.async.} =
|
proc runQueueProcessingLoop*(self: ref BlockProcessor) {.async.} =
|
||||||
while true:
|
while true:
|
||||||
# Cooperative concurrency: one block per loop iteration - because
|
# Cooperative concurrency: one block per loop iteration - because
|
||||||
@ -594,14 +562,6 @@ proc runQueueProcessingLoop*(self: ref BlockProcessor) {.async.} =
|
|||||||
if not blck.resfut.isNil:
|
if not blck.resfut.isNil:
|
||||||
blck.resfut.complete(Result[void, BlockError].err(BlockError.Invalid))
|
blck.resfut.complete(Result[void, BlockError].err(BlockError.Invalid))
|
||||||
else:
|
else:
|
||||||
if executionPayloadStatus == PayloadExecutionStatus.valid or
|
|
||||||
self[].is_optimistic_candidate_block(blck.blck):
|
|
||||||
self[].processBlock(
|
self[].processBlock(
|
||||||
blck,
|
blck,
|
||||||
payloadValid = executionPayloadStatus == PayloadExecutionStatus.valid)
|
payloadValid = executionPayloadStatus == PayloadExecutionStatus.valid)
|
||||||
else:
|
|
||||||
debug "runQueueProcessingLoop: block cannot be optimistically imported",
|
|
||||||
blck = shortLog(blck.blck)
|
|
||||||
if not blck.resfut.isNil:
|
|
||||||
blck.resfut.complete(
|
|
||||||
Result[void, BlockError].err(BlockError.MissingParent))
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user