remove Bellatrix builder API support (#5162)
Co-authored-by: Etan Kissling <etan@status.im>
This commit is contained in:
parent
2954e7fac7
commit
81c989660a
|
@ -935,25 +935,7 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||
|
||||
return RestApiResponse.jsonMsgResponse(BlockValidationSuccess)
|
||||
of ConsensusFork.Bellatrix:
|
||||
let
|
||||
restBlock = decodeBodyJsonOrSsz(
|
||||
bellatrix_mev.SignedBlindedBeaconBlock, body).valueOr:
|
||||
return RestApiResponse.jsonError(Http400, InvalidBlockObjectError,
|
||||
$error)
|
||||
payloadBuilderClient = node.getPayloadBuilderClient(
|
||||
restBlock.message.proposer_index).valueOr:
|
||||
return RestApiResponse.jsonError(
|
||||
Http400, "Unable to initialize payload builder client: " & $error)
|
||||
res = await node.unblindAndRouteBlockMEV(
|
||||
payloadBuilderClient, restBlock)
|
||||
|
||||
if res.isErr():
|
||||
return RestApiResponse.jsonError(
|
||||
Http503, BeaconNodeInSyncError, $res.error())
|
||||
if res.get().isNone():
|
||||
return RestApiResponse.jsonError(Http202, BlockValidationError)
|
||||
|
||||
return RestApiResponse.jsonMsgResponse(BlockValidationSuccess)
|
||||
return RestApiResponse.jsonError(Http400, "FOO")
|
||||
of ConsensusFork.Altair, ConsensusFork.Phase0:
|
||||
# Pre-Bellatrix, this endpoint will accept a `SignedBeaconBlock`.
|
||||
#
|
||||
|
|
|
@ -44,82 +44,6 @@ macro copyFields*(
|
|||
# TODO when https://github.com/nim-lang/Nim/issues/21346 and/or
|
||||
# https://github.com/nim-lang/Nim/issues/21347 fixed, combine and make generic
|
||||
# these two very similar versions of unblindAndRouteBlockMEV
|
||||
proc unblindAndRouteBlockMEV*(
|
||||
node: BeaconNode, payloadBuilderRestClient: RestClientRef,
|
||||
blindedBlock: bellatrix_mev.SignedBlindedBeaconBlock):
|
||||
Future[Result[Opt[BlockRef], string]] {.async.} =
|
||||
# By time submitBlindedBlock is called, must already have done slashing
|
||||
# protection check
|
||||
let unblindedPayload =
|
||||
try:
|
||||
awaitWithTimeout(
|
||||
payloadBuilderRestClient.submitBlindedBlock(blindedBlock),
|
||||
BUILDER_BLOCK_SUBMISSION_DELAY_TOLERANCE):
|
||||
return err("Submitting blinded block timed out")
|
||||
# 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 CatchableError as exc:
|
||||
return err("exception in submitBlindedBlock: " & exc.msg)
|
||||
|
||||
const httpOk = 200
|
||||
if unblindedPayload.status == httpOk:
|
||||
if hash_tree_root(
|
||||
blindedBlock.message.body.execution_payload_header) !=
|
||||
hash_tree_root(unblindedPayload.data.data):
|
||||
debug "unblindAndRouteBlockMEV: unblinded payload doesn't match blinded payload",
|
||||
blindedPayload =
|
||||
blindedBlock.message.body.execution_payload_header
|
||||
else:
|
||||
# Signature provided is consistent with unblinded execution payload,
|
||||
# so construct full beacon block
|
||||
# https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/validator.md#block-proposal
|
||||
var signedBlock = bellatrix.SignedBeaconBlock(
|
||||
signature: blindedBlock.signature)
|
||||
copyFields(
|
||||
signedBlock.message, blindedBlock.message,
|
||||
getFieldNames(typeof(signedBlock.message)))
|
||||
copyFields(
|
||||
signedBlock.message.body, blindedBlock.message.body,
|
||||
getFieldNames(typeof(signedBlock.message.body)))
|
||||
signedBlock.message.body.execution_payload = unblindedPayload.data.data
|
||||
|
||||
signedBlock.root = hash_tree_root(signedBlock.message)
|
||||
|
||||
doAssert signedBlock.root == hash_tree_root(blindedBlock.message)
|
||||
|
||||
debug "unblindAndRouteBlockMEV: proposing unblinded block",
|
||||
blck = shortLog(signedBlock)
|
||||
|
||||
let newBlockRef =
|
||||
(await node.router.routeSignedBeaconBlock(
|
||||
signedBlock, Opt.none(SignedBlobSidecars))).valueOr:
|
||||
# submitBlindedBlock has run, so don't allow fallback to run
|
||||
return err("routeSignedBeaconBlock error") # Errors logged in router
|
||||
|
||||
if newBlockRef.isSome:
|
||||
beacon_block_builder_proposed.inc()
|
||||
notice "Block proposed (MEV)",
|
||||
blockRoot = shortLog(signedBlock.root), blck = shortLog(signedBlock),
|
||||
signature = shortLog(signedBlock.signature)
|
||||
|
||||
return ok newBlockRef
|
||||
else:
|
||||
debug "unblindAndRouteBlockMEV: submitBlindedBlock failed",
|
||||
blindedBlock, payloadStatus = unblindedPayload.status
|
||||
|
||||
# https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/validator.md#proposer-slashing
|
||||
# This means if a validator publishes a signature for a
|
||||
# `BlindedBeaconBlock` (via a dissemination of a
|
||||
# `SignedBlindedBeaconBlock`) then the validator **MUST** not use the
|
||||
# local build process as a fallback, even in the event of some failure
|
||||
# with the external builder network.
|
||||
return err("unblindAndRouteBlockMEV error")
|
||||
|
||||
# TODO currently cannot be combined into one generic function
|
||||
# Only difference is `var signedBlock = capella.SignedBeaconBlock` instead of
|
||||
# `var signedBlock = bellatrix.SignedBeaconBlock`
|
||||
proc unblindAndRouteBlockMEV*(
|
||||
node: BeaconNode, payloadBuilderRestClient: RestClientRef,
|
||||
blindedBlock: capella_mev.SignedBlindedBeaconBlock):
|
||||
|
@ -193,7 +117,7 @@ proc unblindAndRouteBlockMEV*(
|
|||
# with the external buildernetwork.
|
||||
return err("unblindAndRouteBlockMEV error")
|
||||
|
||||
|
||||
# TODO currently cannot be combined into one generic function
|
||||
proc unblindAndRouteBlockMEV*(
|
||||
node: BeaconNode, payloadBuilderRestClient: RestClientRef,
|
||||
blindedBlock: deneb_mev.SignedBlindedBeaconBlock):
|
||||
|
|
|
@ -840,9 +840,15 @@ proc proposeBlockAux(
|
|||
let
|
||||
payloadBuilderBidFut =
|
||||
if usePayloadBuilder:
|
||||
getBuilderBid[SBBB](
|
||||
node, payloadBuilderClient, head, validator, slot, randao,
|
||||
validator_index)
|
||||
when not (EPS is bellatrix.ExecutionPayloadForSigning):
|
||||
getBuilderBid[SBBB](
|
||||
node, payloadBuilderClient, head, validator, slot, randao,
|
||||
validator_index)
|
||||
else:
|
||||
let fut = newFuture[BlindedBlockResult[SBBB]]("builder-bid")
|
||||
fut.complete(BlindedBlockResult[SBBB].err(
|
||||
"Bellatrix Builder API unsupported"))
|
||||
fut
|
||||
else:
|
||||
let fut = newFuture[BlindedBlockResult[SBBB]]("builder-bid")
|
||||
fut.complete(BlindedBlockResult[SBBB].err(
|
||||
|
@ -1083,7 +1089,7 @@ proc proposeBlock(node: BeaconNode,
|
|||
capella_mev.SignedBlindedBeaconBlock, capella.ExecutionPayloadForSigning)
|
||||
else:
|
||||
proposeBlockContinuation(
|
||||
bellatrix_mev.SignedBlindedBeaconBlock, bellatrix.ExecutionPayloadForSigning)
|
||||
capella_mev.SignedBlindedBeaconBlock, bellatrix.ExecutionPayloadForSigning)
|
||||
|
||||
proc handleAttestations(node: BeaconNode, head: BlockRef, slot: Slot) =
|
||||
## Perform all attestations that the validators attached to this node should
|
||||
|
|
Loading…
Reference in New Issue