Skip to content

Commit 1177f33

Browse files
authored
standardize on upcoming/specified engine API timeouts (#3637)
1 parent e7ed733 commit 1177f33

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

beacon_chain/gossip_processing/block_processor.nim

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ export sszdump, signatures_batch
3232
declareHistogram beacon_store_block_duration_seconds,
3333
"storeBlock() duration", buckets = [0.25, 0.5, 1, 2, 4, 8, Inf]
3434

35-
const web3Timeout = 4.seconds
36-
3735
type
3836
BlockEntry* = object
3937
blck*: ForkedSignedBeaconBlock
@@ -349,7 +347,7 @@ proc runForkchoiceUpdated(
349347
discard awaitWithTimeout(
350348
forkchoiceUpdated(
351349
self.consensusManager.eth1Monitor, headBlockRoot, finalizedBlockRoot),
352-
web3Timeout):
350+
FORKCHOICEUPDATED_TIMEOUT):
353351
debug "runForkChoiceUpdated: forkchoiceUpdated timed out"
354352
default(ForkchoiceUpdatedResponse)
355353
except CatchableError as err:
@@ -386,7 +384,7 @@ proc newExecutionPayload*(
386384
awaitWithTimeout(
387385
eth1Monitor.newPayload(
388386
executionPayload.asEngineExecutionPayload),
389-
web3Timeout):
387+
NEWPAYLOAD_TIMEOUT):
390388
info "newPayload: newPayload timed out"
391389
PayloadStatusV1(status: PayloadExecutionStatus.syncing)
392390
payloadStatus = payloadResponse.status

beacon_chain/spec/datatypes/bellatrix.nim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ const
2525
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/bellatrix/beacon-chain.md#transition-settings
2626
TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH* = FAR_FUTURE_EPOCH
2727

28+
# https://github.com/ethereum/execution-apis/blob/2c3dffa1ad301a5b1d46212e1bd65e918265cd6f/src/engine/specification.md#request-1
29+
FORKCHOICEUPDATED_TIMEOUT* = 8.seconds
30+
31+
# https://github.com/ethereum/execution-apis/blob/2c3dffa1ad301a5b1d46212e1bd65e918265cd6f/src/engine/specification.md#request
32+
NEWPAYLOAD_TIMEOUT* = 8.seconds
33+
2834
type
2935
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/bellatrix/beacon-chain.md#custom-types
3036
Transaction* = List[byte, Limit MAX_BYTES_PER_TRANSACTION]

beacon_chain/validators/validator_duties.nim

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,6 @@ proc forkchoice_updated(state: bellatrix.BeaconState,
426426
fee_recipient: ethtypes.Address,
427427
execution_engine: Eth1Monitor):
428428
Future[Option[bellatrix.PayloadID]] {.async.} =
429-
const web3Timeout = 3.seconds
430-
431429
let
432430
timestamp = compute_timestamp_at_slot(state, state.slot)
433431
random = get_randao_mix(state, get_current_epoch(state))
@@ -436,7 +434,7 @@ proc forkchoice_updated(state: bellatrix.BeaconState,
436434
execution_engine.forkchoiceUpdated(
437435
head_block_hash, finalized_block_hash, timestamp, random.data,
438436
fee_recipient),
439-
web3Timeout):
437+
FORKCHOICEUPDATED_TIMEOUT):
440438
info "forkchoice_updated: forkchoiceUpdated timed out"
441439
default(ForkchoiceUpdatedResponse)
442440
payloadId = forkchoiceResponse.payloadId
@@ -473,6 +471,9 @@ proc getExecutionPayload(node: BeaconNode, proposalState: auto):
473471
# Minimize window for Eth1 monitor to shut down connection
474472
await node.consensusManager.eth1Monitor.ensureDataProvider()
475473

474+
# https://github.com/ethereum/execution-apis/blob/2c3dffa1ad301a5b1d46212e1bd65e918265cd6f/src/engine/specification.md#request-2
475+
const GETPAYLOAD_TIMEOUT = 1.seconds
476+
476477
let
477478
feeRecipient =
478479
if node.config.suggestedFeeRecipient.isSome:
@@ -488,11 +489,17 @@ proc getExecutionPayload(node: BeaconNode, proposalState: auto):
488489
payload_id = (await forkchoice_updated(
489490
proposalState.bellatrixData.data, latestHead, latestFinalized,
490491
feeRecipient, node.consensusManager.eth1Monitor))
491-
payload = await get_execution_payload(
492-
payload_id, node.consensusManager.eth1Monitor)
492+
payload = awaitWithTimeout(
493+
get_execution_payload(payload_id, node.consensusManager.eth1Monitor),
494+
GETPAYLOAD_TIMEOUT):
495+
info "getExecutionPayload: getPayload timed out; using empty execution payload"
496+
empty_execution_payload
493497
executionPayloadStatus =
494-
await node.consensusManager.eth1Monitor.newExecutionPayload(
495-
payload)
498+
awaitWithTimeout(
499+
node.consensusManager.eth1Monitor.newExecutionPayload(payload),
500+
NEWPAYLOAD_TIMEOUT):
501+
info "getExecutionPayload: newPayload timed out"
502+
PayloadExecutionStatus.syncing
496503

497504
if executionPayloadStatus != PayloadExecutionStatus.valid:
498505
info "getExecutionPayload: newExecutionPayload not valid; using empty execution payload",

0 commit comments

Comments
 (0)