From 09de83af800644e729e804293e8dd3a86fbdc5d6 Mon Sep 17 00:00:00 2001 From: zah Date: Sat, 20 Aug 2022 09:09:25 +0300 Subject: [PATCH] Reviewed the Engine API calls for missing error handling (#4004) --- beacon_chain/eth1/eth1_monitor.nim | 1 - beacon_chain/validators/validator_duties.nim | 37 ++++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/beacon_chain/eth1/eth1_monitor.nim b/beacon_chain/eth1/eth1_monitor.nim index 741e6f295a..a43b369624 100644 --- a/beacon_chain/eth1/eth1_monitor.nim +++ b/beacon_chain/eth1/eth1_monitor.nim @@ -94,7 +94,6 @@ type cfg: RuntimeConfig finalizedBlockHash: Eth2Digest finalizedDepositsMerkleizer: DepositsMerkleizer - ## The latest block that reached a 50% majority vote from ## the Eth2 validators according to the follow distance and ## the ETH1_VOTING_PERIOD diff --git a/beacon_chain/validators/validator_duties.nim b/beacon_chain/validators/validator_duties.nim index be7f302c72..e08963c826 100644 --- a/beacon_chain/validators/validator_duties.nim +++ b/beacon_chain/validators/validator_duties.nim @@ -317,17 +317,26 @@ proc forkchoice_updated(state: bellatrix.BeaconState, fee_recipient: ethtypes.Address, execution_engine: Eth1Monitor): Future[Option[bellatrix.PayloadID]] {.async.} = + logScope: + head_block_hash + finalized_block_hash + let timestamp = compute_timestamp_at_slot(state, state.slot) random = get_randao_mix(state, get_current_epoch(state)) forkchoiceResponse = - awaitWithTimeout( - execution_engine.forkchoiceUpdated( - head_block_hash, finalized_block_hash, timestamp, random.data, - fee_recipient), - FORKCHOICEUPDATED_TIMEOUT): - info "forkchoice_updated: forkchoiceUpdated timed out" - default(ForkchoiceUpdatedResponse) + try: + awaitWithTimeout( + execution_engine.forkchoiceUpdated( + head_block_hash, finalized_block_hash, timestamp, random.data, + fee_recipient), + FORKCHOICEUPDATED_TIMEOUT): + error "Engine API fork-choice update timed out" + default(ForkchoiceUpdatedResponse) + except CatchableError as err: + error "Engine API fork-choice update failed", err = err.msg + default(ForkchoiceUpdatedResponse) + payloadId = forkchoiceResponse.payloadId return if payloadId.isSome: @@ -401,11 +410,17 @@ proc getExecutionPayload( proposalState.bellatrixData.data, latestHead, latestFinalized, feeRecipient, node.consensusManager.eth1Monitor)) - payload = awaitWithTimeout( - get_execution_payload(payload_id, node.consensusManager.eth1Monitor), - GETPAYLOAD_TIMEOUT): - info "getExecutionPayload: getPayload timed out; using empty execution payload" + payload = try: + awaitWithTimeout( + get_execution_payload(payload_id, node.consensusManager.eth1Monitor), + GETPAYLOAD_TIMEOUT): + warn "Getting execution payload from Engine API timed out", payload_id + empty_execution_payload + except CatchableError as err: + warn "Getting execution payload from Engine API failed", + payload_id, err = err.msg empty_execution_payload + executionPayloadStatus = awaitWithTimeout( node.consensusManager.eth1Monitor.newExecutionPayload(payload),