The body of prepare_beacon_proposer is an array (Fixes #3920) (#3938)

This commit is contained in:
zah 2022-08-09 12:53:02 +03:00 committed by GitHub
parent dc50abbc90
commit 06a5c67e62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 10 deletions

View File

@ -764,21 +764,22 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
"/eth/v1/validator/prepare_beacon_proposer") do ( "/eth/v1/validator/prepare_beacon_proposer") do (
contentBody: Option[ContentBody]) -> RestApiResponse: contentBody: Option[ContentBody]) -> RestApiResponse:
let let
proposerData = body =
block: block:
if contentBody.isNone(): if contentBody.isNone():
return RestApiResponse.jsonError(Http400, EmptyRequestBodyError) return RestApiResponse.jsonError(Http400, EmptyRequestBodyError)
let dres = decodeBody(PrepareBeaconProposerBody, contentBody.get()) let dres = decodeBody(seq[PrepareBeaconProposer], contentBody.get())
if dres.isErr(): if dres.isErr():
return RestApiResponse.jsonError(Http400, return RestApiResponse.jsonError(Http400,
InvalidPrepareBeaconProposerError) InvalidPrepareBeaconProposerError)
dres.get() dres.get()
currentEpoch = node.beaconClock.now.slotOrZero.epoch currentEpoch = node.beaconClock.now.slotOrZero.epoch
node.dynamicFeeRecipientsStore.addMapping( for proposerData in body:
proposerData.validator_index, node.dynamicFeeRecipientsStore.addMapping(
proposerData.fee_recipient, proposerData.validator_index,
currentEpoch) proposerData.fee_recipient,
currentEpoch)
return RestApiResponse.response("", Http200, "text/plain") return RestApiResponse.response("", Http200, "text/plain")

View File

@ -92,7 +92,7 @@ type
ImportDistributedKeystoresBody | ImportDistributedKeystoresBody |
ImportRemoteKeystoresBody | ImportRemoteKeystoresBody |
KeystoresAndSlashingProtection | KeystoresAndSlashingProtection |
PrepareBeaconProposerBody | PrepareBeaconProposer |
ProposerSlashing | ProposerSlashing |
SetFeeRecipientRequest | SetFeeRecipientRequest |
SignedBlindedBeaconBlock | SignedBlindedBeaconBlock |
@ -105,6 +105,7 @@ type
EncodeArrays* = EncodeArrays* =
seq[Attestation] | seq[Attestation] |
seq[PrepareBeaconProposer] |
seq[RemoteKeystoreInfo] | seq[RemoteKeystoreInfo] |
seq[RestCommitteeSubscription] | seq[RestCommitteeSubscription] |
seq[RestSignedContributionAndProof] | seq[RestSignedContributionAndProof] |
@ -128,7 +129,7 @@ type
KeymanagerGenericError | KeymanagerGenericError |
KeystoresAndSlashingProtection | KeystoresAndSlashingProtection |
ListFeeRecipientResponse | ListFeeRecipientResponse |
PrepareBeaconProposerBody | PrepareBeaconProposer |
ProduceBlockResponseV2 | ProduceBlockResponseV2 |
RestDutyError | RestDutyError |
RestGenericError | RestGenericError |

View File

@ -242,7 +242,7 @@ type
epoch*: Epoch epoch*: Epoch
active*: bool active*: bool
PrepareBeaconProposerBody* = object PrepareBeaconProposer* = object
validator_index*: ValidatorIndex validator_index*: ValidatorIndex
fee_recipient*: Eth1Address fee_recipient*: Eth1Address

View File

@ -90,7 +90,7 @@ proc publishContributionAndProofs*(body: seq[RestSignedContributionAndProof]): R
meth: MethodPost.} meth: MethodPost.}
## https://ethereum.github.io/beacon-APIs/#/Validator/publishContributionAndProofs ## https://ethereum.github.io/beacon-APIs/#/Validator/publishContributionAndProofs
proc prepareBeaconProposer*(body: PrepareBeaconProposerBody): RestPlainResponse {. proc prepareBeaconProposer*(body: seq[PrepareBeaconProposer]): RestPlainResponse {.
rest, endpoint: "/eth/v1/validator/prepare_beacon_proposer", rest, endpoint: "/eth/v1/validator/prepare_beacon_proposer",
meth: MethodPost.} meth: MethodPost.}
## https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/prepareBeaconProposer ## https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/prepareBeaconProposer