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: track block source in BlockInput #5486

Merged
merged 2 commits into from
May 14, 2023
Merged

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented May 12, 2023

Motivation

Description

  • The old BlockSource becomes ProducedBlockSource enum
  • New block source enum with 4 possible values: api, gossip, beacon_blocks_by_root and beacon_block_by_range
  • Add BlockSource to BlockInput and refactor all the consumers of preDeneb, postDeneb
  • Add metric to track where blocks come from

@github-actions
Copy link
Contributor

github-actions bot commented May 12, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: bde7843 Previous: f16192f Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 638.58 us/op 582.80 us/op 1.10
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 45.683 us/op 47.418 us/op 0.96
BLS verify - blst-native 1.2257 ms/op 1.2367 ms/op 0.99
BLS verifyMultipleSignatures 3 - blst-native 2.4874 ms/op 2.5355 ms/op 0.98
BLS verifyMultipleSignatures 8 - blst-native 5.3929 ms/op 5.4240 ms/op 0.99
BLS verifyMultipleSignatures 32 - blst-native 19.321 ms/op 19.947 ms/op 0.97
BLS aggregatePubkeys 32 - blst-native 25.972 us/op 26.403 us/op 0.98
BLS aggregatePubkeys 128 - blst-native 101.18 us/op 102.59 us/op 0.99
getAttestationsForBlock 56.290 ms/op 57.316 ms/op 0.98
isKnown best case - 1 super set check 274.00 ns/op 258.00 ns/op 1.06
isKnown normal case - 2 super set checks 263.00 ns/op 256.00 ns/op 1.03
isKnown worse case - 16 super set checks 260.00 ns/op 256.00 ns/op 1.02
CheckpointStateCache - add get delete 5.0000 us/op 5.0360 us/op 0.99
validate gossip signedAggregateAndProof - struct 2.8028 ms/op 2.7976 ms/op 1.00
validate gossip attestation - struct 1.3180 ms/op 1.3351 ms/op 0.99
pickEth1Vote - no votes 1.2352 ms/op 1.3224 ms/op 0.93
pickEth1Vote - max votes 8.7304 ms/op 10.312 ms/op 0.85
pickEth1Vote - Eth1Data hashTreeRoot value x2048 8.5865 ms/op 8.6933 ms/op 0.99
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 13.370 ms/op 15.630 ms/op 0.86
pickEth1Vote - Eth1Data fastSerialize value x2048 646.93 us/op 655.19 us/op 0.99
pickEth1Vote - Eth1Data fastSerialize tree x2048 4.6105 ms/op 4.7735 ms/op 0.97
bytes32 toHexString 503.00 ns/op 502.00 ns/op 1.00
bytes32 Buffer.toString(hex) 359.00 ns/op 387.00 ns/op 0.93
bytes32 Buffer.toString(hex) from Uint8Array 550.00 ns/op 608.00 ns/op 0.90
bytes32 Buffer.toString(hex) + 0x 370.00 ns/op 385.00 ns/op 0.96
Object access 1 prop 0.17400 ns/op 0.16800 ns/op 1.04
Map access 1 prop 0.15800 ns/op 0.15800 ns/op 1.00
Object get x1000 6.4780 ns/op 6.4530 ns/op 1.00
Map get x1000 0.56700 ns/op 0.63200 ns/op 0.90
Object set x1000 52.089 ns/op 54.563 ns/op 0.95
Map set x1000 44.175 ns/op 45.029 ns/op 0.98
Return object 10000 times 0.23540 ns/op 0.24070 ns/op 0.98
Throw Error 10000 times 4.1647 us/op 4.2722 us/op 0.97
fastMsgIdFn sha256 / 200 bytes 3.4220 us/op 3.5330 us/op 0.97
fastMsgIdFn h32 xxhash / 200 bytes 302.00 ns/op 307.00 ns/op 0.98
fastMsgIdFn h64 xxhash / 200 bytes 483.00 ns/op 453.00 ns/op 1.07
fastMsgIdFn sha256 / 1000 bytes 11.823 us/op 11.877 us/op 1.00
fastMsgIdFn h32 xxhash / 1000 bytes 446.00 ns/op 444.00 ns/op 1.00
fastMsgIdFn h64 xxhash / 1000 bytes 482.00 ns/op 497.00 ns/op 0.97
fastMsgIdFn sha256 / 10000 bytes 103.66 us/op 104.42 us/op 0.99
fastMsgIdFn h32 xxhash / 10000 bytes 1.9150 us/op 1.9650 us/op 0.97
fastMsgIdFn h64 xxhash / 10000 bytes 1.3450 us/op 1.4350 us/op 0.94
enrSubnets - fastDeserialize 64 bits 1.2980 us/op 1.5440 us/op 0.84
enrSubnets - ssz BitVector 64 bits 490.00 ns/op 573.00 ns/op 0.86
enrSubnets - fastDeserialize 4 bits 171.00 ns/op 193.00 ns/op 0.89
enrSubnets - ssz BitVector 4 bits 495.00 ns/op 568.00 ns/op 0.87
prioritizePeers score -10:0 att 32-0.1 sync 2-0 101.33 us/op 136.55 us/op 0.74
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 131.73 us/op 149.15 us/op 0.88
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 166.21 us/op 184.55 us/op 0.90
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 303.24 us/op 365.61 us/op 0.83
prioritizePeers score 0:0 att 64-1 sync 4-1 364.57 us/op 429.36 us/op 0.85
array of 16000 items push then shift 1.6311 us/op 1.6736 us/op 0.97
LinkedList of 16000 items push then shift 8.8440 ns/op 9.0760 ns/op 0.97
array of 16000 items push then pop 76.504 ns/op 105.07 ns/op 0.73
LinkedList of 16000 items push then pop 8.6400 ns/op 8.8730 ns/op 0.97
array of 24000 items push then shift 2.4354 us/op 2.4396 us/op 1.00
LinkedList of 24000 items push then shift 8.9530 ns/op 9.3760 ns/op 0.95
array of 24000 items push then pop 77.170 ns/op 84.169 ns/op 0.92
LinkedList of 24000 items push then pop 8.5520 ns/op 8.9610 ns/op 0.95
intersect bitArray bitLen 8 13.316 ns/op 13.626 ns/op 0.98
intersect array and set length 8 78.868 ns/op 80.898 ns/op 0.97
intersect bitArray bitLen 128 44.010 ns/op 44.903 ns/op 0.98
intersect array and set length 128 1.0557 us/op 1.0916 us/op 0.97
Buffer.concat 32 items 3.0580 us/op 2.7020 us/op 1.13
Uint8Array.set 32 items 2.0900 us/op 2.2210 us/op 0.94
pass gossip attestations to forkchoice per slot 3.1270 ms/op 3.0223 ms/op 1.03
computeDeltas 2.9922 ms/op 3.0590 ms/op 0.98
computeProposerBoostScoreFromBalances 1.7610 ms/op 1.8228 ms/op 0.97
altair processAttestation - 250000 vs - 7PWei normalcase 2.1886 ms/op 2.4860 ms/op 0.88
altair processAttestation - 250000 vs - 7PWei worstcase 3.3736 ms/op 3.7923 ms/op 0.89
altair processAttestation - setStatus - 1/6 committees join 141.96 us/op 152.44 us/op 0.93
altair processAttestation - setStatus - 1/3 committees join 282.77 us/op 296.15 us/op 0.95
altair processAttestation - setStatus - 1/2 committees join 380.62 us/op 384.53 us/op 0.99
altair processAttestation - setStatus - 2/3 committees join 471.77 us/op 482.61 us/op 0.98
altair processAttestation - setStatus - 4/5 committees join 660.90 us/op 685.63 us/op 0.96
altair processAttestation - setStatus - 100% committees join 777.79 us/op 795.06 us/op 0.98
altair processBlock - 250000 vs - 7PWei normalcase 18.666 ms/op 17.646 ms/op 1.06
altair processBlock - 250000 vs - 7PWei normalcase hashState 27.355 ms/op 25.944 ms/op 1.05
altair processBlock - 250000 vs - 7PWei worstcase 48.333 ms/op 53.275 ms/op 0.91
altair processBlock - 250000 vs - 7PWei worstcase hashState 65.304 ms/op 72.105 ms/op 0.91
phase0 processBlock - 250000 vs - 7PWei normalcase 2.2761 ms/op 2.1154 ms/op 1.08
phase0 processBlock - 250000 vs - 7PWei worstcase 30.034 ms/op 30.769 ms/op 0.98
altair processEth1Data - 250000 vs - 7PWei normalcase 518.26 us/op 472.38 us/op 1.10
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 8.0120 us/op 8.7070 us/op 0.92
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 28.262 us/op 25.858 us/op 1.09
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 12.196 us/op 10.289 us/op 1.19
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 9.1790 us/op 7.6790 us/op 1.20
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 98.909 us/op 102.32 us/op 0.97
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 658.69 us/op 668.99 us/op 0.98
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 929.31 us/op 907.82 us/op 1.02
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 887.60 us/op 898.99 us/op 0.99
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 2.4272 ms/op 2.4786 ms/op 0.98
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 1.5389 ms/op 1.5140 ms/op 1.02
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 3.9779 ms/op 4.2446 ms/op 0.94
Tree 40 250000 create 343.63 ms/op 321.17 ms/op 1.07
Tree 40 250000 get(125000) 188.73 ns/op 192.80 ns/op 0.98
Tree 40 250000 set(125000) 922.53 ns/op 995.58 ns/op 0.93
Tree 40 250000 toArray() 21.494 ms/op 22.402 ms/op 0.96
Tree 40 250000 iterate all - toArray() + loop 21.651 ms/op 21.971 ms/op 0.99
Tree 40 250000 iterate all - get(i) 73.125 ms/op 76.429 ms/op 0.96
MutableVector 250000 create 10.072 ms/op 10.751 ms/op 0.94
MutableVector 250000 get(125000) 6.4550 ns/op 6.5410 ns/op 0.99
MutableVector 250000 set(125000) 270.08 ns/op 292.25 ns/op 0.92
MutableVector 250000 toArray() 3.1481 ms/op 4.0216 ms/op 0.78
MutableVector 250000 iterate all - toArray() + loop 3.3344 ms/op 3.8995 ms/op 0.86
MutableVector 250000 iterate all - get(i) 1.5305 ms/op 1.5679 ms/op 0.98
Array 250000 create 2.9763 ms/op 3.1348 ms/op 0.95
Array 250000 clone - spread 1.1125 ms/op 1.2059 ms/op 0.92
Array 250000 get(125000) 0.55100 ns/op 0.59000 ns/op 0.93
Array 250000 set(125000) 0.62400 ns/op 0.66400 ns/op 0.94
Array 250000 iterate all - loop 83.024 us/op 84.890 us/op 0.98
effectiveBalanceIncrements clone Uint8Array 300000 25.770 us/op 35.256 us/op 0.73
effectiveBalanceIncrements clone MutableVector 300000 333.00 ns/op 359.00 ns/op 0.93
effectiveBalanceIncrements rw all Uint8Array 300000 169.08 us/op 167.84 us/op 1.01
effectiveBalanceIncrements rw all MutableVector 300000 80.417 ms/op 84.030 ms/op 0.96
phase0 afterProcessEpoch - 250000 vs - 7PWei 115.36 ms/op 119.18 ms/op 0.97
phase0 beforeProcessEpoch - 250000 vs - 7PWei 42.737 ms/op 46.193 ms/op 0.93
altair processEpoch - mainnet_e81889 342.98 ms/op 342.49 ms/op 1.00
mainnet_e81889 - altair beforeProcessEpoch 63.820 ms/op 66.937 ms/op 0.95
mainnet_e81889 - altair processJustificationAndFinalization 19.404 us/op 19.285 us/op 1.01
mainnet_e81889 - altair processInactivityUpdates 6.5467 ms/op 6.3116 ms/op 1.04
mainnet_e81889 - altair processRewardsAndPenalties 56.224 ms/op 66.321 ms/op 0.85
mainnet_e81889 - altair processRegistryUpdates 2.4590 us/op 2.4290 us/op 1.01
mainnet_e81889 - altair processSlashings 509.00 ns/op 510.00 ns/op 1.00
mainnet_e81889 - altair processEth1DataReset 540.00 ns/op 555.00 ns/op 0.97
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.3120 ms/op 1.2658 ms/op 1.04
mainnet_e81889 - altair processSlashingsReset 4.3220 us/op 4.1660 us/op 1.04
mainnet_e81889 - altair processRandaoMixesReset 8.0310 us/op 9.3450 us/op 0.86
mainnet_e81889 - altair processHistoricalRootsUpdate 790.00 ns/op 776.00 ns/op 1.02
mainnet_e81889 - altair processParticipationFlagUpdates 3.8710 us/op 2.7170 us/op 1.42
mainnet_e81889 - altair processSyncCommitteeUpdates 775.00 ns/op 538.00 ns/op 1.44
mainnet_e81889 - altair afterProcessEpoch 130.13 ms/op 140.81 ms/op 0.92
phase0 processEpoch - mainnet_e58758 382.02 ms/op 407.04 ms/op 0.94
mainnet_e58758 - phase0 beforeProcessEpoch 153.56 ms/op 161.28 ms/op 0.95
mainnet_e58758 - phase0 processJustificationAndFinalization 19.146 us/op 27.081 us/op 0.71
mainnet_e58758 - phase0 processRewardsAndPenalties 67.598 ms/op 68.396 ms/op 0.99
mainnet_e58758 - phase0 processRegistryUpdates 10.111 us/op 8.8610 us/op 1.14
mainnet_e58758 - phase0 processSlashings 511.00 ns/op 555.00 ns/op 0.92
mainnet_e58758 - phase0 processEth1DataReset 559.00 ns/op 634.00 ns/op 0.88
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.0259 ms/op 1.0737 ms/op 0.96
mainnet_e58758 - phase0 processSlashingsReset 4.2130 us/op 5.6450 us/op 0.75
mainnet_e58758 - phase0 processRandaoMixesReset 6.4700 us/op 5.6100 us/op 1.15
mainnet_e58758 - phase0 processHistoricalRootsUpdate 627.00 ns/op 665.00 ns/op 0.94
mainnet_e58758 - phase0 processParticipationRecordUpdates 3.4230 us/op 4.3340 us/op 0.79
mainnet_e58758 - phase0 afterProcessEpoch 97.557 ms/op 103.90 ms/op 0.94
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.2841 ms/op 1.2790 ms/op 1.00
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.5520 ms/op 1.7130 ms/op 0.91
altair processInactivityUpdates - 250000 normalcase 24.278 ms/op 23.314 ms/op 1.04
altair processInactivityUpdates - 250000 worstcase 26.655 ms/op 32.914 ms/op 0.81
phase0 processRegistryUpdates - 250000 normalcase 9.7120 us/op 11.136 us/op 0.87
phase0 processRegistryUpdates - 250000 badcase_full_deposits 266.88 us/op 296.42 us/op 0.90
phase0 processRegistryUpdates - 250000 worstcase 0.5 125.26 ms/op 144.32 ms/op 0.87
altair processRewardsAndPenalties - 250000 normalcase 63.836 ms/op 69.283 ms/op 0.92
altair processRewardsAndPenalties - 250000 worstcase 67.519 ms/op 80.707 ms/op 0.84
phase0 getAttestationDeltas - 250000 normalcase 7.0153 ms/op 8.9571 ms/op 0.78
phase0 getAttestationDeltas - 250000 worstcase 6.6196 ms/op 9.0213 ms/op 0.73
phase0 processSlashings - 250000 worstcase 3.4218 ms/op 3.9344 ms/op 0.87
altair processSyncCommitteeUpdates - 250000 175.51 ms/op 201.07 ms/op 0.87
BeaconState.hashTreeRoot - No change 366.00 ns/op 419.00 ns/op 0.87
BeaconState.hashTreeRoot - 1 full validator 50.336 us/op 53.308 us/op 0.94
BeaconState.hashTreeRoot - 32 full validator 562.78 us/op 568.69 us/op 0.99
BeaconState.hashTreeRoot - 512 full validator 5.0063 ms/op 5.7692 ms/op 0.87
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 66.111 us/op 65.842 us/op 1.00
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 910.61 us/op 1.0458 ms/op 0.87
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 12.202 ms/op 12.841 ms/op 0.95
BeaconState.hashTreeRoot - 1 balances 51.230 us/op 50.865 us/op 1.01
BeaconState.hashTreeRoot - 32 balances 467.25 us/op 486.69 us/op 0.96
BeaconState.hashTreeRoot - 512 balances 4.3169 ms/op 4.9453 ms/op 0.87
BeaconState.hashTreeRoot - 250000 balances 77.499 ms/op 73.738 ms/op 1.05
aggregationBits - 2048 els - zipIndexesInBitList 15.861 us/op 22.443 us/op 0.71
regular array get 100000 times 33.387 us/op 35.159 us/op 0.95
wrappedArray get 100000 times 33.280 us/op 35.876 us/op 0.93
arrayWithProxy get 100000 times 16.996 ms/op 18.571 ms/op 0.92
ssz.Root.equals 554.00 ns/op 642.00 ns/op 0.86
byteArrayEquals 550.00 ns/op 661.00 ns/op 0.83
shuffle list - 16384 els 7.0101 ms/op 7.5527 ms/op 0.93
shuffle list - 250000 els 101.06 ms/op 111.20 ms/op 0.91
processSlot - 1 slots 8.8710 us/op 10.953 us/op 0.81
processSlot - 32 slots 1.3493 ms/op 1.6528 ms/op 0.82
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 35.597 ms/op 44.160 ms/op 0.81
getCommitteeAssignments - req 1 vs - 250000 vc 2.9903 ms/op 3.2454 ms/op 0.92
getCommitteeAssignments - req 100 vs - 250000 vc 4.2818 ms/op 4.7237 ms/op 0.91
getCommitteeAssignments - req 1000 vs - 250000 vc 4.5849 ms/op 4.8346 ms/op 0.95
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.7900 ns/op 5.6300 ns/op 0.85
state getBlockRootAtSlot - 250000 vs - 7PWei 612.63 ns/op 823.22 ns/op 0.74
computeProposers - vc 250000 10.891 ms/op 12.106 ms/op 0.90
computeEpochShuffling - vc 250000 105.05 ms/op 118.47 ms/op 0.89
getNextSyncCommittee - vc 250000 175.60 ms/op 208.58 ms/op 0.84
computeSigningRoot for AttestationData 13.429 us/op 16.699 us/op 0.80
hash AttestationData serialized data then Buffer.toString(base64) 2.5695 us/op 2.6583 us/op 0.97
toHexString serialized data 1.1055 us/op 1.6126 us/op 0.69
Buffer.toString(base64) 322.37 ns/op 375.19 ns/op 0.86

by benchmarkbot/action

@twoeths twoeths marked this pull request as ready for review May 12, 2023 13:01
@twoeths twoeths requested a review from a team as a code owner May 12, 2023 13:01
@dapplion dapplion merged commit a59f231 into unstable May 14, 2023
@dapplion dapplion deleted the tuyen/block_source branch May 14, 2023 02:48
@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.

3 participants