standardize on upcoming/specified engine API timeouts (#3637)

This commit is contained in:
tersec 2022-05-17 13:57:33 +00:00 committed by GitHub
parent e7ed7332b3
commit 1177f33363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 11 deletions

View File

@ -32,8 +32,6 @@ export sszdump, signatures_batch
declareHistogram beacon_store_block_duration_seconds, declareHistogram beacon_store_block_duration_seconds,
"storeBlock() duration", buckets = [0.25, 0.5, 1, 2, 4, 8, Inf] "storeBlock() duration", buckets = [0.25, 0.5, 1, 2, 4, 8, Inf]
const web3Timeout = 4.seconds
type type
BlockEntry* = object BlockEntry* = object
blck*: ForkedSignedBeaconBlock blck*: ForkedSignedBeaconBlock
@ -349,7 +347,7 @@ proc runForkchoiceUpdated(
discard awaitWithTimeout( discard awaitWithTimeout(
forkchoiceUpdated( forkchoiceUpdated(
self.consensusManager.eth1Monitor, headBlockRoot, finalizedBlockRoot), self.consensusManager.eth1Monitor, headBlockRoot, finalizedBlockRoot),
web3Timeout): FORKCHOICEUPDATED_TIMEOUT):
debug "runForkChoiceUpdated: forkchoiceUpdated timed out" debug "runForkChoiceUpdated: forkchoiceUpdated timed out"
default(ForkchoiceUpdatedResponse) default(ForkchoiceUpdatedResponse)
except CatchableError as err: except CatchableError as err:
@ -386,7 +384,7 @@ proc newExecutionPayload*(
awaitWithTimeout( awaitWithTimeout(
eth1Monitor.newPayload( eth1Monitor.newPayload(
executionPayload.asEngineExecutionPayload), executionPayload.asEngineExecutionPayload),
web3Timeout): NEWPAYLOAD_TIMEOUT):
info "newPayload: newPayload timed out" info "newPayload: newPayload timed out"
PayloadStatusV1(status: PayloadExecutionStatus.syncing) PayloadStatusV1(status: PayloadExecutionStatus.syncing)
payloadStatus = payloadResponse.status payloadStatus = payloadResponse.status

View File

@ -25,6 +25,12 @@ const
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/bellatrix/beacon-chain.md#transition-settings # https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/bellatrix/beacon-chain.md#transition-settings
TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH* = FAR_FUTURE_EPOCH TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH* = FAR_FUTURE_EPOCH
# https://github.com/ethereum/execution-apis/blob/2c3dffa1ad301a5b1d46212e1bd65e918265cd6f/src/engine/specification.md#request-1
FORKCHOICEUPDATED_TIMEOUT* = 8.seconds
# https://github.com/ethereum/execution-apis/blob/2c3dffa1ad301a5b1d46212e1bd65e918265cd6f/src/engine/specification.md#request
NEWPAYLOAD_TIMEOUT* = 8.seconds
type type
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/bellatrix/beacon-chain.md#custom-types # https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/bellatrix/beacon-chain.md#custom-types
Transaction* = List[byte, Limit MAX_BYTES_PER_TRANSACTION] Transaction* = List[byte, Limit MAX_BYTES_PER_TRANSACTION]

View File

@ -426,8 +426,6 @@ proc forkchoice_updated(state: bellatrix.BeaconState,
fee_recipient: ethtypes.Address, fee_recipient: ethtypes.Address,
execution_engine: Eth1Monitor): execution_engine: Eth1Monitor):
Future[Option[bellatrix.PayloadID]] {.async.} = Future[Option[bellatrix.PayloadID]] {.async.} =
const web3Timeout = 3.seconds
let let
timestamp = compute_timestamp_at_slot(state, state.slot) timestamp = compute_timestamp_at_slot(state, state.slot)
random = get_randao_mix(state, get_current_epoch(state)) random = get_randao_mix(state, get_current_epoch(state))
@ -436,7 +434,7 @@ proc forkchoice_updated(state: bellatrix.BeaconState,
execution_engine.forkchoiceUpdated( execution_engine.forkchoiceUpdated(
head_block_hash, finalized_block_hash, timestamp, random.data, head_block_hash, finalized_block_hash, timestamp, random.data,
fee_recipient), fee_recipient),
web3Timeout): FORKCHOICEUPDATED_TIMEOUT):
info "forkchoice_updated: forkchoiceUpdated timed out" info "forkchoice_updated: forkchoiceUpdated timed out"
default(ForkchoiceUpdatedResponse) default(ForkchoiceUpdatedResponse)
payloadId = forkchoiceResponse.payloadId payloadId = forkchoiceResponse.payloadId
@ -473,6 +471,9 @@ proc getExecutionPayload(node: BeaconNode, proposalState: auto):
# Minimize window for Eth1 monitor to shut down connection # Minimize window for Eth1 monitor to shut down connection
await node.consensusManager.eth1Monitor.ensureDataProvider() await node.consensusManager.eth1Monitor.ensureDataProvider()
# https://github.com/ethereum/execution-apis/blob/2c3dffa1ad301a5b1d46212e1bd65e918265cd6f/src/engine/specification.md#request-2
const GETPAYLOAD_TIMEOUT = 1.seconds
let let
feeRecipient = feeRecipient =
if node.config.suggestedFeeRecipient.isSome: if node.config.suggestedFeeRecipient.isSome:
@ -488,11 +489,17 @@ proc getExecutionPayload(node: BeaconNode, proposalState: auto):
payload_id = (await forkchoice_updated( payload_id = (await forkchoice_updated(
proposalState.bellatrixData.data, latestHead, latestFinalized, proposalState.bellatrixData.data, latestHead, latestFinalized,
feeRecipient, node.consensusManager.eth1Monitor)) feeRecipient, node.consensusManager.eth1Monitor))
payload = await get_execution_payload( payload = awaitWithTimeout(
payload_id, node.consensusManager.eth1Monitor) get_execution_payload(payload_id, node.consensusManager.eth1Monitor),
GETPAYLOAD_TIMEOUT):
info "getExecutionPayload: getPayload timed out; using empty execution payload"
empty_execution_payload
executionPayloadStatus = executionPayloadStatus =
await node.consensusManager.eth1Monitor.newExecutionPayload( awaitWithTimeout(
payload) node.consensusManager.eth1Monitor.newExecutionPayload(payload),
NEWPAYLOAD_TIMEOUT):
info "getExecutionPayload: newPayload timed out"
PayloadExecutionStatus.syncing
if executionPayloadStatus != PayloadExecutionStatus.valid: if executionPayloadStatus != PayloadExecutionStatus.valid:
info "getExecutionPayload: newExecutionPayload not valid; using empty execution payload", info "getExecutionPayload: newExecutionPayload not valid; using empty execution payload",