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

unregisterValidator when removing key from API #4438

Merged
merged 1 commit into from Aug 19, 2022

Conversation

dapplion
Copy link
Contributor

@dapplion dapplion commented Aug 18, 2022

Motivation

In case a public key is removed from the keystore using API, the key is not removed from the map doppelgangerStateByPubkey within the Doppelganger service. This behavior may result in a situation where the validator is killed unintentionally when a mis-
takenly added public key which is already in use by another validator is again removed from the keystore leading to a DoS situation of the validator as the surveillance of the public key within the Doppelganger service is still active.

Description

  • unregisterValidator when removing key from API
  • Remove unnecessary call in removeDutiesForKey(), API calls both validator.removeDutiesForKey() + validator.validatorStore.removeSigner()

Closes #4434

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

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 6011d71 Previous: 9ffdbfa Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.2626 ms/op 2.4179 ms/op 0.94
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 80.432 us/op 87.477 us/op 0.92
BLS verify - blst-native 1.8615 ms/op 2.6841 ms/op 0.69
BLS verifyMultipleSignatures 3 - blst-native 3.8052 ms/op 5.7157 ms/op 0.67
BLS verifyMultipleSignatures 8 - blst-native 8.1933 ms/op 11.658 ms/op 0.70
BLS verifyMultipleSignatures 32 - blst-native 29.696 ms/op 43.537 ms/op 0.68
BLS aggregatePubkeys 32 - blst-native 39.049 us/op 58.647 us/op 0.67
BLS aggregatePubkeys 128 - blst-native 152.57 us/op 228.15 us/op 0.67
getAttestationsForBlock 163.84 ms/op 198.66 ms/op 0.82
isKnown best case - 1 super set check 383.00 ns/op 509.00 ns/op 0.75
isKnown normal case - 2 super set checks 372.00 ns/op 485.00 ns/op 0.77
isKnown worse case - 16 super set checks 375.00 ns/op 493.00 ns/op 0.76
CheckpointStateCache - add get delete 8.4610 us/op 10.967 us/op 0.77
validate gossip signedAggregateAndProof - struct 3.7829 ms/op 6.3082 ms/op 0.60
validate gossip attestation - struct 1.7910 ms/op 3.0692 ms/op 0.58
altair verifyImport mainnet_s3766816:31 4.1967 s/op 5.8872 s/op 0.71
pickEth1Vote - no votes 2.0376 ms/op 2.4676 ms/op 0.83
pickEth1Vote - max votes 24.330 ms/op 25.442 ms/op 0.96
pickEth1Vote - Eth1Data hashTreeRoot value x2048 10.901 ms/op 18.061 ms/op 0.60
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 23.894 ms/op 24.884 ms/op 0.96
pickEth1Vote - Eth1Data fastSerialize value x2048 1.3545 ms/op 1.7626 ms/op 0.77
pickEth1Vote - Eth1Data fastSerialize tree x2048 13.365 ms/op 14.945 ms/op 0.89
bytes32 toHexString 966.00 ns/op 1.1770 us/op 0.82
bytes32 Buffer.toString(hex) 632.00 ns/op 829.00 ns/op 0.76
bytes32 Buffer.toString(hex) from Uint8Array 845.00 ns/op 1.1130 us/op 0.76
bytes32 Buffer.toString(hex) + 0x 643.00 ns/op 842.00 ns/op 0.76
Object access 1 prop 0.31900 ns/op 0.42000 ns/op 0.76
Map access 1 prop 0.26100 ns/op 0.34700 ns/op 0.75
Object get x1000 16.018 ns/op 16.300 ns/op 0.98
Map get x1000 0.86900 ns/op 0.96100 ns/op 0.90
Object set x1000 105.54 ns/op 110.68 ns/op 0.95
Map set x1000 63.341 ns/op 79.549 ns/op 0.80
Return object 10000 times 0.33470 ns/op 0.41770 ns/op 0.80
Throw Error 10000 times 5.2068 us/op 7.0861 us/op 0.73
enrSubnets - fastDeserialize 64 bits 2.5370 us/op 3.0500 us/op 0.83
enrSubnets - ssz BitVector 64 bits 677.00 ns/op 851.00 ns/op 0.80
enrSubnets - fastDeserialize 4 bits 353.00 ns/op 414.00 ns/op 0.85
enrSubnets - ssz BitVector 4 bits 678.00 ns/op 805.00 ns/op 0.84
prioritizePeers score -10:0 att 32-0.1 sync 2-0 84.383 us/op 110.11 us/op 0.77
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 108.67 us/op 150.79 us/op 0.72
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 193.18 us/op 267.26 us/op 0.72
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 403.76 us/op 595.53 us/op 0.68
prioritizePeers score 0:0 att 64-1 sync 4-1 406.29 us/op 616.55 us/op 0.66
RateTracker 1000000 limit, 1 obj count per request 177.26 ns/op 215.60 ns/op 0.82
RateTracker 1000000 limit, 2 obj count per request 138.16 ns/op 156.72 ns/op 0.88
RateTracker 1000000 limit, 4 obj count per request 117.36 ns/op 124.74 ns/op 0.94
RateTracker 1000000 limit, 8 obj count per request 105.20 ns/op 116.21 ns/op 0.91
RateTracker with prune 3.8590 us/op 4.9340 us/op 0.78
array of 16000 items push then shift 2.7325 us/op 5.3437 us/op 0.51
LinkedList of 16000 items push then shift 15.324 ns/op 27.548 ns/op 0.56
array of 16000 items push then pop 210.78 ns/op 238.41 ns/op 0.88
LinkedList of 16000 items push then pop 14.812 ns/op 23.173 ns/op 0.64
array of 24000 items push then shift 4.0398 us/op 8.5070 us/op 0.47
LinkedList of 24000 items push then shift 18.846 ns/op 27.000 ns/op 0.70
array of 24000 items push then pop 203.28 ns/op 245.22 ns/op 0.83
LinkedList of 24000 items push then pop 16.255 ns/op 23.171 ns/op 0.70
intersect bitArray bitLen 8 10.386 ns/op 12.434 ns/op 0.84
intersect array and set length 8 152.20 ns/op 185.30 ns/op 0.82
intersect bitArray bitLen 128 54.727 ns/op 72.050 ns/op 0.76
intersect array and set length 128 2.0148 us/op 2.3241 us/op 0.87
Buffer.concat 32 items 1.6880 ns/op 2.2500 ns/op 0.75
pass gossip attestations to forkchoice per slot 3.1440 ms/op 3.5542 ms/op 0.88
computeDeltas 3.0879 ms/op 4.6458 ms/op 0.66
computeProposerBoostScoreFromBalances 812.87 us/op 911.51 us/op 0.89
altair processAttestation - 250000 vs - 7PWei normalcase 4.1180 ms/op 5.1772 ms/op 0.80
altair processAttestation - 250000 vs - 7PWei worstcase 5.7663 ms/op 7.2496 ms/op 0.80
altair processAttestation - setStatus - 1/6 committees join 189.77 us/op 250.75 us/op 0.76
altair processAttestation - setStatus - 1/3 committees join 358.15 us/op 464.37 us/op 0.77
altair processAttestation - setStatus - 1/2 committees join 499.93 us/op 689.55 us/op 0.73
altair processAttestation - setStatus - 2/3 committees join 644.63 us/op 862.84 us/op 0.75
altair processAttestation - setStatus - 4/5 committees join 901.88 us/op 1.2213 ms/op 0.74
altair processAttestation - setStatus - 100% committees join 1.0744 ms/op 1.5146 ms/op 0.71
altair processBlock - 250000 vs - 7PWei normalcase 26.309 ms/op 33.641 ms/op 0.78
altair processBlock - 250000 vs - 7PWei normalcase hashState 36.961 ms/op 56.209 ms/op 0.66
altair processBlock - 250000 vs - 7PWei worstcase 75.053 ms/op 115.03 ms/op 0.65
altair processBlock - 250000 vs - 7PWei worstcase hashState 88.837 ms/op 120.96 ms/op 0.73
phase0 processBlock - 250000 vs - 7PWei normalcase 3.7350 ms/op 3.9766 ms/op 0.94
phase0 processBlock - 250000 vs - 7PWei worstcase 42.511 ms/op 63.966 ms/op 0.66
altair processEth1Data - 250000 vs - 7PWei normalcase 779.85 us/op 1.4840 ms/op 0.53
Tree 40 250000 create 842.58 ms/op 1.0083 s/op 0.84
Tree 40 250000 get(125000) 277.69 ns/op 326.94 ns/op 0.85
Tree 40 250000 set(125000) 2.8761 us/op 3.0655 us/op 0.94
Tree 40 250000 toArray() 30.815 ms/op 38.649 ms/op 0.80
Tree 40 250000 iterate all - toArray() + loop 31.144 ms/op 39.040 ms/op 0.80
Tree 40 250000 iterate all - get(i) 104.55 ms/op 132.57 ms/op 0.79
MutableVector 250000 create 17.742 ms/op 25.682 ms/op 0.69
MutableVector 250000 get(125000) 11.545 ns/op 13.866 ns/op 0.83
MutableVector 250000 set(125000) 852.52 ns/op 769.61 ns/op 1.11
MutableVector 250000 toArray() 7.6267 ms/op 7.1351 ms/op 1.07
MutableVector 250000 iterate all - toArray() + loop 7.8283 ms/op 8.0038 ms/op 0.98
MutableVector 250000 iterate all - get(i) 3.0386 ms/op 3.5144 ms/op 0.86
Array 250000 create 7.1021 ms/op 6.5985 ms/op 1.08
Array 250000 clone - spread 4.3368 ms/op 2.9943 ms/op 1.45
Array 250000 get(125000) 1.6050 ns/op 1.2390 ns/op 1.30
Array 250000 set(125000) 1.6060 ns/op 1.4050 ns/op 1.14
Array 250000 iterate all - loop 150.16 us/op 146.11 us/op 1.03
effectiveBalanceIncrements clone Uint8Array 300000 105.20 us/op 95.038 us/op 1.11
effectiveBalanceIncrements clone MutableVector 300000 1.3180 us/op 935.00 ns/op 1.41
effectiveBalanceIncrements rw all Uint8Array 300000 222.85 us/op 300.31 us/op 0.74
effectiveBalanceIncrements rw all MutableVector 300000 226.41 ms/op 246.46 ms/op 0.92
phase0 afterProcessEpoch - 250000 vs - 7PWei 168.91 ms/op 207.62 ms/op 0.81
phase0 beforeProcessEpoch - 250000 vs - 7PWei 65.377 ms/op 157.41 ms/op 0.42
altair processEpoch - mainnet_e81889 529.98 ms/op 802.84 ms/op 0.66
mainnet_e81889 - altair beforeProcessEpoch 134.10 ms/op 239.93 ms/op 0.56
mainnet_e81889 - altair processJustificationAndFinalization 19.717 us/op 65.240 us/op 0.30
mainnet_e81889 - altair processInactivityUpdates 9.7171 ms/op 11.150 ms/op 0.87
mainnet_e81889 - altair processRewardsAndPenalties 86.005 ms/op 206.68 ms/op 0.42
mainnet_e81889 - altair processRegistryUpdates 4.0740 us/op 14.581 us/op 0.28
mainnet_e81889 - altair processSlashings 702.00 ns/op 4.1460 us/op 0.17
mainnet_e81889 - altair processEth1DataReset 894.00 ns/op 4.2110 us/op 0.21
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.1284 ms/op 3.0139 ms/op 0.71
mainnet_e81889 - altair processSlashingsReset 5.7540 us/op 28.577 us/op 0.20
mainnet_e81889 - altair processRandaoMixesReset 6.2410 us/op 25.112 us/op 0.25
mainnet_e81889 - altair processHistoricalRootsUpdate 983.00 ns/op 5.0750 us/op 0.19
mainnet_e81889 - altair processParticipationFlagUpdates 3.4510 us/op 16.758 us/op 0.21
mainnet_e81889 - altair processSyncCommitteeUpdates 686.00 ns/op 3.9390 us/op 0.17
mainnet_e81889 - altair afterProcessEpoch 195.20 ms/op 209.98 ms/op 0.93
phase0 processEpoch - mainnet_e58758 508.23 ms/op 811.71 ms/op 0.63
mainnet_e58758 - phase0 beforeProcessEpoch 231.28 ms/op 362.05 ms/op 0.64
mainnet_e58758 - phase0 processJustificationAndFinalization 20.396 us/op 61.554 us/op 0.33
mainnet_e58758 - phase0 processRewardsAndPenalties 141.61 ms/op 175.13 ms/op 0.81
mainnet_e58758 - phase0 processRegistryUpdates 11.150 us/op 33.529 us/op 0.33
mainnet_e58758 - phase0 processSlashings 762.00 ns/op 3.2280 us/op 0.24
mainnet_e58758 - phase0 processEth1DataReset 899.00 ns/op 4.3490 us/op 0.21
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.9193 ms/op 2.1046 ms/op 0.91
mainnet_e58758 - phase0 processSlashingsReset 4.9710 us/op 17.332 us/op 0.29
mainnet_e58758 - phase0 processRandaoMixesReset 5.7780 us/op 23.281 us/op 0.25
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.1110 us/op 4.5610 us/op 0.24
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.8770 us/op 21.540 us/op 0.23
mainnet_e58758 - phase0 afterProcessEpoch 143.66 ms/op 177.34 ms/op 0.81
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.2501 ms/op 2.4781 ms/op 0.91
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.6358 ms/op 2.9279 ms/op 0.90
altair processInactivityUpdates - 250000 normalcase 40.545 ms/op 79.968 ms/op 0.51
altair processInactivityUpdates - 250000 worstcase 47.928 ms/op 55.086 ms/op 0.87
phase0 processRegistryUpdates - 250000 normalcase 8.1460 us/op 27.207 us/op 0.30
phase0 processRegistryUpdates - 250000 badcase_full_deposits 371.19 us/op 511.04 us/op 0.73
phase0 processRegistryUpdates - 250000 worstcase 0.5 204.53 ms/op 319.14 ms/op 0.64
altair processRewardsAndPenalties - 250000 normalcase 113.55 ms/op 175.28 ms/op 0.65
altair processRewardsAndPenalties - 250000 worstcase 81.189 ms/op 182.12 ms/op 0.45
phase0 getAttestationDeltas - 250000 normalcase 13.753 ms/op 14.835 ms/op 0.93
phase0 getAttestationDeltas - 250000 worstcase 14.515 ms/op 14.783 ms/op 0.98
phase0 processSlashings - 250000 worstcase 4.8097 ms/op 7.6117 ms/op 0.63
altair processSyncCommitteeUpdates - 250000 258.96 ms/op 341.25 ms/op 0.76
BeaconState.hashTreeRoot - No change 440.00 ns/op 563.00 ns/op 0.78
BeaconState.hashTreeRoot - 1 full validator 57.731 us/op 79.688 us/op 0.72
BeaconState.hashTreeRoot - 32 full validator 639.89 us/op 1.0320 ms/op 0.62
BeaconState.hashTreeRoot - 512 full validator 5.7792 ms/op 10.554 ms/op 0.55
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 69.445 us/op 110.27 us/op 0.63
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.0558 ms/op 1.7954 ms/op 0.59
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 14.693 ms/op 20.074 ms/op 0.73
BeaconState.hashTreeRoot - 1 balances 53.856 us/op 84.051 us/op 0.64
BeaconState.hashTreeRoot - 32 balances 515.25 us/op 819.32 us/op 0.63
BeaconState.hashTreeRoot - 512 balances 5.3571 ms/op 7.3465 ms/op 0.73
BeaconState.hashTreeRoot - 250000 balances 90.687 ms/op 124.10 ms/op 0.73
aggregationBits - 2048 els - zipIndexesInBitList 33.373 us/op 33.852 us/op 0.99
regular array get 100000 times 59.495 us/op 59.185 us/op 1.01
wrappedArray get 100000 times 59.534 us/op 59.292 us/op 1.00
arrayWithProxy get 100000 times 25.577 ms/op 40.618 ms/op 0.63
ssz.Root.equals 470.00 ns/op 648.00 ns/op 0.73
byteArrayEquals 455.00 ns/op 510.00 ns/op 0.89
shuffle list - 16384 els 10.044 ms/op 12.206 ms/op 0.82
shuffle list - 250000 els 147.68 ms/op 178.53 ms/op 0.83
processSlot - 1 slots 12.163 us/op 16.677 us/op 0.73
processSlot - 32 slots 1.6271 ms/op 2.8218 ms/op 0.58
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 366.07 us/op 704.30 us/op 0.52
getCommitteeAssignments - req 1 vs - 250000 vc 4.7735 ms/op 5.3994 ms/op 0.88
getCommitteeAssignments - req 100 vs - 250000 vc 6.5821 ms/op 7.9159 ms/op 0.83
getCommitteeAssignments - req 1000 vs - 250000 vc 6.9637 ms/op 8.5652 ms/op 0.81
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 8.6300 ns/op 11.390 ns/op 0.76
state getBlockRootAtSlot - 250000 vs - 7PWei 1.2565 us/op 1.2239 us/op 1.03
computeProposers - vc 250000 15.420 ms/op 21.204 ms/op 0.73
computeEpochShuffling - vc 250000 152.32 ms/op 184.97 ms/op 0.82
getNextSyncCommittee - vc 250000 254.36 ms/op 333.39 ms/op 0.76

by benchmarkbot/action

@@ -206,7 +206,6 @@ export class Validator {
}

removeDutiesForKey(pubkey: PubkeyHex): void {
this.validatorStore.removeSigner(pubkey);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why removed here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it already happens in the keymanager api

@wemeetagain wemeetagain merged commit 92b7739 into unstable Aug 19, 2022
@wemeetagain wemeetagain deleted the dapplion/doppelganger-unregisterValidator branch August 19, 2022 15:11
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.

Implement unregistering a validator function when pubkey is removed from keystore
2 participants