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

Implement forkchoice equivocating validators #4586

Merged
merged 3 commits into from Sep 27, 2022

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Sep 22, 2022

Motivation

We want to disregard equivocating validators, see ethereum/consensus-specs#2845

Description

  • Handle onAttesterSlashing in forkchoice
  • Call it when importing a block or gossip
  • Make sure spec tests passed

Closes #4303

TODO

  • Right now upon restart, we fetch all slashed validators as equivocating indices, need to clarify that => we don't have any attestations initially and node has to resync so equivocating_indices should be built up through syncing
  • Do we need onProposerSlashing() handler in forkchoice? => no need since that validator could be active for a while and its attestation is still valid, after that when it's not active it's not part of the committee

@twoeths twoeths changed the title Tuyen/forkchoice equivocating validators Implement forkchoice equivocating validators Sep 22, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 22, 2022

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 065fde3 Previous: fd8e335 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.9612 ms/op 2.1053 ms/op 0.93
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 64.307 us/op 71.008 us/op 0.91
BLS verify - blst-native 2.1694 ms/op 1.9182 ms/op 1.13
BLS verifyMultipleSignatures 3 - blst-native 4.4707 ms/op 4.0199 ms/op 1.11
BLS verifyMultipleSignatures 8 - blst-native 9.6676 ms/op 8.6175 ms/op 1.12
BLS verifyMultipleSignatures 32 - blst-native 35.146 ms/op 29.900 ms/op 1.18
BLS aggregatePubkeys 32 - blst-native 46.498 us/op 38.948 us/op 1.19
BLS aggregatePubkeys 128 - blst-native 181.97 us/op 159.21 us/op 1.14
getAttestationsForBlock 77.758 ms/op 94.012 ms/op 0.83
isKnown best case - 1 super set check 478.00 ns/op 437.00 ns/op 1.09
isKnown normal case - 2 super set checks 468.00 ns/op 412.00 ns/op 1.14
isKnown worse case - 16 super set checks 463.00 ns/op 416.00 ns/op 1.11
CheckpointStateCache - add get delete 8.9870 us/op 9.4750 us/op 0.95
validate gossip signedAggregateAndProof - struct 5.0144 ms/op 4.3962 ms/op 1.14
validate gossip attestation - struct 2.3668 ms/op 2.1398 ms/op 1.11
pickEth1Vote - no votes 2.1756 ms/op 2.2435 ms/op 0.97
pickEth1Vote - max votes 19.106 ms/op 18.706 ms/op 1.02
pickEth1Vote - Eth1Data hashTreeRoot value x2048 12.995 ms/op 11.886 ms/op 1.09
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 20.185 ms/op 19.559 ms/op 1.03
pickEth1Vote - Eth1Data fastSerialize value x2048 1.5299 ms/op 1.4902 ms/op 1.03
pickEth1Vote - Eth1Data fastSerialize tree x2048 12.752 ms/op 13.780 ms/op 0.93
bytes32 toHexString 935.00 ns/op 1.0510 us/op 0.89
bytes32 Buffer.toString(hex) 772.00 ns/op 706.00 ns/op 1.09
bytes32 Buffer.toString(hex) from Uint8Array 1.0390 us/op 936.00 ns/op 1.11
bytes32 Buffer.toString(hex) + 0x 774.00 ns/op 636.00 ns/op 1.22
Object access 1 prop 0.33300 ns/op 0.32800 ns/op 1.02
Map access 1 prop 0.30600 ns/op 0.30000 ns/op 1.02
Object get x1000 10.638 ns/op 15.918 ns/op 0.67
Map get x1000 1.0830 ns/op 0.87000 ns/op 1.24
Object set x1000 72.254 ns/op 99.581 ns/op 0.73
Map set x1000 46.786 ns/op 66.585 ns/op 0.70
Return object 10000 times 0.43350 ns/op 0.36750 ns/op 1.18
Throw Error 10000 times 5.8891 us/op 6.8930 us/op 0.85
enrSubnets - fastDeserialize 64 bits 2.6870 us/op 2.5590 us/op 1.05
enrSubnets - ssz BitVector 64 bits 814.00 ns/op 693.00 ns/op 1.17
enrSubnets - fastDeserialize 4 bits 370.00 ns/op 352.00 ns/op 1.05
enrSubnets - ssz BitVector 4 bits 824.00 ns/op 653.00 ns/op 1.26
prioritizePeers score -10:0 att 32-0.1 sync 2-0 81.761 us/op 95.063 us/op 0.86
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 125.21 us/op 141.10 us/op 0.89
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 213.78 us/op 238.09 us/op 0.90
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 339.17 us/op 469.67 us/op 0.72
prioritizePeers score 0:0 att 64-1 sync 4-1 406.90 us/op 475.82 us/op 0.86
RateTracker 1000000 limit, 1 obj count per request 181.45 ns/op 164.49 ns/op 1.10
RateTracker 1000000 limit, 2 obj count per request 130.53 ns/op 123.46 ns/op 1.06
RateTracker 1000000 limit, 4 obj count per request 104.73 ns/op 104.68 ns/op 1.00
RateTracker 1000000 limit, 8 obj count per request 93.187 ns/op 92.408 ns/op 1.01
RateTracker with prune 3.8530 us/op 4.2700 us/op 0.90
array of 16000 items push then shift 51.575 us/op 4.5058 us/op 11.45
LinkedList of 16000 items push then shift 12.280 ns/op 16.882 ns/op 0.73
array of 16000 items push then pop 204.27 ns/op 212.73 ns/op 0.96
LinkedList of 16000 items push then pop 11.991 ns/op 16.201 ns/op 0.74
array of 24000 items push then shift 77.654 us/op 6.7287 us/op 11.54
LinkedList of 24000 items push then shift 12.922 ns/op 17.366 ns/op 0.74
array of 24000 items push then pop 197.44 ns/op 228.20 ns/op 0.87
LinkedList of 24000 items push then pop 12.064 ns/op 16.313 ns/op 0.74
intersect bitArray bitLen 8 10.840 ns/op 10.632 ns/op 1.02
intersect array and set length 8 140.81 ns/op 162.46 ns/op 0.87
intersect bitArray bitLen 128 55.560 ns/op 60.167 ns/op 0.92
intersect array and set length 128 1.7938 us/op 2.0027 us/op 0.90
Buffer.concat 32 items 1.8710 ns/op 2.0070 ns/op 0.93
pass gossip attestations to forkchoice per slot 5.1593 ms/op 3.4069 ms/op 1.51
computeDeltas 5.0434 ms/op 3.7056 ms/op 1.36
computeProposerBoostScoreFromBalances 803.87 us/op 755.33 us/op 1.06
altair processAttestation - 250000 vs - 7PWei normalcase 3.3687 ms/op 4.5200 ms/op 0.75
altair processAttestation - 250000 vs - 7PWei worstcase 5.2152 ms/op 6.1768 ms/op 0.84
altair processAttestation - setStatus - 1/6 committees join 177.98 us/op 254.59 us/op 0.70
altair processAttestation - setStatus - 1/3 committees join 352.29 us/op 447.04 us/op 0.79
altair processAttestation - setStatus - 1/2 committees join 505.57 us/op 596.71 us/op 0.85
altair processAttestation - setStatus - 2/3 committees join 659.01 us/op 864.70 us/op 0.76
altair processAttestation - setStatus - 4/5 committees join 919.90 us/op 1.0846 ms/op 0.85
altair processAttestation - setStatus - 100% committees join 1.1267 ms/op 1.2786 ms/op 0.88
altair processBlock - 250000 vs - 7PWei normalcase 24.805 ms/op 27.676 ms/op 0.90
altair processBlock - 250000 vs - 7PWei normalcase hashState 38.480 ms/op 42.615 ms/op 0.90
altair processBlock - 250000 vs - 7PWei worstcase 74.611 ms/op 77.641 ms/op 0.96
altair processBlock - 250000 vs - 7PWei worstcase hashState 101.38 ms/op 110.67 ms/op 0.92
phase0 processBlock - 250000 vs - 7PWei normalcase 3.2938 ms/op 3.8516 ms/op 0.86
phase0 processBlock - 250000 vs - 7PWei worstcase 51.723 ms/op 48.038 ms/op 1.08
altair processEth1Data - 250000 vs - 7PWei normalcase 708.24 us/op 937.05 us/op 0.76
Tree 40 250000 create 668.21 ms/op 727.71 ms/op 0.92
Tree 40 250000 get(125000) 236.12 ns/op 271.73 ns/op 0.87
Tree 40 250000 set(125000) 2.1414 us/op 2.3897 us/op 0.90
Tree 40 250000 toArray() 28.206 ms/op 33.452 ms/op 0.84
Tree 40 250000 iterate all - toArray() + loop 27.310 ms/op 33.854 ms/op 0.81
Tree 40 250000 iterate all - get(i) 109.41 ms/op 115.97 ms/op 0.94
MutableVector 250000 create 13.075 ms/op 17.070 ms/op 0.77
MutableVector 250000 get(125000) 10.939 ns/op 12.387 ns/op 0.88
MutableVector 250000 set(125000) 560.87 ns/op 743.94 ns/op 0.75
MutableVector 250000 toArray() 6.0950 ms/op 6.8728 ms/op 0.89
MutableVector 250000 iterate all - toArray() + loop 6.4918 ms/op 6.6127 ms/op 0.98
MutableVector 250000 iterate all - get(i) 3.4785 ms/op 3.6767 ms/op 0.95
Array 250000 create 5.8919 ms/op 6.5225 ms/op 0.90
Array 250000 clone - spread 3.5081 ms/op 4.1642 ms/op 0.84
Array 250000 get(125000) 1.5870 ns/op 1.5630 ns/op 1.02
Array 250000 set(125000) 1.5550 ns/op 1.6130 ns/op 0.96
Array 250000 iterate all - loop 158.60 us/op 123.30 us/op 1.29
effectiveBalanceIncrements clone Uint8Array 300000 49.064 us/op 200.59 us/op 0.24
effectiveBalanceIncrements clone MutableVector 300000 553.00 ns/op 691.00 ns/op 0.80
effectiveBalanceIncrements rw all Uint8Array 300000 247.20 us/op 242.56 us/op 1.02
effectiveBalanceIncrements rw all MutableVector 300000 131.27 ms/op 177.85 ms/op 0.74
phase0 afterProcessEpoch - 250000 vs - 7PWei 198.45 ms/op 165.11 ms/op 1.20
phase0 beforeProcessEpoch - 250000 vs - 7PWei 58.695 ms/op 69.601 ms/op 0.84
altair processEpoch - mainnet_e81889 551.26 ms/op 557.61 ms/op 0.99
mainnet_e81889 - altair beforeProcessEpoch 110.83 ms/op 152.55 ms/op 0.73
mainnet_e81889 - altair processJustificationAndFinalization 17.670 us/op 64.080 us/op 0.28
mainnet_e81889 - altair processInactivityUpdates 8.9135 ms/op 9.8942 ms/op 0.90
mainnet_e81889 - altair processRewardsAndPenalties 79.810 ms/op 95.865 ms/op 0.83
mainnet_e81889 - altair processRegistryUpdates 2.7260 us/op 14.358 us/op 0.19
mainnet_e81889 - altair processSlashings 678.00 ns/op 3.8690 us/op 0.18
mainnet_e81889 - altair processEth1DataReset 673.00 ns/op 4.3300 us/op 0.16
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.9199 ms/op 2.1014 ms/op 0.91
mainnet_e81889 - altair processSlashingsReset 4.4620 us/op 26.327 us/op 0.17
mainnet_e81889 - altair processRandaoMixesReset 5.1170 us/op 26.834 us/op 0.19
mainnet_e81889 - altair processHistoricalRootsUpdate 847.00 ns/op 4.2210 us/op 0.20
mainnet_e81889 - altair processParticipationFlagUpdates 2.4750 us/op 15.046 us/op 0.16
mainnet_e81889 - altair processSyncCommitteeUpdates 604.00 ns/op 3.5700 us/op 0.17
mainnet_e81889 - altair afterProcessEpoch 199.70 ms/op 176.14 ms/op 1.13
phase0 processEpoch - mainnet_e58758 484.76 ms/op 520.30 ms/op 0.93
mainnet_e58758 - phase0 beforeProcessEpoch 178.77 ms/op 232.77 ms/op 0.77
mainnet_e58758 - phase0 processJustificationAndFinalization 18.146 us/op 61.176 us/op 0.30
mainnet_e58758 - phase0 processRewardsAndPenalties 102.63 ms/op 142.88 ms/op 0.72
mainnet_e58758 - phase0 processRegistryUpdates 7.8050 us/op 32.989 us/op 0.24
mainnet_e58758 - phase0 processSlashings 664.00 ns/op 3.1600 us/op 0.21
mainnet_e58758 - phase0 processEth1DataReset 715.00 ns/op 3.6220 us/op 0.20
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.8121 ms/op 1.9563 ms/op 0.93
mainnet_e58758 - phase0 processSlashingsReset 4.2990 us/op 13.425 us/op 0.32
mainnet_e58758 - phase0 processRandaoMixesReset 4.1880 us/op 25.836 us/op 0.16
mainnet_e58758 - phase0 processHistoricalRootsUpdate 714.00 ns/op 4.1650 us/op 0.17
mainnet_e58758 - phase0 processParticipationRecordUpdates 3.4610 us/op 23.535 us/op 0.15
mainnet_e58758 - phase0 afterProcessEpoch 163.91 ms/op 149.72 ms/op 1.09
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.9713 ms/op 2.0507 ms/op 0.96
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.2136 ms/op 2.6758 ms/op 0.83
altair processInactivityUpdates - 250000 normalcase 41.709 ms/op 45.441 ms/op 0.92
altair processInactivityUpdates - 250000 worstcase 34.706 ms/op 56.453 ms/op 0.61
phase0 processRegistryUpdates - 250000 normalcase 6.7370 us/op 26.806 us/op 0.25
phase0 processRegistryUpdates - 250000 badcase_full_deposits 383.95 us/op 445.25 us/op 0.86
phase0 processRegistryUpdates - 250000 worstcase 0.5 176.63 ms/op 254.27 ms/op 0.69
altair processRewardsAndPenalties - 250000 normalcase 76.175 ms/op 135.74 ms/op 0.56
altair processRewardsAndPenalties - 250000 worstcase 107.18 ms/op 88.725 ms/op 1.21
phase0 getAttestationDeltas - 250000 normalcase 11.766 ms/op 12.589 ms/op 0.93
phase0 getAttestationDeltas - 250000 worstcase 11.568 ms/op 13.696 ms/op 0.84
phase0 processSlashings - 250000 worstcase 5.0286 ms/op 5.2926 ms/op 0.95
altair processSyncCommitteeUpdates - 250000 292.00 ms/op 292.97 ms/op 1.00
BeaconState.hashTreeRoot - No change 527.00 ns/op 531.00 ns/op 0.99
BeaconState.hashTreeRoot - 1 full validator 70.640 us/op 67.877 us/op 1.04
BeaconState.hashTreeRoot - 32 full validator 701.33 us/op 847.29 us/op 0.83
BeaconState.hashTreeRoot - 512 full validator 6.8597 ms/op 6.8674 ms/op 1.00
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 91.180 us/op 84.350 us/op 1.08
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.2842 ms/op 1.2740 ms/op 1.01
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 17.102 ms/op 16.080 ms/op 1.06
BeaconState.hashTreeRoot - 1 balances 67.407 us/op 70.387 us/op 0.96
BeaconState.hashTreeRoot - 32 balances 642.51 us/op 620.83 us/op 1.03
BeaconState.hashTreeRoot - 512 balances 7.0960 ms/op 5.8802 ms/op 1.21
BeaconState.hashTreeRoot - 250000 balances 100.29 ms/op 96.995 ms/op 1.03
aggregationBits - 2048 els - zipIndexesInBitList 26.345 us/op 29.152 us/op 0.90
regular array get 100000 times 60.565 us/op 48.500 us/op 1.25
wrappedArray get 100000 times 60.539 us/op 49.849 us/op 1.21
arrayWithProxy get 100000 times 28.213 ms/op 29.262 ms/op 0.96
ssz.Root.equals 468.00 ns/op 524.00 ns/op 0.89
byteArrayEquals 470.00 ns/op 519.00 ns/op 0.91
shuffle list - 16384 els 11.570 ms/op 11.679 ms/op 0.99
shuffle list - 250000 els 169.21 ms/op 144.16 ms/op 1.17
processSlot - 1 slots 13.225 us/op 12.931 us/op 1.02
processSlot - 32 slots 1.9959 ms/op 1.9784 ms/op 1.01
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 404.41 us/op 372.21 us/op 1.09
getCommitteeAssignments - req 1 vs - 250000 vc 5.3857 ms/op 4.6527 ms/op 1.16
getCommitteeAssignments - req 100 vs - 250000 vc 7.8919 ms/op 6.7033 ms/op 1.18
getCommitteeAssignments - req 1000 vs - 250000 vc 8.4716 ms/op 6.7332 ms/op 1.26
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 7.9800 ns/op 8.5100 ns/op 0.94
state getBlockRootAtSlot - 250000 vs - 7PWei 1.1056 us/op 1.2590 us/op 0.88
computeProposers - vc 250000 17.216 ms/op 16.538 ms/op 1.04
computeEpochShuffling - vc 250000 172.08 ms/op 146.49 ms/op 1.17
getNextSyncCommittee - vc 250000 288.54 ms/op 299.83 ms/op 0.96

by benchmarkbot/action

@twoeths twoeths force-pushed the tuyen/forkchoice-equivocating-validators branch from 58136ec to ab612d0 Compare September 22, 2022 05:53
@twoeths twoeths marked this pull request as ready for review September 22, 2022 06:13
@twoeths twoeths requested a review from a team as a code owner September 22, 2022 06:13
Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

LGTM!

@g11tech g11tech mentioned this pull request Sep 26, 2022
29 tasks
@twoeths twoeths merged commit 1beeb2b into unstable Sep 27, 2022
@twoeths twoeths deleted the tuyen/forkchoice-equivocating-validators branch September 27, 2022 01:57
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.

Remove equivocating validators from fork choice consideration
2 participants