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

refactor(network): add gossip publisher module #5450

Merged
merged 2 commits into from
May 2, 2023

Conversation

wemeetagain
Copy link
Member

Motivation

Description

Move publish* functions to a "gossip publisher" module that exists separately from the gossipsub implementation. This separation will allow us to serialize gossip objects in the main thread and then send them to the gossipsub implementation in the network thread.

@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 0e4d80f Previous: da696c0 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 867.92 us/op 477.59 us/op 1.82
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 44.167 us/op 45.078 us/op 0.98
BLS verify - blst-native 1.1949 ms/op 1.2100 ms/op 0.99
BLS verifyMultipleSignatures 3 - blst-native 2.4246 ms/op 2.4567 ms/op 0.99
BLS verifyMultipleSignatures 8 - blst-native 5.0052 ms/op 5.3020 ms/op 0.94
BLS verifyMultipleSignatures 32 - blst-native 18.109 ms/op 19.164 ms/op 0.94
BLS aggregatePubkeys 32 - blst-native 24.315 us/op 25.404 us/op 0.96
BLS aggregatePubkeys 128 - blst-native 95.056 us/op 100.45 us/op 0.95
getAttestationsForBlock 51.100 ms/op 54.413 ms/op 0.94
isKnown best case - 1 super set check 263.00 ns/op 266.00 ns/op 0.99
isKnown normal case - 2 super set checks 252.00 ns/op 269.00 ns/op 0.94
isKnown worse case - 16 super set checks 253.00 ns/op 260.00 ns/op 0.97
CheckpointStateCache - add get delete 4.6110 us/op 5.1410 us/op 0.90
validate gossip signedAggregateAndProof - struct 2.5991 ms/op 2.7817 ms/op 0.93
validate gossip attestation - struct 1.2386 ms/op 1.3277 ms/op 0.93
pickEth1Vote - no votes 1.2528 ms/op 1.2806 ms/op 0.98
pickEth1Vote - max votes 10.424 ms/op 9.5909 ms/op 1.09
pickEth1Vote - Eth1Data hashTreeRoot value x2048 8.8299 ms/op 8.8569 ms/op 1.00
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 14.429 ms/op 14.806 ms/op 0.97
pickEth1Vote - Eth1Data fastSerialize value x2048 680.24 us/op 651.88 us/op 1.04
pickEth1Vote - Eth1Data fastSerialize tree x2048 7.8193 ms/op 5.0565 ms/op 1.55
bytes32 toHexString 482.00 ns/op 540.00 ns/op 0.89
bytes32 Buffer.toString(hex) 345.00 ns/op 371.00 ns/op 0.93
bytes32 Buffer.toString(hex) from Uint8Array 543.00 ns/op 582.00 ns/op 0.93
bytes32 Buffer.toString(hex) + 0x 345.00 ns/op 356.00 ns/op 0.97
Object access 1 prop 0.16000 ns/op 0.16800 ns/op 0.95
Map access 1 prop 0.15600 ns/op 0.16400 ns/op 0.95
Object get x1000 6.5480 ns/op 7.2800 ns/op 0.90
Map get x1000 0.59500 ns/op 0.64000 ns/op 0.93
Object set x1000 50.077 ns/op 53.242 ns/op 0.94
Map set x1000 40.973 ns/op 46.135 ns/op 0.89
Return object 10000 times 0.22430 ns/op 0.23620 ns/op 0.95
Throw Error 10000 times 3.9953 us/op 4.1793 us/op 0.96
fastMsgIdFn sha256 / 200 bytes 3.2860 us/op 3.4820 us/op 0.94
fastMsgIdFn h32 xxhash / 200 bytes 263.00 ns/op 293.00 ns/op 0.90
fastMsgIdFn h64 xxhash / 200 bytes 383.00 ns/op 447.00 ns/op 0.86
fastMsgIdFn sha256 / 1000 bytes 11.129 us/op 11.826 us/op 0.94
fastMsgIdFn h32 xxhash / 1000 bytes 386.00 ns/op 436.00 ns/op 0.89
fastMsgIdFn h64 xxhash / 1000 bytes 451.00 ns/op 516.00 ns/op 0.87
fastMsgIdFn sha256 / 10000 bytes 99.003 us/op 103.83 us/op 0.95
fastMsgIdFn h32 xxhash / 10000 bytes 1.8140 us/op 1.9690 us/op 0.92
fastMsgIdFn h64 xxhash / 10000 bytes 1.2880 us/op 1.4640 us/op 0.88
enrSubnets - fastDeserialize 64 bits 1.3970 us/op 1.3320 us/op 1.05
enrSubnets - ssz BitVector 64 bits 467.00 ns/op 518.00 ns/op 0.90
enrSubnets - fastDeserialize 4 bits 167.00 ns/op 179.00 ns/op 0.93
enrSubnets - ssz BitVector 4 bits 467.00 ns/op 536.00 ns/op 0.87
prioritizePeers score -10:0 att 32-0.1 sync 2-0 100.34 us/op 115.98 us/op 0.87
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 128.56 us/op 155.71 us/op 0.83
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 157.74 us/op 215.37 us/op 0.73
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 288.40 us/op 339.40 us/op 0.85
prioritizePeers score 0:0 att 64-1 sync 4-1 345.69 us/op 403.32 us/op 0.86
array of 16000 items push then shift 1.5699 us/op 1.7986 us/op 0.87
LinkedList of 16000 items push then shift 8.4620 ns/op 9.3970 ns/op 0.90
array of 16000 items push then pop 76.621 ns/op 101.29 ns/op 0.76
LinkedList of 16000 items push then pop 8.1820 ns/op 8.6350 ns/op 0.95
array of 24000 items push then shift 2.2515 us/op 2.4027 us/op 0.94
LinkedList of 24000 items push then shift 8.3590 ns/op 9.0210 ns/op 0.93
array of 24000 items push then pop 72.441 ns/op 89.265 ns/op 0.81
LinkedList of 24000 items push then pop 8.2910 ns/op 9.0530 ns/op 0.92
intersect bitArray bitLen 8 12.978 ns/op 14.049 ns/op 0.92
intersect array and set length 8 76.498 ns/op 96.036 ns/op 0.80
intersect bitArray bitLen 128 42.977 ns/op 46.665 ns/op 0.92
intersect array and set length 128 1.0396 us/op 1.2290 us/op 0.85
Buffer.concat 32 items 2.8760 us/op 2.8900 us/op 1.00
Uint8Array.set 32 items 2.4610 us/op 2.8020 us/op 0.88
pass gossip attestations to forkchoice per slot 2.7233 ms/op 3.2708 ms/op 0.83
computeDeltas 3.4302 ms/op 3.0551 ms/op 1.12
computeProposerBoostScoreFromBalances 1.7717 ms/op 1.8206 ms/op 0.97
altair processAttestation - 250000 vs - 7PWei normalcase 2.0269 ms/op 2.6693 ms/op 0.76
altair processAttestation - 250000 vs - 7PWei worstcase 3.5882 ms/op 3.3200 ms/op 1.08
altair processAttestation - setStatus - 1/6 committees join 133.41 us/op 140.40 us/op 0.95
altair processAttestation - setStatus - 1/3 committees join 258.14 us/op 282.48 us/op 0.91
altair processAttestation - setStatus - 1/2 committees join 361.17 us/op 372.47 us/op 0.97
altair processAttestation - setStatus - 2/3 committees join 453.62 us/op 488.69 us/op 0.93
altair processAttestation - setStatus - 4/5 committees join 620.58 us/op 667.62 us/op 0.93
altair processAttestation - setStatus - 100% committees join 755.92 us/op 771.09 us/op 0.98
altair processBlock - 250000 vs - 7PWei normalcase 18.838 ms/op 14.911 ms/op 1.26
altair processBlock - 250000 vs - 7PWei normalcase hashState 25.607 ms/op 24.314 ms/op 1.05
altair processBlock - 250000 vs - 7PWei worstcase 51.593 ms/op 45.668 ms/op 1.13
altair processBlock - 250000 vs - 7PWei worstcase hashState 72.136 ms/op 63.436 ms/op 1.14
phase0 processBlock - 250000 vs - 7PWei normalcase 1.9047 ms/op 1.9823 ms/op 0.96
phase0 processBlock - 250000 vs - 7PWei worstcase 27.570 ms/op 28.526 ms/op 0.97
altair processEth1Data - 250000 vs - 7PWei normalcase 462.13 us/op 460.71 us/op 1.00
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 6.6010 us/op 7.1220 us/op 0.93
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 19.055 us/op 21.719 us/op 0.88
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 8.2210 us/op 8.9020 us/op 0.92
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 6.1250 us/op 6.8800 us/op 0.89
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 75.042 us/op 85.648 us/op 0.88
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 630.82 us/op 659.93 us/op 0.96
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 902.66 us/op 869.05 us/op 1.04
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 900.51 us/op 869.34 us/op 1.04
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 2.1980 ms/op 2.2643 ms/op 0.97
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 1.4638 ms/op 1.5417 ms/op 0.95
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 3.6072 ms/op 3.8522 ms/op 0.94
Tree 40 250000 create 288.93 ms/op 298.76 ms/op 0.97
Tree 40 250000 get(125000) 172.90 ns/op 179.77 ns/op 0.96
Tree 40 250000 set(125000) 870.53 ns/op 890.87 ns/op 0.98
Tree 40 250000 toArray() 16.846 ms/op 16.647 ms/op 1.01
Tree 40 250000 iterate all - toArray() + loop 16.709 ms/op 16.983 ms/op 0.98
Tree 40 250000 iterate all - get(i) 65.162 ms/op 66.105 ms/op 0.99
MutableVector 250000 create 11.239 ms/op 9.8921 ms/op 1.14
MutableVector 250000 get(125000) 6.4500 ns/op 6.9120 ns/op 0.93
MutableVector 250000 set(125000) 239.57 ns/op 243.22 ns/op 0.98
MutableVector 250000 toArray() 2.6372 ms/op 2.7597 ms/op 0.96
MutableVector 250000 iterate all - toArray() + loop 2.7391 ms/op 2.9208 ms/op 0.94
MutableVector 250000 iterate all - get(i) 1.4962 ms/op 1.5302 ms/op 0.98
Array 250000 create 2.4365 ms/op 2.6297 ms/op 0.93
Array 250000 clone - spread 1.1085 ms/op 1.1367 ms/op 0.98
Array 250000 get(125000) 0.55600 ns/op 0.53200 ns/op 1.05
Array 250000 set(125000) 0.63100 ns/op 0.62300 ns/op 1.01
Array 250000 iterate all - loop 80.739 us/op 82.918 us/op 0.97
effectiveBalanceIncrements clone Uint8Array 300000 24.476 us/op 24.770 us/op 0.99
effectiveBalanceIncrements clone MutableVector 300000 349.00 ns/op 336.00 ns/op 1.04
effectiveBalanceIncrements rw all Uint8Array 300000 165.81 us/op 166.63 us/op 1.00
effectiveBalanceIncrements rw all MutableVector 300000 78.141 ms/op 79.697 ms/op 0.98
phase0 afterProcessEpoch - 250000 vs - 7PWei 111.99 ms/op 111.70 ms/op 1.00
phase0 beforeProcessEpoch - 250000 vs - 7PWei 39.413 ms/op 40.736 ms/op 0.97
altair processEpoch - mainnet_e81889 296.32 ms/op 319.28 ms/op 0.93
mainnet_e81889 - altair beforeProcessEpoch 62.527 ms/op 68.509 ms/op 0.91
mainnet_e81889 - altair processJustificationAndFinalization 17.033 us/op 15.805 us/op 1.08
mainnet_e81889 - altair processInactivityUpdates 4.5989 ms/op 6.1483 ms/op 0.75
mainnet_e81889 - altair processRewardsAndPenalties 50.626 ms/op 49.828 ms/op 1.02
mainnet_e81889 - altair processRegistryUpdates 2.6930 us/op 2.7590 us/op 0.98
mainnet_e81889 - altair processSlashings 489.00 ns/op 482.00 ns/op 1.01
mainnet_e81889 - altair processEth1DataReset 531.00 ns/op 486.00 ns/op 1.09
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.1896 ms/op 1.2245 ms/op 0.97
mainnet_e81889 - altair processSlashingsReset 4.5800 us/op 5.0280 us/op 0.91
mainnet_e81889 - altair processRandaoMixesReset 4.6350 us/op 4.7560 us/op 0.97
mainnet_e81889 - altair processHistoricalRootsUpdate 551.00 ns/op 572.00 ns/op 0.96
mainnet_e81889 - altair processParticipationFlagUpdates 2.1460 us/op 2.1980 us/op 0.98
mainnet_e81889 - altair processSyncCommitteeUpdates 554.00 ns/op 468.00 ns/op 1.18
mainnet_e81889 - altair afterProcessEpoch 116.70 ms/op 118.17 ms/op 0.99
phase0 processEpoch - mainnet_e58758 317.34 ms/op 309.23 ms/op 1.03
mainnet_e58758 - phase0 beforeProcessEpoch 121.89 ms/op 118.87 ms/op 1.03
mainnet_e58758 - phase0 processJustificationAndFinalization 16.552 us/op 16.731 us/op 0.99
mainnet_e58758 - phase0 processRewardsAndPenalties 53.367 ms/op 57.598 ms/op 0.93
mainnet_e58758 - phase0 processRegistryUpdates 7.3140 us/op 7.4050 us/op 0.99
mainnet_e58758 - phase0 processSlashings 491.00 ns/op 500.00 ns/op 0.98
mainnet_e58758 - phase0 processEth1DataReset 509.00 ns/op 494.00 ns/op 1.03
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 942.60 us/op 988.22 us/op 0.95
mainnet_e58758 - phase0 processSlashingsReset 3.0240 us/op 3.4060 us/op 0.89
mainnet_e58758 - phase0 processRandaoMixesReset 4.6870 us/op 6.6960 us/op 0.70
mainnet_e58758 - phase0 processHistoricalRootsUpdate 603.00 ns/op 683.00 ns/op 0.88
mainnet_e58758 - phase0 processParticipationRecordUpdates 3.8580 us/op 4.8750 us/op 0.79
mainnet_e58758 - phase0 afterProcessEpoch 95.763 ms/op 94.729 ms/op 1.01
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.1987 ms/op 1.1994 ms/op 1.00
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.4548 ms/op 1.5196 ms/op 0.96
altair processInactivityUpdates - 250000 normalcase 19.451 ms/op 20.199 ms/op 0.96
altair processInactivityUpdates - 250000 worstcase 21.513 ms/op 22.983 ms/op 0.94
phase0 processRegistryUpdates - 250000 normalcase 6.0090 us/op 6.7190 us/op 0.89
phase0 processRegistryUpdates - 250000 badcase_full_deposits 215.05 us/op 243.87 us/op 0.88
phase0 processRegistryUpdates - 250000 worstcase 0.5 115.57 ms/op 119.35 ms/op 0.97
altair processRewardsAndPenalties - 250000 normalcase 57.111 ms/op 57.236 ms/op 1.00
altair processRewardsAndPenalties - 250000 worstcase 57.765 ms/op 54.870 ms/op 1.05
phase0 getAttestationDeltas - 250000 normalcase 6.3374 ms/op 6.6230 ms/op 0.96
phase0 getAttestationDeltas - 250000 worstcase 6.5897 ms/op 6.5440 ms/op 1.01
phase0 processSlashings - 250000 worstcase 3.5198 ms/op 3.2899 ms/op 1.07
altair processSyncCommitteeUpdates - 250000 170.74 ms/op 175.27 ms/op 0.97
BeaconState.hashTreeRoot - No change 261.00 ns/op 264.00 ns/op 0.99
BeaconState.hashTreeRoot - 1 full validator 48.814 us/op 49.172 us/op 0.99
BeaconState.hashTreeRoot - 32 full validator 500.87 us/op 494.89 us/op 1.01
BeaconState.hashTreeRoot - 512 full validator 4.7911 ms/op 4.9995 ms/op 0.96
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 59.430 us/op 68.867 us/op 0.86
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 819.97 us/op 889.28 us/op 0.92
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 10.693 ms/op 11.158 ms/op 0.96
BeaconState.hashTreeRoot - 1 balances 46.982 us/op 47.710 us/op 0.98
BeaconState.hashTreeRoot - 32 balances 436.97 us/op 447.60 us/op 0.98
BeaconState.hashTreeRoot - 512 balances 4.1386 ms/op 4.3757 ms/op 0.95
BeaconState.hashTreeRoot - 250000 balances 71.118 ms/op 72.823 ms/op 0.98
aggregationBits - 2048 els - zipIndexesInBitList 16.236 us/op 19.459 us/op 0.83
regular array get 100000 times 32.252 us/op 32.931 us/op 0.98
wrappedArray get 100000 times 32.140 us/op 32.858 us/op 0.98
arrayWithProxy get 100000 times 15.712 ms/op 16.028 ms/op 0.98
ssz.Root.equals 547.00 ns/op 550.00 ns/op 0.99
byteArrayEquals 522.00 ns/op 548.00 ns/op 0.95
shuffle list - 16384 els 6.6102 ms/op 6.8209 ms/op 0.97
shuffle list - 250000 els 96.293 ms/op 99.500 ms/op 0.97
processSlot - 1 slots 8.5090 us/op 8.6550 us/op 0.98
processSlot - 32 slots 1.2757 ms/op 1.3296 ms/op 0.96
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 33.568 ms/op 31.634 ms/op 1.06
getCommitteeAssignments - req 1 vs - 250000 vc 2.8243 ms/op 2.8994 ms/op 0.97
getCommitteeAssignments - req 100 vs - 250000 vc 4.0021 ms/op 4.1085 ms/op 0.97
getCommitteeAssignments - req 1000 vs - 250000 vc 4.3355 ms/op 4.4705 ms/op 0.97
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.3100 ns/op 4.2400 ns/op 1.02
state getBlockRootAtSlot - 250000 vs - 7PWei 815.87 ns/op 961.62 ns/op 0.85
computeProposers - vc 250000 10.208 ms/op 10.464 ms/op 0.98
computeEpochShuffling - vc 250000 100.96 ms/op 104.08 ms/op 0.97
getNextSyncCommittee - vc 250000 168.30 ms/op 168.83 ms/op 1.00
computeSigningRoot for AttestationData 12.930 us/op 13.283 us/op 0.97
hash AttestationData serialized data then Buffer.toString(base64) 2.3284 us/op 2.4492 us/op 0.95
toHexString serialized data 1.0463 us/op 1.0833 us/op 0.97
Buffer.toString(base64) 316.22 ns/op 323.08 ns/op 0.98

by benchmarkbot/action

@wemeetagain wemeetagain changed the title refactor: add gossip publisher module refactor(network): add gossip publisher module May 1, 2023
@dapplion
Copy link
Contributor

dapplion commented May 2, 2023

Should the publisher API just be part of the main thread network public API? I wrote some thoughts on how the API of each components should look like

@dapplion dapplion enabled auto-merge (squash) May 2, 2023 04:45
@dapplion dapplion merged commit d835c8c into unstable May 2, 2023
@dapplion dapplion deleted the cayman/gossip-publisher branch May 2, 2023 04:56
@wemeetagain
Copy link
Member Author

🎉 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.

2 participants