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: optimistically verify blocks even before all blobs available #6087

Merged
merged 2 commits into from
Dec 19, 2023

Conversation

g11tech
Copy link
Contributor

@g11tech g11tech commented Nov 5, 2023

(WIP)

while all blobs become available, block can be optimistically verified to save any delays on the import times

this PR implements blockInput with blobsPromise that need to resolve before the block can be imported in a timebound manner else the unknownblock/blob search is initiated

TODO:

  • cleanup
  • add metrics
  • fix tests/types check
  • devnet 11
    • postDeneb blobs
    • blobs with promise
    • promise failing with unknown block search

@g11tech g11tech requested a review from a team as a code owner November 5, 2023 19:31
Copy link
Contributor

github-actions bot commented Nov 5, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 4156b90 Previous: d3005bf Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 804.18 us/op 617.22 us/op 1.30
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 90.928 us/op 84.778 us/op 1.07
BLS verify - blst-native 1.3229 ms/op 1.3312 ms/op 0.99
BLS verifyMultipleSignatures 3 - blst-native 2.7967 ms/op 2.8139 ms/op 0.99
BLS verifyMultipleSignatures 8 - blst-native 6.1350 ms/op 6.1753 ms/op 0.99
BLS verifyMultipleSignatures 32 - blst-native 22.205 ms/op 22.547 ms/op 0.98
BLS verifyMultipleSignatures 64 - blst-native 43.881 ms/op 44.476 ms/op 0.99
BLS verifyMultipleSignatures 128 - blst-native 87.265 ms/op 88.753 ms/op 0.98
BLS deserializing 10000 signatures 949.62 ms/op 920.68 ms/op 1.03
BLS deserializing 100000 signatures 9.6078 s/op 9.6734 s/op 0.99
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.3534 ms/op 1.3640 ms/op 0.99
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.5311 ms/op 1.6998 ms/op 0.90
BLS verifyMultipleSignatures - same message - 32 - blst-native 3.0155 ms/op 2.9494 ms/op 1.02
BLS verifyMultipleSignatures - same message - 64 - blst-native 3.4489 ms/op 4.2028 ms/op 0.82
BLS verifyMultipleSignatures - same message - 128 - blst-native 5.6502 ms/op 7.2895 ms/op 0.78
BLS aggregatePubkeys 32 - blst-native 27.937 us/op 27.930 us/op 1.00
BLS aggregatePubkeys 128 - blst-native 100.71 us/op 101.14 us/op 1.00
getAttestationsForBlock 50.096 ms/op 53.125 ms/op 0.94
getSlashingsAndExits - default max 178.67 us/op 159.65 us/op 1.12
getSlashingsAndExits - 2k 488.70 us/op 423.24 us/op 1.15
proposeBlockBody type=full, size=empty 5.6200 ms/op 5.4065 ms/op 1.04
isKnown best case - 1 super set check 575.00 ns/op 328.00 ns/op 1.75
isKnown normal case - 2 super set checks 482.00 ns/op 309.00 ns/op 1.56
isKnown worse case - 16 super set checks 406.00 ns/op 312.00 ns/op 1.30
CheckpointStateCache - add get delete 6.1550 us/op 5.6810 us/op 1.08
validate api signedAggregateAndProof - struct 2.8643 ms/op 2.7903 ms/op 1.03
validate gossip signedAggregateAndProof - struct 2.8387 ms/op 2.8286 ms/op 1.00
validate gossip attestation - vc 640000 1.4131 ms/op 1.3615 ms/op 1.04
batch validate gossip attestation - vc 640000 - chunk 32 168.90 us/op 164.73 us/op 1.03
batch validate gossip attestation - vc 640000 - chunk 64 150.24 us/op 144.69 us/op 1.04
batch validate gossip attestation - vc 640000 - chunk 128 150.08 us/op 136.49 us/op 1.10
batch validate gossip attestation - vc 640000 - chunk 256 138.22 us/op 138.43 us/op 1.00
pickEth1Vote - no votes 1.2876 ms/op 1.1773 ms/op 1.09
pickEth1Vote - max votes 11.906 ms/op 10.561 ms/op 1.13
pickEth1Vote - Eth1Data hashTreeRoot value x2048 23.918 ms/op 21.590 ms/op 1.11
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 34.394 ms/op 29.080 ms/op 1.18
pickEth1Vote - Eth1Data fastSerialize value x2048 657.65 us/op 613.04 us/op 1.07
pickEth1Vote - Eth1Data fastSerialize tree x2048 5.6534 ms/op 4.5670 ms/op 1.24
bytes32 toHexString 527.00 ns/op 506.00 ns/op 1.04
bytes32 Buffer.toString(hex) 308.00 ns/op 293.00 ns/op 1.05
bytes32 Buffer.toString(hex) from Uint8Array 502.00 ns/op 451.00 ns/op 1.11
bytes32 Buffer.toString(hex) + 0x 308.00 ns/op 285.00 ns/op 1.08
Object access 1 prop 0.19200 ns/op 0.15900 ns/op 1.21
Map access 1 prop 0.14900 ns/op 0.15000 ns/op 0.99
Object get x1000 7.3690 ns/op 7.4470 ns/op 0.99
Map get x1000 0.84700 ns/op 0.78500 ns/op 1.08
Object set x1000 64.916 ns/op 52.329 ns/op 1.24
Map set x1000 51.407 ns/op 40.201 ns/op 1.28
Return object 10000 times 0.24780 ns/op 0.24360 ns/op 1.02
Throw Error 10000 times 3.9411 us/op 3.8881 us/op 1.01
fastMsgIdFn sha256 / 200 bytes 3.4290 us/op 3.3250 us/op 1.03
fastMsgIdFn h32 xxhash / 200 bytes 343.00 ns/op 278.00 ns/op 1.23
fastMsgIdFn h64 xxhash / 200 bytes 391.00 ns/op 338.00 ns/op 1.16
fastMsgIdFn sha256 / 1000 bytes 11.892 us/op 11.364 us/op 1.05
fastMsgIdFn h32 xxhash / 1000 bytes 469.00 ns/op 409.00 ns/op 1.15
fastMsgIdFn h64 xxhash / 1000 bytes 459.00 ns/op 408.00 ns/op 1.13
fastMsgIdFn sha256 / 10000 bytes 105.40 us/op 106.47 us/op 0.99
fastMsgIdFn h32 xxhash / 10000 bytes 2.0030 us/op 2.0190 us/op 0.99
fastMsgIdFn h64 xxhash / 10000 bytes 1.3860 us/op 1.3740 us/op 1.01
send data - 1000 256B messages 22.060 ms/op 19.153 ms/op 1.15
send data - 1000 512B messages 28.712 ms/op 25.787 ms/op 1.11
send data - 1000 1024B messages 43.780 ms/op 41.459 ms/op 1.06
send data - 1000 1200B messages 41.971 ms/op 36.869 ms/op 1.14
send data - 1000 2048B messages 43.955 ms/op 43.427 ms/op 1.01
send data - 1000 4096B messages 32.093 ms/op 40.855 ms/op 0.79
send data - 1000 16384B messages 124.72 ms/op 110.65 ms/op 1.13
send data - 1000 65536B messages 504.03 ms/op 393.80 ms/op 1.28
enrSubnets - fastDeserialize 64 bits 1.6530 us/op 1.3990 us/op 1.18
enrSubnets - ssz BitVector 64 bits 541.00 ns/op 436.00 ns/op 1.24
enrSubnets - fastDeserialize 4 bits 205.00 ns/op 178.00 ns/op 1.15
enrSubnets - ssz BitVector 4 bits 517.00 ns/op 498.00 ns/op 1.04
prioritizePeers score -10:0 att 32-0.1 sync 2-0 111.80 us/op 112.36 us/op 0.99
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 148.05 us/op 138.33 us/op 1.07
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 178.42 us/op 210.82 us/op 0.85
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 337.29 us/op 328.38 us/op 1.03
prioritizePeers score 0:0 att 64-1 sync 4-1 389.07 us/op 363.63 us/op 1.07
array of 16000 items push then shift 1.7174 us/op 1.6982 us/op 1.01
LinkedList of 16000 items push then shift 9.2280 ns/op 9.2030 ns/op 1.00
array of 16000 items push then pop 104.52 ns/op 92.952 ns/op 1.12
LinkedList of 16000 items push then pop 9.2230 ns/op 9.1290 ns/op 1.01
array of 24000 items push then shift 2.6106 us/op 2.5526 us/op 1.02
LinkedList of 24000 items push then shift 9.8700 ns/op 9.1850 ns/op 1.07
array of 24000 items push then pop 155.40 ns/op 139.72 ns/op 1.11
LinkedList of 24000 items push then pop 9.0180 ns/op 9.3410 ns/op 0.97
intersect bitArray bitLen 8 6.6110 ns/op 6.5000 ns/op 1.02
intersect array and set length 8 81.698 ns/op 64.549 ns/op 1.27
intersect bitArray bitLen 128 34.052 ns/op 34.527 ns/op 0.99
intersect array and set length 128 1.0775 us/op 913.79 ns/op 1.18
bitArray.getTrueBitIndexes() bitLen 128 1.7660 us/op 1.5750 us/op 1.12
bitArray.getTrueBitIndexes() bitLen 248 2.9870 us/op 2.6710 us/op 1.12
bitArray.getTrueBitIndexes() bitLen 512 6.3450 us/op 5.0820 us/op 1.25
Buffer.concat 32 items 1.0340 us/op 995.00 ns/op 1.04
Uint8Array.set 32 items 1.9040 us/op 1.9390 us/op 0.98
Set add up to 64 items then delete first 5.1026 us/op 4.3020 us/op 1.19
OrderedSet add up to 64 items then delete first 6.7342 us/op 5.4105 us/op 1.24
Set add up to 64 items then delete last 5.4823 us/op 4.5840 us/op 1.20
OrderedSet add up to 64 items then delete last 7.1965 us/op 5.7861 us/op 1.24
Set add up to 64 items then delete middle 5.4010 us/op 4.6169 us/op 1.17
OrderedSet add up to 64 items then delete middle 8.4883 us/op 7.0188 us/op 1.21
Set add up to 128 items then delete first 10.828 us/op 9.3565 us/op 1.16
OrderedSet add up to 128 items then delete first 14.453 us/op 12.271 us/op 1.18
Set add up to 128 items then delete last 10.737 us/op 9.2541 us/op 1.16
OrderedSet add up to 128 items then delete last 14.621 us/op 11.698 us/op 1.25
Set add up to 128 items then delete middle 10.924 us/op 9.1948 us/op 1.19
OrderedSet add up to 128 items then delete middle 20.318 us/op 16.720 us/op 1.22
Set add up to 256 items then delete first 21.703 us/op 18.887 us/op 1.15
OrderedSet add up to 256 items then delete first 29.803 us/op 25.468 us/op 1.17
Set add up to 256 items then delete last 21.655 us/op 18.273 us/op 1.19
OrderedSet add up to 256 items then delete last 28.680 us/op 23.172 us/op 1.24
Set add up to 256 items then delete middle 21.216 us/op 18.396 us/op 1.15
OrderedSet add up to 256 items then delete middle 51.628 us/op 44.760 us/op 1.15
transfer serialized Status (84 B) 2.1210 us/op 1.7380 us/op 1.22
copy serialized Status (84 B) 1.6920 us/op 1.5060 us/op 1.12
transfer serialized SignedVoluntaryExit (112 B) 2.0960 us/op 1.9820 us/op 1.06
copy serialized SignedVoluntaryExit (112 B) 1.7660 us/op 1.5850 us/op 1.11
transfer serialized ProposerSlashing (416 B) 2.6300 us/op 2.2780 us/op 1.15
copy serialized ProposerSlashing (416 B) 2.8920 us/op 3.1300 us/op 0.92
transfer serialized Attestation (485 B) 2.7880 us/op 3.2250 us/op 0.86
copy serialized Attestation (485 B) 2.7530 us/op 3.1250 us/op 0.88
transfer serialized AttesterSlashing (33232 B) 2.5610 us/op 3.2180 us/op 0.80
copy serialized AttesterSlashing (33232 B) 9.3410 us/op 6.6130 us/op 1.41
transfer serialized Small SignedBeaconBlock (128000 B) 2.9340 us/op 3.0560 us/op 0.96
copy serialized Small SignedBeaconBlock (128000 B) 34.281 us/op 17.824 us/op 1.92
transfer serialized Avg SignedBeaconBlock (200000 B) 3.2550 us/op 3.1870 us/op 1.02
copy serialized Avg SignedBeaconBlock (200000 B) 34.875 us/op 21.438 us/op 1.63
transfer serialized BlobsSidecar (524380 B) 3.5500 us/op 3.1260 us/op 1.14
copy serialized BlobsSidecar (524380 B) 105.57 us/op 97.942 us/op 1.08
transfer serialized Big SignedBeaconBlock (1000000 B) 3.8270 us/op 3.2070 us/op 1.19
copy serialized Big SignedBeaconBlock (1000000 B) 187.63 us/op 219.30 us/op 0.86
pass gossip attestations to forkchoice per slot 4.4235 ms/op 4.2704 ms/op 1.04
forkChoice updateHead vc 100000 bc 64 eq 0 715.03 us/op 686.62 us/op 1.04
forkChoice updateHead vc 600000 bc 64 eq 0 4.6814 ms/op 4.6733 ms/op 1.00
forkChoice updateHead vc 1000000 bc 64 eq 0 8.0683 ms/op 7.1046 ms/op 1.14
forkChoice updateHead vc 600000 bc 320 eq 0 4.8887 ms/op 4.2697 ms/op 1.14
forkChoice updateHead vc 600000 bc 1200 eq 0 4.6989 ms/op 4.3061 ms/op 1.09
forkChoice updateHead vc 600000 bc 7200 eq 0 6.0912 ms/op 5.5790 ms/op 1.09
forkChoice updateHead vc 600000 bc 64 eq 1000 11.724 ms/op 11.315 ms/op 1.04
forkChoice updateHead vc 600000 bc 64 eq 10000 12.661 ms/op 12.085 ms/op 1.05
forkChoice updateHead vc 600000 bc 64 eq 300000 32.506 ms/op 16.275 ms/op 2.00
computeDeltas 500000 validators 300 proto nodes 7.1333 ms/op 6.8184 ms/op 1.05
computeDeltas 500000 validators 1200 proto nodes 6.6751 ms/op 6.6462 ms/op 1.00
computeDeltas 500000 validators 7200 proto nodes 6.3759 ms/op 6.4632 ms/op 0.99
computeDeltas 750000 validators 300 proto nodes 9.6283 ms/op 9.7178 ms/op 0.99
computeDeltas 750000 validators 1200 proto nodes 9.5982 ms/op 9.6766 ms/op 0.99
computeDeltas 750000 validators 7200 proto nodes 9.6458 ms/op 9.9186 ms/op 0.97
computeDeltas 1400000 validators 300 proto nodes 18.555 ms/op 18.761 ms/op 0.99
computeDeltas 1400000 validators 1200 proto nodes 19.373 ms/op 19.513 ms/op 0.99
computeDeltas 1400000 validators 7200 proto nodes 19.548 ms/op 19.919 ms/op 0.98
computeDeltas 2100000 validators 300 proto nodes 28.960 ms/op 29.037 ms/op 1.00
computeDeltas 2100000 validators 1200 proto nodes 28.619 ms/op 29.040 ms/op 0.99
computeDeltas 2100000 validators 7200 proto nodes 29.394 ms/op 29.548 ms/op 0.99
computeProposerBoostScoreFromBalances 500000 validators 3.8118 ms/op 3.8326 ms/op 0.99
computeProposerBoostScoreFromBalances 750000 validators 3.8037 ms/op 3.8195 ms/op 1.00
computeProposerBoostScoreFromBalances 1400000 validators 3.8146 ms/op 3.8045 ms/op 1.00
computeProposerBoostScoreFromBalances 2100000 validators 4.1071 ms/op 3.7577 ms/op 1.09
altair processAttestation - 250000 vs - 7PWei normalcase 3.8795 ms/op 2.2627 ms/op 1.71
altair processAttestation - 250000 vs - 7PWei worstcase 5.0740 ms/op 3.4085 ms/op 1.49
altair processAttestation - setStatus - 1/6 committees join 173.26 us/op 144.29 us/op 1.20
altair processAttestation - setStatus - 1/3 committees join 325.49 us/op 294.06 us/op 1.11
altair processAttestation - setStatus - 1/2 committees join 415.26 us/op 383.54 us/op 1.08
altair processAttestation - setStatus - 2/3 committees join 529.50 us/op 481.10 us/op 1.10
altair processAttestation - setStatus - 4/5 committees join 726.32 us/op 676.40 us/op 1.07
altair processAttestation - setStatus - 100% committees join 869.35 us/op 811.41 us/op 1.07
altair processBlock - 250000 vs - 7PWei normalcase 12.982 ms/op 9.9211 ms/op 1.31
altair processBlock - 250000 vs - 7PWei normalcase hashState 45.621 ms/op 34.756 ms/op 1.31
altair processBlock - 250000 vs - 7PWei worstcase 41.116 ms/op 37.009 ms/op 1.11
altair processBlock - 250000 vs - 7PWei worstcase hashState 104.83 ms/op 95.838 ms/op 1.09
phase0 processBlock - 250000 vs - 7PWei normalcase 3.3118 ms/op 3.2664 ms/op 1.01
phase0 processBlock - 250000 vs - 7PWei worstcase 35.287 ms/op 33.923 ms/op 1.04
altair processEth1Data - 250000 vs - 7PWei normalcase 854.13 us/op 599.97 us/op 1.42
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 17.985 us/op 11.181 us/op 1.61
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 102.14 us/op 62.899 us/op 1.62
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 26.399 us/op 16.665 us/op 1.58
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 14.263 us/op 11.500 us/op 1.24
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 188.22 us/op 189.38 us/op 0.99
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.3557 ms/op 1.4632 ms/op 0.93
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 2.0865 ms/op 1.6798 ms/op 1.24
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.8227 ms/op 2.9176 ms/op 0.62
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 4.0447 ms/op 3.9795 ms/op 1.02
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.3697 ms/op 2.6734 ms/op 0.89
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 5.7359 ms/op 5.7619 ms/op 1.00
Tree 40 250000 create 412.34 ms/op 369.36 ms/op 1.12
Tree 40 250000 get(125000) 204.23 ns/op 211.84 ns/op 0.96
Tree 40 250000 set(125000) 1.0323 us/op 1.0979 us/op 0.94
Tree 40 250000 toArray() 19.360 ms/op 21.738 ms/op 0.89
Tree 40 250000 iterate all - toArray() + loop 22.459 ms/op 20.062 ms/op 1.12
Tree 40 250000 iterate all - get(i) 72.324 ms/op 67.584 ms/op 1.07
MutableVector 250000 create 13.858 ms/op 17.852 ms/op 0.78
MutableVector 250000 get(125000) 6.6850 ns/op 6.6380 ns/op 1.01
MutableVector 250000 set(125000) 285.63 ns/op 281.89 ns/op 1.01
MutableVector 250000 toArray() 3.5586 ms/op 3.3645 ms/op 1.06
MutableVector 250000 iterate all - toArray() + loop 4.1515 ms/op 3.9873 ms/op 1.04
MutableVector 250000 iterate all - get(i) 1.5753 ms/op 1.5522 ms/op 1.01
Array 250000 create 3.8047 ms/op 4.0630 ms/op 0.94
Array 250000 clone - spread 1.3912 ms/op 1.2261 ms/op 1.13
Array 250000 get(125000) 1.1830 ns/op 1.0260 ns/op 1.15
Array 250000 set(125000) 4.5620 ns/op 4.1370 ns/op 1.10
Array 250000 iterate all - loop 168.52 us/op 167.68 us/op 1.01
effectiveBalanceIncrements clone Uint8Array 300000 49.150 us/op 30.217 us/op 1.63
effectiveBalanceIncrements clone MutableVector 300000 457.00 ns/op 346.00 ns/op 1.32
effectiveBalanceIncrements rw all Uint8Array 300000 201.67 us/op 202.79 us/op 0.99
effectiveBalanceIncrements rw all MutableVector 300000 103.69 ms/op 83.258 ms/op 1.25
phase0 afterProcessEpoch - 250000 vs - 7PWei 118.12 ms/op 114.51 ms/op 1.03
phase0 beforeProcessEpoch - 250000 vs - 7PWei 56.231 ms/op 54.807 ms/op 1.03
altair processEpoch - mainnet_e81889 505.31 ms/op 557.44 ms/op 0.91
mainnet_e81889 - altair beforeProcessEpoch 85.037 ms/op 86.784 ms/op 0.98
mainnet_e81889 - altair processJustificationAndFinalization 15.764 us/op 15.000 us/op 1.05
mainnet_e81889 - altair processInactivityUpdates 6.5106 ms/op 6.5800 ms/op 0.99
mainnet_e81889 - altair processRewardsAndPenalties 63.774 ms/op 73.486 ms/op 0.87
mainnet_e81889 - altair processRegistryUpdates 2.5680 us/op 2.2140 us/op 1.16
mainnet_e81889 - altair processSlashings 468.00 ns/op 504.00 ns/op 0.93
mainnet_e81889 - altair processEth1DataReset 538.00 ns/op 596.00 ns/op 0.90
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.4063 ms/op 1.7281 ms/op 0.81
mainnet_e81889 - altair processSlashingsReset 4.9060 us/op 7.3270 us/op 0.67
mainnet_e81889 - altair processRandaoMixesReset 5.6060 us/op 7.5840 us/op 0.74
mainnet_e81889 - altair processHistoricalRootsUpdate 767.00 ns/op 820.00 ns/op 0.94
mainnet_e81889 - altair processParticipationFlagUpdates 2.4640 us/op 1.8720 us/op 1.32
mainnet_e81889 - altair processSyncCommitteeUpdates 802.00 ns/op 744.00 ns/op 1.08
mainnet_e81889 - altair afterProcessEpoch 121.80 ms/op 121.97 ms/op 1.00
capella processEpoch - mainnet_e217614 2.2962 s/op 2.3516 s/op 0.98
mainnet_e217614 - capella beforeProcessEpoch 540.72 ms/op 509.63 ms/op 1.06
mainnet_e217614 - capella processJustificationAndFinalization 18.834 us/op 25.358 us/op 0.74
mainnet_e217614 - capella processInactivityUpdates 19.460 ms/op 20.848 ms/op 0.93
mainnet_e217614 - capella processRewardsAndPenalties 419.52 ms/op 424.85 ms/op 0.99
mainnet_e217614 - capella processRegistryUpdates 20.387 us/op 30.864 us/op 0.66
mainnet_e217614 - capella processSlashings 475.00 ns/op 651.00 ns/op 0.73
mainnet_e217614 - capella processEth1DataReset 470.00 ns/op 500.00 ns/op 0.94
mainnet_e217614 - capella processEffectiveBalanceUpdates 14.184 ms/op 5.5342 ms/op 2.56
mainnet_e217614 - capella processSlashingsReset 3.7040 us/op 4.7140 us/op 0.79
mainnet_e217614 - capella processRandaoMixesReset 5.2120 us/op 5.2700 us/op 0.99
mainnet_e217614 - capella processHistoricalRootsUpdate 622.00 ns/op 506.00 ns/op 1.23
mainnet_e217614 - capella processParticipationFlagUpdates 1.9830 us/op 1.8630 us/op 1.06
mainnet_e217614 - capella afterProcessEpoch 318.86 ms/op 336.52 ms/op 0.95
phase0 processEpoch - mainnet_e58758 442.67 ms/op 519.63 ms/op 0.85
mainnet_e58758 - phase0 beforeProcessEpoch 150.38 ms/op 159.54 ms/op 0.94
mainnet_e58758 - phase0 processJustificationAndFinalization 16.033 us/op 21.727 us/op 0.74
mainnet_e58758 - phase0 processRewardsAndPenalties 52.367 ms/op 67.684 ms/op 0.77
mainnet_e58758 - phase0 processRegistryUpdates 13.106 us/op 16.654 us/op 0.79
mainnet_e58758 - phase0 processSlashings 581.00 ns/op 674.00 ns/op 0.86
mainnet_e58758 - phase0 processEth1DataReset 640.00 ns/op 638.00 ns/op 1.00
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.4785 ms/op 2.1456 ms/op 0.69
mainnet_e58758 - phase0 processSlashingsReset 3.6850 us/op 4.3970 us/op 0.84
mainnet_e58758 - phase0 processRandaoMixesReset 5.0530 us/op 7.6070 us/op 0.66
mainnet_e58758 - phase0 processHistoricalRootsUpdate 520.00 ns/op 678.00 ns/op 0.77
mainnet_e58758 - phase0 processParticipationRecordUpdates 3.8290 us/op 5.8900 us/op 0.65
mainnet_e58758 - phase0 afterProcessEpoch 100.06 ms/op 93.071 ms/op 1.08
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.5691 ms/op 2.5930 ms/op 0.61
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.4548 ms/op 1.5247 ms/op 0.95
altair processInactivityUpdates - 250000 normalcase 21.970 ms/op 30.993 ms/op 0.71
altair processInactivityUpdates - 250000 worstcase 24.347 ms/op 32.809 ms/op 0.74
phase0 processRegistryUpdates - 250000 normalcase 11.928 us/op 12.953 us/op 0.92
phase0 processRegistryUpdates - 250000 badcase_full_deposits 393.13 us/op 643.69 us/op 0.61
phase0 processRegistryUpdates - 250000 worstcase 0.5 128.06 ms/op 138.76 ms/op 0.92
altair processRewardsAndPenalties - 250000 normalcase 55.606 ms/op 72.214 ms/op 0.77
altair processRewardsAndPenalties - 250000 worstcase 62.705 ms/op 69.276 ms/op 0.91
phase0 getAttestationDeltas - 250000 normalcase 9.8956 ms/op 9.3050 ms/op 1.06
phase0 getAttestationDeltas - 250000 worstcase 9.6580 ms/op 9.3875 ms/op 1.03
phase0 processSlashings - 250000 worstcase 103.57 us/op 131.98 us/op 0.78
altair processSyncCommitteeUpdates - 250000 162.84 ms/op 152.37 ms/op 1.07
BeaconState.hashTreeRoot - No change 251.00 ns/op 255.00 ns/op 0.98
BeaconState.hashTreeRoot - 1 full validator 164.76 us/op 189.73 us/op 0.87
BeaconState.hashTreeRoot - 32 full validator 2.0079 ms/op 1.6575 ms/op 1.21
BeaconState.hashTreeRoot - 512 full validator 20.657 ms/op 18.921 ms/op 1.09
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 229.26 us/op 176.72 us/op 1.30
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.8816 ms/op 2.9053 ms/op 0.99
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 28.707 ms/op 32.017 ms/op 0.90
BeaconState.hashTreeRoot - 1 balances 135.61 us/op 139.72 us/op 0.97
BeaconState.hashTreeRoot - 32 balances 1.2000 ms/op 1.2460 ms/op 0.96
BeaconState.hashTreeRoot - 512 balances 11.830 ms/op 13.688 ms/op 0.86
BeaconState.hashTreeRoot - 250000 balances 191.69 ms/op 226.81 ms/op 0.85
aggregationBits - 2048 els - zipIndexesInBitList 18.689 us/op 17.145 us/op 1.09
byteArrayEquals 32 76.297 ns/op 75.458 ns/op 1.01
Buffer.compare 32 55.838 ns/op 55.700 ns/op 1.00
byteArrayEquals 1024 2.0375 us/op 2.0285 us/op 1.00
Buffer.compare 1024 70.574 ns/op 71.235 ns/op 0.99
byteArrayEquals 16384 32.439 us/op 32.605 us/op 0.99
Buffer.compare 16384 256.74 ns/op 262.48 ns/op 0.98
byteArrayEquals 123687377 252.75 ms/op 260.36 ms/op 0.97
Buffer.compare 123687377 8.9456 ms/op 9.0453 ms/op 0.99
byteArrayEquals 32 - diff last byte 84.927 ns/op 81.448 ns/op 1.04
Buffer.compare 32 - diff last byte 58.713 ns/op 62.322 ns/op 0.94
byteArrayEquals 1024 - diff last byte 2.1297 us/op 2.2273 us/op 0.96
Buffer.compare 1024 - diff last byte 76.719 ns/op 75.671 ns/op 1.01
byteArrayEquals 16384 - diff last byte 34.001 us/op 35.119 us/op 0.97
Buffer.compare 16384 - diff last byte 274.15 ns/op 311.74 ns/op 0.88
byteArrayEquals 123687377 - diff last byte 270.12 ms/op 268.16 ms/op 1.01
Buffer.compare 123687377 - diff last byte 9.7015 ms/op 8.8174 ms/op 1.10
byteArrayEquals 32 - random bytes 6.9630 ns/op 6.5850 ns/op 1.06
Buffer.compare 32 - random bytes 65.821 ns/op 64.080 ns/op 1.03
byteArrayEquals 1024 - random bytes 6.6280 ns/op 6.5200 ns/op 1.02
Buffer.compare 1024 - random bytes 78.054 ns/op 63.601 ns/op 1.23
byteArrayEquals 16384 - random bytes 7.8750 ns/op 6.5320 ns/op 1.21
Buffer.compare 16384 - random bytes 74.504 ns/op 63.880 ns/op 1.17
byteArrayEquals 123687377 - random bytes 15.500 ns/op 10.140 ns/op 1.53
Buffer.compare 123687377 - random bytes 77.170 ns/op 77.620 ns/op 0.99
regular array get 100000 times 53.068 us/op 47.681 us/op 1.11
wrappedArray get 100000 times 49.461 us/op 50.827 us/op 0.97
arrayWithProxy get 100000 times 15.051 ms/op 14.774 ms/op 1.02
ssz.Root.equals 57.493 ns/op 60.890 ns/op 0.94
byteArrayEquals 54.903 ns/op 59.525 ns/op 0.92
Buffer.compare 12.132 ns/op 12.994 ns/op 0.93
shuffle list - 16384 els 7.2820 ms/op 7.4534 ms/op 0.98
shuffle list - 250000 els 104.73 ms/op 113.34 ms/op 0.92
processSlot - 1 slots 17.780 us/op 21.388 us/op 0.83
processSlot - 32 slots 3.4556 ms/op 4.1495 ms/op 0.83
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 62.438 ms/op 60.627 ms/op 1.03
getCommitteeAssignments - req 1 vs - 250000 vc 2.5255 ms/op 2.6066 ms/op 0.97
getCommitteeAssignments - req 100 vs - 250000 vc 3.7685 ms/op 3.8584 ms/op 0.98
getCommitteeAssignments - req 1000 vs - 250000 vc 4.0757 ms/op 4.1734 ms/op 0.98
findModifiedValidators - 10000 modified validators 558.89 ms/op 597.54 ms/op 0.94
findModifiedValidators - 1000 modified validators 445.43 ms/op 496.45 ms/op 0.90
findModifiedValidators - 100 modified validators 452.54 ms/op 492.26 ms/op 0.92
findModifiedValidators - 10 modified validators 483.10 ms/op 470.94 ms/op 1.03
findModifiedValidators - 1 modified validators 510.20 ms/op 473.01 ms/op 1.08
findModifiedValidators - no difference 453.85 ms/op 488.08 ms/op 0.93
compare ViewDUs 4.9119 s/op 5.1864 s/op 0.95
compare each validator Uint8Array 1.8161 s/op 1.7828 s/op 1.02
compare ViewDU to Uint8Array 1.1957 s/op 1.3830 s/op 0.86
migrate state 1000000 validators, 24 modified, 0 new 810.18 ms/op 900.06 ms/op 0.90
migrate state 1000000 validators, 1700 modified, 1000 new 1.0987 s/op 1.3101 s/op 0.84
migrate state 1000000 validators, 3400 modified, 2000 new 1.5979 s/op 1.5017 s/op 1.06
migrate state 1500000 validators, 24 modified, 0 new 1.3872 s/op 1.0023 s/op 1.38
migrate state 1500000 validators, 1700 modified, 1000 new 1.1998 s/op 1.2620 s/op 0.95
migrate state 1500000 validators, 3400 modified, 2000 new 1.3994 s/op 1.3991 s/op 1.00
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.0900 ns/op 5.2500 ns/op 0.97
state getBlockRootAtSlot - 250000 vs - 7PWei 669.00 ns/op 939.23 ns/op 0.71
computeProposers - vc 250000 9.6083 ms/op 10.659 ms/op 0.90
computeEpochShuffling - vc 250000 112.27 ms/op 109.01 ms/op 1.03
getNextSyncCommittee - vc 250000 169.65 ms/op 159.40 ms/op 1.06
computeSigningRoot for AttestationData 29.298 us/op 30.713 us/op 0.95
hash AttestationData serialized data then Buffer.toString(base64) 2.4664 us/op 2.3574 us/op 1.05
toHexString serialized data 1.8173 us/op 1.1396 us/op 1.59
Buffer.toString(base64) 275.52 ns/op 233.54 ns/op 1.18

by benchmarkbot/action

@g11tech g11tech mentioned this pull request Nov 6, 2023
40 tasks
@dapplion
Copy link
Contributor

dapplion commented Nov 9, 2023

what's the current strategy now?

@g11tech
Copy link
Contributor Author

g11tech commented Nov 9, 2023

what's the current strategy now?

current strategy is wait till all block and blobs show up and then start the import. Since now there is an additive delay observed on the blobs, its best to verify block as much while the blobs are still becoming available

this PR seems to be working fine on devnet 11 lodestar-geth-1, just need to cleanup and finalize the PR


// proposer boost is not available post 3 sec so try pulling using unknown block hash
// post 3 sec after throwing the availability error
const BLOB_AVAILABILITY_TIMEOUT = 3_000;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should this (time to wait for all blobs to show up before firing unknown block event) be kept 3, or 4 or full 12 sec?

Copy link
Contributor

Choose a reason for hiding this comment

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

Proposer boost is available up to 1/3 into the slot, so 4 sec with Ethereum spec. Why not fire the unknown block event immediately upon receiving the blob? AFAIK lighthouse publish strategy is to publish block first, then blobs

Copy link
Contributor

Choose a reason for hiding this comment

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

right now most of the time unknownBlock always issue beacon_block_by_root due to unknown block root in beacon_attestation message, so should have no issue to fire unknown block event from blobs. It should issue single request per block root anyway.

there is an issue that unknownBlock sync issues beacon_block_root even we're processing gossip block, should avoid these redundant requests in #6105

Copy link
Contributor

Choose a reason for hiding this comment

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

@g11tech do you mean to pull blobs or block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why not fire the unknown block event immediately upon receiving the blob?

here block is available not all blobs, currently block processing is only started we see the block, blobs we keep caching till we see the block and thats something we can handle on the gossip handler of the blob (you have pointed this out there as well)

Also even if block is send before blobs, there is no guarantee one may see block before blobs, so it would be a good idea to wait for some latency in that case as well, but more of this disucssion/resolution there.

Here we have the block but not all blobs and we are verifying the other aspects of the block (state transition, execution payload, signatures) while we wait for blobs to become available. so question is what is the right threshold to wait till we trigger unknownblock/blobs even to pull them by root.

Looking from the devnet12 data, there could be 500ms to 1sec latency so i guess we shouldn't wait for more than a sec defintely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added this issue to tracker (#5279) to tackle on top of blob inclusion proof PR

packages/beacon-node/src/chain/blocks/types.ts Outdated Show resolved Hide resolved
packages/beacon-node/src/chain/blocks/types.ts Outdated Show resolved Hide resolved
packages/beacon-node/src/chain/blocks/types.ts Outdated Show resolved Hide resolved

// proposer boost is not available post 3 sec so try pulling using unknown block hash
// post 3 sec after throwing the availability error
const BLOB_AVAILABILITY_TIMEOUT = 3_000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Proposer boost is available up to 1/3 into the slot, so 4 sec with Ethereum spec. Why not fire the unknown block event immediately upon receiving the blob? AFAIK lighthouse publish strategy is to publish block first, then blobs

// and should have resolved the availability promise, however we could track if the block processing
// was halted and requeue it
//
// handleValidBeaconBlock(blockInput, peerIdStr, seenTimestampSec);
Copy link
Contributor

Choose a reason for hiding this comment

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

So the data received through the blob_sidecar topic is discarded? Both if branches do nothing

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking into the blob validation function noticed that there's an unnecessary call to regen here

const blockState = await chain.regen
.getBlockSlotState(parentRoot, blobSlot, {dontTransferCache: true}, RegenCaller.validateGossipBlob)
.catch(() => {
throw new BlobSidecarGossipError(GossipAction.IGNORE, {code: BlobSidecarErrorCode.PARENT_UNKNOWN, parentRoot});
});

you only need the global pubkey cache and a config, no need to calculate a specific state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the data received through the blob_sidecar topic is discarded? Both if branches do nothing

yes currently only seeing block only we trigger processing doesn't matter if all blobs are available or not (we concurrently wait for availability while other aspects of block are getting verified) and if the data doesn't become available in a threshold time we throw error which triggers pulling the block/blobs by root.

We can also threshold here the delay from the starting of the slot to throw the unknown block event. if the block was there (then we get non null blockinput) it must already be in the block processing queue waiting for blobs to become available which this blob would have resolved the promise if this was the last blob needed.

But if that was not the case then we can throw unknown block to pull by root.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you only need the global pubkey cache and a config, no need to calculate a specific state.

ahh right, had this copied over from block, will see how to optimize.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated in the tracker (#5279) to tackle on top of blob inclusion proof PR

Copy link

codecov bot commented Dec 8, 2023

Codecov Report

Merging #6087 (e6e7e4e) into unstable (d3005bf) will not change coverage.
Report is 1 commits behind head on unstable.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #6087   +/-   ##
=========================================
  Coverage     90.35%   90.35%           
=========================================
  Files            78       78           
  Lines          8087     8087           
  Branches        490      490           
=========================================
  Hits           7307     7307           
  Misses          772      772           
  Partials          8        8           

// Run state transition only
// TODO: Ensure it yields to allow flushing to workers and engine API
verifyBlocksStateTransitionOnly(
preState0,
blocksInput,
dataAvailabilityStatuses,
// hack availability for state transition eval as availability is separately determined
blocks.map(() => DataAvailableStatus.available),
Copy link
Contributor

Choose a reason for hiding this comment

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

should base on block.slot to determine DataAvailableStatus preDeneb vs available?

Copy link
Contributor Author

@g11tech g11tech Dec 18, 2023

Choose a reason for hiding this comment

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

internally in state transition it doesn't matter, but for correctness sake may be we can do it, although its inconsequential here as availability is actually verified as part of full block verification

cleanup pr and add metrics to track

simplify

improvements and type fixes

increase bucket precision

time fixes

improve metrics collection

improve metrics collection

some comments improv

fix the missing writing blobs for blobspromise

rebase fixes

rebase fixes

remove artifact

apply feedback

add more meta info to error

separate out the blockinput cache and attach to chain

rename the cache

apply more feedback

add unittest for seengossipblockinput

add comments
@g11tech g11tech merged commit be92973 into unstable Dec 19, 2023
13 of 15 checks passed
@g11tech g11tech deleted the optimistic-verify branch December 19, 2023 12:34
@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
…hainSafe#6087)

* feat: optimistically verify blocks even before all blobs available

cleanup pr and add metrics to track

simplify

improvements and type fixes

increase bucket precision

time fixes

improve metrics collection

improve metrics collection

some comments improv

fix the missing writing blobs for blobspromise

rebase fixes

rebase fixes

remove artifact

apply feedback

add more meta info to error

separate out the blockinput cache and attach to chain

rename the cache

apply more feedback

add unittest for seengossipblockinput

add comments

* check type fixes
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