From 06a5c67e623aa90e1cb92fc4b68fbb590a46abb8 Mon Sep 17 00:00:00 2001 From: zah Date: Tue, 9 Aug 2022 12:53:02 +0300 Subject: [PATCH] The body of prepare_beacon_proposer is an array (Fixes #3920) (#3938) --- beacon_chain/rpc/rest_validator_api.nim | 13 +++++++------ .../spec/eth2_apis/eth2_rest_serialization.nim | 5 +++-- beacon_chain/spec/eth2_apis/rest_types.nim | 2 +- .../spec/eth2_apis/rest_validator_calls.nim | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/beacon_chain/rpc/rest_validator_api.nim b/beacon_chain/rpc/rest_validator_api.nim index 818b8a3ce..f8e72a849 100644 --- a/beacon_chain/rpc/rest_validator_api.nim +++ b/beacon_chain/rpc/rest_validator_api.nim @@ -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") diff --git a/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim b/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim index b01269804..f93600a3f 100644 --- a/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim +++ b/beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim @@ -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 | diff --git a/beacon_chain/spec/eth2_apis/rest_types.nim b/beacon_chain/spec/eth2_apis/rest_types.nim index af1dfb4a2..355587fc6 100644 --- a/beacon_chain/spec/eth2_apis/rest_types.nim +++ b/beacon_chain/spec/eth2_apis/rest_types.nim @@ -242,7 +242,7 @@ type epoch*: Epoch active*: bool - PrepareBeaconProposerBody* = object + PrepareBeaconProposer* = object validator_index*: ValidatorIndex fee_recipient*: Eth1Address diff --git a/beacon_chain/spec/eth2_apis/rest_validator_calls.nim b/beacon_chain/spec/eth2_apis/rest_validator_calls.nim index 33f0dcce4..e9bebd4a1 100644 --- a/beacon_chain/spec/eth2_apis/rest_validator_calls.nim +++ b/beacon_chain/spec/eth2_apis/rest_validator_calls.nim @@ -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