Don't search for the TTD block after the merge (#4152)
This commit is contained in:
parent
bed8318b7f
commit
154723947b
|
@ -141,6 +141,8 @@ type
|
|||
stopFut: Future[void]
|
||||
getBeaconTime: GetBeaconTimeFn
|
||||
|
||||
ttdReachedField: bool
|
||||
|
||||
when hasGenesisDetection:
|
||||
genesisValidators: seq[ImmutableValidatorData]
|
||||
genesisValidatorKeyToIndex: Table[ValidatorPubKey, ValidatorIndex]
|
||||
|
@ -196,6 +198,9 @@ declareGauge eth1_finalized_deposits,
|
|||
declareGauge eth1_chain_len,
|
||||
"The length of the in-memory chain of Eth1 blocks"
|
||||
|
||||
func ttdReached*(m: Eth1Monitor): bool =
|
||||
m.ttdReachedField
|
||||
|
||||
template cfg(m: Eth1Monitor): auto =
|
||||
m.depositsChain.cfg
|
||||
|
||||
|
@ -1039,7 +1044,8 @@ proc init*(T: type Eth1Monitor,
|
|||
depositContractSnapshot: Option[DepositContractSnapshot],
|
||||
eth1Network: Option[Eth1Network],
|
||||
forcePolling: bool,
|
||||
jwtSecret: Option[seq[byte]]): T =
|
||||
jwtSecret: Option[seq[byte]],
|
||||
ttdReached: bool): T =
|
||||
doAssert web3Urls.len > 0
|
||||
var web3Urls = web3Urls
|
||||
for url in mitems(web3Urls):
|
||||
|
@ -1057,7 +1063,8 @@ proc init*(T: type Eth1Monitor,
|
|||
eth1Progress: newAsyncEvent(),
|
||||
forcePolling: forcePolling,
|
||||
jwtSecret: jwtSecret,
|
||||
blocksPerLogsRequest: targetBlocksPerLogsRequest)
|
||||
blocksPerLogsRequest: targetBlocksPerLogsRequest,
|
||||
ttdReachedField: ttdReached)
|
||||
|
||||
proc safeCancel(fut: var Future[void]) =
|
||||
if not fut.isNil and not fut.finished:
|
||||
|
@ -1450,7 +1457,8 @@ proc startEth1Syncing(m: Eth1Monitor, delayBeforeStart: Duration) {.async.} =
|
|||
let shouldCheckForMergeTransition = block:
|
||||
const FAR_FUTURE_TOTAL_DIFFICULTY =
|
||||
u256"115792089237316195423570985008687907853269984665640564039457584007913129638912"
|
||||
m.cfg.TERMINAL_TOTAL_DIFFICULTY != FAR_FUTURE_TOTAL_DIFFICULTY
|
||||
(not m.ttdReachedField) and
|
||||
(m.cfg.TERMINAL_TOTAL_DIFFICULTY != FAR_FUTURE_TOTAL_DIFFICULTY)
|
||||
|
||||
var didPollOnce = false
|
||||
while true:
|
||||
|
@ -1519,6 +1527,7 @@ proc startEth1Syncing(m: Eth1Monitor, delayBeforeStart: Duration) {.async.} =
|
|||
break
|
||||
terminalBlockCandidate = parentBlock
|
||||
m.terminalBlockHash = some terminalBlockCandidate.hash
|
||||
m.ttdReachedField = true
|
||||
|
||||
debug "startEth1Syncing: found merge terminal block",
|
||||
currentEpoch = m.currentEpoch,
|
||||
|
|
|
@ -503,7 +503,7 @@ proc runQueueProcessingLoop*(self: ref BlockProcessor) {.async.} =
|
|||
executionPayloadStatus =
|
||||
if hasExecutionPayload:
|
||||
# Eth1 syncing is asynchronous from this
|
||||
# TODO self.consensusManager.eth1Monitor.terminalBlockHash.isSome
|
||||
# TODO self.consensusManager.eth1Monitor.ttdReached
|
||||
# should gate this when it works more reliably
|
||||
# TODO detect have-TTD-but-not-is_execution_block case, and where
|
||||
# execution payload was non-zero when TTD detection more reliable
|
||||
|
|
|
@ -541,7 +541,8 @@ proc init*(T: type BeaconNode,
|
|||
getDepositContractSnapshot(),
|
||||
eth1Network,
|
||||
config.web3ForcePolling,
|
||||
optJwtSecret)
|
||||
optJwtSecret,
|
||||
ttdReached = false)
|
||||
|
||||
eth1Monitor.loadPersistedDeposits()
|
||||
|
||||
|
@ -642,7 +643,8 @@ proc init*(T: type BeaconNode,
|
|||
getDepositContractSnapshot(),
|
||||
eth1Network,
|
||||
config.web3ForcePolling,
|
||||
optJwtSecret)
|
||||
optJwtSecret,
|
||||
ttdReached = not dag.loadExecutionBlockRoot(dag.finalizedHead.blck).isZero)
|
||||
|
||||
if config.rpcEnabled:
|
||||
warn "Nimbus's JSON-RPC server has been removed. This includes the --rpc, --rpc-port, and --rpc-address configuration options. https://nimbus.guide/rest-api.html shows how to enable and configure the REST Beacon API server which replaces it."
|
||||
|
|
|
@ -64,7 +64,10 @@ programMain:
|
|||
cfg, db = nil, getBeaconTime, config.web3Urls,
|
||||
none(DepositContractSnapshot), metadata.eth1Network,
|
||||
forcePolling = false,
|
||||
rng[].loadJwtSecret(config, allowCreate = false))
|
||||
rng[].loadJwtSecret(config, allowCreate = false),
|
||||
# TTD is not relevant for the light client, so it's safe
|
||||
# to assume that the TTD has been reached.
|
||||
ttdReached = true)
|
||||
waitFor res.ensureDataProvider()
|
||||
res
|
||||
else:
|
||||
|
|
|
@ -373,18 +373,15 @@ proc getExecutionPayload[T](
|
|||
const GETPAYLOAD_TIMEOUT = 1.seconds
|
||||
|
||||
let
|
||||
terminalBlockHash =
|
||||
if node.eth1Monitor.terminalBlockHash.isSome:
|
||||
node.eth1Monitor.terminalBlockHash.get.asEth2Digest
|
||||
else:
|
||||
default(Eth2Digest)
|
||||
beaconHead = node.attestationPool[].getBeaconHead(node.dag.head)
|
||||
executionBlockRoot = node.dag.loadExecutionBlockRoot(beaconHead.blck)
|
||||
latestHead =
|
||||
if not executionBlockRoot.isZero:
|
||||
executionBlockRoot
|
||||
elif node.eth1Monitor.terminalBlockHash.isSome:
|
||||
node.eth1Monitor.terminalBlockHash.get.asEth2Digest
|
||||
else:
|
||||
terminalBlockHash
|
||||
default(Eth2Digest)
|
||||
latestSafe = beaconHead.safeExecutionPayloadHash
|
||||
latestFinalized = beaconHead.finalizedExecutionPayloadHash
|
||||
feeRecipient = node.getFeeRecipient(pubkey, validator_index, epoch)
|
||||
|
@ -489,8 +486,7 @@ proc makeBeaconBlockForHeadAndSlot*(
|
|||
elif slot.epoch < node.dag.cfg.BELLATRIX_FORK_EPOCH or
|
||||
not (
|
||||
is_merge_transition_complete(proposalState[]) or
|
||||
((not node.eth1Monitor.isNil) and
|
||||
node.eth1Monitor.terminalBlockHash.isSome)):
|
||||
((not node.eth1Monitor.isNil) and node.eth1Monitor.ttdReached)):
|
||||
# https://github.com/nim-lang/Nim/issues/19802
|
||||
(static(default(bellatrix.ExecutionPayload)))
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue