Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions beacon_chain/spec/mev/rest_deneb_mev_calls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
)
21 changes: 17 additions & 4 deletions beacon_chain/spec/mev/rest_electra_mev_calls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
)
21 changes: 13 additions & 8 deletions beacon_chain/validators/message_router_mev.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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).
cheatfate marked this conversation as resolved.
Show resolved Hide resolved
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:
Expand Down
Loading