rm unused and obsolete produceBlindedBlock client-side infrastructure (#6697)

This commit is contained in:
tersec 2024-10-31 03:58:44 +00:00 committed by GitHub
parent d7f77a7b8a
commit c0f7220ab2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 0 additions and 154 deletions

View File

@ -408,8 +408,6 @@ type
GetGraffitiResponse |
GetAggregatedAttestationV2Response
DecodeConsensysTypes* = ProduceBlindedBlockResponse
RestVersioned*[T] = object
data*: T
jsonVersion*: ConsensusFork
@ -3268,51 +3266,6 @@ func readSszResBytes(T: typedesc[RestBlockTypes],
except SszError:
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](
t: typedesc[T],
value: openArray[byte],

View File

@ -538,7 +538,6 @@ type
GetVersionResponse* = DataEnclosedObject[RestNodeVersion]
GetEpochSyncCommitteesResponse* = DataEnclosedObject[RestEpochSyncCommittee]
ProduceAttestationDataResponse* = DataEnclosedObject[AttestationData]
ProduceBlindedBlockResponse* = ForkedBlindedBeaconBlock
ProduceSyncCommitteeContributionResponse* = DataEnclosedObject[SyncCommitteeContribution]
SubmitBlindedBlockResponseDeneb* = DataEnclosedObject[deneb_mev.ExecutionPayloadAndBlobsBundle]
SubmitBlindedBlockResponseElectra* = DataEnclosedObject[electra_mev.ExecutionPayloadAndBlobsBundle]

View File

@ -46,15 +46,6 @@ proc produceBlockV3Plain*(
accept: preferSSZ, meth: MethodGet.}
## 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*(
slot: Slot,
committee_index: CommitteeIndex

View File

@ -2705,103 +2705,6 @@ proc publishBlock*(
raise (ref ValidatorApiError)(
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*(
vc: ValidatorClientRef,
data: ForkedSignedBlindedBeaconBlock,