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 (
contentBody: Option[ContentBody]) -> RestApiResponse:
let
proposerData =
body =
block:
if contentBody.isNone():
return RestApiResponse.jsonError(Http400, EmptyRequestBodyError)
let dres = decodeBody(PrepareBeaconProposerBody, contentBody.get())
let dres = decodeBody(seq[PrepareBeaconProposer], contentBody.get())
if dres.isErr():
return RestApiResponse.jsonError(Http400,
InvalidPrepareBeaconProposerError)
dres.get()
currentEpoch = node.beaconClock.now.slotOrZero.epoch
node.dynamicFeeRecipientsStore.addMapping(
proposerData.validator_index,
proposerData.fee_recipient,
currentEpoch)
for proposerData in body:
node.dynamicFeeRecipientsStore.addMapping(
proposerData.validator_index,
proposerData.fee_recipient,
currentEpoch)
return RestApiResponse.response("", Http200, "text/plain")

View File

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

View File

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

View File

@ -90,7 +90,7 @@ proc publishContributionAndProofs*(body: seq[RestSignedContributionAndProof]): R
meth: MethodPost.}
## 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",
meth: MethodPost.}
## https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/prepareBeaconProposer