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