refactor fcU sending and rename EL-side root to hash (#4614)
This commit is contained in:
parent
07ccd3fa6e
commit
3011d49946
|
@ -68,9 +68,9 @@ proc initLightClient*(
|
||||||
# engine_forkchoiceUpdatedV1
|
# engine_forkchoiceUpdatedV1
|
||||||
let beaconHead = node.attestationPool[].getBeaconHead(nil)
|
let beaconHead = node.attestationPool[].getBeaconHead(nil)
|
||||||
discard await eth1Monitor.runForkchoiceUpdated(
|
discard await eth1Monitor.runForkchoiceUpdated(
|
||||||
headBlockRoot = payload.block_hash,
|
headBlockHash = payload.block_hash,
|
||||||
safeBlockRoot = beaconHead.safeExecutionPayloadHash,
|
safeBlockHash = beaconHead.safeExecutionPayloadHash,
|
||||||
finalizedBlockRoot = beaconHead.finalizedExecutionPayloadHash)
|
finalizedBlockHash = beaconHead.finalizedExecutionPayloadHash)
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
optimisticProcessor = initOptimisticProcessor(
|
optimisticProcessor = initOptimisticProcessor(
|
||||||
|
|
|
@ -166,9 +166,9 @@ func setOptimisticHead*(
|
||||||
|
|
||||||
proc runForkchoiceUpdated*(
|
proc runForkchoiceUpdated*(
|
||||||
eth1Monitor: Eth1Monitor,
|
eth1Monitor: Eth1Monitor,
|
||||||
headBlockRoot, safeBlockRoot, finalizedBlockRoot: Eth2Digest):
|
headBlockHash, safeBlockHash, finalizedBlockHash: Eth2Digest):
|
||||||
Future[(PayloadExecutionStatus, Option[BlockHash])] {.async.} =
|
Future[(PayloadExecutionStatus, Option[BlockHash])] {.async.} =
|
||||||
# Allow finalizedBlockRoot to be 0 to avoid sync deadlocks.
|
# Allow finalizedBlockHash to be 0 to avoid sync deadlocks.
|
||||||
#
|
#
|
||||||
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3675.md#pos-events
|
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3675.md#pos-events
|
||||||
# has "Before the first finalized block occurs in the system the finalized
|
# has "Before the first finalized block occurs in the system the finalized
|
||||||
|
@ -178,7 +178,7 @@ proc runForkchoiceUpdated*(
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/bellatrix/validator.md#executionpayload
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.2/specs/bellatrix/validator.md#executionpayload
|
||||||
# notes "`finalized_block_hash` is the hash of the latest finalized execution
|
# notes "`finalized_block_hash` is the hash of the latest finalized execution
|
||||||
# payload (`Hash32()` if none yet finalized)"
|
# payload (`Hash32()` if none yet finalized)"
|
||||||
doAssert not headBlockRoot.isZero
|
doAssert not headBlockHash.isZero
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Minimize window for Eth1 monitor to shut down connection
|
# Minimize window for Eth1 monitor to shut down connection
|
||||||
|
@ -186,18 +186,18 @@ proc runForkchoiceUpdated*(
|
||||||
|
|
||||||
let fcuR = awaitWithTimeout(
|
let fcuR = awaitWithTimeout(
|
||||||
forkchoiceUpdated(
|
forkchoiceUpdated(
|
||||||
eth1Monitor, headBlockRoot, safeBlockRoot, finalizedBlockRoot),
|
eth1Monitor, headBlockHash, safeBlockHash, finalizedBlockHash),
|
||||||
FORKCHOICEUPDATED_TIMEOUT):
|
FORKCHOICEUPDATED_TIMEOUT):
|
||||||
debug "runForkchoiceUpdated: forkchoiceUpdated timed out",
|
debug "runForkchoiceUpdated: forkchoiceUpdated timed out",
|
||||||
headBlockRoot = shortLog(headBlockRoot),
|
headBlockHash = shortLog(headBlockHash),
|
||||||
safeBlockRoot = shortLog(safeBlockRoot),
|
safeBlockHash = shortLog(safeBlockHash),
|
||||||
finalizedBlockRoot = shortLog(finalizedBlockRoot)
|
finalizedBlockHash = shortLog(finalizedBlockHash)
|
||||||
ForkchoiceUpdatedResponse(
|
ForkchoiceUpdatedResponse(
|
||||||
payloadStatus: PayloadStatusV1(
|
payloadStatus: PayloadStatusV1(
|
||||||
status: PayloadExecutionStatus.syncing))
|
status: PayloadExecutionStatus.syncing))
|
||||||
|
|
||||||
debug "runForkchoiceUpdated: ran forkchoiceUpdated",
|
debug "runForkchoiceUpdated: ran forkchoiceUpdated",
|
||||||
headBlockRoot, safeBlockRoot, finalizedBlockRoot,
|
headBlockHash, safeBlockHash, finalizedBlockHash,
|
||||||
payloadStatus = $fcuR.payloadStatus.status,
|
payloadStatus = $fcuR.payloadStatus.status,
|
||||||
latestValidHash = $fcuR.payloadStatus.latestValidHash,
|
latestValidHash = $fcuR.payloadStatus.latestValidHash,
|
||||||
validationError = $fcuR.payloadStatus.validationError
|
validationError = $fcuR.payloadStatus.validationError
|
||||||
|
@ -206,17 +206,11 @@ proc runForkchoiceUpdated*(
|
||||||
except CatchableError as err:
|
except CatchableError as err:
|
||||||
warn "forkchoiceUpdated failed - check execution client",
|
warn "forkchoiceUpdated failed - check execution client",
|
||||||
err = err.msg,
|
err = err.msg,
|
||||||
headBlockRoot = shortLog(headBlockRoot),
|
headBlockHash = shortLog(headBlockHash),
|
||||||
safeBlockRoot = shortLog(safeBlockRoot),
|
safeBlockHash = shortLog(safeBlockHash),
|
||||||
finalizedBlockRoot = shortLog(finalizedBlockRoot)
|
finalizedBlockHash = shortLog(finalizedBlockHash)
|
||||||
return (PayloadExecutionStatus.syncing, none BlockHash)
|
return (PayloadExecutionStatus.syncing, none BlockHash)
|
||||||
|
|
||||||
proc runForkchoiceUpdatedDiscardResult*(
|
|
||||||
eth1Monitor: Eth1Monitor,
|
|
||||||
headBlockHash, safeBlockHash, finalizedBlockHash: Eth2Digest) {.async.} =
|
|
||||||
discard await eth1Monitor.runForkchoiceUpdated(
|
|
||||||
headBlockHash, safeBlockHash, finalizedBlockHash)
|
|
||||||
|
|
||||||
from ../beacon_clock import GetBeaconTimeFn
|
from ../beacon_clock import GetBeaconTimeFn
|
||||||
from ../fork_choice/fork_choice import mark_root_invalid
|
from ../fork_choice/fork_choice import mark_root_invalid
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,8 @@ import
|
||||||
|
|
||||||
from ../consensus_object_pools/consensus_manager import
|
from ../consensus_object_pools/consensus_manager import
|
||||||
ConsensusManager, checkNextProposer, optimisticExecutionPayloadHash,
|
ConsensusManager, checkNextProposer, optimisticExecutionPayloadHash,
|
||||||
runForkchoiceUpdated, runForkchoiceUpdatedDiscardResult,
|
runForkchoiceUpdated, runProposalForkchoiceUpdated, shouldSyncOptimistically,
|
||||||
runProposalForkchoiceUpdated, shouldSyncOptimistically, updateHead,
|
updateHead, updateHeadWithExecution
|
||||||
updateHeadWithExecution
|
|
||||||
from ../beacon_clock import GetBeaconTimeFn, toFloatSeconds
|
from ../beacon_clock import GetBeaconTimeFn, toFloatSeconds
|
||||||
from ../consensus_object_pools/block_dag import BlockRef, root, shortLog, slot
|
from ../consensus_object_pools/block_dag import BlockRef, root, shortLog, slot
|
||||||
from ../consensus_object_pools/block_pools_types import
|
from ../consensus_object_pools/block_pools_types import
|
||||||
|
@ -549,7 +548,7 @@ proc storeBlock*(
|
||||||
# - "Beacon chain gapped" from DAG head to optimistic head,
|
# - "Beacon chain gapped" from DAG head to optimistic head,
|
||||||
# - followed by "Beacon chain reorged" from optimistic head back to DAG.
|
# - followed by "Beacon chain reorged" from optimistic head back to DAG.
|
||||||
self.consensusManager[].updateHead(newHead.get.blck)
|
self.consensusManager[].updateHead(newHead.get.blck)
|
||||||
await eth1Monitor.runForkchoiceUpdatedDiscardResult(
|
discard await eth1Monitor.runForkchoiceUpdated(
|
||||||
headBlockHash = self.consensusManager[].optimisticExecutionPayloadHash,
|
headBlockHash = self.consensusManager[].optimisticExecutionPayloadHash,
|
||||||
safeBlockHash = newHead.get.safeExecutionPayloadHash,
|
safeBlockHash = newHead.get.safeExecutionPayloadHash,
|
||||||
finalizedBlockHash = newHead.get.finalizedExecutionPayloadHash)
|
finalizedBlockHash = newHead.get.finalizedExecutionPayloadHash)
|
||||||
|
|
|
@ -123,9 +123,9 @@ programMain:
|
||||||
|
|
||||||
# engine_forkchoiceUpdatedV1
|
# engine_forkchoiceUpdatedV1
|
||||||
discard await eth1Monitor.runForkchoiceUpdated(
|
discard await eth1Monitor.runForkchoiceUpdated(
|
||||||
headBlockRoot = payload.block_hash,
|
headBlockHash = payload.block_hash,
|
||||||
safeBlockRoot = payload.block_hash, # stub value
|
safeBlockHash = payload.block_hash, # stub value
|
||||||
finalizedBlockRoot = ZERO_HASH)
|
finalizedBlockHash = ZERO_HASH)
|
||||||
else: discard
|
else: discard
|
||||||
optimisticProcessor = initOptimisticProcessor(
|
optimisticProcessor = initOptimisticProcessor(
|
||||||
getBeaconTime, optimisticHandler)
|
getBeaconTime, optimisticHandler)
|
||||||
|
|
|
@ -1310,8 +1310,8 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||||
assign(ep_dst.gas_limit, ep_src.gas_limit)
|
assign(ep_dst.gas_limit, ep_src.gas_limit)
|
||||||
assign(ep_dst.gas_used, ep_src.gas_used)
|
assign(ep_dst.gas_used, ep_src.gas_used)
|
||||||
assign(ep_dst.timestamp, ep_src.timestamp)
|
assign(ep_dst.timestamp, ep_src.timestamp)
|
||||||
assign(ep_dst.extra_Data, ep_src.extra_Data)
|
assign(ep_dst.extra_data, ep_src.extra_data)
|
||||||
assign(ep_dst.base_fee_per_Gas, ep_src.base_fee_per_Gas)
|
assign(ep_dst.base_fee_per_gas, ep_src.base_fee_per_gas)
|
||||||
assign(ep_dst.block_hash, ep_src.block_hash)
|
assign(ep_dst.block_hash, ep_src.block_hash)
|
||||||
assign(ep_dst.transactions, ep_src.transactions)
|
assign(ep_dst.transactions, ep_src.transactions)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue