From 70c198221ede9c46068a0edf30014732460be6c0 Mon Sep 17 00:00:00 2001 From: cheatfate Date: Thu, 2 May 2024 06:08:27 +0300 Subject: [PATCH 1/2] Fix submitBlindededBlock() do not send consensus-version HTTP header. --- .../spec/mev/rest_deneb_mev_calls.nim | 21 +++++++++++++++---- .../spec/mev/rest_electra_mev_calls.nim | 21 +++++++++++++++---- .../validators/message_router_mev.nim | 21 ++++++++++++------- 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/beacon_chain/spec/mev/rest_deneb_mev_calls.nim b/beacon_chain/spec/mev/rest_deneb_mev_calls.nim index 36ebcb4a33..327144d220 100644 --- a/beacon_chain/spec/mev/rest_deneb_mev_calls.nim +++ b/beacon_chain/spec/mev/rest_deneb_mev_calls.nim @@ -28,8 +28,21 @@ proc getHeaderDeneb*(slot: Slot, meth: MethodGet, connection: {Dedicated, Close}.} ## https://github.com/ethereum/builder-specs/blob/v0.4.0/apis/builder/header.yaml -proc submitBlindedBlock*(body: deneb_mev.SignedBlindedBeaconBlock - ): RestPlainResponse {. - rest, endpoint: "/eth/v1/builder/blinded_blocks", - meth: MethodPost, connection: {Dedicated, Close}.} +proc submitBlindedBlockPlain*( + body: deneb_mev.SignedBlindedBeaconBlock +): RestPlainResponse {. + rest, endpoint: "/eth/v1/builder/blinded_blocks", + meth: MethodPost, connection: {Dedicated, Close}.} + ## https://github.com/ethereum/builder-specs/blob/v0.4.0/apis/builder/blinded_blocks.yaml + +proc submitBlindedBlock*( + client: RestClientRef, + body: deneb_mev.SignedBlindedBeaconBlock +): Future[RestPlainResponse] {. + async: (raises: [CancelledError, RestEncodingError, RestDnsResolveError, + RestCommunicationError]).} = ## https://github.com/ethereum/builder-specs/blob/v0.4.0/apis/builder/blinded_blocks.yaml + await client.submitBlindedBlockPlain( + body, + extraHeaders = @[("eth-consensus-version", toString(ConsensusFork.Deneb))] + ) diff --git a/beacon_chain/spec/mev/rest_electra_mev_calls.nim b/beacon_chain/spec/mev/rest_electra_mev_calls.nim index d6553b7483..2b92d8a55d 100644 --- a/beacon_chain/spec/mev/rest_electra_mev_calls.nim +++ b/beacon_chain/spec/mev/rest_electra_mev_calls.nim @@ -21,8 +21,21 @@ proc getHeaderElectra*(slot: Slot, meth: MethodGet, connection: {Dedicated, Close}.} ## https://github.com/ethereum/builder-specs/blob/v0.4.0/apis/builder/header.yaml -proc submitBlindedBlock*(body: electra_mev.SignedBlindedBeaconBlock - ): RestPlainResponse {. - rest, endpoint: "/eth/v1/builder/blinded_blocks", - meth: MethodPost, connection: {Dedicated, Close}.} +proc submitBlindedBlockPlain*( + body: electra_mev.SignedBlindedBeaconBlock +): RestPlainResponse {. + rest, endpoint: "/eth/v1/builder/blinded_blocks", + meth: MethodPost, connection: {Dedicated, Close}.} ## https://github.com/ethereum/builder-specs/blob/v0.4.0/apis/builder/blinded_blocks.yaml + +proc submitBlindedBlock*( + client: RestClientRef, + body: electra_mev.SignedBlindedBeaconBlock +): Future[RestPlainResponse] {. + async: (raises: [CancelledError, RestEncodingError, RestDnsResolveError, + RestCommunicationError]).} = + ## https://github.com/ethereum/builder-specs/blob/v0.4.0/apis/builder/blinded_blocks.yaml + await client.submitBlindedBlockPlain( + body, + extraHeaders = @[("eth-consensus-version", toString(ConsensusFork.Electra))] + ) diff --git a/beacon_chain/validators/message_router_mev.nim b/beacon_chain/validators/message_router_mev.nim index d98b08b559..963703470f 100644 --- a/beacon_chain/validators/message_router_mev.nim +++ b/beacon_chain/validators/message_router_mev.nim @@ -59,16 +59,21 @@ proc unblindAndRouteBlockMEV*( # protection check let response = try: - awaitWithTimeout( - payloadBuilderRestClient.submitBlindedBlock(blindedBlock), - BUILDER_BLOCK_SUBMISSION_DELAY_TOLERANCE): - return err("Submitting blinded block timed out") + await payloadBuilderRestClient.submitBlindedBlock(blindedBlock). + wait(BUILDER_BLOCK_SUBMISSION_DELAY_TOLERANCE) # From here on, including error paths, disallow local EL production by # returning Opt.some, regardless of whether on head or newBlock. - except RestDecodingError as exc: - return err("REST decoding error submitting blinded block: " & exc.msg) - except RestError as exc: - return err("exception in submitBlindedBlock: " & exc.msg) + except AsyncTimeoutError: + return err("Submitting blinded block timed out") + except RestEncodingError as exc: + return err( + "REST encoding error submitting blinded block, reason " & exc.msg) + except RestDnsResolveError as exc: + return err( + "REST unable to resolve remote host, reason " & exc.msg) + except RestCommunicationError as exc: + return err( + "REST unable to communicate with remote host, reason " & exc.msg) const httpOk = 200 if response.status != httpOk: From 8ba8f406db045f3d1069d101baade76340c62b41 Mon Sep 17 00:00:00 2001 From: cheatfate Date: Thu, 2 May 2024 23:31:46 +0300 Subject: [PATCH 2/2] Address review comments. --- beacon_chain/validators/message_router_mev.nim | 1 - 1 file changed, 1 deletion(-) diff --git a/beacon_chain/validators/message_router_mev.nim b/beacon_chain/validators/message_router_mev.nim index 963703470f..48d8a550e7 100644 --- a/beacon_chain/validators/message_router_mev.nim +++ b/beacon_chain/validators/message_router_mev.nim @@ -12,7 +12,6 @@ import metrics import stew/assign2 import ../beacon_node -from eth/async_utils import awaitWithTimeout from ../spec/datatypes/bellatrix import SignedBeaconBlock from ../spec/mev/rest_deneb_mev_calls import submitBlindedBlock from ../spec/mev/rest_electra_mev_calls import submitBlindedBlock