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

refactor: flatten fork logic in notifyNewPayload #7385

Open
wants to merge 4 commits into
base: unstable
Choose a base branch
from

Conversation

ensi321
Copy link
Contributor

@ensi321 ensi321 commented Jan 22, 2025

The way the current notifyNewPayload is structured does not allow new fork and payload method (eg. focil fork and engine_newPayloadV5) to be added easily without introducing more nested if statement.

This PR flattens the logic into a single layer by having a switch statement which makes new methods to be added easily.

@ensi321 ensi321 requested a review from a team as a code owner January 22, 2025 00:46
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.44%. Comparing base (d584aed) to head (a2306ef).
Report is 15 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #7385      +/-   ##
============================================
- Coverage     48.62%   48.44%   -0.19%     
============================================
  Files           603      602       -1     
  Lines         40510    40407     -103     
  Branches       2071     2069       -2     
============================================
- Hits          19700    19577     -123     
- Misses        20772    20792      +20     
  Partials         38       38              

Copy link
Contributor

github-actions bot commented Jan 22, 2025

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: c10851f Previous: 1748e2e Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.5706 ms/op 1.5653 ms/op 1.00
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 34.201 us/op 31.954 us/op 1.07
BLS verify - blst 854.59 us/op 874.19 us/op 0.98
BLS verifyMultipleSignatures 3 - blst 1.4810 ms/op 1.3144 ms/op 1.13
BLS verifyMultipleSignatures 8 - blst 1.5292 ms/op 2.1034 ms/op 0.73
BLS verifyMultipleSignatures 32 - blst 4.4321 ms/op 4.4426 ms/op 1.00
BLS verifyMultipleSignatures 64 - blst 8.2591 ms/op 8.3587 ms/op 0.99
BLS verifyMultipleSignatures 128 - blst 15.718 ms/op 16.105 ms/op 0.98
BLS deserializing 10000 signatures 603.72 ms/op 628.11 ms/op 0.96
BLS deserializing 100000 signatures 6.0461 s/op 6.2019 s/op 0.97
BLS verifyMultipleSignatures - same message - 3 - blst 918.57 us/op 945.55 us/op 0.97
BLS verifyMultipleSignatures - same message - 8 - blst 1.0718 ms/op 1.1198 ms/op 0.96
BLS verifyMultipleSignatures - same message - 32 - blst 1.6339 ms/op 1.7039 ms/op 0.96
BLS verifyMultipleSignatures - same message - 64 - blst 2.4076 ms/op 2.5471 ms/op 0.95
BLS verifyMultipleSignatures - same message - 128 - blst 3.9402 ms/op 4.1285 ms/op 0.95
BLS aggregatePubkeys 32 - blst 17.121 us/op 17.859 us/op 0.96
BLS aggregatePubkeys 128 - blst 59.771 us/op 62.801 us/op 0.95
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 39.905 ms/op 37.035 ms/op 1.08
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 42.436 ms/op 37.842 ms/op 1.12
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 39.030 ms/op 42.843 ms/op 0.91
getSlashingsAndExits - default max 57.285 us/op 61.673 us/op 0.93
getSlashingsAndExits - 2k 256.33 us/op 278.99 us/op 0.92
proposeBlockBody type=full, size=empty 4.4776 ms/op 4.9624 ms/op 0.90
isKnown best case - 1 super set check 473.00 ns/op 468.00 ns/op 1.01
isKnown normal case - 2 super set checks 470.00 ns/op 443.00 ns/op 1.06
isKnown worse case - 16 super set checks 453.00 ns/op 434.00 ns/op 1.04
InMemoryCheckpointStateCache - add get delete 3.1940 us/op 2.7750 us/op 1.15
validate api signedAggregateAndProof - struct 1.4347 ms/op 1.4030 ms/op 1.02
validate gossip signedAggregateAndProof - struct 1.9270 ms/op 1.4704 ms/op 1.31
batch validate gossip attestation - vc 640000 - chunk 32 117.99 us/op 125.13 us/op 0.94
batch validate gossip attestation - vc 640000 - chunk 64 102.74 us/op 106.23 us/op 0.97
batch validate gossip attestation - vc 640000 - chunk 128 96.363 us/op 99.264 us/op 0.97
batch validate gossip attestation - vc 640000 - chunk 256 93.227 us/op 97.643 us/op 0.95
pickEth1Vote - no votes 790.66 us/op 832.14 us/op 0.95
pickEth1Vote - max votes 5.3025 ms/op 5.2119 ms/op 1.02
pickEth1Vote - Eth1Data hashTreeRoot value x2048 16.717 ms/op 11.377 ms/op 1.47
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 20.939 ms/op 18.812 ms/op 1.11
pickEth1Vote - Eth1Data fastSerialize value x2048 330.90 us/op 366.19 us/op 0.90
pickEth1Vote - Eth1Data fastSerialize tree x2048 3.1616 ms/op 2.7871 ms/op 1.13
bytes32 toHexString 547.00 ns/op 691.00 ns/op 0.79
bytes32 Buffer.toString(hex) 413.00 ns/op 434.00 ns/op 0.95
bytes32 Buffer.toString(hex) from Uint8Array 519.00 ns/op 564.00 ns/op 0.92
bytes32 Buffer.toString(hex) + 0x 418.00 ns/op 426.00 ns/op 0.98
Object access 1 prop 0.30300 ns/op 0.32100 ns/op 0.94
Map access 1 prop 0.30000 ns/op 0.33500 ns/op 0.90
Object get x1000 4.7080 ns/op 5.2070 ns/op 0.90
Map get x1000 5.4630 ns/op 5.9370 ns/op 0.92
Object set x1000 21.868 ns/op 22.977 ns/op 0.95
Map set x1000 19.207 ns/op 18.868 ns/op 1.02
Return object 10000 times 0.27890 ns/op 0.30160 ns/op 0.92
Throw Error 10000 times 2.4755 us/op 2.6614 us/op 0.93
toHex 95.941 ns/op 110.21 ns/op 0.87
Buffer.from 90.213 ns/op 103.00 ns/op 0.88
shared Buffer 59.755 ns/op 70.305 ns/op 0.85
fastMsgIdFn sha256 / 200 bytes 1.8310 us/op 2.0490 us/op 0.89
fastMsgIdFn h32 xxhash / 200 bytes 379.00 ns/op 411.00 ns/op 0.92
fastMsgIdFn h64 xxhash / 200 bytes 423.00 ns/op 439.00 ns/op 0.96
fastMsgIdFn sha256 / 1000 bytes 5.5020 us/op 5.9500 us/op 0.92
fastMsgIdFn h32 xxhash / 1000 bytes 502.00 ns/op 535.00 ns/op 0.94
fastMsgIdFn h64 xxhash / 1000 bytes 491.00 ns/op 518.00 ns/op 0.95
fastMsgIdFn sha256 / 10000 bytes 45.931 us/op 49.603 us/op 0.93
fastMsgIdFn h32 xxhash / 10000 bytes 1.7960 us/op 1.9370 us/op 0.93
fastMsgIdFn h64 xxhash / 10000 bytes 1.2460 us/op 1.3510 us/op 0.92
send data - 1000 256B messages 9.8807 ms/op 11.504 ms/op 0.86
send data - 1000 512B messages 14.356 ms/op 17.497 ms/op 0.82
send data - 1000 1024B messages 21.915 ms/op 20.886 ms/op 1.05
send data - 1000 1200B messages 22.701 ms/op 24.969 ms/op 0.91
send data - 1000 2048B messages 27.582 ms/op 29.938 ms/op 0.92
send data - 1000 4096B messages 19.481 ms/op 25.568 ms/op 0.76
send data - 1000 16384B messages 65.611 ms/op 66.691 ms/op 0.98
send data - 1000 65536B messages 232.71 ms/op 230.88 ms/op 1.01
enrSubnets - fastDeserialize 64 bits 1.1010 us/op 1.1130 us/op 0.99
enrSubnets - ssz BitVector 64 bits 507.00 ns/op 499.00 ns/op 1.02
enrSubnets - fastDeserialize 4 bits 311.00 ns/op 344.00 ns/op 0.90
enrSubnets - ssz BitVector 4 bits 497.00 ns/op 518.00 ns/op 0.96
prioritizePeers score -10:0 att 32-0.1 sync 2-0 111.73 us/op 109.87 us/op 1.02
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 125.26 us/op 130.90 us/op 0.96
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 185.08 us/op 196.67 us/op 0.94
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 329.80 us/op 346.81 us/op 0.95
prioritizePeers score 0:0 att 64-1 sync 4-1 396.58 us/op 395.90 us/op 1.00
array of 16000 items push then shift 1.1808 us/op 1.2170 us/op 0.97
LinkedList of 16000 items push then shift 6.8630 ns/op 7.1550 ns/op 0.96
array of 16000 items push then pop 78.656 ns/op 104.32 ns/op 0.75
LinkedList of 16000 items push then pop 5.9720 ns/op 6.3070 ns/op 0.95
array of 24000 items push then shift 1.7297 us/op 1.9218 us/op 0.90
LinkedList of 24000 items push then shift 6.5540 ns/op 6.3320 ns/op 1.04
array of 24000 items push then pop 99.905 ns/op 106.94 ns/op 0.93
LinkedList of 24000 items push then pop 5.8950 ns/op 6.4680 ns/op 0.91
intersect bitArray bitLen 8 4.9980 ns/op 5.4720 ns/op 0.91
intersect array and set length 8 34.841 ns/op 37.481 ns/op 0.93
intersect bitArray bitLen 128 24.952 ns/op 26.592 ns/op 0.94
intersect array and set length 128 530.35 ns/op 571.67 ns/op 0.93
bitArray.getTrueBitIndexes() bitLen 128 1.3840 us/op 1.4100 us/op 0.98
bitArray.getTrueBitIndexes() bitLen 248 2.1810 us/op 2.1180 us/op 1.03
bitArray.getTrueBitIndexes() bitLen 512 4.0300 us/op 3.7720 us/op 1.07
Buffer.concat 32 items 884.00 ns/op 886.00 ns/op 1.00
Uint8Array.set 32 items 1.5910 us/op 1.6620 us/op 0.96
Buffer.copy 2.6050 us/op 2.3940 us/op 1.09
Uint8Array.set - with subarray 2.3060 us/op 2.3630 us/op 0.98
Uint8Array.set - without subarray 1.7250 us/op 1.7300 us/op 1.00
getUint32 - dataview 376.00 ns/op 417.00 ns/op 0.90
getUint32 - manual 310.00 ns/op 336.00 ns/op 0.92
Set add up to 64 items then delete first 1.6205 us/op 1.7610 us/op 0.92
OrderedSet add up to 64 items then delete first 2.5244 us/op 2.7222 us/op 0.93
Set add up to 64 items then delete last 1.8507 us/op 2.0246 us/op 0.91
OrderedSet add up to 64 items then delete last 2.8002 us/op 3.0132 us/op 0.93
Set add up to 64 items then delete middle 1.8560 us/op 2.0250 us/op 0.92
OrderedSet add up to 64 items then delete middle 4.1151 us/op 4.6284 us/op 0.89
Set add up to 128 items then delete first 3.6651 us/op 4.0406 us/op 0.91
OrderedSet add up to 128 items then delete first 5.7879 us/op 6.6739 us/op 0.87
Set add up to 128 items then delete last 3.6075 us/op 3.7815 us/op 0.95
OrderedSet add up to 128 items then delete last 5.5204 us/op 5.5609 us/op 0.99
Set add up to 128 items then delete middle 3.5440 us/op 3.7100 us/op 0.96
OrderedSet add up to 128 items then delete middle 10.627 us/op 12.261 us/op 0.87
Set add up to 256 items then delete first 8.4734 us/op 7.7349 us/op 1.10
OrderedSet add up to 256 items then delete first 12.206 us/op 12.606 us/op 0.97
Set add up to 256 items then delete last 7.0360 us/op 7.3554 us/op 0.96
OrderedSet add up to 256 items then delete last 10.929 us/op 12.072 us/op 0.91
Set add up to 256 items then delete middle 6.9672 us/op 7.4141 us/op 0.94
OrderedSet add up to 256 items then delete middle 32.151 us/op 34.889 us/op 0.92
transfer serialized Status (84 B) 2.1690 us/op 2.4040 us/op 0.90
copy serialized Status (84 B) 1.3890 us/op 1.4050 us/op 0.99
transfer serialized SignedVoluntaryExit (112 B) 2.3610 us/op 2.4860 us/op 0.95
copy serialized SignedVoluntaryExit (112 B) 1.4420 us/op 1.4910 us/op 0.97
transfer serialized ProposerSlashing (416 B) 2.5750 us/op 2.6270 us/op 0.98
copy serialized ProposerSlashing (416 B) 2.0190 us/op 2.6280 us/op 0.77
transfer serialized Attestation (485 B) 2.7250 us/op 3.2590 us/op 0.84
copy serialized Attestation (485 B) 2.1340 us/op 2.6850 us/op 0.79
transfer serialized AttesterSlashing (33232 B) 2.6870 us/op 3.2690 us/op 0.82
copy serialized AttesterSlashing (33232 B) 4.2850 us/op 5.3270 us/op 0.80
transfer serialized Small SignedBeaconBlock (128000 B) 2.7640 us/op 3.5940 us/op 0.77
copy serialized Small SignedBeaconBlock (128000 B) 12.171 us/op 9.6160 us/op 1.27
transfer serialized Avg SignedBeaconBlock (200000 B) 2.8220 us/op 3.7990 us/op 0.74
copy serialized Avg SignedBeaconBlock (200000 B) 11.705 us/op 12.479 us/op 0.94
transfer serialized BlobsSidecar (524380 B) 3.5150 us/op 3.9350 us/op 0.89
copy serialized BlobsSidecar (524380 B) 70.309 us/op 68.446 us/op 1.03
transfer serialized Big SignedBeaconBlock (1000000 B) 3.8600 us/op 4.3800 us/op 0.88
copy serialized Big SignedBeaconBlock (1000000 B) 137.92 us/op 127.23 us/op 1.08
pass gossip attestations to forkchoice per slot 2.2170 ms/op 2.3499 ms/op 0.94
forkChoice updateHead vc 100000 bc 64 eq 0 358.93 us/op 380.96 us/op 0.94
forkChoice updateHead vc 600000 bc 64 eq 0 2.1714 ms/op 2.3445 ms/op 0.93
forkChoice updateHead vc 1000000 bc 64 eq 0 3.7984 ms/op 3.8599 ms/op 0.98
forkChoice updateHead vc 600000 bc 320 eq 0 2.2369 ms/op 2.3089 ms/op 0.97
forkChoice updateHead vc 600000 bc 1200 eq 0 2.0316 ms/op 2.2048 ms/op 0.92
forkChoice updateHead vc 600000 bc 7200 eq 0 2.7989 ms/op 2.4808 ms/op 1.13
forkChoice updateHead vc 600000 bc 64 eq 1000 9.5381 ms/op 9.4506 ms/op 1.01
forkChoice updateHead vc 600000 bc 64 eq 10000 9.0758 ms/op 9.3398 ms/op 0.97
forkChoice updateHead vc 600000 bc 64 eq 300000 11.506 ms/op 11.232 ms/op 1.02
computeDeltas 500000 validators 300 proto nodes 3.1495 ms/op 3.2276 ms/op 0.98
computeDeltas 500000 validators 1200 proto nodes 3.1406 ms/op 3.1948 ms/op 0.98
computeDeltas 500000 validators 7200 proto nodes 3.1350 ms/op 3.1732 ms/op 0.99
computeDeltas 750000 validators 300 proto nodes 4.8467 ms/op 4.8530 ms/op 1.00
computeDeltas 750000 validators 1200 proto nodes 4.7382 ms/op 4.8287 ms/op 0.98
computeDeltas 750000 validators 7200 proto nodes 4.8268 ms/op 4.8821 ms/op 0.99
computeDeltas 1400000 validators 300 proto nodes 9.0691 ms/op 8.9087 ms/op 1.02
computeDeltas 1400000 validators 1200 proto nodes 9.2120 ms/op 8.9118 ms/op 1.03
computeDeltas 1400000 validators 7200 proto nodes 8.8172 ms/op 8.6853 ms/op 1.02
computeDeltas 2100000 validators 300 proto nodes 13.547 ms/op 13.195 ms/op 1.03
computeDeltas 2100000 validators 1200 proto nodes 13.523 ms/op 13.240 ms/op 1.02
computeDeltas 2100000 validators 7200 proto nodes 13.686 ms/op 13.129 ms/op 1.04
altair processAttestation - 250000 vs - 7PWei normalcase 1.6148 ms/op 1.5966 ms/op 1.01
altair processAttestation - 250000 vs - 7PWei worstcase 2.3917 ms/op 2.3780 ms/op 1.01
altair processAttestation - setStatus - 1/6 committees join 90.826 us/op 89.289 us/op 1.02
altair processAttestation - setStatus - 1/3 committees join 179.10 us/op 160.75 us/op 1.11
altair processAttestation - setStatus - 1/2 committees join 267.11 us/op 242.07 us/op 1.10
altair processAttestation - setStatus - 2/3 committees join 351.08 us/op 323.82 us/op 1.08
altair processAttestation - setStatus - 4/5 committees join 490.13 us/op 455.37 us/op 1.08
altair processAttestation - setStatus - 100% committees join 581.70 us/op 541.69 us/op 1.07
altair processBlock - 250000 vs - 7PWei normalcase 4.4379 ms/op 4.9124 ms/op 0.90
altair processBlock - 250000 vs - 7PWei normalcase hashState 31.798 ms/op 27.527 ms/op 1.16
altair processBlock - 250000 vs - 7PWei worstcase 34.345 ms/op 35.410 ms/op 0.97
altair processBlock - 250000 vs - 7PWei worstcase hashState 73.198 ms/op 73.272 ms/op 1.00
phase0 processBlock - 250000 vs - 7PWei normalcase 1.7480 ms/op 2.1014 ms/op 0.83
phase0 processBlock - 250000 vs - 7PWei worstcase 23.497 ms/op 24.022 ms/op 0.98
altair processEth1Data - 250000 vs - 7PWei normalcase 302.92 us/op 325.26 us/op 0.93
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 5.0580 us/op 7.2550 us/op 0.70
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 27.536 us/op 14.328 us/op 1.92
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 8.8880 us/op 8.0660 us/op 1.10
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 2.5750 us/op 7.4020 us/op 0.35
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 107.40 us/op 114.56 us/op 0.94
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.1743 ms/op 1.2485 ms/op 0.94
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.0068 ms/op 1.0865 ms/op 0.93
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.0003 ms/op 1.0957 ms/op 0.91
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 2.5564 ms/op 2.3358 ms/op 1.09
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 966.52 us/op 975.85 us/op 0.99
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 2.8483 ms/op 2.6651 ms/op 1.07
Tree 40 250000 create 352.47 ms/op 320.26 ms/op 1.10
Tree 40 250000 get(125000) 111.66 ns/op 120.44 ns/op 0.93
Tree 40 250000 set(125000) 1.2200 us/op 1.1879 us/op 1.03
Tree 40 250000 toArray() 9.4353 ms/op 12.682 ms/op 0.74
Tree 40 250000 iterate all - toArray() + loop 9.5133 ms/op 15.520 ms/op 0.61
Tree 40 250000 iterate all - get(i) 40.849 ms/op 37.881 ms/op 1.08
Array 250000 create 2.2721 ms/op 2.4775 ms/op 0.92
Array 250000 clone - spread 1.2369 ms/op 1.2589 ms/op 0.98
Array 250000 get(125000) 0.58300 ns/op 0.55300 ns/op 1.05
Array 250000 set(125000) 0.59000 ns/op 0.57700 ns/op 1.02
Array 250000 iterate all - loop 76.699 us/op 76.344 us/op 1.00
phase0 afterProcessEpoch - 250000 vs - 7PWei 41.809 ms/op 40.932 ms/op 1.02
Array.fill - length 1000000 2.5134 ms/op 2.5310 ms/op 0.99
Array push - length 1000000 13.363 ms/op 14.168 ms/op 0.94
Array.get 0.26265 ns/op 0.25216 ns/op 1.04
Uint8Array.get 0.34304 ns/op 0.31755 ns/op 1.08
phase0 beforeProcessEpoch - 250000 vs - 7PWei 12.098 ms/op 15.203 ms/op 0.80
altair processEpoch - mainnet_e81889 271.11 ms/op 283.03 ms/op 0.96
mainnet_e81889 - altair beforeProcessEpoch 17.697 ms/op 15.199 ms/op 1.16
mainnet_e81889 - altair processJustificationAndFinalization 11.497 us/op 13.387 us/op 0.86
mainnet_e81889 - altair processInactivityUpdates 3.7264 ms/op 3.5587 ms/op 1.05
mainnet_e81889 - altair processRewardsAndPenalties 58.152 ms/op 49.105 ms/op 1.18
mainnet_e81889 - altair processRegistryUpdates 2.3190 us/op 2.1800 us/op 1.06
mainnet_e81889 - altair processSlashings 827.00 ns/op 811.00 ns/op 1.02
mainnet_e81889 - altair processEth1DataReset 868.00 ns/op 894.00 ns/op 0.97
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.6219 ms/op 1.6211 ms/op 1.00
mainnet_e81889 - altair processSlashingsReset 2.5730 us/op 2.6420 us/op 0.97
mainnet_e81889 - altair processRandaoMixesReset 3.4590 us/op 3.3400 us/op 1.04
mainnet_e81889 - altair processHistoricalRootsUpdate 854.00 ns/op 883.00 ns/op 0.97
mainnet_e81889 - altair processParticipationFlagUpdates 2.0320 us/op 1.9310 us/op 1.05
mainnet_e81889 - altair processSyncCommitteeUpdates 744.00 ns/op 819.00 ns/op 0.91
mainnet_e81889 - altair afterProcessEpoch 41.540 ms/op 43.173 ms/op 0.96
capella processEpoch - mainnet_e217614 975.17 ms/op 978.93 ms/op 1.00
mainnet_e217614 - capella beforeProcessEpoch 61.252 ms/op 63.911 ms/op 0.96
mainnet_e217614 - capella processJustificationAndFinalization 11.349 us/op 10.345 us/op 1.10
mainnet_e217614 - capella processInactivityUpdates 12.803 ms/op 12.624 ms/op 1.01
mainnet_e217614 - capella processRewardsAndPenalties 262.95 ms/op 247.84 ms/op 1.06
mainnet_e217614 - capella processRegistryUpdates 10.217 us/op 11.037 us/op 0.93
mainnet_e217614 - capella processSlashings 821.00 ns/op 855.00 ns/op 0.96
mainnet_e217614 - capella processEth1DataReset 841.00 ns/op 820.00 ns/op 1.03
mainnet_e217614 - capella processEffectiveBalanceUpdates 11.593 ms/op 3.5293 ms/op 3.28
mainnet_e217614 - capella processSlashingsReset 2.8580 us/op 1.4820 us/op 1.93
mainnet_e217614 - capella processRandaoMixesReset 3.2800 us/op 3.4940 us/op 0.94
mainnet_e217614 - capella processHistoricalRootsUpdate 958.00 ns/op 758.00 ns/op 1.26
mainnet_e217614 - capella processParticipationFlagUpdates 1.4370 us/op 1.4140 us/op 1.02
mainnet_e217614 - capella afterProcessEpoch 101.08 ms/op 102.03 ms/op 0.99
phase0 processEpoch - mainnet_e58758 312.83 ms/op 311.00 ms/op 1.01
mainnet_e58758 - phase0 beforeProcessEpoch 73.271 ms/op 74.847 ms/op 0.98
mainnet_e58758 - phase0 processJustificationAndFinalization 13.143 us/op 12.726 us/op 1.03
mainnet_e58758 - phase0 processRewardsAndPenalties 31.749 ms/op 30.333 ms/op 1.05
mainnet_e58758 - phase0 processRegistryUpdates 4.1950 us/op 6.9070 us/op 0.61
mainnet_e58758 - phase0 processSlashings 561.00 ns/op 944.00 ns/op 0.59
mainnet_e58758 - phase0 processEth1DataReset 503.00 ns/op 816.00 ns/op 0.62
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 770.65 us/op 1.3356 ms/op 0.58
mainnet_e58758 - phase0 processSlashingsReset 2.3550 us/op 2.3740 us/op 0.99
mainnet_e58758 - phase0 processRandaoMixesReset 3.4720 us/op 3.6040 us/op 0.96
mainnet_e58758 - phase0 processHistoricalRootsUpdate 773.00 ns/op 817.00 ns/op 0.95
mainnet_e58758 - phase0 processParticipationRecordUpdates 3.5340 us/op 3.3550 us/op 1.05
mainnet_e58758 - phase0 afterProcessEpoch 33.919 ms/op 35.321 ms/op 0.96
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.6252 ms/op 911.91 us/op 1.78
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.3568 ms/op 1.2086 ms/op 1.12
altair processInactivityUpdates - 250000 normalcase 16.335 ms/op 15.697 ms/op 1.04
altair processInactivityUpdates - 250000 worstcase 16.735 ms/op 16.515 ms/op 1.01
phase0 processRegistryUpdates - 250000 normalcase 4.5040 us/op 2.6820 us/op 1.68
phase0 processRegistryUpdates - 250000 badcase_full_deposits 292.79 us/op 285.47 us/op 1.03
phase0 processRegistryUpdates - 250000 worstcase 0.5 100.99 ms/op 94.361 ms/op 1.07
altair processRewardsAndPenalties - 250000 normalcase 48.422 ms/op 49.404 ms/op 0.98
altair processRewardsAndPenalties - 250000 worstcase 34.567 ms/op 40.183 ms/op 0.86
phase0 getAttestationDeltas - 250000 normalcase 5.7895 ms/op 4.7672 ms/op 1.21
phase0 getAttestationDeltas - 250000 worstcase 5.3264 ms/op 5.0448 ms/op 1.06
phase0 processSlashings - 250000 worstcase 88.347 us/op 83.007 us/op 1.06
altair processSyncCommitteeUpdates - 250000 92.989 ms/op 92.327 ms/op 1.01
BeaconState.hashTreeRoot - No change 454.00 ns/op 448.00 ns/op 1.01
BeaconState.hashTreeRoot - 1 full validator 104.94 us/op 99.307 us/op 1.06
BeaconState.hashTreeRoot - 32 full validator 1.2083 ms/op 1.4092 ms/op 0.86
BeaconState.hashTreeRoot - 512 full validator 10.961 ms/op 11.187 ms/op 0.98
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 136.68 us/op 146.09 us/op 0.94
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.7543 ms/op 1.8672 ms/op 0.94
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 22.869 ms/op 23.627 ms/op 0.97
BeaconState.hashTreeRoot - 1 balances 109.35 us/op 121.32 us/op 0.90
BeaconState.hashTreeRoot - 32 balances 1.2798 ms/op 1.2942 ms/op 0.99
BeaconState.hashTreeRoot - 512 balances 9.2452 ms/op 7.4127 ms/op 1.25
BeaconState.hashTreeRoot - 250000 balances 194.70 ms/op 175.21 ms/op 1.11
aggregationBits - 2048 els - zipIndexesInBitList 19.842 us/op 19.821 us/op 1.00
byteArrayEquals 32 45.400 ns/op 44.536 ns/op 1.02
Buffer.compare 32 14.537 ns/op 14.226 ns/op 1.02
byteArrayEquals 1024 1.2005 us/op 1.1549 us/op 1.04
Buffer.compare 1024 21.404 ns/op 22.023 ns/op 0.97
byteArrayEquals 16384 19.048 us/op 18.358 us/op 1.04
Buffer.compare 16384 167.57 ns/op 189.01 ns/op 0.89
byteArrayEquals 123687377 143.93 ms/op 138.78 ms/op 1.04
Buffer.compare 123687377 5.2886 ms/op 5.3418 ms/op 0.99
byteArrayEquals 32 - diff last byte 45.597 ns/op 43.629 ns/op 1.05
Buffer.compare 32 - diff last byte 14.928 ns/op 14.517 ns/op 1.03
byteArrayEquals 1024 - diff last byte 1.2036 us/op 1.1536 us/op 1.04
Buffer.compare 1024 - diff last byte 22.818 ns/op 22.181 ns/op 1.03
byteArrayEquals 16384 - diff last byte 19.101 us/op 18.503 us/op 1.03
Buffer.compare 16384 - diff last byte 169.34 ns/op 174.71 ns/op 0.97
byteArrayEquals 123687377 - diff last byte 148.19 ms/op 141.80 ms/op 1.05
Buffer.compare 123687377 - diff last byte 5.3545 ms/op 4.0957 ms/op 1.31
byteArrayEquals 32 - random bytes 5.1460 ns/op 4.9130 ns/op 1.05
Buffer.compare 32 - random bytes 16.693 ns/op 16.298 ns/op 1.02
byteArrayEquals 1024 - random bytes 5.1560 ns/op 4.9840 ns/op 1.03
Buffer.compare 1024 - random bytes 15.976 ns/op 15.802 ns/op 1.01
byteArrayEquals 16384 - random bytes 5.1530 ns/op 4.9480 ns/op 1.04
Buffer.compare 16384 - random bytes 16.637 ns/op 15.773 ns/op 1.05
byteArrayEquals 123687377 - random bytes 8.2400 ns/op 7.8900 ns/op 1.04
Buffer.compare 123687377 - random bytes 18.980 ns/op 18.770 ns/op 1.01
regular array get 100000 times 31.840 us/op 29.854 us/op 1.07
wrappedArray get 100000 times 31.832 us/op 29.742 us/op 1.07
arrayWithProxy get 100000 times 10.682 ms/op 9.3537 ms/op 1.14
ssz.Root.equals 45.570 ns/op 43.084 ns/op 1.06
byteArrayEquals 45.039 ns/op 41.808 ns/op 1.08
Buffer.compare 9.4020 ns/op 8.7040 ns/op 1.08
processSlot - 1 slots 11.550 us/op 10.923 us/op 1.06
processSlot - 32 slots 3.4760 ms/op 2.4367 ms/op 1.43
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 40.065 ms/op 40.229 ms/op 1.00
getCommitteeAssignments - req 1 vs - 250000 vc 1.8260 ms/op 1.7251 ms/op 1.06
getCommitteeAssignments - req 100 vs - 250000 vc 3.5922 ms/op 3.4071 ms/op 1.05
getCommitteeAssignments - req 1000 vs - 250000 vc 3.8038 ms/op 3.6537 ms/op 1.04
findModifiedValidators - 10000 modified validators 239.88 ms/op 229.13 ms/op 1.05
findModifiedValidators - 1000 modified validators 149.10 ms/op 133.76 ms/op 1.11
findModifiedValidators - 100 modified validators 140.66 ms/op 142.87 ms/op 0.98
findModifiedValidators - 10 modified validators 131.64 ms/op 130.18 ms/op 1.01
findModifiedValidators - 1 modified validators 118.73 ms/op 121.63 ms/op 0.98
findModifiedValidators - no difference 139.20 ms/op 152.00 ms/op 0.92
compare ViewDUs 3.3420 s/op 3.3439 s/op 1.00
compare each validator Uint8Array 1.5038 s/op 1.6096 s/op 0.93
compare ViewDU to Uint8Array 661.38 ms/op 639.98 ms/op 1.03
migrate state 1000000 validators, 24 modified, 0 new 708.12 ms/op 657.74 ms/op 1.08
migrate state 1000000 validators, 1700 modified, 1000 new 976.76 ms/op 905.18 ms/op 1.08
migrate state 1000000 validators, 3400 modified, 2000 new 1.1379 s/op 1.0738 s/op 1.06
migrate state 1500000 validators, 24 modified, 0 new 765.15 ms/op 738.77 ms/op 1.04
migrate state 1500000 validators, 1700 modified, 1000 new 961.92 ms/op 939.29 ms/op 1.02
migrate state 1500000 validators, 3400 modified, 2000 new 1.1297 s/op 1.1154 s/op 1.01
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.9800 ns/op 6.2100 ns/op 0.96
state getBlockRootAtSlot - 250000 vs - 7PWei 890.82 ns/op 1.0431 us/op 0.85
computeProposers - vc 250000 5.7513 ms/op 6.6853 ms/op 0.86
computeEpochShuffling - vc 250000 35.301 ms/op 34.647 ms/op 1.02
getNextSyncCommittee - vc 250000 97.455 ms/op 111.45 ms/op 0.87
computeSigningRoot for AttestationData 28.266 us/op 28.617 us/op 0.99
hash AttestationData serialized data then Buffer.toString(base64) 1.1034 us/op 1.1232 us/op 0.98
toHexString serialized data 715.92 ns/op 728.97 ns/op 0.98
Buffer.toString(base64) 121.58 ns/op 131.85 ns/op 0.92
nodejs block root to RootHex using toHex 103.94 ns/op 103.30 ns/op 1.01
nodejs block root to RootHex using toRootHex 71.534 ns/op 66.677 ns/op 1.07
browser block root to RootHex using the deprecated toHexString 192.46 ns/op 195.38 ns/op 0.99
browser block root to RootHex using toHex 153.11 ns/op 155.97 ns/op 0.98
browser block root to RootHex using toRootHex 150.16 ns/op 137.94 ns/op 1.09

by benchmarkbot/action

Copy link
Member

@nflaig nflaig left a comment

Choose a reason for hiding this comment

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

Generally looks good, left some thoughts

packages/beacon-node/src/execution/engine/http.ts Outdated Show resolved Hide resolved
packages/beacon-node/src/execution/engine/http.ts Outdated Show resolved Hide resolved
packages/beacon-node/src/execution/engine/types.ts Outdated Show resolved Hide resolved
@ensi321 ensi321 changed the title chore: flatten fork logic in notifyNewPayload refactor: flatten fork logic in notifyNewPayload Jan 23, 2025
serializedExecutionRequests,
],
method,
params: generateSerializedNewPayloadParams(fork, method, {executionPayload}),
Copy link
Member

@nflaig nflaig Jan 23, 2025

Choose a reason for hiding this comment

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

while this looks much cleaner here, we lose a lot of type safety

eg. it's possible to call it like this without complaints

params: generateSerializedNewPayloadParams(fork, method, {}),

and then you will just notice this at runtime

@ensi321 ensi321 requested a review from nflaig January 30, 2025 03:06
Copy link
Member

@nflaig nflaig left a comment

Choose a reason for hiding this comment

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

I am bit unsure about this, it adds more layers of indirection and a lot more boilerplate code.

While the nested if-statements are not sustainable forever, I think right now it's not that bad.

But curious what others think

@@ -82,6 +85,22 @@ export type EngineApiRpcParamTypes = {
engine_getBlobsV1: [DATA[]];
};

// Can extend keys to other engine API whenever it sees fit
export type EngineApiParamTypes = {
Copy link
Member

Choose a reason for hiding this comment

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

so while this type now makes the function call type safe it still offers the possibility that the type is not updated correctly, I was playing around with this locally and though to myself adding another type is not acceptable

@ensi321
Copy link
Contributor Author

ensi321 commented Jan 31, 2025

I am bit unsure about this, it adds more layers of indirection and a lot more boilerplate code.

While the nested if-statements are not sustainable forever, I think right now it's not that bad.

But curious what others think

How about we revert back to b29d470 and break down the if statements here to several ifs? One if statement for each required param check.

@nflaig
Copy link
Member

nflaig commented Jan 31, 2025

How about we revert back to b29d470 and break down the if statements here to several ifs? One if statement for each required param check.

I think that was better than what we have now, I don't have a good idea how to make it better right now, would have to take another look myself

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.

2 participants