2024-02-18 01:16:49 +00:00
|
|
|
# beacon_chain
|
2024-01-03 05:58:34 +00:00
|
|
|
# Copyright (c) 2018-2024 Status Research & Development GmbH
|
2021-08-03 15:17:11 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2023-01-20 14:14:37 +00:00
|
|
|
{.push raises: [].}
|
2021-08-03 15:17:11 +00:00
|
|
|
|
|
|
|
import
|
2024-01-13 09:54:24 +00:00
|
|
|
presto/client,
|
2021-08-03 15:17:11 +00:00
|
|
|
"."/[rest_types, eth2_rest_serialization]
|
|
|
|
|
2024-01-13 09:54:24 +00:00
|
|
|
export client, rest_types, eth2_rest_serialization
|
2021-08-03 15:17:11 +00:00
|
|
|
|
2023-03-03 20:20:01 +00:00
|
|
|
proc getAttesterDutiesPlain*(
|
|
|
|
epoch: Epoch,
|
|
|
|
body: seq[ValidatorIndex]
|
|
|
|
): RestPlainResponse {.
|
|
|
|
rest, endpoint: "/eth/v1/validator/duties/attester/{epoch}",
|
|
|
|
meth: MethodPost.}
|
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/getAttesterDuties
|
|
|
|
|
|
|
|
proc getProposerDutiesPlain*(
|
|
|
|
epoch: Epoch
|
|
|
|
): RestPlainResponse {.
|
2021-08-03 15:17:11 +00:00
|
|
|
rest, endpoint: "/eth/v1/validator/duties/proposer/{epoch}",
|
|
|
|
meth: MethodGet.}
|
2021-08-27 09:00:06 +00:00
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/getProposerDuties
|
2021-08-03 15:17:11 +00:00
|
|
|
|
2023-03-03 20:20:01 +00:00
|
|
|
proc getSyncCommitteeDutiesPlain*(
|
|
|
|
epoch: Epoch,
|
|
|
|
body: seq[ValidatorIndex]
|
|
|
|
): RestPlainResponse {.
|
|
|
|
rest, endpoint: "/eth/v1/validator/duties/sync/{epoch}",
|
|
|
|
meth: MethodPost.}
|
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/getSyncCommitteeDuties
|
|
|
|
|
2024-02-02 15:24:40 +00:00
|
|
|
proc produceBlockV3Plain*(
|
|
|
|
slot: Slot,
|
|
|
|
randao_reveal: ValidatorSig,
|
2024-05-19 01:49:43 +00:00
|
|
|
graffiti: GraffitiBytes,
|
|
|
|
builder_boost_factor: uint64
|
2024-02-02 15:24:40 +00:00
|
|
|
): RestPlainResponse {.
|
|
|
|
rest, endpoint: "/eth/v3/validator/blocks/{slot}",
|
|
|
|
accept: preferSSZ, meth: MethodGet.}
|
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/produceBlockV3
|
|
|
|
|
2023-03-03 20:20:01 +00:00
|
|
|
proc produceBlindedBlockPlain*(
|
|
|
|
slot: Slot,
|
|
|
|
randao_reveal: ValidatorSig,
|
|
|
|
graffiti: GraffitiBytes
|
|
|
|
): RestPlainResponse {.
|
|
|
|
rest, endpoint: "/eth/v1/validator/blinded_blocks/{slot}",
|
2023-06-14 06:04:15 +00:00
|
|
|
accept: preferSSZ, meth: MethodGet.}
|
2022-11-24 09:14:05 +00:00
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/produceBlindedBlock
|
|
|
|
|
2023-03-03 20:20:01 +00:00
|
|
|
proc produceAttestationDataPlain*(
|
|
|
|
slot: Slot,
|
|
|
|
committee_index: CommitteeIndex
|
|
|
|
): RestPlainResponse {.
|
2021-08-03 15:17:11 +00:00
|
|
|
rest, endpoint: "/eth/v1/validator/attestation_data",
|
|
|
|
meth: MethodGet.}
|
2021-08-27 09:00:06 +00:00
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/produceAttestationData
|
2021-08-03 15:17:11 +00:00
|
|
|
|
2023-03-03 20:20:01 +00:00
|
|
|
proc getAggregatedAttestationPlain*(
|
|
|
|
attestation_data_root: Eth2Digest,
|
|
|
|
slot: Slot
|
|
|
|
): RestPlainResponse {.
|
|
|
|
rest, endpoint: "/eth/v1/validator/aggregate_attestation"
|
|
|
|
meth: MethodGet.}
|
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/getAggregatedAttestation
|
|
|
|
|
2024-09-06 12:15:30 +00:00
|
|
|
proc getAggregatedAttestationPlainV2*(
|
2024-10-16 17:20:39 +00:00
|
|
|
attestation_data_root: Eth2Digest,
|
|
|
|
slot: Slot,
|
|
|
|
committee_index: CommitteeIndex
|
|
|
|
): RestPlainResponse {.
|
|
|
|
rest, endpoint: "/eth/v2/validator/aggregate_attestation"
|
|
|
|
meth: MethodGet.}
|
|
|
|
## https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Validator/getAggregatedAttestationV2
|
2024-09-06 12:15:30 +00:00
|
|
|
|
2023-03-03 20:20:01 +00:00
|
|
|
proc publishAggregateAndProofs*(
|
2024-05-14 04:12:35 +00:00
|
|
|
body: seq[phase0.SignedAggregateAndProof]
|
2023-03-03 20:20:01 +00:00
|
|
|
): RestPlainResponse {.
|
2021-08-03 15:17:11 +00:00
|
|
|
rest, endpoint: "/eth/v1/validator/aggregate_and_proofs",
|
|
|
|
meth: MethodPost.}
|
2021-08-27 09:00:06 +00:00
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/publishAggregateAndProofs
|
2021-08-03 15:17:11 +00:00
|
|
|
|
2024-10-16 17:20:39 +00:00
|
|
|
proc publishAggregateAndProofsV2Plain*(
|
|
|
|
body: seq[ForkySignedAggregateAndProof]
|
|
|
|
): RestPlainResponse {.
|
|
|
|
rest, endpoint: "/eth/v2/validator/aggregate_and_proofs",
|
|
|
|
meth: MethodPost.}
|
|
|
|
## https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Validator/publishAggregateAndProofsV2
|
|
|
|
|
|
|
|
proc publishAggregateAndProofsV2*[T: ForkySignedAggregateAndProof](
|
|
|
|
client: RestClientRef,
|
|
|
|
body: seq[T]
|
|
|
|
): Future[RestPlainResponse] {.
|
|
|
|
async: (raises: [CancelledError, RestEncodingError, RestDnsResolveError,
|
|
|
|
RestCommunicationError], raw: true).} =
|
2024-09-13 21:11:09 +00:00
|
|
|
## https://ethereum.github.io/beacon-APIs/?urls.primaryName=dev#/Validator/publishAggregateAndProofsV2
|
2024-10-16 17:20:39 +00:00
|
|
|
let
|
|
|
|
consensus = T.kind.toString()
|
|
|
|
client.publishAggregateAndProofsV2Plain(
|
|
|
|
body, extraHeaders = @[("eth-consensus-version", consensus)])
|
2024-09-13 21:11:09 +00:00
|
|
|
|
2023-03-03 20:20:01 +00:00
|
|
|
proc prepareBeaconCommitteeSubnet*(
|
|
|
|
body: seq[RestCommitteeSubscription]
|
|
|
|
): RestPlainResponse {.
|
2021-08-03 15:17:11 +00:00
|
|
|
rest, endpoint: "/eth/v1/validator/beacon_committee_subscriptions",
|
|
|
|
meth: MethodPost.}
|
2021-08-27 09:00:06 +00:00
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/prepareBeaconCommitteeSubnet
|
2021-08-03 15:17:11 +00:00
|
|
|
|
2023-03-03 20:20:01 +00:00
|
|
|
proc prepareSyncCommitteeSubnets*(
|
|
|
|
body: seq[RestSyncCommitteeSubscription]
|
|
|
|
): RestPlainResponse {.
|
2021-10-19 17:44:05 +00:00
|
|
|
rest, endpoint: "/eth/v1/validator/sync_committee_subscriptions",
|
|
|
|
meth: MethodPost.}
|
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/prepareSyncCommitteeSubnets
|
2021-08-03 15:17:11 +00:00
|
|
|
|
2023-03-03 20:20:01 +00:00
|
|
|
proc produceSyncCommitteeContributionPlain*(
|
|
|
|
slot: Slot,
|
|
|
|
subcommittee_index: SyncSubcommitteeIndex,
|
|
|
|
beacon_block_root: Eth2Digest
|
|
|
|
): RestPlainResponse {.
|
2021-10-19 17:44:05 +00:00
|
|
|
rest, endpoint: "/eth/v1/validator/sync_committee_contribution",
|
|
|
|
meth: MethodGet.}
|
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/produceSyncCommitteeContribution
|
2021-08-03 15:17:11 +00:00
|
|
|
|
2021-10-19 17:44:05 +00:00
|
|
|
proc publishContributionAndProofs*(body: seq[RestSignedContributionAndProof]): RestPlainResponse {.
|
|
|
|
rest, endpoint: "/eth/v1/validator/contribution_and_proofs",
|
|
|
|
meth: MethodPost.}
|
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/publishContributionAndProofs
|
2022-07-25 20:12:53 +00:00
|
|
|
|
2022-08-09 09:53:02 +00:00
|
|
|
proc prepareBeaconProposer*(body: seq[PrepareBeaconProposer]): RestPlainResponse {.
|
2022-07-25 20:12:53 +00:00
|
|
|
rest, endpoint: "/eth/v1/validator/prepare_beacon_proposer",
|
|
|
|
meth: MethodPost.}
|
|
|
|
## https://ethereum.github.io/beacon-APIs/#/ValidatorRequiredApi/prepareBeaconProposer
|
2022-10-29 09:00:51 +00:00
|
|
|
|
|
|
|
proc registerValidator*(body: seq[SignedValidatorRegistrationV1]): RestPlainResponse {.
|
|
|
|
rest, endpoint: "/eth/v1/validator/register_validator",
|
|
|
|
meth: MethodPost.}
|
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/registerValidator
|
2022-12-06 11:29:00 +00:00
|
|
|
|
|
|
|
proc getValidatorsLiveness*(epoch: Epoch,
|
|
|
|
body: seq[ValidatorIndex]
|
|
|
|
): RestPlainResponse {.
|
|
|
|
rest, endpoint: "/eth/v1/validator/liveness/{epoch}",
|
|
|
|
meth: MethodPost.}
|
2023-11-08 12:03:51 +00:00
|
|
|
|
|
|
|
proc submitBeaconCommitteeSelectionsPlain*(
|
|
|
|
body: seq[RestBeaconCommitteeSelection]
|
|
|
|
): RestPlainResponse {.
|
|
|
|
rest, endpoint: "/eth/v1/validator/beacon_committee_selections",
|
|
|
|
meth: MethodPost.}
|
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/submitBeaconCommitteeSelections
|
|
|
|
|
|
|
|
proc submitSyncCommitteeSelectionsPlain*(
|
|
|
|
body: seq[RestSyncCommitteeSelection]
|
|
|
|
): RestPlainResponse {.
|
|
|
|
rest, endpoint: "/eth/v1/validator/sync_committee_selections",
|
|
|
|
meth: MethodPost.}
|
|
|
|
## https://ethereum.github.io/beacon-APIs/#/Validator/submitSyncCommitteeSelections
|