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:
Dustin Brody 2020-07-23 20:24:38 +02:00 committed by zah
parent db397cc5f3
commit c142de4b7f
4 changed files with 15 additions and 7 deletions

View File

@ -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))

View File

@ -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

View File

@ -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

View File

@ -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 =