improve deposit processing performance (#4082)
When there are a lot of deposits, we decompress the public key into a crypto cache. To avoid having those caches grow unreasonably big, make sure to operate on the decompressed pubkey instead.
This commit is contained in:
parent
bf3a014287
commit
0191225896
|
@ -530,11 +530,9 @@ const
|
|||
DOMAIN_CONTRIBUTION_AND_PROOF* = DomainType([byte 0x09, 0x00, 0x00, 0x00])
|
||||
|
||||
func getImmutableValidatorData*(validator: Validator): ImmutableValidatorData2 =
|
||||
let cookedKey = validator.pubkey.load() # Loading the pubkey is slow!
|
||||
doAssert cookedKey.isSome,
|
||||
"Cannot parse validator key: " & toHex(validator.pubkey)
|
||||
let cookedKey = validator.pubkey.loadValid() # `Validator` has valid key
|
||||
ImmutableValidatorData2(
|
||||
pubkey: cookedKey.get(),
|
||||
pubkey: cookedKey,
|
||||
withdrawal_credentials: validator.withdrawal_credentials)
|
||||
|
||||
template makeLimitedUInt*(T: untyped, limit: SomeUnsignedInt) =
|
||||
|
|
|
@ -200,13 +200,24 @@ func get_deposit_signature*(message: DepositMessage, version: Version,
|
|||
blsSign(privkey, signing_root.data)
|
||||
|
||||
proc verify_deposit_signature*(preset: RuntimeConfig,
|
||||
deposit: DepositData): bool =
|
||||
deposit: DepositData,
|
||||
pubkey: CookedPubKey): bool =
|
||||
let
|
||||
deposit_message = deposit.getDepositMessage()
|
||||
signing_root = compute_deposit_signing_root(
|
||||
preset.GENESIS_FORK_VERSION, deposit_message)
|
||||
|
||||
blsVerify(deposit.pubkey, signing_root.data, deposit.signature)
|
||||
blsVerify(pubkey, signing_root.data, deposit.signature)
|
||||
|
||||
proc verify_deposit_signature*(preset: RuntimeConfig,
|
||||
deposit: DepositData): bool =
|
||||
# Deposits come with compressed public keys; uncompressing them is expensive.
|
||||
# `blsVerify` fills an internal cache when using `ValidatorPubKey`.
|
||||
# To avoid filling this cache unnecessarily, uncompress explicitly here.
|
||||
let pubkey = deposit.pubkey.load() # Loading the pubkey is slow!
|
||||
if pubkey.isNone:
|
||||
return false
|
||||
verify_deposit_signature(preset, deposit, pubkey.get)
|
||||
|
||||
func compute_voluntary_exit_signing_root*(
|
||||
fork: Fork, genesis_validators_root: Eth2Digest,
|
||||
|
|
Loading…
Reference in New Issue