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: produce phase0 beacon block body once #6270

Merged
merged 11 commits into from
Jan 11, 2024

Conversation

nazarhussain
Copy link
Contributor

Motivation

Make the block production more efficient.

Description

  • Produce the beacon-block-phase0 once during the race of execution and builder blocks.

Closes #6159

Steps to test or reproduce

  • Run all tests.

@nazarhussain nazarhussain requested a review from a team as a code owner January 9, 2024 10:40
@nazarhussain nazarhussain self-assigned this Jan 9, 2024
Comment on lines +485 to +486
// TODO: To avoid breaking changes for metric define this attribute
const blockType = BlockType.Full;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To avoid changes in the metrics structure for now in this PR I had to fix this type for now. We may think to refactor the metrics structure after merging this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't metric consolidation be part of this PR, feel like passing blockType around just for metrics is not ideal

Copy link

codecov bot commented Jan 9, 2024

Codecov Report

Merging #6270 (d6c45e0) into unstable (0b2d35a) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #6270   +/-   ##
=========================================
  Coverage     80.38%   80.38%           
=========================================
  Files           202      202           
  Lines         19620    19620           
  Branches       1176     1176           
=========================================
  Hits          15771    15771           
  Misses         3821     3821           
  Partials         28       28           

Copy link
Contributor

github-actions bot commented Jan 9, 2024

⚠️ Performance Alert ⚠️

Possible performance regression was detected for some benchmarks.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold.

Benchmark suite Current: 1f3d59a Previous: 2f9daba Ratio
getSlashingsAndExits - default max 608.44 us/op 157.43 us/op 3.86

🚀🚀 Significant benchmark improvement detected

Benchmark suite Current: 1f3d59a Previous: 2f9daba Ratio
forkChoice updateHead vc 600000 bc 64 eq 300000 16.175 ms/op 73.899 ms/op 0.22
Full benchmark results
Benchmark suite Current: 1f3d59a Previous: 2f9daba Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 602.35 us/op 1.0833 ms/op 0.56
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 131.10 us/op 150.56 us/op 0.87
BLS verify - blst-native 1.4166 ms/op 1.3555 ms/op 1.05
BLS verifyMultipleSignatures 3 - blst-native 3.0737 ms/op 2.8768 ms/op 1.07
BLS verifyMultipleSignatures 8 - blst-native 6.4585 ms/op 6.5073 ms/op 0.99
BLS verifyMultipleSignatures 32 - blst-native 23.624 ms/op 22.939 ms/op 1.03
BLS verifyMultipleSignatures 64 - blst-native 46.578 ms/op 45.907 ms/op 1.01
BLS verifyMultipleSignatures 128 - blst-native 91.266 ms/op 94.548 ms/op 0.97
BLS deserializing 10000 signatures 1.0146 s/op 989.18 ms/op 1.03
BLS deserializing 100000 signatures 9.8169 s/op 8.9786 s/op 1.09
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.6004 ms/op 1.3545 ms/op 1.18
BLS verifyMultipleSignatures - same message - 8 - blst-native 2.0279 ms/op 1.5316 ms/op 1.32
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.7861 ms/op 2.3576 ms/op 1.18
BLS verifyMultipleSignatures - same message - 64 - blst-native 4.2258 ms/op 3.6056 ms/op 1.17
BLS verifyMultipleSignatures - same message - 128 - blst-native 6.8536 ms/op 6.0624 ms/op 1.13
BLS aggregatePubkeys 32 - blst-native 32.658 us/op 28.375 us/op 1.15
BLS aggregatePubkeys 128 - blst-native 125.89 us/op 105.59 us/op 1.19
getAttestationsForBlock 87.110 ms/op 52.173 ms/op 1.67
getSlashingsAndExits - default max 608.44 us/op 157.43 us/op 3.86
getSlashingsAndExits - 2k 1.1607 ms/op 443.68 us/op 2.62
proposeBlockBody type=full, size=empty 9.8403 ms/op 6.3285 ms/op 1.55
isKnown best case - 1 super set check 942.00 ns/op 482.00 ns/op 1.95
isKnown normal case - 2 super set checks 843.00 ns/op 524.00 ns/op 1.61
isKnown worse case - 16 super set checks 949.00 ns/op 527.00 ns/op 1.80
CheckpointStateCache - add get delete 10.436 us/op 5.8590 us/op 1.78
validate api signedAggregateAndProof - struct 3.4263 ms/op 2.8255 ms/op 1.21
validate gossip signedAggregateAndProof - struct 3.5482 ms/op 2.8599 ms/op 1.24
validate gossip attestation - vc 640000 1.6488 ms/op 1.3989 ms/op 1.18
batch validate gossip attestation - vc 640000 - chunk 32 224.26 us/op 172.55 us/op 1.30
batch validate gossip attestation - vc 640000 - chunk 64 203.65 us/op 151.52 us/op 1.34
batch validate gossip attestation - vc 640000 - chunk 128 162.14 us/op 150.81 us/op 1.08
batch validate gossip attestation - vc 640000 - chunk 256 147.98 us/op 137.01 us/op 1.08
pickEth1Vote - no votes 1.3515 ms/op 1.3510 ms/op 1.00
pickEth1Vote - max votes 10.875 ms/op 15.508 ms/op 0.70
pickEth1Vote - Eth1Data hashTreeRoot value x2048 19.890 ms/op 26.373 ms/op 0.75
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 28.551 ms/op 33.595 ms/op 0.85
pickEth1Vote - Eth1Data fastSerialize value x2048 766.18 us/op 678.91 us/op 1.13
pickEth1Vote - Eth1Data fastSerialize tree x2048 5.6453 ms/op 5.2699 ms/op 1.07
bytes32 toHexString 766.00 ns/op 649.00 ns/op 1.18
bytes32 Buffer.toString(hex) 309.00 ns/op 322.00 ns/op 0.96
bytes32 Buffer.toString(hex) from Uint8Array 543.00 ns/op 524.00 ns/op 1.04
bytes32 Buffer.toString(hex) + 0x 319.00 ns/op 309.00 ns/op 1.03
Object access 1 prop 0.23100 ns/op 0.21500 ns/op 1.07
Map access 1 prop 0.15300 ns/op 0.15500 ns/op 0.99
Object get x1000 7.3480 ns/op 8.2010 ns/op 0.90
Map get x1000 0.89100 ns/op 0.86400 ns/op 1.03
Object set x1000 74.780 ns/op 69.869 ns/op 1.07
Map set x1000 52.892 ns/op 53.305 ns/op 0.99
Return object 10000 times 0.35880 ns/op 0.29180 ns/op 1.23
Throw Error 10000 times 4.5503 us/op 4.0928 us/op 1.11
fastMsgIdFn sha256 / 200 bytes 4.4310 us/op 3.4630 us/op 1.28
fastMsgIdFn h32 xxhash / 200 bytes 420.00 ns/op 357.00 ns/op 1.18
fastMsgIdFn h64 xxhash / 200 bytes 506.00 ns/op 432.00 ns/op 1.17
fastMsgIdFn sha256 / 1000 bytes 13.644 us/op 11.981 us/op 1.14
fastMsgIdFn h32 xxhash / 1000 bytes 617.00 ns/op 487.00 ns/op 1.27
fastMsgIdFn h64 xxhash / 1000 bytes 531.00 ns/op 487.00 ns/op 1.09
fastMsgIdFn sha256 / 10000 bytes 112.41 us/op 104.58 us/op 1.07
fastMsgIdFn h32 xxhash / 10000 bytes 2.6400 us/op 2.0340 us/op 1.30
fastMsgIdFn h64 xxhash / 10000 bytes 1.7710 us/op 1.4140 us/op 1.25
send data - 1000 256B messages 22.581 ms/op 21.782 ms/op 1.04
send data - 1000 512B messages 29.685 ms/op 30.072 ms/op 0.99
send data - 1000 1024B messages 44.166 ms/op 44.183 ms/op 1.00
send data - 1000 1200B messages 43.886 ms/op 42.696 ms/op 1.03
send data - 1000 2048B messages 47.669 ms/op 51.015 ms/op 0.93
send data - 1000 4096B messages 48.769 ms/op 48.002 ms/op 1.02
send data - 1000 16384B messages 122.22 ms/op 115.19 ms/op 1.06
send data - 1000 65536B messages 526.06 ms/op 509.71 ms/op 1.03
enrSubnets - fastDeserialize 64 bits 1.4990 us/op 1.7370 us/op 0.86
enrSubnets - ssz BitVector 64 bits 450.00 ns/op 565.00 ns/op 0.80
enrSubnets - fastDeserialize 4 bits 209.00 ns/op 243.00 ns/op 0.86
enrSubnets - ssz BitVector 4 bits 504.00 ns/op 621.00 ns/op 0.81
prioritizePeers score -10:0 att 32-0.1 sync 2-0 110.61 us/op 137.84 us/op 0.80
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 147.00 us/op 151.23 us/op 0.97
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 202.66 us/op 212.44 us/op 0.95
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 344.09 us/op 374.13 us/op 0.92
prioritizePeers score 0:0 att 64-1 sync 4-1 386.81 us/op 440.87 us/op 0.88
array of 16000 items push then shift 1.7097 us/op 1.9117 us/op 0.89
LinkedList of 16000 items push then shift 9.2860 ns/op 10.527 ns/op 0.88
array of 16000 items push then pop 113.36 ns/op 121.63 ns/op 0.93
LinkedList of 16000 items push then pop 8.9800 ns/op 9.9270 ns/op 0.90
array of 24000 items push then shift 2.5846 us/op 2.8080 us/op 0.92
LinkedList of 24000 items push then shift 9.1490 ns/op 11.091 ns/op 0.82
array of 24000 items push then pop 144.87 ns/op 171.82 ns/op 0.84
LinkedList of 24000 items push then pop 8.9190 ns/op 10.176 ns/op 0.88
intersect bitArray bitLen 8 6.4350 ns/op 7.4910 ns/op 0.86
intersect array and set length 8 65.171 ns/op 95.657 ns/op 0.68
intersect bitArray bitLen 128 34.195 ns/op 44.265 ns/op 0.77
intersect array and set length 128 879.27 ns/op 1.1487 us/op 0.77
bitArray.getTrueBitIndexes() bitLen 128 1.7110 us/op 1.9450 us/op 0.88
bitArray.getTrueBitIndexes() bitLen 248 2.8910 us/op 3.2420 us/op 0.89
bitArray.getTrueBitIndexes() bitLen 512 5.4390 us/op 6.8840 us/op 0.79
Buffer.concat 32 items 1.0740 us/op 1.1200 us/op 0.96
Uint8Array.set 32 items 1.8950 us/op 2.2580 us/op 0.84
Set add up to 64 items then delete first 4.5890 us/op 5.2696 us/op 0.87
OrderedSet add up to 64 items then delete first 5.7199 us/op 6.8635 us/op 0.83
Set add up to 64 items then delete last 4.9471 us/op 5.5330 us/op 0.89
OrderedSet add up to 64 items then delete last 5.9614 us/op 7.2127 us/op 0.83
Set add up to 64 items then delete middle 4.7513 us/op 5.5118 us/op 0.86
OrderedSet add up to 64 items then delete middle 7.4607 us/op 8.6534 us/op 0.86
Set add up to 128 items then delete first 9.4505 us/op 10.967 us/op 0.86
OrderedSet add up to 128 items then delete first 13.032 us/op 15.838 us/op 0.82
Set add up to 128 items then delete last 10.284 us/op 10.974 us/op 0.94
OrderedSet add up to 128 items then delete last 12.358 us/op 15.219 us/op 0.81
Set add up to 128 items then delete middle 10.406 us/op 11.079 us/op 0.94
OrderedSet add up to 128 items then delete middle 18.580 us/op 20.401 us/op 0.91
Set add up to 256 items then delete first 20.670 us/op 22.838 us/op 0.91
OrderedSet add up to 256 items then delete first 27.132 us/op 31.675 us/op 0.86
Set add up to 256 items then delete last 19.421 us/op 21.741 us/op 0.89
OrderedSet add up to 256 items then delete last 24.542 us/op 31.432 us/op 0.78
Set add up to 256 items then delete middle 19.056 us/op 21.919 us/op 0.87
OrderedSet add up to 256 items then delete middle 47.117 us/op 57.519 us/op 0.82
transfer serialized Status (84 B) 1.9340 us/op 1.9060 us/op 1.01
copy serialized Status (84 B) 1.6590 us/op 1.6420 us/op 1.01
transfer serialized SignedVoluntaryExit (112 B) 1.9800 us/op 2.0770 us/op 0.95
copy serialized SignedVoluntaryExit (112 B) 1.6090 us/op 1.7230 us/op 0.93
transfer serialized ProposerSlashing (416 B) 2.1160 us/op 2.7780 us/op 0.76
copy serialized ProposerSlashing (416 B) 2.1210 us/op 2.5280 us/op 0.84
transfer serialized Attestation (485 B) 2.4520 us/op 2.4600 us/op 1.00
copy serialized Attestation (485 B) 2.7010 us/op 2.4240 us/op 1.11
transfer serialized AttesterSlashing (33232 B) 3.2750 us/op 2.6760 us/op 1.22
copy serialized AttesterSlashing (33232 B) 8.2660 us/op 9.3990 us/op 0.88
transfer serialized Small SignedBeaconBlock (128000 B) 3.7840 us/op 3.3390 us/op 1.13
copy serialized Small SignedBeaconBlock (128000 B) 17.155 us/op 31.232 us/op 0.55
transfer serialized Avg SignedBeaconBlock (200000 B) 3.8840 us/op 3.5540 us/op 1.09
copy serialized Avg SignedBeaconBlock (200000 B) 23.220 us/op 47.474 us/op 0.49
transfer serialized BlobsSidecar (524380 B) 3.6340 us/op 5.1780 us/op 0.70
copy serialized BlobsSidecar (524380 B) 86.279 us/op 266.21 us/op 0.32
transfer serialized Big SignedBeaconBlock (1000000 B) 3.0790 us/op 6.6700 us/op 0.46
copy serialized Big SignedBeaconBlock (1000000 B) 281.41 us/op 280.14 us/op 1.00
pass gossip attestations to forkchoice per slot 4.2774 ms/op 4.2726 ms/op 1.00
forkChoice updateHead vc 100000 bc 64 eq 0 692.56 us/op 740.28 us/op 0.94
forkChoice updateHead vc 600000 bc 64 eq 0 5.3054 ms/op 7.6021 ms/op 0.70
forkChoice updateHead vc 1000000 bc 64 eq 0 7.2356 ms/op 8.7033 ms/op 0.83
forkChoice updateHead vc 600000 bc 320 eq 0 4.2400 ms/op 4.8677 ms/op 0.87
forkChoice updateHead vc 600000 bc 1200 eq 0 4.4952 ms/op 7.5091 ms/op 0.60
forkChoice updateHead vc 600000 bc 7200 eq 0 5.7594 ms/op 9.3137 ms/op 0.62
forkChoice updateHead vc 600000 bc 64 eq 1000 11.437 ms/op 17.658 ms/op 0.65
forkChoice updateHead vc 600000 bc 64 eq 10000 12.046 ms/op 16.323 ms/op 0.74
forkChoice updateHead vc 600000 bc 64 eq 300000 16.175 ms/op 73.899 ms/op 0.22
computeDeltas 500000 validators 300 proto nodes 6.6242 ms/op 9.1457 ms/op 0.72
computeDeltas 500000 validators 1200 proto nodes 6.4289 ms/op 7.5427 ms/op 0.85
computeDeltas 500000 validators 7200 proto nodes 6.3189 ms/op 7.0774 ms/op 0.89
computeDeltas 750000 validators 300 proto nodes 9.6700 ms/op 10.396 ms/op 0.93
computeDeltas 750000 validators 1200 proto nodes 9.5554 ms/op 9.9185 ms/op 0.96
computeDeltas 750000 validators 7200 proto nodes 9.6728 ms/op 9.8560 ms/op 0.98
computeDeltas 1400000 validators 300 proto nodes 19.520 ms/op 19.113 ms/op 1.02
computeDeltas 1400000 validators 1200 proto nodes 18.854 ms/op 19.010 ms/op 0.99
computeDeltas 1400000 validators 7200 proto nodes 18.467 ms/op 19.462 ms/op 0.95
computeDeltas 2100000 validators 300 proto nodes 27.491 ms/op 28.722 ms/op 0.96
computeDeltas 2100000 validators 1200 proto nodes 27.307 ms/op 28.869 ms/op 0.95
computeDeltas 2100000 validators 7200 proto nodes 28.111 ms/op 29.428 ms/op 0.96
computeProposerBoostScoreFromBalances 500000 validators 3.6637 ms/op 3.8506 ms/op 0.95
computeProposerBoostScoreFromBalances 750000 validators 3.7587 ms/op 3.8079 ms/op 0.99
computeProposerBoostScoreFromBalances 1400000 validators 3.7296 ms/op 3.7889 ms/op 0.98
computeProposerBoostScoreFromBalances 2100000 validators 3.8036 ms/op 3.7992 ms/op 1.00
altair processAttestation - 250000 vs - 7PWei normalcase 2.8222 ms/op 2.9805 ms/op 0.95
altair processAttestation - 250000 vs - 7PWei worstcase 3.4530 ms/op 3.9941 ms/op 0.86
altair processAttestation - setStatus - 1/6 committees join 184.86 us/op 158.71 us/op 1.16
altair processAttestation - setStatus - 1/3 committees join 361.06 us/op 303.56 us/op 1.19
altair processAttestation - setStatus - 1/2 committees join 481.50 us/op 402.66 us/op 1.20
altair processAttestation - setStatus - 2/3 committees join 609.53 us/op 499.24 us/op 1.22
altair processAttestation - setStatus - 4/5 committees join 791.34 us/op 704.01 us/op 1.12
altair processAttestation - setStatus - 100% committees join 970.27 us/op 822.41 us/op 1.18
altair processBlock - 250000 vs - 7PWei normalcase 10.730 ms/op 10.742 ms/op 1.00
altair processBlock - 250000 vs - 7PWei normalcase hashState 42.886 ms/op 39.811 ms/op 1.08
altair processBlock - 250000 vs - 7PWei worstcase 42.425 ms/op 39.838 ms/op 1.06
altair processBlock - 250000 vs - 7PWei worstcase hashState 96.199 ms/op 103.03 ms/op 0.93
phase0 processBlock - 250000 vs - 7PWei normalcase 2.4525 ms/op 2.9551 ms/op 0.83
phase0 processBlock - 250000 vs - 7PWei worstcase 31.860 ms/op 32.638 ms/op 0.98
altair processEth1Data - 250000 vs - 7PWei normalcase 761.60 us/op 685.89 us/op 1.11
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 15.087 us/op 10.605 us/op 1.42
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 82.793 us/op 68.177 us/op 1.21
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 31.730 us/op 32.281 us/op 0.98
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 11.394 us/op 14.242 us/op 0.80
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 201.73 us/op 247.99 us/op 0.81
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.5218 ms/op 1.5248 ms/op 1.00
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 2.1822 ms/op 1.9344 ms/op 1.13
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 2.1021 ms/op 2.0925 ms/op 1.00
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 3.9560 ms/op 4.3837 ms/op 0.90
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.8085 ms/op 2.8034 ms/op 1.00
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 6.5828 ms/op 7.9550 ms/op 0.83
Tree 40 250000 create 416.89 ms/op 550.71 ms/op 0.76
Tree 40 250000 get(125000) 216.24 ns/op 214.08 ns/op 1.01
Tree 40 250000 set(125000) 1.1687 us/op 1.1891 us/op 0.98
Tree 40 250000 toArray() 22.429 ms/op 26.095 ms/op 0.86
Tree 40 250000 iterate all - toArray() + loop 21.749 ms/op 24.865 ms/op 0.87
Tree 40 250000 iterate all - get(i) 76.191 ms/op 78.375 ms/op 0.97
MutableVector 250000 create 13.680 ms/op 21.972 ms/op 0.62
MutableVector 250000 get(125000) 6.6600 ns/op 6.8290 ns/op 0.98
MutableVector 250000 set(125000) 347.96 ns/op 561.85 ns/op 0.62
MutableVector 250000 toArray() 4.6925 ms/op 4.6263 ms/op 1.01
MutableVector 250000 iterate all - toArray() + loop 4.4016 ms/op 5.4042 ms/op 0.81
MutableVector 250000 iterate all - get(i) 1.5526 ms/op 1.6312 ms/op 0.95
Array 250000 create 3.2276 ms/op 4.6508 ms/op 0.69
Array 250000 clone - spread 1.2840 ms/op 1.6972 ms/op 0.76
Array 250000 get(125000) 1.0470 ns/op 1.6470 ns/op 0.64
Array 250000 set(125000) 4.1280 ns/op 5.4920 ns/op 0.75
Array 250000 iterate all - loop 166.56 us/op 178.37 us/op 0.93
effectiveBalanceIncrements clone Uint8Array 300000 41.401 us/op 58.253 us/op 0.71
effectiveBalanceIncrements clone MutableVector 300000 363.00 ns/op 413.00 ns/op 0.88
effectiveBalanceIncrements rw all Uint8Array 300000 202.19 us/op 244.91 us/op 0.83
effectiveBalanceIncrements rw all MutableVector 300000 89.454 ms/op 198.99 ms/op 0.45
phase0 afterProcessEpoch - 250000 vs - 7PWei 113.92 ms/op 135.86 ms/op 0.84
phase0 beforeProcessEpoch - 250000 vs - 7PWei 58.043 ms/op 71.441 ms/op 0.81
altair processEpoch - mainnet_e81889 532.98 ms/op 650.15 ms/op 0.82
mainnet_e81889 - altair beforeProcessEpoch 86.987 ms/op 114.76 ms/op 0.76
mainnet_e81889 - altair processJustificationAndFinalization 14.967 us/op 31.336 us/op 0.48
mainnet_e81889 - altair processInactivityUpdates 7.5384 ms/op 10.021 ms/op 0.75
mainnet_e81889 - altair processRewardsAndPenalties 68.854 ms/op 76.470 ms/op 0.90
mainnet_e81889 - altair processRegistryUpdates 2.4890 us/op 4.6300 us/op 0.54
mainnet_e81889 - altair processSlashings 547.00 ns/op 1.0340 us/op 0.53
mainnet_e81889 - altair processEth1DataReset 500.00 ns/op 1.2110 us/op 0.41
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.5476 ms/op 2.3501 ms/op 0.66
mainnet_e81889 - altair processSlashingsReset 3.6980 us/op 11.381 us/op 0.32
mainnet_e81889 - altair processRandaoMixesReset 5.5690 us/op 7.9240 us/op 0.70
mainnet_e81889 - altair processHistoricalRootsUpdate 604.00 ns/op 1.5490 us/op 0.39
mainnet_e81889 - altair processParticipationFlagUpdates 2.4870 us/op 5.4800 us/op 0.45
mainnet_e81889 - altair processSyncCommitteeUpdates 639.00 ns/op 1.4440 us/op 0.44
mainnet_e81889 - altair afterProcessEpoch 120.05 ms/op 137.50 ms/op 0.87
capella processEpoch - mainnet_e217614 2.1831 s/op 2.4550 s/op 0.89
mainnet_e217614 - capella beforeProcessEpoch 500.15 ms/op 590.37 ms/op 0.85
mainnet_e217614 - capella processJustificationAndFinalization 25.845 us/op 22.970 us/op 1.13
mainnet_e217614 - capella processInactivityUpdates 24.660 ms/op 20.502 ms/op 1.20
mainnet_e217614 - capella processRewardsAndPenalties 421.51 ms/op 458.30 ms/op 0.92
mainnet_e217614 - capella processRegistryUpdates 26.781 us/op 26.122 us/op 1.03
mainnet_e217614 - capella processSlashings 510.00 ns/op 760.00 ns/op 0.67
mainnet_e217614 - capella processEth1DataReset 422.00 ns/op 667.00 ns/op 0.63
mainnet_e217614 - capella processEffectiveBalanceUpdates 4.5154 ms/op 5.1554 ms/op 0.88
mainnet_e217614 - capella processSlashingsReset 3.3740 us/op 7.1820 us/op 0.47
mainnet_e217614 - capella processRandaoMixesReset 4.6840 us/op 7.6170 us/op 0.61
mainnet_e217614 - capella processHistoricalRootsUpdate 565.00 ns/op 728.00 ns/op 0.78
mainnet_e217614 - capella processParticipationFlagUpdates 1.5820 us/op 3.0850 us/op 0.51
mainnet_e217614 - capella afterProcessEpoch 332.22 ms/op 314.78 ms/op 1.06
phase0 processEpoch - mainnet_e58758 478.82 ms/op 501.33 ms/op 0.96
mainnet_e58758 - phase0 beforeProcessEpoch 140.05 ms/op 176.22 ms/op 0.79
mainnet_e58758 - phase0 processJustificationAndFinalization 18.601 us/op 23.579 us/op 0.79
mainnet_e58758 - phase0 processRewardsAndPenalties 54.772 ms/op 55.465 ms/op 0.99
mainnet_e58758 - phase0 processRegistryUpdates 9.9020 us/op 20.762 us/op 0.48
mainnet_e58758 - phase0 processSlashings 658.00 ns/op 597.00 ns/op 1.10
mainnet_e58758 - phase0 processEth1DataReset 622.00 ns/op 420.00 ns/op 1.48
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.1523 ms/op 1.1190 ms/op 1.03
mainnet_e58758 - phase0 processSlashingsReset 3.4110 us/op 3.4880 us/op 0.98
mainnet_e58758 - phase0 processRandaoMixesReset 4.5750 us/op 3.9270 us/op 1.17
mainnet_e58758 - phase0 processHistoricalRootsUpdate 624.00 ns/op 438.00 ns/op 1.42
mainnet_e58758 - phase0 processParticipationRecordUpdates 5.1370 us/op 5.1100 us/op 1.01
mainnet_e58758 - phase0 afterProcessEpoch 102.27 ms/op 97.547 ms/op 1.05
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.4548 ms/op 1.3844 ms/op 1.05
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.0777 ms/op 1.6254 ms/op 1.28
altair processInactivityUpdates - 250000 normalcase 36.678 ms/op 21.967 ms/op 1.67
altair processInactivityUpdates - 250000 worstcase 36.487 ms/op 27.086 ms/op 1.35
phase0 processRegistryUpdates - 250000 normalcase 18.120 us/op 9.2040 us/op 1.97
phase0 processRegistryUpdates - 250000 badcase_full_deposits 489.78 us/op 383.11 us/op 1.28
phase0 processRegistryUpdates - 250000 worstcase 0.5 138.19 ms/op 128.84 ms/op 1.07
altair processRewardsAndPenalties - 250000 normalcase 66.190 ms/op 56.018 ms/op 1.18
altair processRewardsAndPenalties - 250000 worstcase 63.641 ms/op 56.125 ms/op 1.13
phase0 getAttestationDeltas - 250000 normalcase 12.378 ms/op 9.8234 ms/op 1.26
phase0 getAttestationDeltas - 250000 worstcase 13.174 ms/op 9.0507 ms/op 1.46
phase0 processSlashings - 250000 worstcase 137.31 us/op 101.19 us/op 1.36
altair processSyncCommitteeUpdates - 250000 167.41 ms/op 158.76 ms/op 1.05
BeaconState.hashTreeRoot - No change 285.00 ns/op 262.00 ns/op 1.09
BeaconState.hashTreeRoot - 1 full validator 142.94 us/op 140.51 us/op 1.02
BeaconState.hashTreeRoot - 32 full validator 1.4963 ms/op 1.7516 ms/op 0.85
BeaconState.hashTreeRoot - 512 full validator 16.383 ms/op 20.753 ms/op 0.79
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 177.12 us/op 212.75 us/op 0.83
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.6005 ms/op 2.3311 ms/op 1.12
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 38.415 ms/op 29.135 ms/op 1.32
BeaconState.hashTreeRoot - 1 balances 200.49 us/op 136.04 us/op 1.47
BeaconState.hashTreeRoot - 32 balances 1.6536 ms/op 1.2310 ms/op 1.34
BeaconState.hashTreeRoot - 512 balances 13.820 ms/op 14.468 ms/op 0.96
BeaconState.hashTreeRoot - 250000 balances 235.87 ms/op 207.87 ms/op 1.13
aggregationBits - 2048 els - zipIndexesInBitList 19.483 us/op 21.490 us/op 0.91
byteArrayEquals 32 81.204 ns/op 76.494 ns/op 1.06
Buffer.compare 32 58.243 ns/op 56.387 ns/op 1.03
byteArrayEquals 1024 2.1628 us/op 2.1245 us/op 1.02
Buffer.compare 1024 73.910 ns/op 72.459 ns/op 1.02
byteArrayEquals 16384 33.541 us/op 33.591 us/op 1.00
Buffer.compare 16384 256.86 ns/op 281.21 ns/op 0.91
byteArrayEquals 123687377 279.67 ms/op 259.70 ms/op 1.08
Buffer.compare 123687377 10.343 ms/op 9.0816 ms/op 1.14
byteArrayEquals 32 - diff last byte 97.962 ns/op 86.105 ns/op 1.14
Buffer.compare 32 - diff last byte 66.303 ns/op 59.825 ns/op 1.11
byteArrayEquals 1024 - diff last byte 2.6715 us/op 2.1964 us/op 1.22
Buffer.compare 1024 - diff last byte 82.751 ns/op 74.722 ns/op 1.11
byteArrayEquals 16384 - diff last byte 41.419 us/op 37.832 us/op 1.09
Buffer.compare 16384 - diff last byte 328.46 ns/op 288.07 ns/op 1.14
byteArrayEquals 123687377 - diff last byte 297.99 ms/op 270.75 ms/op 1.10
Buffer.compare 123687377 - diff last byte 9.3237 ms/op 8.5491 ms/op 1.09
byteArrayEquals 32 - random bytes 6.8020 ns/op 6.0440 ns/op 1.13
Buffer.compare 32 - random bytes 71.252 ns/op 62.474 ns/op 1.14
byteArrayEquals 1024 - random bytes 6.9950 ns/op 6.0800 ns/op 1.15
Buffer.compare 1024 - random bytes 62.075 ns/op 61.336 ns/op 1.01
byteArrayEquals 16384 - random bytes 5.6700 ns/op 6.0170 ns/op 0.94
Buffer.compare 16384 - random bytes 61.464 ns/op 61.207 ns/op 1.00
byteArrayEquals 123687377 - random bytes 9.1100 ns/op 8.7400 ns/op 1.04
Buffer.compare 123687377 - random bytes 73.800 ns/op 68.810 ns/op 1.07
regular array get 100000 times 49.331 us/op 45.820 us/op 1.08
wrappedArray get 100000 times 46.185 us/op 45.590 us/op 1.01
arrayWithProxy get 100000 times 14.708 ms/op 14.168 ms/op 1.04
ssz.Root.equals 55.282 ns/op 54.334 ns/op 1.02
byteArrayEquals 56.434 ns/op 58.953 ns/op 0.96
Buffer.compare 11.587 ns/op 11.912 ns/op 0.97
shuffle list - 16384 els 7.2229 ms/op 7.2580 ms/op 1.00
shuffle list - 250000 els 107.89 ms/op 104.12 ms/op 1.04
processSlot - 1 slots 17.150 us/op 18.557 us/op 0.92
processSlot - 32 slots 3.8189 ms/op 3.3182 ms/op 1.15
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 61.588 ms/op 57.075 ms/op 1.08
getCommitteeAssignments - req 1 vs - 250000 vc 2.5578 ms/op 2.5255 ms/op 1.01
getCommitteeAssignments - req 100 vs - 250000 vc 3.7832 ms/op 3.7268 ms/op 1.02
getCommitteeAssignments - req 1000 vs - 250000 vc 4.1093 ms/op 4.1089 ms/op 1.00
findModifiedValidators - 10000 modified validators 619.17 ms/op 539.01 ms/op 1.15
findModifiedValidators - 1000 modified validators 446.17 ms/op 432.53 ms/op 1.03
findModifiedValidators - 100 modified validators 467.52 ms/op 436.82 ms/op 1.07
findModifiedValidators - 10 modified validators 459.05 ms/op 423.54 ms/op 1.08
findModifiedValidators - 1 modified validators 533.86 ms/op 415.54 ms/op 1.28
findModifiedValidators - no difference 517.57 ms/op 409.32 ms/op 1.26
compare ViewDUs 5.9182 s/op 4.6927 s/op 1.26
compare each validator Uint8Array 1.9192 s/op 1.8310 s/op 1.05
compare ViewDU to Uint8Array 1.3619 s/op 1.3664 s/op 1.00
migrate state 1000000 validators, 24 modified, 0 new 867.77 ms/op 767.86 ms/op 1.13
migrate state 1000000 validators, 1700 modified, 1000 new 1.1302 s/op 1.1455 s/op 0.99
migrate state 1000000 validators, 3400 modified, 2000 new 1.3890 s/op 1.3654 s/op 1.02
migrate state 1500000 validators, 24 modified, 0 new 786.02 ms/op 759.97 ms/op 1.03
migrate state 1500000 validators, 1700 modified, 1000 new 1.0922 s/op 1.0894 s/op 1.00
migrate state 1500000 validators, 3400 modified, 2000 new 1.3114 s/op 1.3176 s/op 1.00
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.7500 ns/op 4.6800 ns/op 1.01
state getBlockRootAtSlot - 250000 vs - 7PWei 594.14 ns/op 761.77 ns/op 0.78
computeProposers - vc 250000 9.9911 ms/op 10.107 ms/op 0.99
computeEpochShuffling - vc 250000 105.90 ms/op 102.96 ms/op 1.03
getNextSyncCommittee - vc 250000 160.51 ms/op 159.09 ms/op 1.01
computeSigningRoot for AttestationData 23.940 us/op 29.131 us/op 0.82
hash AttestationData serialized data then Buffer.toString(base64) 2.3672 us/op 2.3337 us/op 1.01
toHexString serialized data 1.0814 us/op 1.1162 us/op 0.97
Buffer.toString(base64) 224.53 ns/op 239.71 ns/op 0.94

by benchmarkbot/action

Comment on lines +206 to +208
export type CommonBlockBody = phase0.BeaconBlockBody &
Pick<capella.BeaconBlockBody, "blsToExecutionChanges"> &
Pick<altair.BeaconBlockBody, "syncAggregate">;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Omit<allForks.BeaconBlockBody, "executionPayload"> is not type-safe, so why used explicit attributes here.

Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

need to see why sim merge are failing else looks good (retriggered the run as it failed all image pull for geth)
also unit tests are failing @nazarhussain

g11tech
g11tech previously approved these changes Jan 9, 2024
Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

approving, sim merge seem to be failing because of docker pull limit, retry in couple of hours and merge in if everytthing passes @nazarhussain

@@ -287,7 +287,11 @@ export function getValidatorApi({
// as of now fee recipient checks can not be performed because builder does not return bid recipient
{
skipHeadChecksAndUpdate,
}: Omit<routes.validator.ExtraProduceBlockOps, "builderSelection"> & {skipHeadChecksAndUpdate?: boolean} = {}
commonBlockBody,
}: Omit<routes.validator.ExtraProduceBlockOps, "builderSelection"> & {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the usage of this type Omit<routes.validator.ExtraProduceBlockOps, "builderSelection">, can we drop it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Somehow it's used on the line 400 of this file. I will clean this up in a separate PR in-progress to clean up this flow.

Comment on lines +583 to +585
blockType === BlockType.Full
? this.metrics?.executionBlockProductionTimeSteps
: this.metrics?.builderBlockProductionTimeSteps;
Copy link
Member

Choose a reason for hiding this comment

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

Is it still required to have 2 different metrics for this? maybe should be consolidated into a single metric

There is also the option now to return blinded local blocks (#6227), metric naming should reflect that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mentioned it earlier in discussion that this metric need cleanup.

/** process_sync_committee_contributions is implemented in syncCommitteeContribution.getSyncAggregate */
export async function produceCommonBlockBody<T extends BlockType>(
this: BeaconChain,
blockType: T,
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to pass blockType here? Shouldn't be relevant for this function

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 we can pass call this for either type of block.

Copy link
Member

Choose a reason for hiding this comment

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

But why do we need to know the block type at all? The function produces the same result irrespective of the block type we pass here (or at least that's what I understood is the goal of this PR, to consolidate body production and only do it once).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As of current implementation we need to know block type to update respective metric. Once we consolidate metrics then we don't need block type for common block body.

Copy link
Member

Choose a reason for hiding this comment

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

Let's keep metrics as is for now then, will give this another review locally as it is probably easier that way

packages/beacon-node/src/api/impl/validator/index.ts Outdated Show resolved Hide resolved
Comment on lines +485 to +486
// TODO: To avoid breaking changes for metric define this attribute
const blockType = BlockType.Full;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't metric consolidation be part of this PR, feel like passing blockType around just for metrics is not ideal

Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

as per discussions with @nazarhussain and other comments and my own opinions on how metrics need to be included for the common (my view point: just duplicate them on full and blinded panels whenever body build is triggered as a common path), seems like we need discussion on this so that we have consensus on what is useful for the team.

approving now with an understanding for an immediate metrics consolidation followup PR to be done by @nazarhussain post discussion on how reflect the metrics of common path

@nazarhussain nazarhussain merged commit aa87c54 into unstable Jan 11, 2024
13 of 15 checks passed
@nazarhussain nazarhussain deleted the nh/6159-common-block-body branch January 11, 2024 11:59
@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
* Update the beacon block production for phase0

* Update the workflow with common body

* Fix lint errors

* Fix the types

* Fix the log message

* Fix mutation of the common block body

* Fix lint formatting

* Fix lint formatting
jeluard pushed a commit to jeluard/lodestar that referenced this pull request Jan 30, 2024
* Update the beacon block production for phase0

* Update the workflow with common body

* Fix lint errors

* Fix the types

* Fix the log message

* Fix mutation of the common block body

* Fix lint formatting

* Fix lint formatting
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.

Produce phase0 beacon block body once
5 participants