mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-11 06:46:10 +00:00
Client definitions for the sync committee REST APIs (#3002)
This commit is contained in:
parent
724a9083ec
commit
44d762119c
@ -49,13 +49,17 @@ type
|
||||
ProposerSlashing |
|
||||
phase0.SignedBeaconBlock |
|
||||
altair.SignedBeaconBlock |
|
||||
SignedVoluntaryExit
|
||||
SignedVoluntaryExit |
|
||||
SyncCommitteeIndex
|
||||
|
||||
EncodeArrays* =
|
||||
seq[ValidatorIndex] |
|
||||
seq[Attestation] |
|
||||
seq[SignedAggregateAndProof] |
|
||||
seq[RestCommitteeSubscription]
|
||||
seq[RestCommitteeSubscription] |
|
||||
seq[RestSyncCommitteeSubscription] |
|
||||
seq[RestSyncCommitteeMessage] |
|
||||
seq[RestSignedContributionAndProof]
|
||||
|
||||
DecodeTypes* =
|
||||
DataEnclosedObject |
|
||||
@ -874,8 +878,10 @@ proc readValue*(reader: var JsonReader[RestJson],
|
||||
raises: [IOError, SerializationError, Defect].} =
|
||||
let res = Base10.decode(uint8, reader.readValue(string))
|
||||
if res.isOk():
|
||||
# TODO (cheatfate): Here should be present check for maximum value.
|
||||
value = SyncCommitteeIndex(res.get())
|
||||
if res.get() < SYNC_COMMITTEE_SUBNET_COUNT:
|
||||
value = SyncCommitteeIndex(res.get())
|
||||
else:
|
||||
reader.raiseUnexpectedValue("Sync sub-committee index out of rage")
|
||||
else:
|
||||
reader.raiseUnexpectedValue($res.error())
|
||||
|
||||
@ -976,7 +982,7 @@ proc decodeBytes*[T: SszDecodeTypes](t: typedesc[T], value: openarray[byte],
|
||||
proc encodeString*(value: string): RestResult[string] =
|
||||
ok(value)
|
||||
|
||||
proc encodeString*(value: Epoch|Slot|CommitteeIndex): RestResult[string] =
|
||||
proc encodeString*(value: Epoch|Slot|CommitteeIndex|SyncCommitteeIndex): RestResult[string] =
|
||||
ok(Base10.toString(uint64(value)))
|
||||
|
||||
proc encodeString*(value: ValidatorSig): RestResult[string] =
|
||||
@ -1214,6 +1220,14 @@ proc decodeString*(t: typedesc[CommitteeIndex],
|
||||
let res = ? Base10.decode(uint64, value)
|
||||
ok(CommitteeIndex(res))
|
||||
|
||||
proc decodeString*(t: typedesc[SyncCommitteeIndex],
|
||||
value: string): Result[SyncCommitteeIndex, cstring] =
|
||||
let res = ? Base10.decode(uint8, value)
|
||||
if res.get < SYNC_COMMITTEE_SUBNET_COUNT:
|
||||
ok(CommitteeIndex(res))
|
||||
else:
|
||||
err("sync subcommittee index out of range")
|
||||
|
||||
proc decodeString*(t: typedesc[Eth2Digest],
|
||||
value: string): Result[Eth2Digest, cstring] =
|
||||
if len(value) != RootHashSize + 2:
|
||||
|
@ -258,11 +258,10 @@ proc submitPoolProposerSlashings*(body: ProposerSlashing): RestPlainResponse {.
|
||||
meth: MethodPost.}
|
||||
## https://ethereum.github.io/beacon-APIs/#/Beacon/submitPoolProposerSlashings
|
||||
|
||||
# TODO Altair
|
||||
# proc submitPoolSyncCommitteeSignatures*(body: seq[RestSyncCommitteeSignature]): RestPlainResponse {.
|
||||
# rest, endpoint: "/eth/v1/beacon/pool/sync_committees",
|
||||
# meth: MethodPost.}
|
||||
# ## https://ethereum.github.io/beacon-APIs/#/Beacon/submitPoolSyncCommitteeSignatures
|
||||
proc submitPoolSyncCommitteeSignatures*(body: seq[RestSyncCommitteeMessage]): RestPlainResponse {.
|
||||
rest, endpoint: "/eth/v1/beacon/pool/sync_committees",
|
||||
meth: MethodPost.}
|
||||
## https://ethereum.github.io/beacon-APIs/#/Beacon/submitPoolSyncCommitteeSignatures
|
||||
|
||||
proc getPoolVoluntaryExits*(): RestResponse[GetPoolVoluntaryExitsResponse] {.
|
||||
rest, endpoint: "/api/eth/v1/beacon/pool/voluntary_exits",
|
||||
|
@ -107,6 +107,28 @@ type
|
||||
validator_index*: ValidatorIndex
|
||||
validator_sync_committee_indices*: seq[SyncCommitteeIndex]
|
||||
|
||||
RestSyncCommitteeMessage* = object
|
||||
slot*: Slot
|
||||
beacon_block_root*: Eth2Digest
|
||||
validator_index*: uint64
|
||||
signature*: ValidatorSig
|
||||
|
||||
RestSyncCommitteeContribution* = object
|
||||
slot*: Slot
|
||||
beacon_block_root*: Eth2Digest
|
||||
subcommittee_index*: uint64
|
||||
aggregation_bits*: SyncCommitteeAggregationBits ##\
|
||||
signature*: ValidatorSig
|
||||
|
||||
RestContributionAndProof* = object
|
||||
aggregator_index*: uint64
|
||||
selection_proof*: ValidatorSig
|
||||
contribution*: RestSyncCommitteeContribution
|
||||
|
||||
RestSignedContributionAndProof* = object
|
||||
message*: RestContributionAndProof
|
||||
signature*: ValidatorSig
|
||||
|
||||
RestCommitteeSubscription* = object
|
||||
validator_index*: ValidatorIndex
|
||||
committee_index*: CommitteeIndex
|
||||
@ -291,7 +313,7 @@ type
|
||||
RestBlockInfo* = object
|
||||
slot*: Slot
|
||||
blck* {.serializedFieldName: "block".}: Eth2Digest
|
||||
|
||||
|
||||
RestEpochSyncCommittee* = object
|
||||
validators*: seq[ValidatorIndex]
|
||||
validator_aggregates*: seq[seq[ValidatorIndex]]
|
||||
@ -347,6 +369,7 @@ type
|
||||
GetPoolProposerSlashingsResponse* = DataEnclosedObject[seq[ProposerSlashing]]
|
||||
GetPoolVoluntaryExitsResponse* = DataEnclosedObject[seq[SignedVoluntaryExit]]
|
||||
GetProposerDutiesResponse* = DataRootEnclosedObject[seq[RestProposerDuty]]
|
||||
GetSyncCommitteeDutiesResponse* = DataEnclosedObject[seq[RestSyncCommitteeDuty]]
|
||||
GetSpecResponse* = DataEnclosedObject[RestSpec]
|
||||
GetStateFinalityCheckpointsResponse* = DataEnclosedObject[RestBeaconStatesFinalityCheckpoints]
|
||||
GetStateForkResponse* = DataEnclosedObject[Fork]
|
||||
|
@ -24,11 +24,12 @@ proc getProposerDuties*(epoch: Epoch): RestResponse[GetProposerDutiesResponse] {
|
||||
meth: MethodGet.}
|
||||
## https://ethereum.github.io/beacon-APIs/#/Validator/getProposerDuties
|
||||
|
||||
# TODO altair
|
||||
# proc getSyncCommitteeDuties*(epoch: Epoch): RestResponse[DataRestSyncCommitteeDuties] {.
|
||||
# rest, endpoint: "/eth/v1/validator/duties/sync/{epoch}",
|
||||
# meth: MethodPost.}
|
||||
# ## https://ethereum.github.io/beacon-APIs/#/Validator/getSyncCommitteeDuties
|
||||
proc getSyncCommitteeDuties*(epoch: Epoch,
|
||||
body: seq[ValidatorIndex]
|
||||
): RestResponse[GetSyncCommitteeDutiesResponse] {.
|
||||
rest, endpoint: "/eth/v1/validator/duties/sync/{epoch}",
|
||||
meth: MethodPost.}
|
||||
## https://ethereum.github.io/beacon-APIs/#/Validator/getSyncCommitteeDuties
|
||||
|
||||
proc produceBlock*(slot: Slot, randao_reveal: ValidatorSig,
|
||||
graffiti: GraffitiBytes
|
||||
@ -68,21 +69,19 @@ proc prepareBeaconCommitteeSubnet*(body: seq[RestCommitteeSubscription]): RestPl
|
||||
meth: MethodPost.}
|
||||
## https://ethereum.github.io/beacon-APIs/#/Validator/prepareBeaconCommitteeSubnet
|
||||
|
||||
# TODO altair
|
||||
# proc prepareSyncCommitteeSubnets*(body: seq[int]
|
||||
# ): RestPlainResponse {.
|
||||
# rest, endpoint: "/eth/v1/validator/sync_committee_subscriptions",
|
||||
# meth: MethodPost.}
|
||||
# ## https://ethereum.github.io/beacon-APIs/#/Validator/prepareSyncCommitteeSubnets
|
||||
proc prepareSyncCommitteeSubnets*(body: seq[RestSyncCommitteeSubscription]): RestPlainResponse {.
|
||||
rest, endpoint: "/eth/v1/validator/sync_committee_subscriptions",
|
||||
meth: MethodPost.}
|
||||
## https://ethereum.github.io/beacon-APIs/#/Validator/prepareSyncCommitteeSubnets
|
||||
|
||||
# proc produceSyncCommitteeContribution*(body: seq[int]
|
||||
# ): RestPlainResponse {.
|
||||
# rest, endpoint: "/eth/v1/validator/sync_committee_contribution",
|
||||
# meth: MethodPost.}
|
||||
# ## https://ethereum.github.io/beacon-APIs/#/Validator/produceSyncCommitteeContribution
|
||||
proc produceSyncCommitteeContribution*(slot: Slot,
|
||||
subcommittee_index: SyncCommitteeIndex,
|
||||
beacon_block_root: Eth2Digest): RestPlainResponse {.
|
||||
rest, endpoint: "/eth/v1/validator/sync_committee_contribution",
|
||||
meth: MethodGet.}
|
||||
## https://ethereum.github.io/beacon-APIs/#/Validator/produceSyncCommitteeContribution
|
||||
|
||||
# proc publishContributionAndProofs*(body: seq[RestCommitteeSubscription]
|
||||
# ): RestPlainResponse {.
|
||||
# rest, endpoint: "/eth/v1/validator/contribution_and_proofs",
|
||||
# meth: MethodPost.}
|
||||
# ## https://ethereum.github.io/beacon-APIs/#/Validator/publishContributionAndProofs
|
||||
proc publishContributionAndProofs*(body: seq[RestSignedContributionAndProof]): RestPlainResponse {.
|
||||
rest, endpoint: "/eth/v1/validator/contribution_and_proofs",
|
||||
meth: MethodPost.}
|
||||
## https://ethereum.github.io/beacon-APIs/#/Validator/publishContributionAndProofs
|
||||
|
Loading…
x
Reference in New Issue
Block a user