From 1177f333638b694f2f40fdc052426fbe9078d7b9 Mon Sep 17 00:00:00 2001 From: tersec Date: Tue, 17 May 2022 13:57:33 +0000 Subject: [PATCH] standardize on upcoming/specified engine API timeouts (#3637) --- .../gossip_processing/block_processor.nim | 6 ++---- beacon_chain/spec/datatypes/bellatrix.nim | 6 ++++++ beacon_chain/validators/validator_duties.nim | 21 ++++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/beacon_chain/gossip_processing/block_processor.nim b/beacon_chain/gossip_processing/block_processor.nim index fc9a6d0ea..f1b8b199f 100644 --- a/beacon_chain/gossip_processing/block_processor.nim +++ b/beacon_chain/gossip_processing/block_processor.nim @@ -32,8 +32,6 @@ export sszdump, signatures_batch declareHistogram beacon_store_block_duration_seconds, "storeBlock() duration", buckets = [0.25, 0.5, 1, 2, 4, 8, Inf] -const web3Timeout = 4.seconds - type BlockEntry* = object blck*: ForkedSignedBeaconBlock @@ -349,7 +347,7 @@ proc runForkchoiceUpdated( discard awaitWithTimeout( forkchoiceUpdated( self.consensusManager.eth1Monitor, headBlockRoot, finalizedBlockRoot), - web3Timeout): + FORKCHOICEUPDATED_TIMEOUT): debug "runForkChoiceUpdated: forkchoiceUpdated timed out" default(ForkchoiceUpdatedResponse) except CatchableError as err: @@ -386,7 +384,7 @@ proc newExecutionPayload*( awaitWithTimeout( eth1Monitor.newPayload( executionPayload.asEngineExecutionPayload), - web3Timeout): + NEWPAYLOAD_TIMEOUT): info "newPayload: newPayload timed out" PayloadStatusV1(status: PayloadExecutionStatus.syncing) payloadStatus = payloadResponse.status diff --git a/beacon_chain/spec/datatypes/bellatrix.nim b/beacon_chain/spec/datatypes/bellatrix.nim index c9b38cbf2..212b4a409 100644 --- a/beacon_chain/spec/datatypes/bellatrix.nim +++ b/beacon_chain/spec/datatypes/bellatrix.nim @@ -25,6 +25,12 @@ const # 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 + # 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 # 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] diff --git a/beacon_chain/validators/validator_duties.nim b/beacon_chain/validators/validator_duties.nim index 58fe1c4ad..0bf3e087a 100644 --- a/beacon_chain/validators/validator_duties.nim +++ b/beacon_chain/validators/validator_duties.nim @@ -426,8 +426,6 @@ proc forkchoice_updated(state: bellatrix.BeaconState, fee_recipient: ethtypes.Address, execution_engine: Eth1Monitor): Future[Option[bellatrix.PayloadID]] {.async.} = - const web3Timeout = 3.seconds - let timestamp = compute_timestamp_at_slot(state, state.slot) random = get_randao_mix(state, get_current_epoch(state)) @@ -436,7 +434,7 @@ proc forkchoice_updated(state: bellatrix.BeaconState, execution_engine.forkchoiceUpdated( head_block_hash, finalized_block_hash, timestamp, random.data, fee_recipient), - web3Timeout): + FORKCHOICEUPDATED_TIMEOUT): info "forkchoice_updated: forkchoiceUpdated timed out" default(ForkchoiceUpdatedResponse) payloadId = forkchoiceResponse.payloadId @@ -473,6 +471,9 @@ proc getExecutionPayload(node: BeaconNode, proposalState: auto): # Minimize window for Eth1 monitor to shut down connection 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 feeRecipient = if node.config.suggestedFeeRecipient.isSome: @@ -488,11 +489,17 @@ proc getExecutionPayload(node: BeaconNode, proposalState: auto): payload_id = (await forkchoice_updated( proposalState.bellatrixData.data, latestHead, latestFinalized, feeRecipient, node.consensusManager.eth1Monitor)) - payload = await get_execution_payload( - payload_id, node.consensusManager.eth1Monitor) + payload = awaitWithTimeout( + get_execution_payload(payload_id, node.consensusManager.eth1Monitor), + GETPAYLOAD_TIMEOUT): + info "getExecutionPayload: getPayload timed out; using empty execution payload" + empty_execution_payload executionPayloadStatus = - await node.consensusManager.eth1Monitor.newExecutionPayload( - payload) + awaitWithTimeout( + node.consensusManager.eth1Monitor.newExecutionPayload(payload), + NEWPAYLOAD_TIMEOUT): + info "getExecutionPayload: newPayload timed out" + PayloadExecutionStatus.syncing if executionPayloadStatus != PayloadExecutionStatus.valid: info "getExecutionPayload: newExecutionPayload not valid; using empty execution payload",