Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate pubkeys args in keymanager API #4442

Merged
merged 1 commit into from
Aug 18, 2022

Conversation

dapplion
Copy link
Contributor

@dapplion dapplion commented Aug 18, 2022

Motivation

deleteRemoteKeys() takes a set of public keys as input but does not perform input validation on them. It is advised to perform an explicit input validation on all provided public keys. Having explicit checks will make the code more robust wrt. refactoring.

Description

Validate pubkeys args in keymanager API

Closes #4445

@dapplion dapplion requested a review from a team as a code owner August 18, 2022 13:54
@github-actions
Copy link
Contributor

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 068b35a Previous: 9ffdbfa Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.3097 ms/op 2.4179 ms/op 0.96
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 72.904 us/op 87.477 us/op 0.83
BLS verify - blst-native 2.5182 ms/op 2.6841 ms/op 0.94
BLS verifyMultipleSignatures 3 - blst-native 5.2055 ms/op 5.7157 ms/op 0.91
BLS verifyMultipleSignatures 8 - blst-native 11.627 ms/op 11.658 ms/op 1.00
BLS verifyMultipleSignatures 32 - blst-native 40.941 ms/op 43.537 ms/op 0.94
BLS aggregatePubkeys 32 - blst-native 55.809 us/op 58.647 us/op 0.95
BLS aggregatePubkeys 128 - blst-native 221.72 us/op 228.15 us/op 0.97
getAttestationsForBlock 192.40 ms/op 198.66 ms/op 0.97
isKnown best case - 1 super set check 531.00 ns/op 509.00 ns/op 1.04
isKnown normal case - 2 super set checks 518.00 ns/op 485.00 ns/op 1.07
isKnown worse case - 16 super set checks 488.00 ns/op 493.00 ns/op 0.99
CheckpointStateCache - add get delete 11.017 us/op 10.967 us/op 1.00
validate gossip signedAggregateAndProof - struct 6.4504 ms/op 6.3082 ms/op 1.02
validate gossip attestation - struct 2.9382 ms/op 3.0692 ms/op 0.96
altair verifyImport mainnet_s3766816:31 5.6638 s/op 5.8872 s/op 0.96
pickEth1Vote - no votes 2.4084 ms/op 2.4676 ms/op 0.98
pickEth1Vote - max votes 24.661 ms/op 25.442 ms/op 0.97
pickEth1Vote - Eth1Data hashTreeRoot value x2048 16.748 ms/op 18.061 ms/op 0.93
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 21.779 ms/op 24.884 ms/op 0.88
pickEth1Vote - Eth1Data fastSerialize value x2048 1.7032 ms/op 1.7626 ms/op 0.97
pickEth1Vote - Eth1Data fastSerialize tree x2048 14.562 ms/op 14.945 ms/op 0.97
bytes32 toHexString 1.2880 us/op 1.1770 us/op 1.09
bytes32 Buffer.toString(hex) 799.00 ns/op 829.00 ns/op 0.96
bytes32 Buffer.toString(hex) from Uint8Array 1.0050 us/op 1.1130 us/op 0.90
bytes32 Buffer.toString(hex) + 0x 745.00 ns/op 842.00 ns/op 0.88
Object access 1 prop 0.36200 ns/op 0.42000 ns/op 0.86
Map access 1 prop 0.32900 ns/op 0.34700 ns/op 0.95
Object get x1000 15.678 ns/op 16.300 ns/op 0.96
Map get x1000 0.90500 ns/op 0.96100 ns/op 0.94
Object set x1000 101.98 ns/op 110.68 ns/op 0.92
Map set x1000 75.584 ns/op 79.549 ns/op 0.95
Return object 10000 times 0.42890 ns/op 0.41770 ns/op 1.03
Throw Error 10000 times 6.7097 us/op 7.0861 us/op 0.95
enrSubnets - fastDeserialize 64 bits 2.8620 us/op 3.0500 us/op 0.94
enrSubnets - ssz BitVector 64 bits 801.00 ns/op 851.00 ns/op 0.94
enrSubnets - fastDeserialize 4 bits 410.00 ns/op 414.00 ns/op 0.99
enrSubnets - ssz BitVector 4 bits 834.00 ns/op 805.00 ns/op 1.04
prioritizePeers score -10:0 att 32-0.1 sync 2-0 120.45 us/op 110.11 us/op 1.09
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 155.41 us/op 150.79 us/op 1.03
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 263.08 us/op 267.26 us/op 0.98
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 508.83 us/op 595.53 us/op 0.85
prioritizePeers score 0:0 att 64-1 sync 4-1 586.45 us/op 616.55 us/op 0.95
RateTracker 1000000 limit, 1 obj count per request 194.93 ns/op 215.60 ns/op 0.90
RateTracker 1000000 limit, 2 obj count per request 142.53 ns/op 156.72 ns/op 0.91
RateTracker 1000000 limit, 4 obj count per request 119.45 ns/op 124.74 ns/op 0.96
RateTracker 1000000 limit, 8 obj count per request 108.95 ns/op 116.21 ns/op 0.94
RateTracker with prune 4.7280 us/op 4.9340 us/op 0.96
array of 16000 items push then shift 5.1333 us/op 5.3437 us/op 0.96
LinkedList of 16000 items push then shift 28.355 ns/op 27.548 ns/op 1.03
array of 16000 items push then pop 223.75 ns/op 238.41 ns/op 0.94
LinkedList of 16000 items push then pop 23.428 ns/op 23.173 ns/op 1.01
array of 24000 items push then shift 7.8047 us/op 8.5070 us/op 0.92
LinkedList of 24000 items push then shift 26.304 ns/op 27.000 ns/op 0.97
array of 24000 items push then pop 240.29 ns/op 245.22 ns/op 0.98
LinkedList of 24000 items push then pop 24.034 ns/op 23.171 ns/op 1.04
intersect bitArray bitLen 8 12.939 ns/op 12.434 ns/op 1.04
intersect array and set length 8 197.54 ns/op 185.30 ns/op 1.07
intersect bitArray bitLen 128 72.060 ns/op 72.050 ns/op 1.00
intersect array and set length 128 2.5727 us/op 2.3241 us/op 1.11
Buffer.concat 32 items 2.3140 ns/op 2.2500 ns/op 1.03
pass gossip attestations to forkchoice per slot 3.3492 ms/op 3.5542 ms/op 0.94
computeDeltas 3.7070 ms/op 4.6458 ms/op 0.80
computeProposerBoostScoreFromBalances 834.69 us/op 911.51 us/op 0.92
altair processAttestation - 250000 vs - 7PWei normalcase 4.8493 ms/op 5.1772 ms/op 0.94
altair processAttestation - 250000 vs - 7PWei worstcase 7.4054 ms/op 7.2496 ms/op 1.02
altair processAttestation - setStatus - 1/6 committees join 241.35 us/op 250.75 us/op 0.96
altair processAttestation - setStatus - 1/3 committees join 455.63 us/op 464.37 us/op 0.98
altair processAttestation - setStatus - 1/2 committees join 654.36 us/op 689.55 us/op 0.95
altair processAttestation - setStatus - 2/3 committees join 837.43 us/op 862.84 us/op 0.97
altair processAttestation - setStatus - 4/5 committees join 1.2353 ms/op 1.2213 ms/op 1.01
altair processAttestation - setStatus - 100% committees join 1.4047 ms/op 1.5146 ms/op 0.93
altair processBlock - 250000 vs - 7PWei normalcase 31.563 ms/op 33.641 ms/op 0.94
altair processBlock - 250000 vs - 7PWei normalcase hashState 51.698 ms/op 56.209 ms/op 0.92
altair processBlock - 250000 vs - 7PWei worstcase 121.30 ms/op 115.03 ms/op 1.05
altair processBlock - 250000 vs - 7PWei worstcase hashState 148.01 ms/op 120.96 ms/op 1.22
phase0 processBlock - 250000 vs - 7PWei normalcase 4.3154 ms/op 3.9766 ms/op 1.09
phase0 processBlock - 250000 vs - 7PWei worstcase 65.958 ms/op 63.966 ms/op 1.03
altair processEth1Data - 250000 vs - 7PWei normalcase 985.70 us/op 1.4840 ms/op 0.66
Tree 40 250000 create 991.00 ms/op 1.0083 s/op 0.98
Tree 40 250000 get(125000) 313.06 ns/op 326.94 ns/op 0.96
Tree 40 250000 set(125000) 2.8847 us/op 3.0655 us/op 0.94
Tree 40 250000 toArray() 34.666 ms/op 38.649 ms/op 0.90
Tree 40 250000 iterate all - toArray() + loop 34.182 ms/op 39.040 ms/op 0.88
Tree 40 250000 iterate all - get(i) 129.27 ms/op 132.57 ms/op 0.98
MutableVector 250000 create 27.776 ms/op 25.682 ms/op 1.08
MutableVector 250000 get(125000) 13.641 ns/op 13.866 ns/op 0.98
MutableVector 250000 set(125000) 724.27 ns/op 769.61 ns/op 0.94
MutableVector 250000 toArray() 7.0761 ms/op 7.1351 ms/op 0.99
MutableVector 250000 iterate all - toArray() + loop 7.2958 ms/op 8.0038 ms/op 0.91
MutableVector 250000 iterate all - get(i) 3.5586 ms/op 3.5144 ms/op 1.01
Array 250000 create 6.6443 ms/op 6.5985 ms/op 1.01
Array 250000 clone - spread 2.8584 ms/op 2.9943 ms/op 0.95
Array 250000 get(125000) 1.2460 ns/op 1.2390 ns/op 1.01
Array 250000 set(125000) 1.3300 ns/op 1.4050 ns/op 0.95
Array 250000 iterate all - loop 141.33 us/op 146.11 us/op 0.97
effectiveBalanceIncrements clone Uint8Array 300000 93.815 us/op 95.038 us/op 0.99
effectiveBalanceIncrements clone MutableVector 300000 859.00 ns/op 935.00 ns/op 0.92
effectiveBalanceIncrements rw all Uint8Array 300000 296.62 us/op 300.31 us/op 0.99
effectiveBalanceIncrements rw all MutableVector 300000 222.83 ms/op 246.46 ms/op 0.90
phase0 afterProcessEpoch - 250000 vs - 7PWei 225.56 ms/op 207.62 ms/op 1.09
phase0 beforeProcessEpoch - 250000 vs - 7PWei 166.26 ms/op 157.41 ms/op 1.06
altair processEpoch - mainnet_e81889 651.05 ms/op 802.84 ms/op 0.81
mainnet_e81889 - altair beforeProcessEpoch 158.74 ms/op 239.93 ms/op 0.66
mainnet_e81889 - altair processJustificationAndFinalization 58.341 us/op 65.240 us/op 0.89
mainnet_e81889 - altair processInactivityUpdates 11.398 ms/op 11.150 ms/op 1.02
mainnet_e81889 - altair processRewardsAndPenalties 173.08 ms/op 206.68 ms/op 0.84
mainnet_e81889 - altair processRegistryUpdates 12.505 us/op 14.581 us/op 0.86
mainnet_e81889 - altair processSlashings 3.8630 us/op 4.1460 us/op 0.93
mainnet_e81889 - altair processEth1DataReset 4.3370 us/op 4.2110 us/op 1.03
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.5352 ms/op 3.0139 ms/op 0.84
mainnet_e81889 - altair processSlashingsReset 19.674 us/op 28.577 us/op 0.69
mainnet_e81889 - altair processRandaoMixesReset 21.575 us/op 25.112 us/op 0.86
mainnet_e81889 - altair processHistoricalRootsUpdate 4.0550 us/op 5.0750 us/op 0.80
mainnet_e81889 - altair processParticipationFlagUpdates 11.074 us/op 16.758 us/op 0.66
mainnet_e81889 - altair processSyncCommitteeUpdates 3.3400 us/op 3.9390 us/op 0.85
mainnet_e81889 - altair afterProcessEpoch 212.64 ms/op 209.98 ms/op 1.01
phase0 processEpoch - mainnet_e58758 621.82 ms/op 811.71 ms/op 0.77
mainnet_e58758 - phase0 beforeProcessEpoch 281.32 ms/op 362.05 ms/op 0.78
mainnet_e58758 - phase0 processJustificationAndFinalization 58.035 us/op 61.554 us/op 0.94
mainnet_e58758 - phase0 processRewardsAndPenalties 157.88 ms/op 175.13 ms/op 0.90
mainnet_e58758 - phase0 processRegistryUpdates 29.124 us/op 33.529 us/op 0.87
mainnet_e58758 - phase0 processSlashings 3.0240 us/op 3.2280 us/op 0.94
mainnet_e58758 - phase0 processEth1DataReset 3.5610 us/op 4.3490 us/op 0.82
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.4636 ms/op 2.1046 ms/op 1.17
mainnet_e58758 - phase0 processSlashingsReset 21.846 us/op 17.332 us/op 1.26
mainnet_e58758 - phase0 processRandaoMixesReset 23.570 us/op 23.281 us/op 1.01
mainnet_e58758 - phase0 processHistoricalRootsUpdate 4.5360 us/op 4.5610 us/op 0.99
mainnet_e58758 - phase0 processParticipationRecordUpdates 25.878 us/op 21.540 us/op 1.20
mainnet_e58758 - phase0 afterProcessEpoch 170.76 ms/op 177.34 ms/op 0.96
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.3298 ms/op 2.4781 ms/op 0.94
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.8443 ms/op 2.9279 ms/op 0.97
altair processInactivityUpdates - 250000 normalcase 49.897 ms/op 79.968 ms/op 0.62
altair processInactivityUpdates - 250000 worstcase 56.414 ms/op 55.086 ms/op 1.02
phase0 processRegistryUpdates - 250000 normalcase 31.089 us/op 27.207 us/op 1.14
phase0 processRegistryUpdates - 250000 badcase_full_deposits 516.31 us/op 511.04 us/op 1.01
phase0 processRegistryUpdates - 250000 worstcase 0.5 234.17 ms/op 319.14 ms/op 0.73
altair processRewardsAndPenalties - 250000 normalcase 128.48 ms/op 175.28 ms/op 0.73
altair processRewardsAndPenalties - 250000 worstcase 144.78 ms/op 182.12 ms/op 0.79
phase0 getAttestationDeltas - 250000 normalcase 14.165 ms/op 14.835 ms/op 0.95
phase0 getAttestationDeltas - 250000 worstcase 14.726 ms/op 14.783 ms/op 1.00
phase0 processSlashings - 250000 worstcase 6.6771 ms/op 7.6117 ms/op 0.88
altair processSyncCommitteeUpdates - 250000 331.78 ms/op 341.25 ms/op 0.97
BeaconState.hashTreeRoot - No change 597.00 ns/op 563.00 ns/op 1.06
BeaconState.hashTreeRoot - 1 full validator 86.243 us/op 79.688 us/op 1.08
BeaconState.hashTreeRoot - 32 full validator 841.96 us/op 1.0320 ms/op 0.82
BeaconState.hashTreeRoot - 512 full validator 8.0213 ms/op 10.554 ms/op 0.76
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 109.22 us/op 110.27 us/op 0.99
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.5892 ms/op 1.7954 ms/op 0.89
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 20.515 ms/op 20.074 ms/op 1.02
BeaconState.hashTreeRoot - 1 balances 76.031 us/op 84.051 us/op 0.90
BeaconState.hashTreeRoot - 32 balances 824.66 us/op 819.32 us/op 1.01
BeaconState.hashTreeRoot - 512 balances 7.0553 ms/op 7.3465 ms/op 0.96
BeaconState.hashTreeRoot - 250000 balances 108.64 ms/op 124.10 ms/op 0.88
aggregationBits - 2048 els - zipIndexesInBitList 30.740 us/op 33.852 us/op 0.91
regular array get 100000 times 54.283 us/op 59.185 us/op 0.92
wrappedArray get 100000 times 54.207 us/op 59.292 us/op 0.91
arrayWithProxy get 100000 times 33.432 ms/op 40.618 ms/op 0.82
ssz.Root.equals 547.00 ns/op 648.00 ns/op 0.84
byteArrayEquals 546.00 ns/op 510.00 ns/op 1.07
shuffle list - 16384 els 12.566 ms/op 12.206 ms/op 1.03
shuffle list - 250000 els 173.89 ms/op 178.53 ms/op 0.97
processSlot - 1 slots 17.750 us/op 16.677 us/op 1.06
processSlot - 32 slots 2.2626 ms/op 2.8218 ms/op 0.80
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 601.38 us/op 704.30 us/op 0.85
getCommitteeAssignments - req 1 vs - 250000 vc 5.1059 ms/op 5.3994 ms/op 0.95
getCommitteeAssignments - req 100 vs - 250000 vc 7.3835 ms/op 7.9159 ms/op 0.93
getCommitteeAssignments - req 1000 vs - 250000 vc 8.1954 ms/op 8.5652 ms/op 0.96
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 9.7800 ns/op 11.390 ns/op 0.86
state getBlockRootAtSlot - 250000 vs - 7PWei 1.1888 us/op 1.2239 us/op 0.97
computeProposers - vc 250000 18.850 ms/op 21.204 ms/op 0.89
computeEpochShuffling - vc 250000 178.61 ms/op 184.97 ms/op 0.97
getNextSyncCommittee - vc 250000 321.13 ms/op 333.39 ms/op 0.96

by benchmarkbot/action

@wemeetagain wemeetagain merged commit 43d76da into unstable Aug 18, 2022
@wemeetagain wemeetagain deleted the dapplion/validate-pubkeys-api branch August 18, 2022 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No explicit public key validation on Keymanager
2 participants