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 distributed aggregation selections #5344

Merged
merged 11 commits into from
Apr 14, 2023

Conversation

nflaig
Copy link
Member

@nflaig nflaig commented Apr 5, 2023

Motivation

Implements ethereum/beacon-APIs#224 based on guide, closes #5334

Description

  • Add beacon and sync committee selection APIs
  • Implement distributed attestation aggregation selection
  • Implement distributed sync committee aggregation selection
  • Update unit tests to check additional steps

Additional context

@nflaig nflaig force-pushed the nflaig/dvt-aggregation-selections branch from 8899e32 to bbbf68b Compare April 5, 2023 12:08
@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 2d49291 Previous: c65e1a4 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 716.53 us/op 630.92 us/op 1.14
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 51.461 us/op 52.468 us/op 0.98
BLS verify - blst-native 1.2594 ms/op 1.2685 ms/op 0.99
BLS verifyMultipleSignatures 3 - blst-native 2.5647 ms/op 2.5284 ms/op 1.01
BLS verifyMultipleSignatures 8 - blst-native 5.5303 ms/op 5.3596 ms/op 1.03
BLS verifyMultipleSignatures 32 - blst-native 20.313 ms/op 19.412 ms/op 1.05
BLS aggregatePubkeys 32 - blst-native 27.491 us/op 25.942 us/op 1.06
BLS aggregatePubkeys 128 - blst-native 109.64 us/op 102.04 us/op 1.07
getAttestationsForBlock 64.390 ms/op 55.706 ms/op 1.16
isKnown best case - 1 super set check 282.00 ns/op 259.00 ns/op 1.09
isKnown normal case - 2 super set checks 275.00 ns/op 256.00 ns/op 1.07
isKnown worse case - 16 super set checks 276.00 ns/op 254.00 ns/op 1.09
CheckpointStateCache - add get delete 6.0450 us/op 5.3850 us/op 1.12
validate gossip signedAggregateAndProof - struct 3.0143 ms/op 2.8081 ms/op 1.07
validate gossip attestation - struct 1.3694 ms/op 1.3226 ms/op 1.04
pickEth1Vote - no votes 1.3780 ms/op 1.2662 ms/op 1.09
pickEth1Vote - max votes 13.916 ms/op 8.7918 ms/op 1.58
pickEth1Vote - Eth1Data hashTreeRoot value x2048 10.059 ms/op 8.5054 ms/op 1.18
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 17.223 ms/op 13.595 ms/op 1.27
pickEth1Vote - Eth1Data fastSerialize value x2048 811.10 us/op 738.65 us/op 1.10
pickEth1Vote - Eth1Data fastSerialize tree x2048 9.0635 ms/op 4.7920 ms/op 1.89
bytes32 toHexString 732.00 ns/op 497.00 ns/op 1.47
bytes32 Buffer.toString(hex) 423.00 ns/op 347.00 ns/op 1.22
bytes32 Buffer.toString(hex) from Uint8Array 624.00 ns/op 543.00 ns/op 1.15
bytes32 Buffer.toString(hex) + 0x 422.00 ns/op 345.00 ns/op 1.22
Object access 1 prop 0.19000 ns/op 0.16100 ns/op 1.18
Map access 1 prop 0.16900 ns/op 0.15900 ns/op 1.06
Object get x1000 7.1100 ns/op 7.2240 ns/op 0.98
Map get x1000 0.58400 ns/op 0.61100 ns/op 0.96
Object set x1000 58.665 ns/op 51.995 ns/op 1.13
Map set x1000 47.871 ns/op 44.646 ns/op 1.07
Return object 10000 times 0.25500 ns/op 0.23430 ns/op 1.09
Throw Error 10000 times 4.4718 us/op 4.1858 us/op 1.07
fastMsgIdFn sha256 / 200 bytes 3.8180 us/op 3.3910 us/op 1.13
fastMsgIdFn h32 xxhash / 200 bytes 338.00 ns/op 273.00 ns/op 1.24
fastMsgIdFn h64 xxhash / 200 bytes 485.00 ns/op 381.00 ns/op 1.27
fastMsgIdFn sha256 / 1000 bytes 12.417 us/op 11.445 us/op 1.08
fastMsgIdFn h32 xxhash / 1000 bytes 477.00 ns/op 394.00 ns/op 1.21
fastMsgIdFn h64 xxhash / 1000 bytes 570.00 ns/op 527.00 ns/op 1.08
fastMsgIdFn sha256 / 10000 bytes 120.00 us/op 104.23 us/op 1.15
fastMsgIdFn h32 xxhash / 10000 bytes 2.3090 us/op 1.9710 us/op 1.17
fastMsgIdFn h64 xxhash / 10000 bytes 1.7080 us/op 1.4450 us/op 1.18
enrSubnets - fastDeserialize 64 bits 2.1620 us/op 1.4400 us/op 1.50
enrSubnets - ssz BitVector 64 bits 759.00 ns/op 568.00 ns/op 1.34
enrSubnets - fastDeserialize 4 bits 217.00 ns/op 196.00 ns/op 1.11
enrSubnets - ssz BitVector 4 bits 702.00 ns/op 586.00 ns/op 1.20
prioritizePeers score -10:0 att 32-0.1 sync 2-0 144.53 us/op 117.35 us/op 1.23
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 168.67 us/op 136.21 us/op 1.24
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 206.38 us/op 189.29 us/op 1.09
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 390.69 us/op 339.51 us/op 1.15
prioritizePeers score 0:0 att 64-1 sync 4-1 469.85 us/op 408.46 us/op 1.15
array of 16000 items push then shift 1.7901 us/op 1.6580 us/op 1.08
LinkedList of 16000 items push then shift 9.8690 ns/op 8.9410 ns/op 1.10
array of 16000 items push then pop 119.46 ns/op 126.78 ns/op 0.94
LinkedList of 16000 items push then pop 9.5610 ns/op 9.2550 ns/op 1.03
array of 24000 items push then shift 2.5167 us/op 2.3870 us/op 1.05
LinkedList of 24000 items push then shift 10.783 ns/op 9.8720 ns/op 1.09
array of 24000 items push then pop 91.247 ns/op 84.114 ns/op 1.08
LinkedList of 24000 items push then pop 9.9800 ns/op 9.4850 ns/op 1.05
intersect bitArray bitLen 8 14.675 ns/op 13.753 ns/op 1.07
intersect array and set length 8 120.03 ns/op 118.00 ns/op 1.02
intersect bitArray bitLen 128 48.199 ns/op 45.804 ns/op 1.05
intersect array and set length 128 1.4091 us/op 1.3223 us/op 1.07
Buffer.concat 32 items 3.3460 us/op 3.0360 us/op 1.10
Uint8Array.set 32 items 2.5050 us/op 2.6290 us/op 0.95
pass gossip attestations to forkchoice per slot 4.0365 ms/op 3.2363 ms/op 1.25
computeDeltas 3.5925 ms/op 2.9602 ms/op 1.21
computeProposerBoostScoreFromBalances 1.9790 ms/op 1.7993 ms/op 1.10
altair processAttestation - 250000 vs - 7PWei normalcase 3.6818 ms/op 2.9351 ms/op 1.25
altair processAttestation - 250000 vs - 7PWei worstcase 4.7669 ms/op 4.1191 ms/op 1.16
altair processAttestation - setStatus - 1/6 committees join 170.22 us/op 142.80 us/op 1.19
altair processAttestation - setStatus - 1/3 committees join 304.58 us/op 283.50 us/op 1.07
altair processAttestation - setStatus - 1/2 committees join 433.68 us/op 380.96 us/op 1.14
altair processAttestation - setStatus - 2/3 committees join 509.92 us/op 476.14 us/op 1.07
altair processAttestation - setStatus - 4/5 committees join 729.36 us/op 664.33 us/op 1.10
altair processAttestation - setStatus - 100% committees join 868.42 us/op 777.18 us/op 1.12
altair processBlock - 250000 vs - 7PWei normalcase 22.859 ms/op 17.686 ms/op 1.29
altair processBlock - 250000 vs - 7PWei normalcase hashState 28.699 ms/op 27.727 ms/op 1.04
altair processBlock - 250000 vs - 7PWei worstcase 61.991 ms/op 49.126 ms/op 1.26
altair processBlock - 250000 vs - 7PWei worstcase hashState 92.026 ms/op 69.982 ms/op 1.32
phase0 processBlock - 250000 vs - 7PWei normalcase 3.1367 ms/op 2.4305 ms/op 1.29
phase0 processBlock - 250000 vs - 7PWei worstcase 35.593 ms/op 30.444 ms/op 1.17
altair processEth1Data - 250000 vs - 7PWei normalcase 729.48 us/op 602.90 us/op 1.21
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 15.222 us/op 9.0440 us/op 1.68
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 39.055 us/op 30.320 us/op 1.29
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 18.412 us/op 12.358 us/op 1.49
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 15.645 us/op 8.8390 us/op 1.77
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 122.76 us/op 114.73 us/op 1.07
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 883.70 us/op 655.58 us/op 1.35
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 1.2468 ms/op 921.32 us/op 1.35
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 1.0541 ms/op 895.04 us/op 1.18
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 3.7614 ms/op 2.5156 ms/op 1.50
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 2.1860 ms/op 1.6565 ms/op 1.32
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 6.3039 ms/op 4.2007 ms/op 1.50
Tree 40 250000 create 669.91 ms/op 342.36 ms/op 1.96
Tree 40 250000 get(125000) 229.61 ns/op 189.18 ns/op 1.21
Tree 40 250000 set(125000) 2.3444 us/op 1.0120 us/op 2.32
Tree 40 250000 toArray() 27.048 ms/op 20.088 ms/op 1.35
Tree 40 250000 iterate all - toArray() + loop 26.847 ms/op 22.077 ms/op 1.22
Tree 40 250000 iterate all - get(i) 89.911 ms/op 75.302 ms/op 1.19
MutableVector 250000 create 15.086 ms/op 10.856 ms/op 1.39
MutableVector 250000 get(125000) 8.8770 ns/op 6.3810 ns/op 1.39
MutableVector 250000 set(125000) 548.06 ns/op 287.69 ns/op 1.90
MutableVector 250000 toArray() 4.7172 ms/op 3.1419 ms/op 1.50
MutableVector 250000 iterate all - toArray() + loop 4.2845 ms/op 3.1444 ms/op 1.36
MutableVector 250000 iterate all - get(i) 1.9149 ms/op 1.4785 ms/op 1.30
Array 250000 create 3.8876 ms/op 2.7895 ms/op 1.39
Array 250000 clone - spread 1.4078 ms/op 1.1009 ms/op 1.28
Array 250000 get(125000) 0.67800 ns/op 0.53600 ns/op 1.26
Array 250000 set(125000) 0.97600 ns/op 0.60800 ns/op 1.61
Array 250000 iterate all - loop 107.15 us/op 100.57 us/op 1.07
effectiveBalanceIncrements clone Uint8Array 300000 55.372 us/op 24.680 us/op 2.24
effectiveBalanceIncrements clone MutableVector 300000 461.00 ns/op 334.00 ns/op 1.38
effectiveBalanceIncrements rw all Uint8Array 300000 187.33 us/op 166.67 us/op 1.12
effectiveBalanceIncrements rw all MutableVector 300000 138.31 ms/op 77.584 ms/op 1.78
phase0 afterProcessEpoch - 250000 vs - 7PWei 128.52 ms/op 110.83 ms/op 1.16
phase0 beforeProcessEpoch - 250000 vs - 7PWei 50.631 ms/op 41.136 ms/op 1.23
altair processEpoch - mainnet_e81889 395.34 ms/op 293.69 ms/op 1.35
mainnet_e81889 - altair beforeProcessEpoch 84.016 ms/op 47.458 ms/op 1.77
mainnet_e81889 - altair processJustificationAndFinalization 32.676 us/op 16.683 us/op 1.96
mainnet_e81889 - altair processInactivityUpdates 7.7548 ms/op 4.9814 ms/op 1.56
mainnet_e81889 - altair processRewardsAndPenalties 80.728 ms/op 65.194 ms/op 1.24
mainnet_e81889 - altair processRegistryUpdates 6.4600 us/op 2.5140 us/op 2.57
mainnet_e81889 - altair processSlashings 1.6240 us/op 521.00 ns/op 3.12
mainnet_e81889 - altair processEth1DataReset 1.0970 us/op 537.00 ns/op 2.04
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.6064 ms/op 1.1943 ms/op 1.35
mainnet_e81889 - altair processSlashingsReset 10.292 us/op 5.0270 us/op 2.05
mainnet_e81889 - altair processRandaoMixesReset 11.032 us/op 4.5820 us/op 2.41
mainnet_e81889 - altair processHistoricalRootsUpdate 2.0840 us/op 583.00 ns/op 3.57
mainnet_e81889 - altair processParticipationFlagUpdates 8.8940 us/op 2.4210 us/op 3.67
mainnet_e81889 - altair processSyncCommitteeUpdates 1.3540 us/op 551.00 ns/op 2.46
mainnet_e81889 - altair afterProcessEpoch 145.07 ms/op 115.68 ms/op 1.25
phase0 processEpoch - mainnet_e58758 461.38 ms/op 313.01 ms/op 1.47
mainnet_e58758 - phase0 beforeProcessEpoch 176.16 ms/op 118.53 ms/op 1.49
mainnet_e58758 - phase0 processJustificationAndFinalization 27.234 us/op 15.852 us/op 1.72
mainnet_e58758 - phase0 processRewardsAndPenalties 68.809 ms/op 52.630 ms/op 1.31
mainnet_e58758 - phase0 processRegistryUpdates 9.5180 us/op 7.7120 us/op 1.23
mainnet_e58758 - phase0 processSlashings 566.00 ns/op 549.00 ns/op 1.03
mainnet_e58758 - phase0 processEth1DataReset 518.00 ns/op 558.00 ns/op 0.93
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.7592 ms/op 939.40 us/op 1.87
mainnet_e58758 - phase0 processSlashingsReset 3.9220 us/op 3.8250 us/op 1.03
mainnet_e58758 - phase0 processRandaoMixesReset 4.6450 us/op 5.2450 us/op 0.89
mainnet_e58758 - phase0 processHistoricalRootsUpdate 576.00 ns/op 901.00 ns/op 0.64
mainnet_e58758 - phase0 processParticipationRecordUpdates 6.4680 us/op 4.9400 us/op 1.31
mainnet_e58758 - phase0 afterProcessEpoch 95.968 ms/op 89.754 ms/op 1.07
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.1999 ms/op 1.2260 ms/op 0.98
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.1968 ms/op 1.5015 ms/op 1.46
altair processInactivityUpdates - 250000 normalcase 24.808 ms/op 25.274 ms/op 0.98
altair processInactivityUpdates - 250000 worstcase 24.254 ms/op 26.235 ms/op 0.92
phase0 processRegistryUpdates - 250000 normalcase 10.957 us/op 6.7210 us/op 1.63
phase0 processRegistryUpdates - 250000 badcase_full_deposits 475.12 us/op 218.41 us/op 2.18
phase0 processRegistryUpdates - 250000 worstcase 0.5 146.58 ms/op 119.48 ms/op 1.23
altair processRewardsAndPenalties - 250000 normalcase 71.825 ms/op 67.562 ms/op 1.06
altair processRewardsAndPenalties - 250000 worstcase 80.026 ms/op 68.256 ms/op 1.17
phase0 getAttestationDeltas - 250000 normalcase 6.5815 ms/op 6.6219 ms/op 0.99
phase0 getAttestationDeltas - 250000 worstcase 6.4967 ms/op 6.4585 ms/op 1.01
phase0 processSlashings - 250000 worstcase 3.5068 ms/op 3.2099 ms/op 1.09
altair processSyncCommitteeUpdates - 250000 183.28 ms/op 167.71 ms/op 1.09
BeaconState.hashTreeRoot - No change 270.00 ns/op 340.00 ns/op 0.79
BeaconState.hashTreeRoot - 1 full validator 54.198 us/op 50.581 us/op 1.07
BeaconState.hashTreeRoot - 32 full validator 571.54 us/op 475.45 us/op 1.20
BeaconState.hashTreeRoot - 512 full validator 5.5850 ms/op 5.1387 ms/op 1.09
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 69.769 us/op 60.647 us/op 1.15
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.0630 ms/op 866.25 us/op 1.23
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 12.457 ms/op 11.390 ms/op 1.09
BeaconState.hashTreeRoot - 1 balances 57.755 us/op 46.951 us/op 1.23
BeaconState.hashTreeRoot - 32 balances 436.10 us/op 464.62 us/op 0.94
BeaconState.hashTreeRoot - 512 balances 4.9827 ms/op 4.2921 ms/op 1.16
BeaconState.hashTreeRoot - 250000 balances 77.216 ms/op 72.892 ms/op 1.06
aggregationBits - 2048 els - zipIndexesInBitList 14.995 us/op 15.043 us/op 1.00
regular array get 100000 times 32.166 us/op 32.388 us/op 0.99
wrappedArray get 100000 times 32.027 us/op 32.392 us/op 0.99
arrayWithProxy get 100000 times 16.931 ms/op 15.974 ms/op 1.06
ssz.Root.equals 536.00 ns/op 538.00 ns/op 1.00
byteArrayEquals 529.00 ns/op 528.00 ns/op 1.00
shuffle list - 16384 els 6.7938 ms/op 6.4719 ms/op 1.05
shuffle list - 250000 els 99.451 ms/op 95.073 ms/op 1.05
processSlot - 1 slots 8.5870 us/op 7.9890 us/op 1.07
processSlot - 32 slots 1.4162 ms/op 1.3258 ms/op 1.07
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 40.936 ms/op 36.068 ms/op 1.13
getCommitteeAssignments - req 1 vs - 250000 vc 2.9570 ms/op 2.9392 ms/op 1.01
getCommitteeAssignments - req 100 vs - 250000 vc 4.1379 ms/op 4.0790 ms/op 1.01
getCommitteeAssignments - req 1000 vs - 250000 vc 4.5684 ms/op 4.4030 ms/op 1.04
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.4500 ns/op 4.5600 ns/op 0.98
state getBlockRootAtSlot - 250000 vs - 7PWei 940.46 ns/op 907.43 ns/op 1.04
computeProposers - vc 250000 10.814 ms/op 10.237 ms/op 1.06
computeEpochShuffling - vc 250000 113.56 ms/op 100.74 ms/op 1.13
getNextSyncCommittee - vc 250000 171.82 ms/op 166.86 ms/op 1.03
computeSigningRoot for AttestationData 13.371 us/op 12.998 us/op 1.03
hash AttestationData serialized data then Buffer.toString(base64) 2.5481 us/op 2.4009 us/op 1.06
toHexString serialized data 1.1283 us/op 1.0320 us/op 1.09
Buffer.toString(base64) 367.48 ns/op 300.47 ns/op 1.22

by benchmarkbot/action

@nflaig nflaig force-pushed the nflaig/dvt-aggregation-selections branch 6 times, most recently from f5be68e to 19342ae Compare April 5, 2023 22:07
@nflaig nflaig force-pushed the nflaig/dvt-aggregation-selections branch from 19342ae to c3977a8 Compare April 5, 2023 22:10
@nflaig nflaig force-pushed the nflaig/dvt-aggregation-selections branch from c3977a8 to 2ad316e Compare April 6, 2023 11:43
@nflaig nflaig marked this pull request as ready for review April 6, 2023 11:58
@nflaig nflaig requested a review from a team as a code owner April 6, 2023 11:58
@nflaig nflaig added this to the v1.8.0 milestone Apr 6, 2023
wemeetagain
wemeetagain previously approved these changes Apr 6, 2023
Copy link
Member

@wemeetagain wemeetagain left a comment

Choose a reason for hiding this comment

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

Logic looks good to me. Good job with the helpful comments and generally clean code.
Leaving open for another pair of eyes.

@nflaig
Copy link
Member Author

nflaig commented Apr 6, 2023

Thanks for the review @wemeetagain! Yeah please let it open, still want to add unit tests and wait for more results from Obol testing this on their cluster

matthewkeil
matthewkeil previously approved these changes Apr 6, 2023
Copy link
Member

@matthewkeil matthewkeil left a comment

Choose a reason for hiding this comment

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

The code looks awesome and the comments were even better. Approving for code structure and high-fiving for quality! Reading the spec and implementation notes to familiarize myself.

@nflaig nflaig dismissed stale reviews from matthewkeil and wemeetagain via d76bf7b April 7, 2023 16:17
@nflaig nflaig force-pushed the nflaig/dvt-aggregation-selections branch from e4925ec to 78155a7 Compare April 14, 2023 15:07
@nflaig
Copy link
Member Author

nflaig commented Apr 14, 2023

Obol has successfully tested Lodestar on their cluster 🚀

image

@nflaig nflaig requested a review from wemeetagain April 14, 2023 16:19
Copy link
Member

@wemeetagain wemeetagain left a comment

Choose a reason for hiding this comment

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

Read thru again. LGTM
Again great attention to detail.

@wemeetagain wemeetagain merged commit b5e8b8b into unstable Apr 14, 2023
@wemeetagain wemeetagain deleted the nflaig/dvt-aggregation-selections branch April 14, 2023 18:26
@wemeetagain
Copy link
Member

🎉 This PR is included in v1.8.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 Attestation and Sync Committee aggregation selection
3 participants