mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-22 04:24:05 +00:00
Adopt BN and VC header sizes and requirements, to avoid users confusion with default configuration options. (#4556)
Add comments.
This commit is contained in:
parent
c22384d7ba
commit
08ed8ad43e
@ -451,9 +451,12 @@ type
|
||||
name: "rest-max-body-size" .}: Natural
|
||||
|
||||
restMaxRequestHeadersSize* {.
|
||||
defaultValue: 64
|
||||
defaultValue: 128
|
||||
desc: "Maximum size of REST request headers (kilobytes)"
|
||||
name: "rest-max-headers-size" .}: Natural
|
||||
## NOTE: If you going to adjust this value please check value
|
||||
## ``ClientMaximumValidatorIds`` and comments in
|
||||
## `spec/eth2_apis/rest_types.nim`. This values depend on each other.
|
||||
|
||||
keymanagerEnabled* {.
|
||||
desc: "Enable the REST keymanager API"
|
||||
|
@ -254,7 +254,7 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||
return RestApiResponse.jsonError(Http400,
|
||||
InvalidValidatorIdValueError)
|
||||
let ires = id.get()
|
||||
if len(ires) > MaximumValidatorIds:
|
||||
if len(ires) > ServerMaximumValidatorIds:
|
||||
return RestApiResponse.jsonError(Http400,
|
||||
MaximumNumberOfValidatorIdsError)
|
||||
ires
|
||||
@ -445,7 +445,7 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||
return RestApiResponse.jsonError(Http400,
|
||||
InvalidValidatorIdValueError)
|
||||
let ires = id.get()
|
||||
if len(ires) > MaximumValidatorIds:
|
||||
if len(ires) > ServerMaximumValidatorIds:
|
||||
return RestApiResponse.jsonError(Http400,
|
||||
MaximumNumberOfValidatorIdsError)
|
||||
ires
|
||||
|
@ -27,11 +27,35 @@ export forks, phase0, altair, bellatrix, capella, bellatrix_mev
|
||||
const
|
||||
# https://github.com/ethereum/eth2.0-APIs/blob/master/apis/beacon/states/validator_balances.yaml#L17
|
||||
# https://github.com/ethereum/eth2.0-APIs/blob/master/apis/beacon/states/validators.yaml#L17
|
||||
MaximumValidatorIds* = 16384
|
||||
# Maximum number of validators that can be served by the REST server in one
|
||||
# request, if the number of validator exceeds this value REST server
|
||||
# will return HTTP error 400.
|
||||
ServerMaximumValidatorIds* = 16384
|
||||
|
||||
# Maximum number of validators that can be sent in single request by
|
||||
# validator client (VC).
|
||||
# NOTE: This value depend on beacon node's `rest-max-headers-size`
|
||||
# configuration option.
|
||||
#
|
||||
# Size of public key in HTTP request could be calculated by formula -
|
||||
# bytes48 * 2 + len("0x") + len(",") = 99 bytes.
|
||||
# So 1024 keys will occupy 101,376 bytes. Default value for HTTP headers size
|
||||
# is 128Kb = 131,072 bytes.
|
||||
ClientMaximumValidatorIds* = 1024
|
||||
|
||||
# https://github.com/ethereum/beacon-APIs/blob/master/apis/validator/duties/attester.yaml#L32
|
||||
# https://github.com/ethereum/beacon-APIs/blob/master/apis/validator/duties/sync.yaml#L16
|
||||
# Maximum number of validator ids sent with validator client's duties
|
||||
# requests. Validator ids are sent in decimal encoding with comma, so
|
||||
# number of ids should not exceed beacon node's `rest-max-body-size`.
|
||||
DutiesMaximumValidatorIds* = 16384
|
||||
|
||||
const
|
||||
preferSSZ* = "application/octet-stream,application/json;q=0.9"
|
||||
|
||||
static:
|
||||
doAssert(ClientMaximumValidatorIds <= ServerMaximumValidatorIds)
|
||||
|
||||
type
|
||||
EventTopic* {.pure.} = enum
|
||||
Head, Block, Attestation, VoluntaryExit, FinalizedCheckpoint, ChainReorg,
|
||||
|
@ -51,7 +51,7 @@ proc pollForValidatorIndices*(vc: ValidatorClientRef) {.async.} =
|
||||
var offset = 0
|
||||
|
||||
while offset < len(validatorIdents):
|
||||
let arraySize = min(MaximumValidatorIds, len(validatorIdents))
|
||||
let arraySize = min(ClientMaximumValidatorIds, len(validatorIdents))
|
||||
|
||||
let idents =
|
||||
block:
|
||||
@ -119,7 +119,9 @@ proc pollForAttesterDuties*(vc: ValidatorClientRef,
|
||||
|
||||
var offset = 0
|
||||
while offset < len(validatorIndices):
|
||||
let arraySize = min(MaximumValidatorIds, len(validatorIndices))
|
||||
let arraySize = min(DutiesMaximumValidatorIds, len(validatorIndices))
|
||||
# We use `DutiesMaximumValidatorIds` here because validator ids are sent
|
||||
# in HTTP request body and NOT in HTTP request headers.
|
||||
let indices =
|
||||
block:
|
||||
var res = newSeq[ValidatorIndex](arraySize)
|
||||
@ -255,7 +257,9 @@ proc pollForSyncCommitteeDuties*(vc: ValidatorClientRef,
|
||||
|
||||
while offset < len(validatorIndices):
|
||||
let
|
||||
arraySize = min(MaximumValidatorIds, remainingItems)
|
||||
arraySize = min(DutiesMaximumValidatorIds, remainingItems)
|
||||
# We use `DutiesMaximumValidatorIds` here because validator ids are sent
|
||||
# in HTTP request body and NOT in HTTP request headers.
|
||||
indices = validatorIndices[offset ..< (offset + arraySize)]
|
||||
|
||||
res =
|
||||
|
Loading…
x
Reference in New Issue
Block a user