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: prune BlsToExecutionChange opPool with head state #6252

Merged

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Jan 5, 2024

Motivation

  • Right now we use finalized state to prune BlsToExecutionChange but it's not available anymore after n-historical state work, that's also in our TODO list

Description

this is a prerequisite for #6250

Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Merging #6252 (22801c7) into unstable (9262064) will not change coverage.
Report is 2 commits behind head on unstable.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #6252   +/-   ##
=========================================
  Coverage     80.31%   80.31%           
=========================================
  Files           202      202           
  Lines         19543    19543           
  Branches       1169     1169           
=========================================
  Hits          15695    15695           
  Misses         3820     3820           
  Partials         28       28           

Copy link
Contributor

github-actions bot commented Jan 5, 2024

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 03930ab Previous: 48dbc58 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 588.53 us/op 601.86 us/op 0.98
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 145.17 us/op 53.849 us/op 2.70
BLS verify - blst-native 1.3986 ms/op 1.1381 ms/op 1.23
BLS verifyMultipleSignatures 3 - blst-native 2.9608 ms/op 2.3952 ms/op 1.24
BLS verifyMultipleSignatures 8 - blst-native 6.4346 ms/op 5.2063 ms/op 1.24
BLS verifyMultipleSignatures 32 - blst-native 23.590 ms/op 19.354 ms/op 1.22
BLS verifyMultipleSignatures 64 - blst-native 46.680 ms/op 36.780 ms/op 1.27
BLS verifyMultipleSignatures 128 - blst-native 91.802 ms/op 72.899 ms/op 1.26
BLS deserializing 10000 signatures 1.0084 s/op 795.49 ms/op 1.27
BLS deserializing 100000 signatures 9.3426 s/op 8.2272 s/op 1.14
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.3816 ms/op 1.0620 ms/op 1.30
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.5457 ms/op 1.1954 ms/op 1.29
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.3808 ms/op 2.6004 ms/op 0.92
BLS verifyMultipleSignatures - same message - 64 - blst-native 3.4843 ms/op 2.7861 ms/op 1.25
BLS verifyMultipleSignatures - same message - 128 - blst-native 5.7191 ms/op 6.6543 ms/op 0.86
BLS aggregatePubkeys 32 - blst-native 26.060 us/op 23.884 us/op 1.09
BLS aggregatePubkeys 128 - blst-native 102.97 us/op 86.897 us/op 1.18
getAttestationsForBlock 46.989 ms/op 35.754 ms/op 1.31
getSlashingsAndExits - default max 180.04 us/op 117.98 us/op 1.53
getSlashingsAndExits - 2k 347.03 us/op 321.95 us/op 1.08
proposeBlockBody type=full, size=empty 5.5833 ms/op 4.1229 ms/op 1.35
isKnown best case - 1 super set check 344.00 ns/op 298.00 ns/op 1.15
isKnown normal case - 2 super set checks 317.00 ns/op 303.00 ns/op 1.05
isKnown worse case - 16 super set checks 298.00 ns/op 311.00 ns/op 0.96
CheckpointStateCache - add get delete 5.0610 us/op 3.5490 us/op 1.43
validate api signedAggregateAndProof - struct 2.7547 ms/op 2.2706 ms/op 1.21
validate gossip signedAggregateAndProof - struct 2.7600 ms/op 2.2689 ms/op 1.22
validate gossip attestation - vc 640000 1.3496 ms/op 1.0808 ms/op 1.25
batch validate gossip attestation - vc 640000 - chunk 32 156.53 us/op 132.04 us/op 1.19
batch validate gossip attestation - vc 640000 - chunk 64 138.45 us/op 119.06 us/op 1.16
batch validate gossip attestation - vc 640000 - chunk 128 132.16 us/op 113.10 us/op 1.17
batch validate gossip attestation - vc 640000 - chunk 256 125.90 us/op 110.07 us/op 1.14
pickEth1Vote - no votes 1.1306 ms/op 870.80 us/op 1.30
pickEth1Vote - max votes 10.788 ms/op 8.5079 ms/op 1.27
pickEth1Vote - Eth1Data hashTreeRoot value x2048 21.176 ms/op 14.839 ms/op 1.43
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 24.326 ms/op 24.957 ms/op 0.97
pickEth1Vote - Eth1Data fastSerialize value x2048 567.75 us/op 396.32 us/op 1.43
pickEth1Vote - Eth1Data fastSerialize tree x2048 5.4480 ms/op 7.2075 ms/op 0.76
bytes32 toHexString 493.00 ns/op 428.00 ns/op 1.15
bytes32 Buffer.toString(hex) 278.00 ns/op 310.00 ns/op 0.90
bytes32 Buffer.toString(hex) from Uint8Array 434.00 ns/op 399.00 ns/op 1.09
bytes32 Buffer.toString(hex) + 0x 275.00 ns/op 305.00 ns/op 0.90
Object access 1 prop 0.15000 ns/op 0.18900 ns/op 0.79
Map access 1 prop 0.13800 ns/op 0.18000 ns/op 0.77
Object get x1000 7.6640 ns/op 4.7900 ns/op 1.60
Map get x1000 0.72700 ns/op 0.72500 ns/op 1.00
Object set x1000 49.377 ns/op 24.669 ns/op 2.00
Map set x1000 38.493 ns/op 16.940 ns/op 2.27
Return object 10000 times 0.23540 ns/op 0.22070 ns/op 1.07
Throw Error 10000 times 3.8483 us/op 2.6463 us/op 1.45
fastMsgIdFn sha256 / 200 bytes 3.1970 us/op 1.8920 us/op 1.69
fastMsgIdFn h32 xxhash / 200 bytes 264.00 ns/op 306.00 ns/op 0.86
fastMsgIdFn h64 xxhash / 200 bytes 329.00 ns/op 358.00 ns/op 0.92
fastMsgIdFn sha256 / 1000 bytes 11.008 us/op 5.8610 us/op 1.88
fastMsgIdFn h32 xxhash / 1000 bytes 386.00 ns/op 426.00 ns/op 0.91
fastMsgIdFn h64 xxhash / 1000 bytes 391.00 ns/op 446.00 ns/op 0.88
fastMsgIdFn sha256 / 10000 bytes 98.266 us/op 50.163 us/op 1.96
fastMsgIdFn h32 xxhash / 10000 bytes 1.9090 us/op 1.7350 us/op 1.10
fastMsgIdFn h64 xxhash / 10000 bytes 1.3060 us/op 1.2100 us/op 1.08
send data - 1000 256B messages 18.594 ms/op 11.612 ms/op 1.60
send data - 1000 512B messages 24.455 ms/op 15.134 ms/op 1.62
send data - 1000 1024B messages 38.494 ms/op 22.143 ms/op 1.74
send data - 1000 1200B messages 36.709 ms/op 28.841 ms/op 1.27
send data - 1000 2048B messages 42.827 ms/op 32.716 ms/op 1.31
send data - 1000 4096B messages 26.718 ms/op 30.230 ms/op 0.88
send data - 1000 16384B messages 117.62 ms/op 94.598 ms/op 1.24
send data - 1000 65536B messages 470.73 ms/op 455.21 ms/op 1.03
enrSubnets - fastDeserialize 64 bits 1.2050 us/op 1.2750 us/op 0.95
enrSubnets - ssz BitVector 64 bits 411.00 ns/op 495.00 ns/op 0.83
enrSubnets - fastDeserialize 4 bits 160.00 ns/op 247.00 ns/op 0.65
enrSubnets - ssz BitVector 4 bits 409.00 ns/op 505.00 ns/op 0.81
prioritizePeers score -10:0 att 32-0.1 sync 2-0 98.702 us/op 74.573 us/op 1.32
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 120.57 us/op 87.922 us/op 1.37
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 157.48 us/op 119.14 us/op 1.32
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 272.52 us/op 191.44 us/op 1.42
prioritizePeers score 0:0 att 64-1 sync 4-1 322.57 us/op 201.13 us/op 1.60
array of 16000 items push then shift 1.5420 us/op 1.3038 us/op 1.18
LinkedList of 16000 items push then shift 8.5530 ns/op 5.9650 ns/op 1.43
array of 16000 items push then pop 78.898 ns/op 86.058 ns/op 0.92
LinkedList of 16000 items push then pop 8.6710 ns/op 5.7930 ns/op 1.50
array of 24000 items push then shift 2.3772 us/op 1.8746 us/op 1.27
LinkedList of 24000 items push then shift 8.8560 ns/op 6.5900 ns/op 1.34
array of 24000 items push then pop 109.76 ns/op 104.04 ns/op 1.05
LinkedList of 24000 items push then pop 8.2940 ns/op 5.6420 ns/op 1.47
intersect bitArray bitLen 8 6.1930 ns/op 4.9470 ns/op 1.25
intersect array and set length 8 60.195 ns/op 48.429 ns/op 1.24
intersect bitArray bitLen 128 32.424 ns/op 27.681 ns/op 1.17
intersect array and set length 128 822.28 ns/op 679.87 ns/op 1.21
bitArray.getTrueBitIndexes() bitLen 128 1.4470 us/op 1.2200 us/op 1.19
bitArray.getTrueBitIndexes() bitLen 248 2.5470 us/op 2.0010 us/op 1.27
bitArray.getTrueBitIndexes() bitLen 512 4.7830 us/op 3.5390 us/op 1.35
Buffer.concat 32 items 966.00 ns/op 841.00 ns/op 1.15
Uint8Array.set 32 items 1.5960 us/op 1.4870 us/op 1.07
Set add up to 64 items then delete first 4.0190 us/op 1.7569 us/op 2.29
OrderedSet add up to 64 items then delete first 5.1651 us/op 2.6812 us/op 1.93
Set add up to 64 items then delete last 4.6268 us/op 1.9978 us/op 2.32
OrderedSet add up to 64 items then delete last 5.5967 us/op 2.9776 us/op 1.88
Set add up to 64 items then delete middle 4.5589 us/op 2.0154 us/op 2.26
OrderedSet add up to 64 items then delete middle 6.9588 us/op 4.1736 us/op 1.67
Set add up to 128 items then delete first 8.9420 us/op 3.9257 us/op 2.28
OrderedSet add up to 128 items then delete first 12.253 us/op 6.2338 us/op 1.97
Set add up to 128 items then delete last 9.0807 us/op 3.7957 us/op 2.39
OrderedSet add up to 128 items then delete last 11.129 us/op 5.7110 us/op 1.95
Set add up to 128 items then delete middle 8.6778 us/op 3.7920 us/op 2.29
OrderedSet add up to 128 items then delete middle 16.090 us/op 10.606 us/op 1.52
Set add up to 256 items then delete first 17.903 us/op 7.6586 us/op 2.34
OrderedSet add up to 256 items then delete first 24.015 us/op 12.324 us/op 1.95
Set add up to 256 items then delete last 17.290 us/op 7.7356 us/op 2.24
OrderedSet add up to 256 items then delete last 23.084 us/op 11.285 us/op 2.05
Set add up to 256 items then delete middle 18.070 us/op 7.4561 us/op 2.42
OrderedSet add up to 256 items then delete middle 44.469 us/op 30.360 us/op 1.46
transfer serialized Status (84 B) 1.6360 us/op 1.4450 us/op 1.13
copy serialized Status (84 B) 1.3680 us/op 1.2680 us/op 1.08
transfer serialized SignedVoluntaryExit (112 B) 1.7410 us/op 1.4990 us/op 1.16
copy serialized SignedVoluntaryExit (112 B) 1.6310 us/op 1.2880 us/op 1.27
transfer serialized ProposerSlashing (416 B) 3.0690 us/op 1.8650 us/op 1.65
copy serialized ProposerSlashing (416 B) 2.9570 us/op 1.7330 us/op 1.71
transfer serialized Attestation (485 B) 3.1810 us/op 1.8110 us/op 1.76
copy serialized Attestation (485 B) 2.9970 us/op 1.8050 us/op 1.66
transfer serialized AttesterSlashing (33232 B) 3.0220 us/op 1.9180 us/op 1.58
copy serialized AttesterSlashing (33232 B) 6.2370 us/op 3.8180 us/op 1.63
transfer serialized Small SignedBeaconBlock (128000 B) 3.2260 us/op 1.9940 us/op 1.62
copy serialized Small SignedBeaconBlock (128000 B) 14.347 us/op 8.7910 us/op 1.63
transfer serialized Avg SignedBeaconBlock (200000 B) 3.3500 us/op 2.0760 us/op 1.61
copy serialized Avg SignedBeaconBlock (200000 B) 20.323 us/op 12.632 us/op 1.61
transfer serialized BlobsSidecar (524380 B) 3.0630 us/op 2.5770 us/op 1.19
copy serialized BlobsSidecar (524380 B) 82.363 us/op 71.097 us/op 1.16
transfer serialized Big SignedBeaconBlock (1000000 B) 3.2880 us/op 2.9080 us/op 1.13
copy serialized Big SignedBeaconBlock (1000000 B) 152.75 us/op 148.10 us/op 1.03
pass gossip attestations to forkchoice per slot 3.6810 ms/op 3.0737 ms/op 1.20
forkChoice updateHead vc 100000 bc 64 eq 0 726.79 us/op 450.39 us/op 1.61
forkChoice updateHead vc 600000 bc 64 eq 0 4.1434 ms/op 2.6412 ms/op 1.57
forkChoice updateHead vc 1000000 bc 64 eq 0 8.4793 ms/op 4.5983 ms/op 1.84
forkChoice updateHead vc 600000 bc 320 eq 0 4.0323 ms/op 2.8212 ms/op 1.43
forkChoice updateHead vc 600000 bc 1200 eq 0 4.3199 ms/op 3.0553 ms/op 1.41
forkChoice updateHead vc 600000 bc 7200 eq 0 5.2884 ms/op 3.5951 ms/op 1.47
forkChoice updateHead vc 600000 bc 64 eq 1000 11.114 ms/op 9.9137 ms/op 1.12
forkChoice updateHead vc 600000 bc 64 eq 10000 11.872 ms/op 9.7168 ms/op 1.22
forkChoice updateHead vc 600000 bc 64 eq 300000 16.187 ms/op 13.124 ms/op 1.23
computeDeltas 500000 validators 300 proto nodes 6.5458 ms/op 3.0592 ms/op 2.14
computeDeltas 500000 validators 1200 proto nodes 6.3558 ms/op 2.9531 ms/op 2.15
computeDeltas 500000 validators 7200 proto nodes 6.2606 ms/op 3.0783 ms/op 2.03
computeDeltas 750000 validators 300 proto nodes 9.5309 ms/op 4.6321 ms/op 2.06
computeDeltas 750000 validators 1200 proto nodes 9.5547 ms/op 4.5074 ms/op 2.12
computeDeltas 750000 validators 7200 proto nodes 9.6552 ms/op 4.7118 ms/op 2.05
computeDeltas 1400000 validators 300 proto nodes 18.537 ms/op 8.9739 ms/op 2.07
computeDeltas 1400000 validators 1200 proto nodes 18.562 ms/op 9.2702 ms/op 2.00
computeDeltas 1400000 validators 7200 proto nodes 18.431 ms/op 9.7743 ms/op 1.89
computeDeltas 2100000 validators 300 proto nodes 27.487 ms/op 14.285 ms/op 1.92
computeDeltas 2100000 validators 1200 proto nodes 27.617 ms/op 14.599 ms/op 1.89
computeDeltas 2100000 validators 7200 proto nodes 27.261 ms/op 13.592 ms/op 2.01
computeProposerBoostScoreFromBalances 500000 validators 3.6142 ms/op 3.3153 ms/op 1.09
computeProposerBoostScoreFromBalances 750000 validators 3.5600 ms/op 3.2474 ms/op 1.10
computeProposerBoostScoreFromBalances 1400000 validators 3.5983 ms/op 3.2345 ms/op 1.11
computeProposerBoostScoreFromBalances 2100000 validators 3.7383 ms/op 3.1975 ms/op 1.17
altair processAttestation - 250000 vs - 7PWei normalcase 2.1137 ms/op 1.8449 ms/op 1.15
altair processAttestation - 250000 vs - 7PWei worstcase 3.1445 ms/op 2.6921 ms/op 1.17
altair processAttestation - setStatus - 1/6 committees join 139.00 us/op 94.724 us/op 1.47
altair processAttestation - setStatus - 1/3 committees join 271.74 us/op 194.85 us/op 1.39
altair processAttestation - setStatus - 1/2 committees join 385.89 us/op 271.06 us/op 1.42
altair processAttestation - setStatus - 2/3 committees join 461.96 us/op 366.91 us/op 1.26
altair processAttestation - setStatus - 4/5 committees join 631.59 us/op 496.05 us/op 1.27
altair processAttestation - setStatus - 100% committees join 770.16 us/op 591.50 us/op 1.30
altair processBlock - 250000 vs - 7PWei normalcase 10.232 ms/op 8.2950 ms/op 1.23
altair processBlock - 250000 vs - 7PWei normalcase hashState 39.326 ms/op 24.380 ms/op 1.61
altair processBlock - 250000 vs - 7PWei worstcase 36.049 ms/op 30.569 ms/op 1.18
altair processBlock - 250000 vs - 7PWei worstcase hashState 93.089 ms/op 63.411 ms/op 1.47
phase0 processBlock - 250000 vs - 7PWei normalcase 2.4969 ms/op 2.7389 ms/op 0.91
phase0 processBlock - 250000 vs - 7PWei worstcase 29.829 ms/op 25.924 ms/op 1.15
altair processEth1Data - 250000 vs - 7PWei normalcase 504.69 us/op 291.52 us/op 1.73
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 11.620 us/op 11.579 us/op 1.00
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 31.828 us/op 26.475 us/op 1.20
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 16.956 us/op 15.050 us/op 1.13
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 10.404 us/op 14.585 us/op 0.71
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 164.38 us/op 171.90 us/op 0.96
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.0783 ms/op 1.2924 ms/op 0.83
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.5019 ms/op 1.4515 ms/op 1.03
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.4919 ms/op 1.1550 ms/op 1.29
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 2.9708 ms/op 2.4762 ms/op 1.20
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.2967 ms/op 1.8162 ms/op 1.26
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 4.5864 ms/op 4.1865 ms/op 1.10
Tree 40 250000 create 346.28 ms/op 280.51 ms/op 1.23
Tree 40 250000 get(125000) 197.65 ns/op 118.85 ns/op 1.66
Tree 40 250000 set(125000) 1.0193 us/op 896.08 ns/op 1.14
Tree 40 250000 toArray() 18.309 ms/op 20.334 ms/op 0.90
Tree 40 250000 iterate all - toArray() + loop 18.384 ms/op 21.357 ms/op 0.86
Tree 40 250000 iterate all - get(i) 63.741 ms/op 48.717 ms/op 1.31
MutableVector 250000 create 10.757 ms/op 13.569 ms/op 0.79
MutableVector 250000 get(125000) 6.2300 ns/op 6.0330 ns/op 1.03
MutableVector 250000 set(125000) 262.07 ns/op 204.21 ns/op 1.28
MutableVector 250000 toArray() 4.9831 ms/op 2.1924 ms/op 2.27
MutableVector 250000 iterate all - toArray() + loop 3.3271 ms/op 2.6240 ms/op 1.27
MutableVector 250000 iterate all - get(i) 1.5400 ms/op 1.3465 ms/op 1.14
Array 250000 create 2.4658 ms/op 2.1555 ms/op 1.14
Array 250000 clone - spread 1.2242 ms/op 1.2518 ms/op 0.98
Array 250000 get(125000) 1.0370 ns/op 1.0690 ns/op 0.97
Array 250000 set(125000) 4.1310 ns/op 1.2810 ns/op 3.22
Array 250000 iterate all - loop 166.22 us/op 154.58 us/op 1.08
effectiveBalanceIncrements clone Uint8Array 300000 25.009 us/op 15.007 us/op 1.67
effectiveBalanceIncrements clone MutableVector 300000 331.00 ns/op 448.00 ns/op 0.74
effectiveBalanceIncrements rw all Uint8Array 300000 191.76 us/op 186.29 us/op 1.03
effectiveBalanceIncrements rw all MutableVector 300000 76.803 ms/op 65.813 ms/op 1.17
phase0 afterProcessEpoch - 250000 vs - 7PWei 105.45 ms/op 75.252 ms/op 1.40
phase0 beforeProcessEpoch - 250000 vs - 7PWei 51.352 ms/op 45.205 ms/op 1.14
altair processEpoch - mainnet_e81889 511.39 ms/op 387.59 ms/op 1.32
mainnet_e81889 - altair beforeProcessEpoch 81.161 ms/op 72.125 ms/op 1.13
mainnet_e81889 - altair processJustificationAndFinalization 13.826 us/op 10.813 us/op 1.28
mainnet_e81889 - altair processInactivityUpdates 5.6030 ms/op 4.1132 ms/op 1.36
mainnet_e81889 - altair processRewardsAndPenalties 61.860 ms/op 55.843 ms/op 1.11
mainnet_e81889 - altair processRegistryUpdates 2.6950 us/op 1.7710 us/op 1.52
mainnet_e81889 - altair processSlashings 455.00 ns/op 540.00 ns/op 0.84
mainnet_e81889 - altair processEth1DataReset 471.00 ns/op 591.00 ns/op 0.80
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.4269 ms/op 1.8053 ms/op 0.79
mainnet_e81889 - altair processSlashingsReset 3.4330 us/op 2.4310 us/op 1.41
mainnet_e81889 - altair processRandaoMixesReset 3.7210 us/op 2.0710 us/op 1.80
mainnet_e81889 - altair processHistoricalRootsUpdate 621.00 ns/op 453.00 ns/op 1.37
mainnet_e81889 - altair processParticipationFlagUpdates 2.2300 us/op 1.9440 us/op 1.15
mainnet_e81889 - altair processSyncCommitteeUpdates 650.00 ns/op 617.00 ns/op 1.05
mainnet_e81889 - altair afterProcessEpoch 118.14 ms/op 76.964 ms/op 1.54
capella processEpoch - mainnet_e217614 2.0650 s/op 1.8234 s/op 1.13
mainnet_e217614 - capella beforeProcessEpoch 482.10 ms/op 455.62 ms/op 1.06
mainnet_e217614 - capella processJustificationAndFinalization 19.017 us/op 10.998 us/op 1.73
mainnet_e217614 - capella processInactivityUpdates 21.408 ms/op 13.550 ms/op 1.58
mainnet_e217614 - capella processRewardsAndPenalties 430.52 ms/op 355.07 ms/op 1.21
mainnet_e217614 - capella processRegistryUpdates 18.717 us/op 7.3120 us/op 2.56
mainnet_e217614 - capella processSlashings 585.00 ns/op 306.00 ns/op 1.91
mainnet_e217614 - capella processEth1DataReset 409.00 ns/op 285.00 ns/op 1.44
mainnet_e217614 - capella processEffectiveBalanceUpdates 4.2885 ms/op 7.5275 ms/op 0.57
mainnet_e217614 - capella processSlashingsReset 3.5330 us/op 1.3640 us/op 2.59
mainnet_e217614 - capella processRandaoMixesReset 4.4820 us/op 1.6700 us/op 2.68
mainnet_e217614 - capella processHistoricalRootsUpdate 621.00 ns/op 300.00 ns/op 2.07
mainnet_e217614 - capella processParticipationFlagUpdates 1.9380 us/op 1.1930 us/op 1.62
mainnet_e217614 - capella afterProcessEpoch 290.76 ms/op 196.45 ms/op 1.48
phase0 processEpoch - mainnet_e58758 425.81 ms/op 401.08 ms/op 1.06
mainnet_e58758 - phase0 beforeProcessEpoch 121.18 ms/op 116.07 ms/op 1.04
mainnet_e58758 - phase0 processJustificationAndFinalization 14.886 us/op 10.065 us/op 1.48
mainnet_e58758 - phase0 processRewardsAndPenalties 51.750 ms/op 46.073 ms/op 1.12
mainnet_e58758 - phase0 processRegistryUpdates 9.1730 us/op 6.9130 us/op 1.33
mainnet_e58758 - phase0 processSlashings 512.00 ns/op 599.00 ns/op 0.85
mainnet_e58758 - phase0 processEth1DataReset 394.00 ns/op 477.00 ns/op 0.83
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.1487 ms/op 1.3896 ms/op 0.83
mainnet_e58758 - phase0 processSlashingsReset 2.7440 us/op 2.4460 us/op 1.12
mainnet_e58758 - phase0 processRandaoMixesReset 3.6880 us/op 2.6610 us/op 1.39
mainnet_e58758 - phase0 processHistoricalRootsUpdate 423.00 ns/op 542.00 ns/op 0.78
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.5110 us/op 2.4930 us/op 1.81
mainnet_e58758 - phase0 afterProcessEpoch 93.402 ms/op 62.593 ms/op 1.49
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.4315 ms/op 956.39 us/op 1.50
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.9412 ms/op 1.1427 ms/op 1.70
altair processInactivityUpdates - 250000 normalcase 23.402 ms/op 22.079 ms/op 1.06
altair processInactivityUpdates - 250000 worstcase 21.601 ms/op 22.058 ms/op 0.98
phase0 processRegistryUpdates - 250000 normalcase 8.2460 us/op 4.8510 us/op 1.70
phase0 processRegistryUpdates - 250000 badcase_full_deposits 311.46 us/op 366.01 us/op 0.85
phase0 processRegistryUpdates - 250000 worstcase 0.5 118.83 ms/op 120.75 ms/op 0.98
altair processRewardsAndPenalties - 250000 normalcase 57.297 ms/op 60.206 ms/op 0.95
altair processRewardsAndPenalties - 250000 worstcase 55.460 ms/op 50.244 ms/op 1.10
phase0 getAttestationDeltas - 250000 normalcase 8.8450 ms/op 5.6864 ms/op 1.56
phase0 getAttestationDeltas - 250000 worstcase 8.9998 ms/op 5.8095 ms/op 1.55
phase0 processSlashings - 250000 worstcase 80.321 us/op 75.206 us/op 1.07
altair processSyncCommitteeUpdates - 250000 154.42 ms/op 112.03 ms/op 1.38
BeaconState.hashTreeRoot - No change 237.00 ns/op 334.00 ns/op 0.71
BeaconState.hashTreeRoot - 1 full validator 138.08 us/op 145.71 us/op 0.95
BeaconState.hashTreeRoot - 32 full validator 1.7744 ms/op 1.4313 ms/op 1.24
BeaconState.hashTreeRoot - 512 full validator 18.342 ms/op 15.113 ms/op 1.21
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 191.76 us/op 154.47 us/op 1.24
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.5589 ms/op 1.7267 ms/op 1.48
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 23.021 ms/op 28.225 ms/op 0.82
BeaconState.hashTreeRoot - 1 balances 133.71 us/op 148.62 us/op 0.90
BeaconState.hashTreeRoot - 32 balances 1.2843 ms/op 1.1362 ms/op 1.13
BeaconState.hashTreeRoot - 512 balances 13.809 ms/op 13.086 ms/op 1.06
BeaconState.hashTreeRoot - 250000 balances 217.89 ms/op 189.78 ms/op 1.15
aggregationBits - 2048 els - zipIndexesInBitList 16.391 us/op 12.280 us/op 1.33
byteArrayEquals 32 75.125 ns/op 60.721 ns/op 1.24
Buffer.compare 32 55.762 ns/op 34.767 ns/op 1.60
byteArrayEquals 1024 2.0482 us/op 1.6204 us/op 1.26
Buffer.compare 1024 70.939 ns/op 40.030 ns/op 1.77
byteArrayEquals 16384 32.664 us/op 25.795 us/op 1.27
Buffer.compare 16384 274.31 ns/op 221.55 ns/op 1.24
byteArrayEquals 123687377 244.41 ms/op 196.23 ms/op 1.25
Buffer.compare 123687377 6.1518 ms/op 4.0995 ms/op 1.50
byteArrayEquals 32 - diff last byte 69.343 ns/op 61.757 ns/op 1.12
Buffer.compare 32 - diff last byte 54.751 ns/op 38.741 ns/op 1.41
byteArrayEquals 1024 - diff last byte 1.9673 us/op 1.7580 us/op 1.12
Buffer.compare 1024 - diff last byte 69.606 ns/op 47.631 ns/op 1.46
byteArrayEquals 16384 - diff last byte 31.251 us/op 28.052 us/op 1.11
Buffer.compare 16384 - diff last byte 241.87 ns/op 228.11 ns/op 1.06
byteArrayEquals 123687377 - diff last byte 244.92 ms/op 208.86 ms/op 1.17
Buffer.compare 123687377 - diff last byte 6.0729 ms/op 3.8039 ms/op 1.60
byteArrayEquals 32 - random bytes 5.3340 ns/op 4.6480 ns/op 1.15
Buffer.compare 32 - random bytes 60.147 ns/op 39.861 ns/op 1.51
byteArrayEquals 1024 - random bytes 5.1720 ns/op 4.5030 ns/op 1.15
Buffer.compare 1024 - random bytes 59.535 ns/op 38.051 ns/op 1.56
byteArrayEquals 16384 - random bytes 5.1520 ns/op 4.6420 ns/op 1.11
Buffer.compare 16384 - random bytes 59.389 ns/op 37.767 ns/op 1.57
byteArrayEquals 123687377 - random bytes 8.4000 ns/op 7.7900 ns/op 1.08
Buffer.compare 123687377 - random bytes 62.490 ns/op 42.000 ns/op 1.49
regular array get 100000 times 43.733 us/op 41.936 us/op 1.04
wrappedArray get 100000 times 43.897 us/op 41.118 us/op 1.07
arrayWithProxy get 100000 times 15.612 ms/op 10.656 ms/op 1.47
ssz.Root.equals 52.441 ns/op 55.792 ns/op 0.94
byteArrayEquals 51.076 ns/op 54.987 ns/op 0.93
Buffer.compare 10.399 ns/op 9.5290 ns/op 1.09
shuffle list - 16384 els 6.8958 ms/op 4.5485 ms/op 1.52
shuffle list - 250000 els 101.46 ms/op 67.100 ms/op 1.51
processSlot - 1 slots 16.045 us/op 12.792 us/op 1.25
processSlot - 32 slots 3.6101 ms/op 3.4739 ms/op 1.04
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 57.983 ms/op 54.463 ms/op 1.06
getCommitteeAssignments - req 1 vs - 250000 vc 2.4913 ms/op 2.1592 ms/op 1.15
getCommitteeAssignments - req 100 vs - 250000 vc 3.6688 ms/op 3.2509 ms/op 1.13
getCommitteeAssignments - req 1000 vs - 250000 vc 3.9875 ms/op 3.6894 ms/op 1.08
findModifiedValidators - 10000 modified validators 568.88 ms/op 415.91 ms/op 1.37
findModifiedValidators - 1000 modified validators 427.04 ms/op 328.85 ms/op 1.30
findModifiedValidators - 100 modified validators 392.00 ms/op 288.82 ms/op 1.36
findModifiedValidators - 10 modified validators 405.50 ms/op 309.41 ms/op 1.31
findModifiedValidators - 1 modified validators 395.92 ms/op 288.79 ms/op 1.37
findModifiedValidators - no difference 386.81 ms/op 300.13 ms/op 1.29
compare ViewDUs 4.3753 s/op 3.8290 s/op 1.14
compare each validator Uint8Array 1.3846 s/op 1.9063 s/op 0.73
compare ViewDU to Uint8Array 1.0717 s/op 759.63 ms/op 1.41
migrate state 1000000 validators, 24 modified, 0 new 789.80 ms/op 760.64 ms/op 1.04
migrate state 1000000 validators, 1700 modified, 1000 new 1.0921 s/op 994.25 ms/op 1.10
migrate state 1000000 validators, 3400 modified, 2000 new 1.3200 s/op 1.2249 s/op 1.08
migrate state 1500000 validators, 24 modified, 0 new 793.11 ms/op 742.34 ms/op 1.07
migrate state 1500000 validators, 1700 modified, 1000 new 1.0840 s/op 1.0026 s/op 1.08
migrate state 1500000 validators, 3400 modified, 2000 new 1.3195 s/op 1.1121 s/op 1.19
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 3.9200 ns/op 4.4400 ns/op 0.88
state getBlockRootAtSlot - 250000 vs - 7PWei 797.47 ns/op 390.48 ns/op 2.04
computeProposers - vc 250000 8.9477 ms/op 5.6602 ms/op 1.58
computeEpochShuffling - vc 250000 97.030 ms/op 65.540 ms/op 1.48
getNextSyncCommittee - vc 250000 146.30 ms/op 97.056 ms/op 1.51
computeSigningRoot for AttestationData 26.315 us/op 16.627 us/op 1.58
hash AttestationData serialized data then Buffer.toString(base64) 2.2558 us/op 1.2787 us/op 1.76
toHexString serialized data 997.93 ns/op 828.93 ns/op 1.20
Buffer.toString(base64) 197.04 ns/op 147.56 ns/op 1.34

by benchmarkbot/action

@twoeths twoeths marked this pull request as ready for review January 5, 2024 04:45
@twoeths twoeths requested a review from a team as a code owner January 5, 2024 04:45

const recentBlsToExecutionChangeIndexes = new Set(
recentBlsToExecutionChanges.map((blsToExecutionChange) => blsToExecutionChange.message.validatorIndex)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

This check looks insufficient. The prune handler is only called once per finalization event ~1 time / epoch. Then only the execution changes included in that block will be pruned, with all remaining changes staying there.

A more complete solution, using our state caches:

Attach new cache to the state:

  • appliedBlsToExecutionChangesCurrentEpoch
  • appliedBlsToExecutionChangesPreviousEpoch

During block processing you register the validator index of applied execution changes. During epoch transition you rotate the caches. Then to prune you use the appliedBlsToExecutionChangesPreviousEpoch list to prune those. This will give you the complete list of items to prune if there are no re-orgs deeper than 1 epoch, which is an okay compromise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then only the execution changes included in that block will be pruned, with all remaining changes staying there.

just to clarify, execution changes in the head block is not pruned, others will be pruned. So we store BLSToExecutionChange messages in max 33 slots

A more complete solution, using our state caches

the solution works, however I think it's too much for this feature since we have to apply ImmutableJS to maintain these 2 arrays like in EIP-6110 implementation #6042 Also it's tricky in the edge case

I think there are pros and cons for these 2 solutions:

# BLSToExecutionChange messages in block slot in opPool pros cons
current 3 epochs straightforward have to query the finalized state
no state cache (this PR) 1 slot to 33 slots no state cache is needed, lighthouse runs it since capella cover 1-slot reorg scenario only
state cache (Lion's suggestion) 32 slots to 64 slots cover up to 1-epoch reorg scenario need to have 2 ImmutableJS arrays maintained, also need to think about edge case when finalized checkpoint happens >4s, after clock epoch

I prefer the no state cache approach as it's worked for lighthouse since capella and in the worse case if the reorg happen, it'll not affect block reward (if it's the bn's turn to propose block) and messages will be added back once gossip seenTTL passes anyway, I'd like to know others' opinions cc @wemeetagain @g11tech

Copy link
Member

Choose a reason for hiding this comment

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

I think what @tuyennhv proposed here is sufficient and his reasoning is sound.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, thanks for the table! please monitor metrics after deploying to check the pool is not growing

Copy link
Contributor

Choose a reason for hiding this comment

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

the heuristic is fine i guess, since no one is anyway producing these messages and deep reorgs are rare on mainnet

@twoeths twoeths merged commit ea49409 into unstable Jan 9, 2024
14 of 15 checks passed
@twoeths twoeths deleted the tuyen/prune_bls_to_execution_change_with_head_state branch January 9, 2024 01:17
@wemeetagain
Copy link
Member

🎉 This PR is included in v1.14.0 🎉

ensi321 pushed a commit to ensi321/lodestar that referenced this pull request Jan 22, 2024
* feat: prune BlsToExecutionChange opPool with head state

* fix: address PR comment
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.

5 participants