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: decouple the deneb blob and block production #5492

Merged
merged 4 commits into from
May 19, 2023
Merged

Conversation

g11tech
Copy link
Contributor

@g11tech g11tech commented May 14, 2023

As part of by parts integration of free the blobs PR

Update the blob and block production and signing flow as per the decoupled blob spec

implements:

@g11tech g11tech requested a review from a team as a code owner May 14, 2023 10:57
@github-actions
Copy link
Contributor

github-actions bot commented May 14, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 1f7a988 Previous: 812ac92 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 909.05 us/op 613.24 us/op 1.48
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 46.819 us/op 60.822 us/op 0.77
BLS verify - blst-native 1.2324 ms/op 1.2913 ms/op 0.95
BLS verifyMultipleSignatures 3 - blst-native 2.5035 ms/op 2.6469 ms/op 0.95
BLS verifyMultipleSignatures 8 - blst-native 5.4146 ms/op 5.5207 ms/op 0.98
BLS verifyMultipleSignatures 32 - blst-native 19.522 ms/op 19.605 ms/op 1.00
BLS aggregatePubkeys 32 - blst-native 25.881 us/op 26.560 us/op 0.97
BLS aggregatePubkeys 128 - blst-native 102.02 us/op 102.21 us/op 1.00
getAttestationsForBlock 53.230 ms/op 68.145 ms/op 0.78
isKnown best case - 1 super set check 255.00 ns/op 270.00 ns/op 0.94
isKnown normal case - 2 super set checks 254.00 ns/op 269.00 ns/op 0.94
isKnown worse case - 16 super set checks 257.00 ns/op 263.00 ns/op 0.98
CheckpointStateCache - add get delete 5.3180 us/op 6.2450 us/op 0.85
validate gossip signedAggregateAndProof - struct 2.8154 ms/op 3.0769 ms/op 0.92
validate gossip attestation - struct 1.3248 ms/op 1.3728 ms/op 0.97
pickEth1Vote - no votes 1.3596 ms/op 1.4218 ms/op 0.96
pickEth1Vote - max votes 10.536 ms/op 11.940 ms/op 0.88
pickEth1Vote - Eth1Data hashTreeRoot value x2048 8.9461 ms/op 10.516 ms/op 0.85
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 15.016 ms/op 17.022 ms/op 0.88
pickEth1Vote - Eth1Data fastSerialize value x2048 639.60 us/op 765.51 us/op 0.84
pickEth1Vote - Eth1Data fastSerialize tree x2048 4.8979 ms/op 6.0191 ms/op 0.81
bytes32 toHexString 519.00 ns/op 726.00 ns/op 0.71
bytes32 Buffer.toString(hex) 355.00 ns/op 442.00 ns/op 0.80
bytes32 Buffer.toString(hex) from Uint8Array 540.00 ns/op 638.00 ns/op 0.85
bytes32 Buffer.toString(hex) + 0x 382.00 ns/op 441.00 ns/op 0.87
Object access 1 prop 0.17300 ns/op 0.20800 ns/op 0.83
Map access 1 prop 0.15900 ns/op 0.17100 ns/op 0.93
Object get x1000 6.5370 ns/op 7.3640 ns/op 0.89
Map get x1000 0.66500 ns/op 0.59600 ns/op 1.12
Object set x1000 53.340 ns/op 76.178 ns/op 0.70
Map set x1000 44.659 ns/op 57.682 ns/op 0.77
Return object 10000 times 0.24090 ns/op 0.26520 ns/op 0.91
Throw Error 10000 times 4.1715 us/op 4.4616 us/op 0.93
fastMsgIdFn sha256 / 200 bytes 3.3890 us/op 3.7270 us/op 0.91
fastMsgIdFn h32 xxhash / 200 bytes 307.00 ns/op 333.00 ns/op 0.92
fastMsgIdFn h64 xxhash / 200 bytes 444.00 ns/op 500.00 ns/op 0.89
fastMsgIdFn sha256 / 1000 bytes 11.882 us/op 12.254 us/op 0.97
fastMsgIdFn h32 xxhash / 1000 bytes 433.00 ns/op 460.00 ns/op 0.94
fastMsgIdFn h64 xxhash / 1000 bytes 499.00 ns/op 649.00 ns/op 0.77
fastMsgIdFn sha256 / 10000 bytes 105.95 us/op 146.17 us/op 0.72
fastMsgIdFn h32 xxhash / 10000 bytes 2.1370 us/op 2.9440 us/op 0.73
fastMsgIdFn h64 xxhash / 10000 bytes 1.5350 us/op 2.3130 us/op 0.66
enrSubnets - fastDeserialize 64 bits 1.3660 us/op 3.0960 us/op 0.44
enrSubnets - ssz BitVector 64 bits 522.00 ns/op 1.0860 us/op 0.48
enrSubnets - fastDeserialize 4 bits 188.00 ns/op 373.00 ns/op 0.50
enrSubnets - ssz BitVector 4 bits 553.00 ns/op 1.0450 us/op 0.53
prioritizePeers score -10:0 att 32-0.1 sync 2-0 109.84 us/op 216.08 us/op 0.51
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 157.22 us/op 279.04 us/op 0.56
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 190.04 us/op 329.94 us/op 0.58
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 327.43 us/op 563.44 us/op 0.58
prioritizePeers score 0:0 att 64-1 sync 4-1 395.54 us/op 790.24 us/op 0.50
array of 16000 items push then shift 1.6851 us/op 2.5764 us/op 0.65
LinkedList of 16000 items push then shift 8.8970 ns/op 15.683 ns/op 0.57
array of 16000 items push then pop 103.12 ns/op 173.89 ns/op 0.59
LinkedList of 16000 items push then pop 9.0940 ns/op 16.165 ns/op 0.56
array of 24000 items push then shift 2.4208 us/op 4.2206 us/op 0.57
LinkedList of 24000 items push then shift 8.9040 ns/op 15.082 ns/op 0.59
array of 24000 items push then pop 82.415 ns/op 156.36 ns/op 0.53
LinkedList of 24000 items push then pop 9.0540 ns/op 15.316 ns/op 0.59
intersect bitArray bitLen 8 13.629 ns/op 30.701 ns/op 0.44
intersect array and set length 8 81.934 ns/op 150.18 ns/op 0.55
intersect bitArray bitLen 128 46.048 ns/op 53.029 ns/op 0.87
intersect array and set length 128 1.1075 us/op 1.5224 us/op 0.73
Buffer.concat 32 items 3.1680 us/op 6.2040 us/op 0.51
Uint8Array.set 32 items 2.9840 us/op 5.0740 us/op 0.59
pass gossip attestations to forkchoice per slot 2.9169 ms/op 5.2660 ms/op 0.55
computeDeltas 2.9578 ms/op 4.8865 ms/op 0.61
computeProposerBoostScoreFromBalances 1.7839 ms/op 2.1414 ms/op 0.83
altair processAttestation - 250000 vs - 7PWei normalcase 2.2161 ms/op 3.7465 ms/op 0.59
altair processAttestation - 250000 vs - 7PWei worstcase 3.3675 ms/op 5.5744 ms/op 0.60
altair processAttestation - setStatus - 1/6 committees join 144.04 us/op 162.90 us/op 0.88
altair processAttestation - setStatus - 1/3 committees join 281.60 us/op 321.06 us/op 0.88
altair processAttestation - setStatus - 1/2 committees join 370.64 us/op 434.46 us/op 0.85
altair processAttestation - setStatus - 2/3 committees join 450.19 us/op 509.74 us/op 0.88
altair processAttestation - setStatus - 4/5 committees join 632.20 us/op 733.82 us/op 0.86
altair processAttestation - setStatus - 100% committees join 759.39 us/op 877.38 us/op 0.87
altair processBlock - 250000 vs - 7PWei normalcase 19.058 ms/op 22.297 ms/op 0.85
altair processBlock - 250000 vs - 7PWei normalcase hashState 26.372 ms/op 30.926 ms/op 0.85
altair processBlock - 250000 vs - 7PWei worstcase 54.268 ms/op 61.970 ms/op 0.88
altair processBlock - 250000 vs - 7PWei worstcase hashState 67.367 ms/op 77.260 ms/op 0.87
phase0 processBlock - 250000 vs - 7PWei normalcase 1.9508 ms/op 2.4902 ms/op 0.78
phase0 processBlock - 250000 vs - 7PWei worstcase 28.070 ms/op 31.892 ms/op 0.88
altair processEth1Data - 250000 vs - 7PWei normalcase 448.32 us/op 564.21 us/op 0.79
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 7.5050 us/op 8.3120 us/op 0.90
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 19.935 us/op 23.102 us/op 0.86
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 9.1830 us/op 10.145 us/op 0.91
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 7.3530 us/op 7.4000 us/op 0.99
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 75.423 us/op 91.779 us/op 0.82
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 614.70 us/op 769.34 us/op 0.80
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 896.72 us/op 1.2757 ms/op 0.70
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 877.75 us/op 1.6943 ms/op 0.52
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 2.2126 ms/op 2.6478 ms/op 0.84
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 1.4887 ms/op 1.7497 ms/op 0.85
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 3.8895 ms/op 4.0459 ms/op 0.96
Tree 40 250000 create 313.69 ms/op 322.84 ms/op 0.97
Tree 40 250000 get(125000) 174.81 ns/op 187.56 ns/op 0.93
Tree 40 250000 set(125000) 860.61 ns/op 916.10 ns/op 0.94
Tree 40 250000 toArray() 16.107 ms/op 17.208 ms/op 0.94
Tree 40 250000 iterate all - toArray() + loop 16.252 ms/op 18.313 ms/op 0.89
Tree 40 250000 iterate all - get(i) 64.319 ms/op 69.910 ms/op 0.92
MutableVector 250000 create 10.167 ms/op 13.634 ms/op 0.75
MutableVector 250000 get(125000) 6.2980 ns/op 6.4700 ns/op 0.97
MutableVector 250000 set(125000) 260.47 ns/op 259.96 ns/op 1.00
MutableVector 250000 toArray() 2.7861 ms/op 2.6893 ms/op 1.04
MutableVector 250000 iterate all - toArray() + loop 3.0971 ms/op 2.7939 ms/op 1.11
MutableVector 250000 iterate all - get(i) 1.4288 ms/op 1.5276 ms/op 0.94
Array 250000 create 2.4401 ms/op 2.9231 ms/op 0.83
Array 250000 clone - spread 1.0569 ms/op 1.0637 ms/op 0.99
Array 250000 get(125000) 0.50100 ns/op 0.53600 ns/op 0.93
Array 250000 set(125000) 0.57100 ns/op 0.61100 ns/op 0.93
Array 250000 iterate all - loop 95.187 us/op 83.267 us/op 1.14
effectiveBalanceIncrements clone Uint8Array 300000 23.201 us/op 28.095 us/op 0.83
effectiveBalanceIncrements clone MutableVector 300000 302.00 ns/op 331.00 ns/op 0.91
effectiveBalanceIncrements rw all Uint8Array 300000 157.24 us/op 168.56 us/op 0.93
effectiveBalanceIncrements rw all MutableVector 300000 72.535 ms/op 79.092 ms/op 0.92
phase0 afterProcessEpoch - 250000 vs - 7PWei 108.42 ms/op 120.15 ms/op 0.90
phase0 beforeProcessEpoch - 250000 vs - 7PWei 40.898 ms/op 43.727 ms/op 0.94
altair processEpoch - mainnet_e81889 321.78 ms/op 349.26 ms/op 0.92
mainnet_e81889 - altair beforeProcessEpoch 63.499 ms/op 59.821 ms/op 1.06
mainnet_e81889 - altair processJustificationAndFinalization 16.839 us/op 35.592 us/op 0.47
mainnet_e81889 - altair processInactivityUpdates 5.4897 ms/op 5.8928 ms/op 0.93
mainnet_e81889 - altair processRewardsAndPenalties 71.022 ms/op 88.618 ms/op 0.80
mainnet_e81889 - altair processRegistryUpdates 2.8900 us/op 4.3640 us/op 0.66
mainnet_e81889 - altair processSlashings 438.00 ns/op 942.00 ns/op 0.46
mainnet_e81889 - altair processEth1DataReset 583.00 ns/op 874.00 ns/op 0.67
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2637 ms/op 2.2920 ms/op 0.55
mainnet_e81889 - altair processSlashingsReset 4.5750 us/op 6.3590 us/op 0.72
mainnet_e81889 - altair processRandaoMixesReset 5.7330 us/op 7.5010 us/op 0.76
mainnet_e81889 - altair processHistoricalRootsUpdate 643.00 ns/op 1.0720 us/op 0.60
mainnet_e81889 - altair processParticipationFlagUpdates 5.0770 us/op 3.7900 us/op 1.34
mainnet_e81889 - altair processSyncCommitteeUpdates 897.00 ns/op 916.00 ns/op 0.98
mainnet_e81889 - altair afterProcessEpoch 130.24 ms/op 129.21 ms/op 1.01
phase0 processEpoch - mainnet_e58758 358.34 ms/op 402.90 ms/op 0.89
mainnet_e58758 - phase0 beforeProcessEpoch 133.32 ms/op 154.44 ms/op 0.86
mainnet_e58758 - phase0 processJustificationAndFinalization 17.137 us/op 16.967 us/op 1.01
mainnet_e58758 - phase0 processRewardsAndPenalties 60.766 ms/op 74.299 ms/op 0.82
mainnet_e58758 - phase0 processRegistryUpdates 7.9280 us/op 13.746 us/op 0.58
mainnet_e58758 - phase0 processSlashings 561.00 ns/op 906.00 ns/op 0.62
mainnet_e58758 - phase0 processEth1DataReset 551.00 ns/op 654.00 ns/op 0.84
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.0168 ms/op 1.8864 ms/op 0.54
mainnet_e58758 - phase0 processSlashingsReset 4.2740 us/op 7.1670 us/op 0.60
mainnet_e58758 - phase0 processRandaoMixesReset 4.6610 us/op 5.4720 us/op 0.85
mainnet_e58758 - phase0 processHistoricalRootsUpdate 585.00 ns/op 988.00 ns/op 0.59
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.0780 us/op 6.6770 us/op 0.61
mainnet_e58758 - phase0 afterProcessEpoch 98.940 ms/op 94.470 ms/op 1.05
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.2594 ms/op 1.1920 ms/op 1.06
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.5883 ms/op 1.4511 ms/op 1.09
altair processInactivityUpdates - 250000 normalcase 26.434 ms/op 31.460 ms/op 0.84
altair processInactivityUpdates - 250000 worstcase 26.449 ms/op 31.430 ms/op 0.84
phase0 processRegistryUpdates - 250000 normalcase 6.6740 us/op 10.931 us/op 0.61
phase0 processRegistryUpdates - 250000 badcase_full_deposits 270.76 us/op 466.01 us/op 0.58
phase0 processRegistryUpdates - 250000 worstcase 0.5 126.99 ms/op 156.19 ms/op 0.81
altair processRewardsAndPenalties - 250000 normalcase 68.700 ms/op 82.023 ms/op 0.84
altair processRewardsAndPenalties - 250000 worstcase 68.544 ms/op 83.210 ms/op 0.82
phase0 getAttestationDeltas - 250000 normalcase 6.9142 ms/op 6.5851 ms/op 1.05
phase0 getAttestationDeltas - 250000 worstcase 6.4717 ms/op 6.5383 ms/op 0.99
phase0 processSlashings - 250000 worstcase 3.5866 ms/op 3.5070 ms/op 1.02
altair processSyncCommitteeUpdates - 250000 171.52 ms/op 188.35 ms/op 0.91
BeaconState.hashTreeRoot - No change 356.00 ns/op 274.00 ns/op 1.30
BeaconState.hashTreeRoot - 1 full validator 49.335 us/op 57.164 us/op 0.86
BeaconState.hashTreeRoot - 32 full validator 488.60 us/op 637.91 us/op 0.77
BeaconState.hashTreeRoot - 512 full validator 5.1646 ms/op 5.9803 ms/op 0.86
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 61.731 us/op 66.564 us/op 0.93
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 853.51 us/op 1.0040 ms/op 0.85
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 10.729 ms/op 11.311 ms/op 0.95
BeaconState.hashTreeRoot - 1 balances 47.008 us/op 59.518 us/op 0.79
BeaconState.hashTreeRoot - 32 balances 432.85 us/op 443.78 us/op 0.98
BeaconState.hashTreeRoot - 512 balances 3.9401 ms/op 4.8830 ms/op 0.81
BeaconState.hashTreeRoot - 250000 balances 77.704 ms/op 86.887 ms/op 0.89
aggregationBits - 2048 els - zipIndexesInBitList 15.290 us/op 15.326 us/op 1.00
regular array get 100000 times 42.221 us/op 32.637 us/op 1.29
wrappedArray get 100000 times 43.974 us/op 32.947 us/op 1.33
arrayWithProxy get 100000 times 16.124 ms/op 15.322 ms/op 1.05
ssz.Root.equals 573.00 ns/op 535.00 ns/op 1.07
byteArrayEquals 533.00 ns/op 529.00 ns/op 1.01
shuffle list - 16384 els 6.7657 ms/op 6.7520 ms/op 1.00
shuffle list - 250000 els 99.779 ms/op 99.493 ms/op 1.00
processSlot - 1 slots 8.4260 us/op 9.0310 us/op 0.93
processSlot - 32 slots 1.2953 ms/op 1.3694 ms/op 0.95
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 37.909 ms/op 40.728 ms/op 0.93
getCommitteeAssignments - req 1 vs - 250000 vc 2.9026 ms/op 2.9989 ms/op 0.97
getCommitteeAssignments - req 100 vs - 250000 vc 4.1032 ms/op 4.1596 ms/op 0.99
getCommitteeAssignments - req 1000 vs - 250000 vc 4.4669 ms/op 4.4883 ms/op 1.00
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.8900 ns/op 4.6900 ns/op 1.04
state getBlockRootAtSlot - 250000 vs - 7PWei 1.0059 us/op 860.69 ns/op 1.17
computeProposers - vc 250000 10.216 ms/op 10.143 ms/op 1.01
computeEpochShuffling - vc 250000 106.16 ms/op 101.82 ms/op 1.04
getNextSyncCommittee - vc 250000 184.74 ms/op 167.58 ms/op 1.10
computeSigningRoot for AttestationData 14.652 us/op 12.592 us/op 1.16
hash AttestationData serialized data then Buffer.toString(base64) 2.5420 us/op 2.4470 us/op 1.04
toHexString serialized data 1.1035 us/op 1.0623 us/op 1.04
Buffer.toString(base64) 335.95 ns/op 324.43 ns/op 1.04

