mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-11 06:46:10 +00:00
Fix #3463 (validator index-out-of-bound errors triggered through the REST API)
This commit is contained in:
parent
8955edf158
commit
5ef2ce4069
@ -251,13 +251,15 @@ func keysToIndices*(cacheTable: var Table[ValidatorPubKey, ValidatorIndex],
|
||||
keys: openArray[ValidatorPubKey]
|
||||
): seq[Option[ValidatorIndex]] =
|
||||
var indices = newSeq[Option[ValidatorIndex]](len(keys))
|
||||
let totalValidatorsInState = getStateField(forkedState, validators).lenu64
|
||||
var keyset =
|
||||
block:
|
||||
var res: Table[ValidatorPubKey, int]
|
||||
for inputIndex, pubkey in keys.pairs():
|
||||
# Try to search in cache first.
|
||||
cacheTable.withValue(pubkey, vindex):
|
||||
indices[inputIndex] = some(vindex[])
|
||||
if uint64(vindex[]) < totalValidatorsInState:
|
||||
indices[inputIndex] = some(vindex[])
|
||||
do:
|
||||
res[pubkey] = inputIndex
|
||||
res
|
||||
|
Loading…
x
Reference in New Issue
Block a user