mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-11 14:54:12 +00:00
rest: fix invalid type RestSyncCommitteeSubscription
Using the wrong type here causes requests to fail due to the overly zealous parameter validation - the failure is harmless in the current duty subscription model, but would have caused more serious failures down the line.
This commit is contained in:
parent
6bf3330d73
commit
4e2d2ff7f4
@ -606,7 +606,7 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||||||
# https://ethereum.github.io/beacon-APIs/#/Validator/produceSyncCommitteeContribution
|
# https://ethereum.github.io/beacon-APIs/#/Validator/produceSyncCommitteeContribution
|
||||||
router.api(MethodGet,
|
router.api(MethodGet,
|
||||||
"/eth/v1/validator/sync_committee_contribution") do (
|
"/eth/v1/validator/sync_committee_contribution") do (
|
||||||
slot: Option[Slot], subcommittee_index: Option[uint64],
|
slot: Option[Slot], subcommittee_index: Option[SyncSubCommitteeIndex],
|
||||||
beacon_block_root: Option[Eth2Digest]) -> RestApiResponse:
|
beacon_block_root: Option[Eth2Digest]) -> RestApiResponse:
|
||||||
let qslot =
|
let qslot =
|
||||||
if slot.isNone():
|
if slot.isNone():
|
||||||
@ -626,8 +626,7 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||||||
return RestApiResponse.jsonError(Http400,
|
return RestApiResponse.jsonError(Http400,
|
||||||
MissingSubCommitteeIndexValueError)
|
MissingSubCommitteeIndexValueError)
|
||||||
else:
|
else:
|
||||||
let v = subcommittee_index.get()
|
let res = subcommittee_index.get()
|
||||||
let res = (v and SyncSubcommitteeIndex.init(v.get()))
|
|
||||||
if res.isErr():
|
if res.isErr():
|
||||||
return RestApiResponse.jsonError(Http400,
|
return RestApiResponse.jsonError(Http400,
|
||||||
InvalidSubCommitteeIndexValueError,
|
InvalidSubCommitteeIndexValueError,
|
||||||
|
@ -579,6 +579,9 @@ template makeLimitedU64*(T: untyped, limit: uint64) =
|
|||||||
template asInt*(x: T): int = int(distinctBase(x))
|
template asInt*(x: T): int = int(distinctBase(x))
|
||||||
template asUInt64*(x: T): uint64 = uint64(distinctBase(x))
|
template asUInt64*(x: T): uint64 = uint64(distinctBase(x))
|
||||||
|
|
||||||
|
template toSszType(x: T): uint64 =
|
||||||
|
{.error: "Limited types should not be used with SSZ (abi differences)".}
|
||||||
|
|
||||||
makeLimitedU64(CommitteeIndex, MAX_COMMITTEES_PER_SLOT)
|
makeLimitedU64(CommitteeIndex, MAX_COMMITTEES_PER_SLOT)
|
||||||
makeLimitedU64(SubnetId, ATTESTATION_SUBNET_COUNT)
|
makeLimitedU64(SubnetId, ATTESTATION_SUBNET_COUNT)
|
||||||
|
|
||||||
|
@ -52,7 +52,6 @@ type
|
|||||||
phase0.SignedBeaconBlock |
|
phase0.SignedBeaconBlock |
|
||||||
altair.SignedBeaconBlock |
|
altair.SignedBeaconBlock |
|
||||||
SignedVoluntaryExit |
|
SignedVoluntaryExit |
|
||||||
SyncSubcommitteeIndex |
|
|
||||||
Web3SignerRequest |
|
Web3SignerRequest |
|
||||||
KeystoresAndSlashingProtection |
|
KeystoresAndSlashingProtection |
|
||||||
DeleteKeystoresBody
|
DeleteKeystoresBody
|
||||||
@ -904,24 +903,6 @@ proc writeValue*(writer: var JsonWriter[RestJson], value: ForkedHashedBeaconStat
|
|||||||
writer.writeField("data", value.mergeData.data)
|
writer.writeField("data", value.mergeData.data)
|
||||||
writer.endRecord()
|
writer.endRecord()
|
||||||
|
|
||||||
# SyncSubcommitteeIndex
|
|
||||||
proc writeValue*(writer: var JsonWriter[RestJson],
|
|
||||||
value: SyncSubcommitteeIndex) {.
|
|
||||||
raises: [IOError, Defect].} =
|
|
||||||
writeValue(writer, value.asUInt64)
|
|
||||||
|
|
||||||
proc readValue*(reader: var JsonReader[RestJson],
|
|
||||||
value: var SyncSubcommitteeIndex) {.
|
|
||||||
raises: [IOError, SerializationError, Defect].} =
|
|
||||||
var v: uint64
|
|
||||||
reader.readValue(v)
|
|
||||||
|
|
||||||
let res = SyncSubcommitteeIndex.init(v)
|
|
||||||
if res.isOk():
|
|
||||||
value = res.get()
|
|
||||||
else:
|
|
||||||
reader.raiseUnexpectedValue($res.error())
|
|
||||||
|
|
||||||
# Web3SignerRequest
|
# Web3SignerRequest
|
||||||
proc writeValue*(writer: var JsonWriter[RestJson],
|
proc writeValue*(writer: var JsonWriter[RestJson],
|
||||||
value: Web3SignerRequest) {.
|
value: Web3SignerRequest) {.
|
||||||
|
@ -138,7 +138,7 @@ type
|
|||||||
|
|
||||||
RestSyncCommitteeSubscription* = object
|
RestSyncCommitteeSubscription* = object
|
||||||
validator_index*: ValidatorIndex
|
validator_index*: ValidatorIndex
|
||||||
sync_committee_indices*: seq[SyncSubcommitteeIndex]
|
sync_committee_indices*: seq[IndexInSyncCommittee]
|
||||||
until_epoch*: Epoch
|
until_epoch*: Epoch
|
||||||
|
|
||||||
RestBeaconStatesFinalityCheckpoints* = object
|
RestBeaconStatesFinalityCheckpoints* = object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user