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

feat: add disablePeerScoring flag #5478

Merged
merged 2 commits into from
May 13, 2023
Merged

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented May 11, 2023

Motivation

Add a feature flag to disable peer scoring for testing devnets

Description

  • Refactor score.ts to multiple files
  • Add IPeerScore interface, the current/default implementation is RealScore
  • Add disablePeerScoring flag, use MaxScore with this flag

Closes #5475

@github-actions
Copy link
Contributor

github-actions bot commented May 11, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 5cf0505 Previous: f16192f Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 989.20 us/op 582.80 us/op 1.70
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 43.375 us/op 47.418 us/op 0.91
BLS verify - blst-native 1.1642 ms/op 1.2367 ms/op 0.94
BLS verifyMultipleSignatures 3 - blst-native 2.3567 ms/op 2.5355 ms/op 0.93
BLS verifyMultipleSignatures 8 - blst-native 5.3558 ms/op 5.4240 ms/op 0.99
BLS verifyMultipleSignatures 32 - blst-native 19.684 ms/op 19.947 ms/op 0.99
BLS aggregatePubkeys 32 - blst-native 26.358 us/op 26.403 us/op 1.00
BLS aggregatePubkeys 128 - blst-native 100.90 us/op 102.59 us/op 0.98
getAttestationsForBlock 60.574 ms/op 57.316 ms/op 1.06
isKnown best case - 1 super set check 259.00 ns/op 258.00 ns/op 1.00
isKnown normal case - 2 super set checks 248.00 ns/op 256.00 ns/op 0.97
isKnown worse case - 16 super set checks 251.00 ns/op 256.00 ns/op 0.98
CheckpointStateCache - add get delete 4.8340 us/op 5.0360 us/op 0.96
validate gossip signedAggregateAndProof - struct 2.6882 ms/op 2.7976 ms/op 0.96
validate gossip attestation - struct 1.2921 ms/op 1.3351 ms/op 0.97
pickEth1Vote - no votes 1.1898 ms/op 1.3224 ms/op 0.90
pickEth1Vote - max votes 12.261 ms/op 10.312 ms/op 1.19
pickEth1Vote - Eth1Data hashTreeRoot value x2048 9.1762 ms/op 8.6933 ms/op 1.06
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 18.617 ms/op 15.630 ms/op 1.19
pickEth1Vote - Eth1Data fastSerialize value x2048 611.94 us/op 655.19 us/op 0.93
pickEth1Vote - Eth1Data fastSerialize tree x2048 8.2026 ms/op 4.7735 ms/op 1.72
bytes32 toHexString 468.00 ns/op 502.00 ns/op 0.93
bytes32 Buffer.toString(hex) 332.00 ns/op 387.00 ns/op 0.86
bytes32 Buffer.toString(hex) from Uint8Array 543.00 ns/op 608.00 ns/op 0.89
bytes32 Buffer.toString(hex) + 0x 332.00 ns/op 385.00 ns/op 0.86
Object access 1 prop 0.16400 ns/op 0.16800 ns/op 0.98
Map access 1 prop 0.16200 ns/op 0.15800 ns/op 1.03
Object get x1000 6.6950 ns/op 6.4530 ns/op 1.04
Map get x1000 0.52800 ns/op 0.63200 ns/op 0.84
Object set x1000 50.191 ns/op 54.563 ns/op 0.92
Map set x1000 42.841 ns/op 45.029 ns/op 0.95
Return object 10000 times 0.23480 ns/op 0.24070 ns/op 0.98
Throw Error 10000 times 4.1428 us/op 4.2722 us/op 0.97
fastMsgIdFn sha256 / 200 bytes 3.4250 us/op 3.5330 us/op 0.97
fastMsgIdFn h32 xxhash / 200 bytes 272.00 ns/op 307.00 ns/op 0.89
fastMsgIdFn h64 xxhash / 200 bytes 387.00 ns/op 453.00 ns/op 0.85
fastMsgIdFn sha256 / 1000 bytes 11.583 us/op 11.877 us/op 0.98
fastMsgIdFn h32 xxhash / 1000 bytes 400.00 ns/op 444.00 ns/op 0.90
fastMsgIdFn h64 xxhash / 1000 bytes 463.00 ns/op 497.00 ns/op 0.93
fastMsgIdFn sha256 / 10000 bytes 103.95 us/op 104.42 us/op 1.00
fastMsgIdFn h32 xxhash / 10000 bytes 1.8790 us/op 1.9650 us/op 0.96
fastMsgIdFn h64 xxhash / 10000 bytes 1.3270 us/op 1.4350 us/op 0.92
enrSubnets - fastDeserialize 64 bits 1.2340 us/op 1.5440 us/op 0.80
enrSubnets - ssz BitVector 64 bits 485.00 ns/op 573.00 ns/op 0.85
enrSubnets - fastDeserialize 4 bits 162.00 ns/op 193.00 ns/op 0.84
enrSubnets - ssz BitVector 4 bits 483.00 ns/op 568.00 ns/op 0.85
prioritizePeers score -10:0 att 32-0.1 sync 2-0 103.98 us/op 136.55 us/op 0.76
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 132.15 us/op 149.15 us/op 0.89
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 164.31 us/op 184.55 us/op 0.89
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 302.44 us/op 365.61 us/op 0.83
prioritizePeers score 0:0 att 64-1 sync 4-1 361.13 us/op 429.36 us/op 0.84
array of 16000 items push then shift 1.6245 us/op 1.6736 us/op 0.97
LinkedList of 16000 items push then shift 8.8180 ns/op 9.0760 ns/op 0.97
array of 16000 items push then pop 81.115 ns/op 105.07 ns/op 0.77
LinkedList of 16000 items push then pop 8.5840 ns/op 8.8730 ns/op 0.97
array of 24000 items push then shift 2.3760 us/op 2.4396 us/op 0.97
LinkedList of 24000 items push then shift 9.1690 ns/op 9.3760 ns/op 0.98
array of 24000 items push then pop 77.109 ns/op 84.169 ns/op 0.92
LinkedList of 24000 items push then pop 8.3310 ns/op 8.9610 ns/op 0.93
intersect bitArray bitLen 8 12.999 ns/op 13.626 ns/op 0.95
intersect array and set length 8 75.751 ns/op 80.898 ns/op 0.94
intersect bitArray bitLen 128 43.238 ns/op 44.903 ns/op 0.96
intersect array and set length 128 1.0165 us/op 1.0916 us/op 0.93
Buffer.concat 32 items 2.5650 us/op 2.7020 us/op 0.95
Uint8Array.set 32 items 2.2300 us/op 2.2210 us/op 1.00
pass gossip attestations to forkchoice per slot 3.0099 ms/op 3.0223 ms/op 1.00
computeDeltas 4.2523 ms/op 3.0590 ms/op 1.39
computeProposerBoostScoreFromBalances 1.7564 ms/op 1.8228 ms/op 0.96
altair processAttestation - 250000 vs - 7PWei normalcase 2.2144 ms/op 2.4860 ms/op 0.89
altair processAttestation - 250000 vs - 7PWei worstcase 4.0785 ms/op 3.7923 ms/op 1.08
altair processAttestation - setStatus - 1/6 committees join 135.36 us/op 152.44 us/op 0.89
altair processAttestation - setStatus - 1/3 committees join 267.12 us/op 296.15 us/op 0.90
altair processAttestation - setStatus - 1/2 committees join 373.66 us/op 384.53 us/op 0.97
altair processAttestation - setStatus - 2/3 committees join 461.97 us/op 482.61 us/op 0.96
altair processAttestation - setStatus - 4/5 committees join 657.64 us/op 685.63 us/op 0.96
altair processAttestation - setStatus - 100% committees join 744.11 us/op 795.06 us/op 0.94
altair processBlock - 250000 vs - 7PWei normalcase 22.460 ms/op 17.646 ms/op 1.27
altair processBlock - 250000 vs - 7PWei normalcase hashState 28.809 ms/op 25.944 ms/op 1.11
altair processBlock - 250000 vs - 7PWei worstcase 64.038 ms/op 53.275 ms/op 1.20
altair processBlock - 250000 vs - 7PWei worstcase hashState 86.295 ms/op 72.105 ms/op 1.20
phase0 processBlock - 250000 vs - 7PWei normalcase 2.0900 ms/op 2.1154 ms/op 0.99
phase0 processBlock - 250000 vs - 7PWei worstcase 33.791 ms/op 30.769 ms/op 1.10
altair processEth1Data - 250000 vs - 7PWei normalcase 460.88 us/op 472.38 us/op 0.98
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 10.925 us/op 8.7070 us/op 1.25
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 31.874 us/op 25.858 us/op 1.23
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 12.554 us/op 10.289 us/op 1.22
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 10.657 us/op 7.6790 us/op 1.39
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 122.66 us/op 102.32 us/op 1.20
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 1.2364 ms/op 668.99 us/op 1.85
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 879.97 us/op 907.82 us/op 0.97
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 1.6235 ms/op 898.99 us/op 1.81
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 2.1786 ms/op 2.4786 ms/op 0.88
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 2.5005 ms/op 1.5140 ms/op 1.65
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 3.8370 ms/op 4.2446 ms/op 0.90
Tree 40 250000 create 309.75 ms/op 321.17 ms/op 0.96
Tree 40 250000 get(125000) 174.38 ns/op 192.80 ns/op 0.90
Tree 40 250000 set(125000) 897.42 ns/op 995.58 ns/op 0.90
Tree 40 250000 toArray() 16.962 ms/op 22.402 ms/op 0.76
Tree 40 250000 iterate all - toArray() + loop 16.689 ms/op 21.971 ms/op 0.76
Tree 40 250000 iterate all - get(i) 64.296 ms/op 76.429 ms/op 0.84
MutableVector 250000 create 14.561 ms/op 10.751 ms/op 1.35
MutableVector 250000 get(125000) 6.2340 ns/op 6.5410 ns/op 0.95
MutableVector 250000 set(125000) 237.03 ns/op 292.25 ns/op 0.81
MutableVector 250000 toArray() 2.8440 ms/op 4.0216 ms/op 0.71
MutableVector 250000 iterate all - toArray() + loop 2.8664 ms/op 3.8995 ms/op 0.74
MutableVector 250000 iterate all - get(i) 1.4854 ms/op 1.5679 ms/op 0.95
Array 250000 create 2.6252 ms/op 3.1348 ms/op 0.84
Array 250000 clone - spread 1.1867 ms/op 1.2059 ms/op 0.98
Array 250000 get(125000) 0.56300 ns/op 0.59000 ns/op 0.95
Array 250000 set(125000) 0.64800 ns/op 0.66400 ns/op 0.98
Array 250000 iterate all - loop 82.276 us/op 84.890 us/op 0.97
effectiveBalanceIncrements clone Uint8Array 300000 24.534 us/op 35.256 us/op 0.70
effectiveBalanceIncrements clone MutableVector 300000 375.00 ns/op 359.00 ns/op 1.04
effectiveBalanceIncrements rw all Uint8Array 300000 168.26 us/op 167.84 us/op 1.00
effectiveBalanceIncrements rw all MutableVector 300000 80.724 ms/op 84.030 ms/op 0.96
phase0 afterProcessEpoch - 250000 vs - 7PWei 115.53 ms/op 119.18 ms/op 0.97
phase0 beforeProcessEpoch - 250000 vs - 7PWei 32.876 ms/op 46.193 ms/op 0.71
altair processEpoch - mainnet_e81889 361.94 ms/op 342.49 ms/op 1.06
mainnet_e81889 - altair beforeProcessEpoch 65.321 ms/op 66.937 ms/op 0.98
mainnet_e81889 - altair processJustificationAndFinalization 28.144 us/op 19.285 us/op 1.46
mainnet_e81889 - altair processInactivityUpdates 6.0168 ms/op 6.3116 ms/op 0.95
mainnet_e81889 - altair processRewardsAndPenalties 73.836 ms/op 66.321 ms/op 1.11
mainnet_e81889 - altair processRegistryUpdates 4.5280 us/op 2.4290 us/op 1.86
mainnet_e81889 - altair processSlashings 853.00 ns/op 510.00 ns/op 1.67
mainnet_e81889 - altair processEth1DataReset 833.00 ns/op 555.00 ns/op 1.50
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.2802 ms/op 1.2658 ms/op 1.80
mainnet_e81889 - altair processSlashingsReset 7.7490 us/op 4.1660 us/op 1.86
mainnet_e81889 - altair processRandaoMixesReset 7.3660 us/op 9.3450 us/op 0.79
mainnet_e81889 - altair processHistoricalRootsUpdate 907.00 ns/op 776.00 ns/op 1.17
mainnet_e81889 - altair processParticipationFlagUpdates 3.7700 us/op 2.7170 us/op 1.39
mainnet_e81889 - altair processSyncCommitteeUpdates 929.00 ns/op 538.00 ns/op 1.73
mainnet_e81889 - altair afterProcessEpoch 117.84 ms/op 140.81 ms/op 0.84
phase0 processEpoch - mainnet_e58758 361.80 ms/op 407.04 ms/op 0.89
mainnet_e58758 - phase0 beforeProcessEpoch 132.73 ms/op 161.28 ms/op 0.82
mainnet_e58758 - phase0 processJustificationAndFinalization 26.447 us/op 27.081 us/op 0.98
mainnet_e58758 - phase0 processRewardsAndPenalties 76.276 ms/op 68.396 ms/op 1.12
mainnet_e58758 - phase0 processRegistryUpdates 11.952 us/op 8.8610 us/op 1.35
mainnet_e58758 - phase0 processSlashings 809.00 ns/op 555.00 ns/op 1.46
mainnet_e58758 - phase0 processEth1DataReset 772.00 ns/op 634.00 ns/op 1.22
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.8709 ms/op 1.0737 ms/op 1.74
mainnet_e58758 - phase0 processSlashingsReset 4.9630 us/op 5.6450 us/op 0.88
mainnet_e58758 - phase0 processRandaoMixesReset 7.7740 us/op 5.6100 us/op 1.39
mainnet_e58758 - phase0 processHistoricalRootsUpdate 946.00 ns/op 665.00 ns/op 1.42
mainnet_e58758 - phase0 processParticipationRecordUpdates 6.5060 us/op 4.3340 us/op 1.50
mainnet_e58758 - phase0 afterProcessEpoch 96.802 ms/op 103.90 ms/op 0.93
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.1839 ms/op 1.2790 ms/op 0.93
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.4415 ms/op 1.7130 ms/op 0.84
altair processInactivityUpdates - 250000 normalcase 27.837 ms/op 23.314 ms/op 1.19
altair processInactivityUpdates - 250000 worstcase 29.604 ms/op 32.914 ms/op 0.90
phase0 processRegistryUpdates - 250000 normalcase 6.5800 us/op 11.136 us/op 0.59
phase0 processRegistryUpdates - 250000 badcase_full_deposits 465.63 us/op 296.42 us/op 1.57
phase0 processRegistryUpdates - 250000 worstcase 0.5 139.32 ms/op 144.32 ms/op 0.97
altair processRewardsAndPenalties - 250000 normalcase 73.309 ms/op 69.283 ms/op 1.06
altair processRewardsAndPenalties - 250000 worstcase 79.547 ms/op 80.707 ms/op 0.99
phase0 getAttestationDeltas - 250000 normalcase 6.4536 ms/op 8.9571 ms/op 0.72
phase0 getAttestationDeltas - 250000 worstcase 6.4431 ms/op 9.0213 ms/op 0.71
phase0 processSlashings - 250000 worstcase 3.5444 ms/op 3.9344 ms/op 0.90
altair processSyncCommitteeUpdates - 250000 177.34 ms/op 201.07 ms/op 0.88
BeaconState.hashTreeRoot - No change 275.00 ns/op 419.00 ns/op 0.66
BeaconState.hashTreeRoot - 1 full validator 60.524 us/op 53.308 us/op 1.14
BeaconState.hashTreeRoot - 32 full validator 664.57 us/op 568.69 us/op 1.17
BeaconState.hashTreeRoot - 512 full validator 7.2951 ms/op 5.7692 ms/op 1.26
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 70.741 us/op 65.842 us/op 1.07
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 890.32 us/op 1.0458 ms/op 0.85
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 11.476 ms/op 12.841 ms/op 0.89
BeaconState.hashTreeRoot - 1 balances 55.439 us/op 50.865 us/op 1.09
BeaconState.hashTreeRoot - 32 balances 555.19 us/op 486.69 us/op 1.14
BeaconState.hashTreeRoot - 512 balances 4.6861 ms/op 4.9453 ms/op 0.95
BeaconState.hashTreeRoot - 250000 balances 82.463 ms/op 73.738 ms/op 1.12
aggregationBits - 2048 els - zipIndexesInBitList 16.305 us/op 22.443 us/op 0.73
regular array get 100000 times 33.366 us/op 35.159 us/op 0.95
wrappedArray get 100000 times 33.450 us/op 35.876 us/op 0.93
arrayWithProxy get 100000 times 16.348 ms/op 18.571 ms/op 0.88
ssz.Root.equals 578.00 ns/op 642.00 ns/op 0.90
byteArrayEquals 571.00 ns/op 661.00 ns/op 0.86
shuffle list - 16384 els 6.6885 ms/op 7.5527 ms/op 0.89
shuffle list - 250000 els 98.799 ms/op 111.20 ms/op 0.89
processSlot - 1 slots 8.3380 us/op 10.953 us/op 0.76
processSlot - 32 slots 1.4126 ms/op 1.6528 ms/op 0.85
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 37.807 ms/op 44.160 ms/op 0.86
getCommitteeAssignments - req 1 vs - 250000 vc 2.9925 ms/op 3.2454 ms/op 0.92
getCommitteeAssignments - req 100 vs - 250000 vc 4.2541 ms/op 4.7237 ms/op 0.90
getCommitteeAssignments - req 1000 vs - 250000 vc 4.5971 ms/op 4.8346 ms/op 0.95
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.5100 ns/op 5.6300 ns/op 0.80
state getBlockRootAtSlot - 250000 vs - 7PWei 587.71 ns/op 823.22 ns/op 0.71
computeProposers - vc 250000 10.641 ms/op 12.106 ms/op 0.88
computeEpochShuffling - vc 250000 105.79 ms/op 118.47 ms/op 0.89
getNextSyncCommittee - vc 250000 179.66 ms/op 208.58 ms/op 0.86
computeSigningRoot for AttestationData 13.949 us/op 16.699 us/op 0.84
hash AttestationData serialized data then Buffer.toString(base64) 2.4729 us/op 2.6583 us/op 0.93
toHexString serialized data 1.0960 us/op 1.6126 us/op 0.68
Buffer.toString(base64) 324.74 ns/op 375.19 ns/op 0.87

by benchmarkbot/action

@twoeths
Copy link
Contributor Author

twoeths commented May 11, 2023

blocked by #5479

g11tech
g11tech previously approved these changes May 11, 2023
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.

looks good and useful 👍

@twoeths twoeths force-pushed the tuyen/disable_peer_scoring branch from 440b00d to c6b3a78 Compare May 11, 2023 09:14
@twoeths twoeths marked this pull request as ready for review May 12, 2023 03:15
@twoeths twoeths requested a review from a team as a code owner May 12, 2023 03:15
@twoeths twoeths force-pushed the tuyen/disable_peer_scoring branch from 26b660f to 3b02edd Compare May 12, 2023 03:24
Copy link
Member

@nflaig nflaig left a comment

Choose a reason for hiding this comment

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

lgtm

@twoeths twoeths merged commit 4e17cac into unstable May 13, 2023
@twoeths twoeths deleted the tuyen/disable_peer_scoring branch May 13, 2023 03:14
@wemeetagain
Copy link
Member

🎉 This PR is included in v1.9.0 🎉

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 --disable-peer-scoring flag for local testing
5 participants