be more consistent about pubkeys fed to verify_foo_signature() not being separately initialized, while pubkeys, generally, used for matching purposes, elsewhere explicitly initialized
This commit is contained in:
parent
db397cc5f3
commit
c142de4b7f
|
@ -879,4 +879,6 @@ proc getProposer*(
|
|||
balances=state.balances
|
||||
return
|
||||
|
||||
return some((proposerIdx.get(), state.validators[proposerIdx.get()].pubkey))
|
||||
return some((
|
||||
proposerIdx.get(),
|
||||
state.validators[proposerIdx.get()].pubkey.initPubKey))
|
||||
|
|
|
@ -88,11 +88,12 @@ proc process_deposit*(preset: RuntimePreset,
|
|||
|
||||
let
|
||||
pubkey = deposit.data.pubkey
|
||||
pubkey_inited = pubkey.initPubKey # TODO replicate previous PR semantics, check later
|
||||
amount = deposit.data.amount
|
||||
var index = -1
|
||||
|
||||
for i, validator in state.validators:
|
||||
if pubkey == validator.pubkey:
|
||||
if pubkey == validator.pubkey.initPubKey:
|
||||
index = i
|
||||
break
|
||||
|
||||
|
|
|
@ -122,10 +122,16 @@ proc toRealPubKey(pubkey: ValidatorPubKey): Option[ValidatorPubKey] =
|
|||
if fromBytes(val, pubkey.blob):
|
||||
some ValidatorPubKey(kind: Real, blsValue: val)
|
||||
else:
|
||||
none(ValidatorPubKey)
|
||||
none ValidatorPubKey
|
||||
validatorKeyCache[key] = maybeRealKey
|
||||
maybeRealKey
|
||||
|
||||
proc initPubKey*(pubkey: ValidatorPubKey): ValidatorPubKey =
|
||||
let key = toRealPubKey(pubkey)
|
||||
if key.isNone:
|
||||
return ValidatorPubKey()
|
||||
key.get
|
||||
|
||||
func aggregate*(x: var ValidatorSig, other: ValidatorSig) =
|
||||
## Aggregate 2 Validator Signatures
|
||||
## This assumes that they are real signatures
|
||||
|
@ -245,8 +251,7 @@ func fromRaw*(T: type ValidatorPrivKey, bytes: openArray[byte]): BlsResult[T] =
|
|||
func fromRaw*[N, T](BT: type BlsValue[N, T], bytes: openArray[byte]): BlsResult[BT] =
|
||||
# This is a workaround, so that we can deserialize the serialization of a
|
||||
# default-initialized BlsValue without raising an exception
|
||||
when defined(ssz_testing) or T is blscurve.PublicKey:
|
||||
# Only for SSZ parsing tests, everything is an opaque blob
|
||||
when defined(ssz_testing) or BT is ValidatorPubKey:
|
||||
ok BT(kind: OpaqueBlob, blob: toArray(N, bytes))
|
||||
else:
|
||||
# Try if valid BLS value
|
||||
|
|
|
@ -60,10 +60,10 @@ proc addLocalValidators*(node: BeaconNode) =
|
|||
|
||||
info "Local validators attached ", count = node.attachedValidators.count
|
||||
|
||||
func getAttachedValidator*(node: BeaconNode,
|
||||
proc getAttachedValidator*(node: BeaconNode,
|
||||
state: BeaconState,
|
||||
idx: ValidatorIndex): AttachedValidator =
|
||||
let validatorKey = state.validators[idx].pubkey
|
||||
let validatorKey = state.validators[idx].pubkey.initPubKey
|
||||
node.attachedValidators.getValidator(validatorKey)
|
||||
|
||||
proc isSynced*(node: BeaconNode, head: BlockRef): bool =
|
||||
|
|
Loading…
Reference in New Issue