by benchmarkbot/action

// Prune old blobSidecars for block production, those are only useful on their slot
if (this.config.getForkSeq(slot) >= ForkSeq.deneb) {
if (this.producedBlobSidecarsCache.size > 0) {
for (const [key, {slot: blobSlot}] of this.producedBlobSidecarsCache) {
Copy link
Contributor

Choose a reason for hiding this comment

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

not related to this PR, why don't we have producedBlobSidecarsCache with slot or block number as key so that we don't have to do a full scan here? I think we should have slot/block number in all of the consumer of the cache

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because its not re-org safe

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean we cache by slot, and then by block hash, and when we search we filter by slot first, then by block hash (I notice all of the consumers have slot).
it'd be easier to prune by slot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmmm can be done but sounds like an overkill since the freshest blobs are the most likely to be used in the proposal and are added to cache by increasing slot order, so pruning out by max naturally follows that order

add some breathing room

reduce diff

apply feedback

use typeguards

fix typo

update comment
signedBlobSidecars: SignedBlobSidecars,
},
{typeName: "SignedBlockContents", jsonCase: "eth2"}
);
Copy link
Contributor

@dapplion dapplion May 18, 2023

Choose a reason for hiding this comment

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

Is this a spec'ed type? Types in packages/types should exclusively include spec'ed types, which need merkleization and / or serialization. Else define in beacon-node package

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think its just beacon-apis serialization type, might be useful in eventually supporting ssz encoded/decoded responses in api, but for now will move into beacon-api package itself and import/use from there 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dapplion have done some refactoring on this, let me know if you find it suitable now

@g11tech g11tech changed the title refactor: decouple the deneb blob and block production feat: decouple the deneb blob and block production May 19, 2023
Copy link
Contributor

@dapplion dapplion left a comment

Choose a reason for hiding this comment

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

Looks great!

@g11tech g11tech merged commit 402c46f into unstable May 19, 2023
@g11tech g11tech deleted the ftp/apis branch May 19, 2023 17:59
@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.

4 participants