Fix POST to eth/v1/builder/blinded_blocks missing header Eth-Consensus-Version. (#6256)

* Fix submitBlindededBlock() do not send consensus-version HTTP header.

* Address review comments.
This commit is contained in:
Eugene Kabanov 2024-05-03 04:08:16 +03:00 committed by GitHub
parent 7bef68ce93
commit 484f48953b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 47 additions and 17 deletions

View File

@ -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))]
)

View File

@ -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))]
)

View File

@ -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
@ -59,16 +58,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: