rm unused and obsolete produceBlindedBlock client-side infrastructure (#6697)
This commit is contained in:
parent
d7f77a7b8a
commit
c0f7220ab2
|
@ -408,8 +408,6 @@ type
|
||||||
GetGraffitiResponse |
|
GetGraffitiResponse |
|
||||||
GetAggregatedAttestationV2Response
|
GetAggregatedAttestationV2Response
|
||||||
|
|
||||||
DecodeConsensysTypes* = ProduceBlindedBlockResponse
|
|
||||||
|
|
||||||
RestVersioned*[T] = object
|
RestVersioned*[T] = object
|
||||||
data*: T
|
data*: T
|
||||||
jsonVersion*: ConsensusFork
|
jsonVersion*: ConsensusFork
|
||||||
|
@ -3268,51 +3266,6 @@ func readSszResBytes(T: typedesc[RestBlockTypes],
|
||||||
except SszError:
|
except SszError:
|
||||||
err("Invalid SSZ object")
|
err("Invalid SSZ object")
|
||||||
|
|
||||||
proc decodeBytes*[T: DecodeConsensysTypes](
|
|
||||||
t: typedesc[T],
|
|
||||||
value: openArray[byte],
|
|
||||||
contentType: Opt[ContentTypeData],
|
|
||||||
consensusVersion: string
|
|
||||||
): RestResult[T] =
|
|
||||||
let mediaType =
|
|
||||||
if contentType.isNone() or
|
|
||||||
isWildCard(contentType.get().mediaType):
|
|
||||||
return err("Invalid/missing Content-Type value")
|
|
||||||
else:
|
|
||||||
contentType.get().mediaType
|
|
||||||
|
|
||||||
if mediaType == ApplicationJsonMediaType:
|
|
||||||
try:
|
|
||||||
ok(RestJson.decode(value, T,
|
|
||||||
requireAllFields = true,
|
|
||||||
allowUnknownFields = true))
|
|
||||||
except SerializationError as exc:
|
|
||||||
debug "Failed to deserialize REST JSON data",
|
|
||||||
err = exc.formatMsg("<data>"),
|
|
||||||
data = string.fromBytes(value)
|
|
||||||
return err("Serialization error")
|
|
||||||
elif mediaType == OctetStreamMediaType:
|
|
||||||
when t is ProduceBlindedBlockResponse:
|
|
||||||
let fork = ConsensusFork.decodeString(consensusVersion).valueOr:
|
|
||||||
return err("Invalid or Unsupported consensus version")
|
|
||||||
case fork
|
|
||||||
of ConsensusFork.Electra:
|
|
||||||
let
|
|
||||||
blck = ? readSszResBytes(electra_mev.BlindedBeaconBlock, value)
|
|
||||||
forked = ForkedBlindedBeaconBlock(
|
|
||||||
kind: ConsensusFork.Electra, electraData: blck)
|
|
||||||
ok(ProduceBlindedBlockResponse(forked))
|
|
||||||
of ConsensusFork.Deneb:
|
|
||||||
let
|
|
||||||
blck = ? readSszResBytes(deneb_mev.BlindedBeaconBlock, value)
|
|
||||||
forked = ForkedBlindedBeaconBlock(
|
|
||||||
kind: ConsensusFork.Deneb, denebData: blck)
|
|
||||||
ok(ProduceBlindedBlockResponse(forked))
|
|
||||||
of ConsensusFork.Phase0 .. ConsensusFork.Capella:
|
|
||||||
err("Unable to decode blinded block for pre-Deneb forks")
|
|
||||||
else:
|
|
||||||
err("Unsupported Content-Type")
|
|
||||||
|
|
||||||
proc decodeBytes*[T: ProduceBlockResponseV3](
|
proc decodeBytes*[T: ProduceBlockResponseV3](
|
||||||
t: typedesc[T],
|
t: typedesc[T],
|
||||||
value: openArray[byte],
|
value: openArray[byte],
|
||||||
|
|
|
@ -538,7 +538,6 @@ type
|
||||||
GetVersionResponse* = DataEnclosedObject[RestNodeVersion]
|
GetVersionResponse* = DataEnclosedObject[RestNodeVersion]
|
||||||
GetEpochSyncCommitteesResponse* = DataEnclosedObject[RestEpochSyncCommittee]
|
GetEpochSyncCommitteesResponse* = DataEnclosedObject[RestEpochSyncCommittee]
|
||||||
ProduceAttestationDataResponse* = DataEnclosedObject[AttestationData]
|
ProduceAttestationDataResponse* = DataEnclosedObject[AttestationData]
|
||||||
ProduceBlindedBlockResponse* = ForkedBlindedBeaconBlock
|
|
||||||
ProduceSyncCommitteeContributionResponse* = DataEnclosedObject[SyncCommitteeContribution]
|
ProduceSyncCommitteeContributionResponse* = DataEnclosedObject[SyncCommitteeContribution]
|
||||||
SubmitBlindedBlockResponseDeneb* = DataEnclosedObject[deneb_mev.ExecutionPayloadAndBlobsBundle]
|
SubmitBlindedBlockResponseDeneb* = DataEnclosedObject[deneb_mev.ExecutionPayloadAndBlobsBundle]
|
||||||
SubmitBlindedBlockResponseElectra* = DataEnclosedObject[electra_mev.ExecutionPayloadAndBlobsBundle]
|
SubmitBlindedBlockResponseElectra* = DataEnclosedObject[electra_mev.ExecutionPayloadAndBlobsBundle]
|
||||||
|
|
|
@ -46,15 +46,6 @@ proc produceBlockV3Plain*(
|
||||||
accept: preferSSZ, meth: MethodGet.}
|
accept: preferSSZ, meth: MethodGet.}
|
||||||
## https://ethereum.github.io/beacon-APIs/#/Validator/produceBlockV3
|
## https://ethereum.github.io/beacon-APIs/#/Validator/produceBlockV3
|
||||||
|
|
||||||
proc produceBlindedBlockPlain*(
|
|
||||||
slot: Slot,
|
|
||||||
randao_reveal: ValidatorSig,
|
|
||||||
graffiti: GraffitiBytes
|
|
||||||
): RestPlainResponse {.
|
|
||||||
rest, endpoint: "/eth/v1/validator/blinded_blocks/{slot}",
|
|
||||||
accept: preferSSZ, meth: MethodGet.}
|
|
||||||
## https://ethereum.github.io/beacon-APIs/#/Validator/produceBlindedBlock
|
|
||||||
|
|
||||||
proc produceAttestationDataPlain*(
|
proc produceAttestationDataPlain*(
|
||||||
slot: Slot,
|
slot: Slot,
|
||||||
committee_index: CommitteeIndex
|
committee_index: CommitteeIndex
|
||||||
|
|
|
@ -2705,103 +2705,6 @@ proc publishBlock*(
|
||||||
raise (ref ValidatorApiError)(
|
raise (ref ValidatorApiError)(
|
||||||
msg: "Failed to publish block", data: failures)
|
msg: "Failed to publish block", data: failures)
|
||||||
|
|
||||||
proc produceBlindedBlock*(
|
|
||||||
vc: ValidatorClientRef,
|
|
||||||
slot: Slot,
|
|
||||||
randao_reveal: ValidatorSig,
|
|
||||||
graffiti: GraffitiBytes,
|
|
||||||
strategy: ApiStrategyKind
|
|
||||||
): Future[ProduceBlindedBlockResponse] {.
|
|
||||||
async: (raises: [CancelledError, ValidatorApiError]).} =
|
|
||||||
const
|
|
||||||
RequestName = "produceBlindedBlock"
|
|
||||||
|
|
||||||
var failures: seq[ApiNodeFailure]
|
|
||||||
|
|
||||||
case strategy
|
|
||||||
of ApiStrategyKind.First, ApiStrategyKind.Best:
|
|
||||||
let res = vc.firstSuccessParallel(
|
|
||||||
RestPlainResponse,
|
|
||||||
ProduceBlindedBlockResponse,
|
|
||||||
SlotDuration,
|
|
||||||
ViableNodeStatus,
|
|
||||||
{BeaconNodeRole.BlockProposalData},
|
|
||||||
produceBlindedBlockPlain(it, slot, randao_reveal, graffiti)):
|
|
||||||
if apiResponse.isErr():
|
|
||||||
handleCommunicationError()
|
|
||||||
ApiResponse[ProduceBlindedBlockResponse].err(apiResponse.error)
|
|
||||||
else:
|
|
||||||
let response = apiResponse.get()
|
|
||||||
case response.status:
|
|
||||||
of 200:
|
|
||||||
let
|
|
||||||
version = response.headers.getString("eth-consensus-version")
|
|
||||||
res = decodeBytes(ProduceBlindedBlockResponse, response.data,
|
|
||||||
response.contentType, version)
|
|
||||||
if res.isErr():
|
|
||||||
handleUnexpectedData()
|
|
||||||
ApiResponse[ProduceBlindedBlockResponse].err($res.error)
|
|
||||||
else:
|
|
||||||
ApiResponse[ProduceBlindedBlockResponse].ok(res.get())
|
|
||||||
of 400:
|
|
||||||
# TODO(cheatfate): We not going to update BN status for this handler,
|
|
||||||
# because BN reports 400 for any type of error that does not mean
|
|
||||||
# that BN is incompatible.
|
|
||||||
let failure = ApiNodeFailure.init(ApiFailure.Invalid, RequestName,
|
|
||||||
strategy, node, response.status, response.getErrorMessage())
|
|
||||||
failures.add(failure)
|
|
||||||
ApiResponse[ProduceBlindedBlockResponse].err(ResponseInvalidError)
|
|
||||||
of 500:
|
|
||||||
handle500()
|
|
||||||
ApiResponse[ProduceBlindedBlockResponse].err(ResponseInternalError)
|
|
||||||
of 503:
|
|
||||||
handle503()
|
|
||||||
ApiResponse[ProduceBlindedBlockResponse].err(ResponseNoSyncError)
|
|
||||||
else:
|
|
||||||
handleUnexpectedCode()
|
|
||||||
ApiResponse[ProduceBlindedBlockResponse].err(ResponseUnexpectedError)
|
|
||||||
|
|
||||||
if res.isErr():
|
|
||||||
raise (ref ValidatorApiError)(msg: res.error, data: failures)
|
|
||||||
return res.get()
|
|
||||||
|
|
||||||
of ApiStrategyKind.Priority:
|
|
||||||
vc.firstSuccessSequential(
|
|
||||||
RestPlainResponse,
|
|
||||||
SlotDuration,
|
|
||||||
ViableNodeStatus,
|
|
||||||
{BeaconNodeRole.BlockProposalData},
|
|
||||||
produceBlindedBlockPlain(it, slot, randao_reveal, graffiti)):
|
|
||||||
if apiResponse.isErr():
|
|
||||||
handleCommunicationError()
|
|
||||||
false
|
|
||||||
else:
|
|
||||||
let response = apiResponse.get()
|
|
||||||
case response.status:
|
|
||||||
of 200:
|
|
||||||
let
|
|
||||||
version = response.headers.getString("eth-consensus-version")
|
|
||||||
res = decodeBytes(ProduceBlindedBlockResponse, response.data,
|
|
||||||
response.contentType, version)
|
|
||||||
if res.isOk(): return res.get()
|
|
||||||
handleUnexpectedData()
|
|
||||||
false
|
|
||||||
of 400:
|
|
||||||
handle400()
|
|
||||||
false
|
|
||||||
of 500:
|
|
||||||
handle500()
|
|
||||||
false
|
|
||||||
of 503:
|
|
||||||
handle503()
|
|
||||||
false
|
|
||||||
else:
|
|
||||||
handleUnexpectedCode()
|
|
||||||
false
|
|
||||||
|
|
||||||
raise (ref ValidatorApiError)(
|
|
||||||
msg: "Failed to produce blinded block", data: failures)
|
|
||||||
|
|
||||||
proc publishBlindedBlockV2*(
|
proc publishBlindedBlockV2*(
|
||||||
vc: ValidatorClientRef,
|
vc: ValidatorClientRef,
|
||||||
data: ForkedSignedBlindedBeaconBlock,
|
data: ForkedSignedBlindedBeaconBlock,
|
||||||
|
|
Loading…
Reference in New Issue