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: support fetching historical proposer duties #7130

Merged
merged 14 commits into from
Oct 11, 2024

Conversation

nflaig
Copy link
Member

@nflaig nflaig commented Oct 7, 2024

Motivation

Fetching historical (mostly finalized) proposer duties has been a requirement by smoothing pools in the past. In addition, dappnode is building a staking rewards dashboard which also requires to pull finalized proposer duties from the node of the staker. Right now, Lodestar is the only beacon node that does not support serving this data.

Description

This change adds supports to fetch historical proposer duties by utilizing historical state regen added in #6033.

This has it's known limitations of being rather slow for far back epochs but for the most common use case which is fetching proposer duties for the finalized epoch it takes around 2 seconds to fetch duties which seems acceptable.

TODO

  • add test cases

@philknows philknows added this to the v1.23.0 milestone Oct 7, 2024
Copy link

codecov bot commented Oct 7, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 49.12%. Comparing base (4b7d871) to head (439d26a).
Report is 2 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #7130      +/-   ##
============================================
- Coverage     49.12%   49.12%   -0.01%     
============================================
  Files           597      597              
  Lines         39718    39721       +3     
  Branches       2085     2085              
============================================
- Hits          19512    19511       -1     
- Misses        20165    20168       +3     
- Partials         41       42       +1     

Copy link
Contributor

github-actions bot commented Oct 7, 2024

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 52104c3 Previous: ac6edd3 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.1823 ms/op 1.9204 ms/op 1.14
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 75.294 us/op 39.560 us/op 1.90
BLS verify - blst 1.0941 ms/op 898.92 us/op 1.22
BLS verifyMultipleSignatures 3 - blst 1.5293 ms/op 1.3742 ms/op 1.11
BLS verifyMultipleSignatures 8 - blst 2.0957 ms/op 2.1552 ms/op 0.97
BLS verifyMultipleSignatures 32 - blst 6.3379 ms/op 4.5677 ms/op 1.39
BLS verifyMultipleSignatures 64 - blst 11.220 ms/op 8.5810 ms/op 1.31
BLS verifyMultipleSignatures 128 - blst 18.232 ms/op 16.269 ms/op 1.12
BLS deserializing 10000 signatures 731.83 ms/op 616.99 ms/op 1.19
BLS deserializing 100000 signatures 7.2664 s/op 6.2932 s/op 1.15
BLS verifyMultipleSignatures - same message - 3 - blst 1.2022 ms/op 989.40 us/op 1.22
BLS verifyMultipleSignatures - same message - 8 - blst 1.2095 ms/op 1.0942 ms/op 1.11
BLS verifyMultipleSignatures - same message - 32 - blst 1.9035 ms/op 1.7047 ms/op 1.12
BLS verifyMultipleSignatures - same message - 64 - blst 2.6537 ms/op 2.6104 ms/op 1.02
BLS verifyMultipleSignatures - same message - 128 - blst 4.4781 ms/op 4.2510 ms/op 1.05
BLS aggregatePubkeys 32 - blst 21.360 us/op 18.701 us/op 1.14
BLS aggregatePubkeys 128 - blst 73.533 us/op 64.932 us/op 1.13
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 65.643 ms/op 66.626 ms/op 0.99
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 59.680 ms/op 47.974 ms/op 1.24
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 41.578 ms/op 31.813 ms/op 1.31
getSlashingsAndExits - default max 116.61 us/op 82.961 us/op 1.41
getSlashingsAndExits - 2k 356.10 us/op 304.25 us/op 1.17
proposeBlockBody type=full, size=empty 6.2965 ms/op 4.7030 ms/op 1.34
isKnown best case - 1 super set check 580.00 ns/op 548.00 ns/op 1.06
isKnown normal case - 2 super set checks 573.00 ns/op 481.00 ns/op 1.19
isKnown worse case - 16 super set checks 587.00 ns/op 475.00 ns/op 1.24
InMemoryCheckpointStateCache - add get delete 3.9270 us/op 2.9970 us/op 1.31
updateUnfinalizedPubkeys - updating 10 pubkeys 1.9777 ms/op 871.76 us/op 2.27
updateUnfinalizedPubkeys - updating 100 pubkeys 7.2367 ms/op 2.8367 ms/op 2.55
updateUnfinalizedPubkeys - updating 1000 pubkeys 69.731 ms/op 38.542 ms/op 1.81
validate api signedAggregateAndProof - struct 2.1434 ms/op 1.5673 ms/op 1.37
validate gossip signedAggregateAndProof - struct 2.1247 ms/op 1.5267 ms/op 1.39
batch validate gossip attestation - vc 640000 - chunk 32 164.82 us/op 124.93 us/op 1.32
batch validate gossip attestation - vc 640000 - chunk 64 144.42 us/op 114.94 us/op 1.26
batch validate gossip attestation - vc 640000 - chunk 128 134.30 us/op 109.35 us/op 1.23
batch validate gossip attestation - vc 640000 - chunk 256 137.67 us/op 105.38 us/op 1.31
pickEth1Vote - no votes 1.3218 ms/op 893.66 us/op 1.48
pickEth1Vote - max votes 10.659 ms/op 4.9052 ms/op 2.17
pickEth1Vote - Eth1Data hashTreeRoot value x2048 22.523 ms/op 13.985 ms/op 1.61
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 34.678 ms/op 22.188 ms/op 1.56
pickEth1Vote - Eth1Data fastSerialize value x2048 645.82 us/op 373.22 us/op 1.73
pickEth1Vote - Eth1Data fastSerialize tree x2048 3.9480 ms/op 3.1453 ms/op 1.26
bytes32 toHexString 802.00 ns/op 896.00 ns/op 0.90
bytes32 Buffer.toString(hex) 283.00 ns/op 510.00 ns/op 0.55
bytes32 Buffer.toString(hex) from Uint8Array 535.00 ns/op 712.00 ns/op 0.75
bytes32 Buffer.toString(hex) + 0x 273.00 ns/op 484.00 ns/op 0.56
Object access 1 prop 0.21900 ns/op 0.38900 ns/op 0.56
Map access 1 prop 0.15700 ns/op 0.34400 ns/op 0.46
Object get x1000 6.8330 ns/op 5.2860 ns/op 1.29
Map get x1000 7.6770 ns/op 6.3410 ns/op 1.21
Object set x1000 66.975 ns/op 25.085 ns/op 2.67
Map set x1000 44.274 ns/op 22.085 ns/op 2.00
Return object 10000 times 0.34700 ns/op 0.31840 ns/op 1.09
Throw Error 10000 times 3.9975 us/op 3.1949 us/op 1.25
toHex 206.19 ns/op 133.55 ns/op 1.54
Buffer.from 171.62 ns/op 112.24 ns/op 1.53
shared Buffer 101.71 ns/op 92.703 ns/op 1.10
fastMsgIdFn sha256 / 200 bytes 2.7350 us/op 2.3970 us/op 1.14
fastMsgIdFn h32 xxhash / 200 bytes 328.00 ns/op 514.00 ns/op 0.64
fastMsgIdFn h64 xxhash / 200 bytes 323.00 ns/op 468.00 ns/op 0.69
fastMsgIdFn sha256 / 1000 bytes 8.3580 us/op 6.2330 us/op 1.34
fastMsgIdFn h32 xxhash / 1000 bytes 476.00 ns/op 595.00 ns/op 0.80
fastMsgIdFn h64 xxhash / 1000 bytes 398.00 ns/op 581.00 ns/op 0.69
fastMsgIdFn sha256 / 10000 bytes 72.567 us/op 59.864 us/op 1.21
fastMsgIdFn h32 xxhash / 10000 bytes 2.1300 us/op 2.1390 us/op 1.00
fastMsgIdFn h64 xxhash / 10000 bytes 1.3860 us/op 1.4100 us/op 0.98
send data - 1000 256B messages 18.182 ms/op 10.938 ms/op 1.66
send data - 1000 512B messages 20.935 ms/op 16.919 ms/op 1.24
send data - 1000 1024B messages 30.426 ms/op 26.077 ms/op 1.17
send data - 1000 1200B messages 33.921 ms/op 25.485 ms/op 1.33
send data - 1000 2048B messages 43.312 ms/op 35.649 ms/op 1.21
send data - 1000 4096B messages 44.071 ms/op 31.093 ms/op 1.42
send data - 1000 16384B messages 90.050 ms/op 71.227 ms/op 1.26
send data - 1000 65536B messages 275.51 ms/op 541.30 ms/op 0.51
enrSubnets - fastDeserialize 64 bits 1.7240 us/op 1.7220 us/op 1.00
enrSubnets - ssz BitVector 64 bits 498.00 ns/op 847.00 ns/op 0.59
enrSubnets - fastDeserialize 4 bits 229.00 ns/op 495.00 ns/op 0.46
enrSubnets - ssz BitVector 4 bits 514.00 ns/op 799.00 ns/op 0.64
prioritizePeers score -10:0 att 32-0.1 sync 2-0 229.24 us/op 256.68 us/op 0.89
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 208.44 us/op 305.57 us/op 0.68
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 446.79 us/op 534.34 us/op 0.84
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 601.20 us/op 591.33 us/op 1.02
prioritizePeers score 0:0 att 64-1 sync 4-1 1.1439 ms/op 1.1677 ms/op 0.98
array of 16000 items push then shift 1.7762 us/op 1.6760 us/op 1.06
LinkedList of 16000 items push then shift 8.4810 ns/op 10.528 ns/op 0.81
array of 16000 items push then pop 148.25 ns/op 187.12 ns/op 0.79
LinkedList of 16000 items push then pop 7.9370 ns/op 8.3810 ns/op 0.95
array of 24000 items push then shift 2.6609 us/op 2.1895 us/op 1.22
LinkedList of 24000 items push then shift 11.397 ns/op 11.874 ns/op 0.96
array of 24000 items push then pop 224.65 ns/op 217.78 ns/op 1.03
LinkedList of 24000 items push then pop 8.8320 ns/op 11.271 ns/op 0.78
intersect bitArray bitLen 8 7.3950 ns/op 6.3000 ns/op 1.17
intersect array and set length 8 73.234 ns/op 94.322 ns/op 0.78
intersect bitArray bitLen 128 34.762 ns/op 32.119 ns/op 1.08
intersect array and set length 128 988.60 ns/op 1.0127 us/op 0.98
bitArray.getTrueBitIndexes() bitLen 128 2.4340 us/op 3.0460 us/op 0.80
bitArray.getTrueBitIndexes() bitLen 248 4.9520 us/op 3.8340 us/op 1.29
bitArray.getTrueBitIndexes() bitLen 512 9.9840 us/op 9.3330 us/op 1.07
Buffer.concat 32 items 1.1250 us/op 1.2100 us/op 0.93
Uint8Array.set 32 items 2.4140 us/op 1.7760 us/op 1.36
Buffer.copy 2.2570 us/op 2.0720 us/op 1.09
Uint8Array.set - with subarray 3.4100 us/op 2.2560 us/op 1.51
Uint8Array.set - without subarray 2.6060 us/op 1.9770 us/op 1.32
getUint32 - dataview 328.00 ns/op 532.00 ns/op 0.62
getUint32 - manual 289.00 ns/op 522.00 ns/op 0.55
Set add up to 64 items then delete first 3.2795 us/op 2.2781 us/op 1.44
OrderedSet add up to 64 items then delete first 5.7120 us/op 3.0991 us/op 1.84
Set add up to 64 items then delete last 4.3571 us/op 4.4103 us/op 0.99
OrderedSet add up to 64 items then delete last 6.4045 us/op 5.2723 us/op 1.21
Set add up to 64 items then delete middle 3.6458 us/op 3.2397 us/op 1.13
OrderedSet add up to 64 items then delete middle 7.2986 us/op 6.9798 us/op 1.05
Set add up to 128 items then delete first 7.3033 us/op 6.3323 us/op 1.15
OrderedSet add up to 128 items then delete first 12.412 us/op 7.5891 us/op 1.64
Set add up to 128 items then delete last 6.8684 us/op 6.1522 us/op 1.12
OrderedSet add up to 128 items then delete last 10.585 us/op 9.2507 us/op 1.14
Set add up to 128 items then delete middle 7.7716 us/op 5.4761 us/op 1.42
OrderedSet add up to 128 items then delete middle 21.570 us/op 15.739 us/op 1.37
Set add up to 256 items then delete first 16.976 us/op 12.492 us/op 1.36
OrderedSet add up to 256 items then delete first 27.472 us/op 18.626 us/op 1.47
Set add up to 256 items then delete last 16.042 us/op 10.199 us/op 1.57
OrderedSet add up to 256 items then delete last 23.579 us/op 15.434 us/op 1.53
Set add up to 256 items then delete middle 14.985 us/op 8.7193 us/op 1.72
OrderedSet add up to 256 items then delete middle 53.741 us/op 40.521 us/op 1.33
transfer serialized Status (84 B) 1.6180 us/op 1.4910 us/op 1.09
copy serialized Status (84 B) 1.4350 us/op 1.3910 us/op 1.03
transfer serialized SignedVoluntaryExit (112 B) 2.0350 us/op 1.5540 us/op 1.31
copy serialized SignedVoluntaryExit (112 B) 1.6600 us/op 1.5800 us/op 1.05
transfer serialized ProposerSlashing (416 B) 2.5830 us/op 2.3130 us/op 1.12
copy serialized ProposerSlashing (416 B) 2.9140 us/op 2.5450 us/op 1.14
transfer serialized Attestation (485 B) 3.0390 us/op 2.0620 us/op 1.47
copy serialized Attestation (485 B) 2.9210 us/op 2.1810 us/op 1.34
transfer serialized AttesterSlashing (33232 B) 2.1980 us/op 2.5530 us/op 0.86
copy serialized AttesterSlashing (33232 B) 9.1220 us/op 4.8200 us/op 1.89
transfer serialized Small SignedBeaconBlock (128000 B) 3.1690 us/op 2.6460 us/op 1.20
copy serialized Small SignedBeaconBlock (128000 B) 28.721 us/op 13.227 us/op 2.17
transfer serialized Avg SignedBeaconBlock (200000 B) 4.6220 us/op 2.8010 us/op 1.65
copy serialized Avg SignedBeaconBlock (200000 B) 53.093 us/op 12.476 us/op 4.26
transfer serialized BlobsSidecar (524380 B) 5.7460 us/op 2.6340 us/op 2.18
copy serialized BlobsSidecar (524380 B) 132.97 us/op 113.04 us/op 1.18
transfer serialized Big SignedBeaconBlock (1000000 B) 4.8130 us/op 3.3680 us/op 1.43
copy serialized Big SignedBeaconBlock (1000000 B) 296.64 us/op 141.36 us/op 2.10
pass gossip attestations to forkchoice per slot 3.5409 ms/op 2.6964 ms/op 1.31
forkChoice updateHead vc 100000 bc 64 eq 0 543.84 us/op 355.03 us/op 1.53
forkChoice updateHead vc 600000 bc 64 eq 0 4.9708 ms/op 3.8167 ms/op 1.30
forkChoice updateHead vc 1000000 bc 64 eq 0 6.0333 ms/op 4.0543 ms/op 1.49
forkChoice updateHead vc 600000 bc 320 eq 0 3.5222 ms/op 2.4958 ms/op 1.41
forkChoice updateHead vc 600000 bc 1200 eq 0 3.8527 ms/op 2.6482 ms/op 1.45
forkChoice updateHead vc 600000 bc 7200 eq 0 4.9437 ms/op 2.9965 ms/op 1.65
forkChoice updateHead vc 600000 bc 64 eq 1000 11.783 ms/op 10.668 ms/op 1.10
forkChoice updateHead vc 600000 bc 64 eq 10000 11.562 ms/op 9.7946 ms/op 1.18
forkChoice updateHead vc 600000 bc 64 eq 300000 15.952 ms/op 12.221 ms/op 1.31
computeDeltas 500000 validators 300 proto nodes 4.2628 ms/op 3.6387 ms/op 1.17
computeDeltas 500000 validators 1200 proto nodes 4.2897 ms/op 3.7342 ms/op 1.15
computeDeltas 500000 validators 7200 proto nodes 4.2401 ms/op 3.4967 ms/op 1.21
computeDeltas 750000 validators 300 proto nodes 6.0879 ms/op 5.1593 ms/op 1.18
computeDeltas 750000 validators 1200 proto nodes 6.2118 ms/op 5.2520 ms/op 1.18
computeDeltas 750000 validators 7200 proto nodes 6.4476 ms/op 5.3245 ms/op 1.21
computeDeltas 1400000 validators 300 proto nodes 11.764 ms/op 9.8863 ms/op 1.19
computeDeltas 1400000 validators 1200 proto nodes 12.943 ms/op 9.6558 ms/op 1.34
computeDeltas 1400000 validators 7200 proto nodes 12.392 ms/op 9.7000 ms/op 1.28
computeDeltas 2100000 validators 300 proto nodes 19.071 ms/op 16.990 ms/op 1.12
computeDeltas 2100000 validators 1200 proto nodes 20.598 ms/op 18.979 ms/op 1.09
computeDeltas 2100000 validators 7200 proto nodes 22.606 ms/op 15.660 ms/op 1.44
altair processAttestation - 250000 vs - 7PWei normalcase 3.4770 ms/op 2.3777 ms/op 1.46
altair processAttestation - 250000 vs - 7PWei worstcase 4.2046 ms/op 3.5025 ms/op 1.20
altair processAttestation - setStatus - 1/6 committees join 137.40 us/op 72.341 us/op 1.90
altair processAttestation - setStatus - 1/3 committees join 244.76 us/op 149.83 us/op 1.63
altair processAttestation - setStatus - 1/2 committees join 332.89 us/op 237.31 us/op 1.40
altair processAttestation - setStatus - 2/3 committees join 401.67 us/op 317.13 us/op 1.27
altair processAttestation - setStatus - 4/5 committees join 616.64 us/op 449.53 us/op 1.37
altair processAttestation - setStatus - 100% committees join 738.25 us/op 545.13 us/op 1.35
altair processBlock - 250000 vs - 7PWei normalcase 8.1385 ms/op 7.9496 ms/op 1.02
altair processBlock - 250000 vs - 7PWei normalcase hashState 30.646 ms/op 27.443 ms/op 1.12
altair processBlock - 250000 vs - 7PWei worstcase 43.121 ms/op 37.072 ms/op 1.16
altair processBlock - 250000 vs - 7PWei worstcase hashState 85.785 ms/op 75.007 ms/op 1.14
phase0 processBlock - 250000 vs - 7PWei normalcase 2.7619 ms/op 2.3181 ms/op 1.19
phase0 processBlock - 250000 vs - 7PWei worstcase 28.863 ms/op 23.530 ms/op 1.23
altair processEth1Data - 250000 vs - 7PWei normalcase 534.77 us/op 249.48 us/op 2.14
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 9.0750 us/op 5.2270 us/op 1.74
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 51.653 us/op 32.433 us/op 1.59
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 18.026 us/op 9.8310 us/op 1.83
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 10.291 us/op 6.5550 us/op 1.57
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 215.11 us/op 129.12 us/op 1.67
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.4267 ms/op 1.5190 ms/op 0.94
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.9192 ms/op 1.2299 ms/op 1.56
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.7524 ms/op 1.2067 ms/op 1.45
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 5.1314 ms/op 2.9728 ms/op 1.73
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.0032 ms/op 1.3222 ms/op 1.52
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 4.7248 ms/op 3.4650 ms/op 1.36
Tree 40 250000 create 305.80 ms/op 222.80 ms/op 1.37
Tree 40 250000 get(125000) 162.31 ns/op 124.08 ns/op 1.31
Tree 40 250000 set(125000) 795.01 ns/op 573.02 ns/op 1.39
Tree 40 250000 toArray() 21.153 ms/op 19.261 ms/op 1.10
Tree 40 250000 iterate all - toArray() + loop 24.457 ms/op 21.185 ms/op 1.15
Tree 40 250000 iterate all - get(i) 64.314 ms/op 52.360 ms/op 1.23
Array 250000 create 3.7474 ms/op 3.2951 ms/op 1.14
Array 250000 clone - spread 1.5425 ms/op 1.3187 ms/op 1.17
Array 250000 get(125000) 0.43000 ns/op 0.62900 ns/op 0.68
Array 250000 set(125000) 0.46300 ns/op 0.60400 ns/op 0.77
Array 250000 iterate all - loop 110.00 us/op 77.227 us/op 1.42
phase0 afterProcessEpoch - 250000 vs - 7PWei 101.18 ms/op 79.980 ms/op 1.27
Array.fill - length 1000000 4.4750 ms/op 3.7940 ms/op 1.18
Array push - length 1000000 19.399 ms/op 23.446 ms/op 0.83
Array.get 0.32191 ns/op 0.27727 ns/op 1.16
Uint8Array.get 0.48092 ns/op 0.36063 ns/op 1.33
phase0 beforeProcessEpoch - 250000 vs - 7PWei 21.135 ms/op 22.445 ms/op 0.94
altair processEpoch - mainnet_e81889 349.33 ms/op 306.13 ms/op 1.14
mainnet_e81889 - altair beforeProcessEpoch 19.546 ms/op 17.391 ms/op 1.12
mainnet_e81889 - altair processJustificationAndFinalization 13.723 us/op 14.043 us/op 0.98
mainnet_e81889 - altair processInactivityUpdates 6.2591 ms/op 4.7967 ms/op 1.30
mainnet_e81889 - altair processRewardsAndPenalties 53.375 ms/op 55.773 ms/op 0.96
mainnet_e81889 - altair processRegistryUpdates 2.1800 us/op 2.3400 us/op 0.93
mainnet_e81889 - altair processSlashings 519.00 ns/op 956.00 ns/op 0.54
mainnet_e81889 - altair processEth1DataReset 588.00 ns/op 791.00 ns/op 0.74
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.7304 ms/op 1.0995 ms/op 1.57
mainnet_e81889 - altair processSlashingsReset 4.2820 us/op 2.9970 us/op 1.43
mainnet_e81889 - altair processRandaoMixesReset 6.3290 us/op 3.9390 us/op 1.61
mainnet_e81889 - altair processHistoricalRootsUpdate 1.0780 us/op 789.00 ns/op 1.37
mainnet_e81889 - altair processParticipationFlagUpdates 4.8610 us/op 2.4860 us/op 1.96
mainnet_e81889 - altair processSyncCommitteeUpdates 521.00 ns/op 676.00 ns/op 0.77
mainnet_e81889 - altair afterProcessEpoch 95.761 ms/op 79.409 ms/op 1.21
capella processEpoch - mainnet_e217614 1.2463 s/op 1.1434 s/op 1.09
mainnet_e217614 - capella beforeProcessEpoch 80.166 ms/op 66.945 ms/op 1.20
mainnet_e217614 - capella processJustificationAndFinalization 24.196 us/op 12.042 us/op 2.01
mainnet_e217614 - capella processInactivityUpdates 18.582 ms/op 12.975 ms/op 1.43
mainnet_e217614 - capella processRewardsAndPenalties 256.75 ms/op 246.79 ms/op 1.04
mainnet_e217614 - capella processRegistryUpdates 15.078 us/op 10.753 us/op 1.40
mainnet_e217614 - capella processSlashings 579.00 ns/op 781.00 ns/op 0.74
mainnet_e217614 - capella processEth1DataReset 537.00 ns/op 660.00 ns/op 0.81
mainnet_e217614 - capella processEffectiveBalanceUpdates 17.889 ms/op 5.7367 ms/op 3.12
mainnet_e217614 - capella processSlashingsReset 11.813 us/op 2.5470 us/op 4.64
mainnet_e217614 - capella processRandaoMixesReset 6.1550 us/op 3.4900 us/op 1.76
mainnet_e217614 - capella processHistoricalRootsUpdate 839.00 ns/op 718.00 ns/op 1.17
mainnet_e217614 - capella processParticipationFlagUpdates 4.1120 us/op 1.7030 us/op 2.41
mainnet_e217614 - capella afterProcessEpoch 255.76 ms/op 198.29 ms/op 1.29
phase0 processEpoch - mainnet_e58758 481.60 ms/op 337.65 ms/op 1.43
mainnet_e58758 - phase0 beforeProcessEpoch 105.11 ms/op 77.098 ms/op 1.36
mainnet_e58758 - phase0 processJustificationAndFinalization 29.459 us/op 10.025 us/op 2.94
mainnet_e58758 - phase0 processRewardsAndPenalties 43.362 ms/op 34.291 ms/op 1.26
mainnet_e58758 - phase0 processRegistryUpdates 13.315 us/op 5.8330 us/op 2.28
mainnet_e58758 - phase0 processSlashings 567.00 ns/op 806.00 ns/op 0.70
mainnet_e58758 - phase0 processEth1DataReset 821.00 ns/op 721.00 ns/op 1.14
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.0533 ms/op 1.3683 ms/op 1.50
mainnet_e58758 - phase0 processSlashingsReset 4.0690 us/op 2.0320 us/op 2.00
mainnet_e58758 - phase0 processRandaoMixesReset 6.7100 us/op 3.5750 us/op 1.88
mainnet_e58758 - phase0 processHistoricalRootsUpdate 469.00 ns/op 766.00 ns/op 0.61
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.9730 us/op 3.1920 us/op 1.56
mainnet_e58758 - phase0 afterProcessEpoch 81.463 ms/op 61.709 ms/op 1.32
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.9400 ms/op 988.74 us/op 1.96
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.5704 ms/op 1.5894 ms/op 1.62
altair processInactivityUpdates - 250000 normalcase 22.583 ms/op 17.099 ms/op 1.32
altair processInactivityUpdates - 250000 worstcase 23.912 ms/op 17.587 ms/op 1.36
phase0 processRegistryUpdates - 250000 normalcase 8.8300 us/op 7.1050 us/op 1.24
phase0 processRegistryUpdates - 250000 badcase_full_deposits 340.78 us/op 302.31 us/op 1.13
phase0 processRegistryUpdates - 250000 worstcase 0.5 143.85 ms/op 107.00 ms/op 1.34
altair processRewardsAndPenalties - 250000 normalcase 42.997 ms/op 45.341 ms/op 0.95
altair processRewardsAndPenalties - 250000 worstcase 43.621 ms/op 37.840 ms/op 1.15
phase0 getAttestationDeltas - 250000 normalcase 8.8024 ms/op 5.9599 ms/op 1.48
phase0 getAttestationDeltas - 250000 worstcase 8.6507 ms/op 6.0685 ms/op 1.43
phase0 processSlashings - 250000 worstcase 132.79 us/op 83.104 us/op 1.60
altair processSyncCommitteeUpdates - 250000 139.19 ms/op 97.052 ms/op 1.43
BeaconState.hashTreeRoot - No change 238.00 ns/op 458.00 ns/op 0.52
BeaconState.hashTreeRoot - 1 full validator 127.10 us/op 87.623 us/op 1.45
BeaconState.hashTreeRoot - 32 full validator 1.5303 ms/op 1.0850 ms/op 1.41
BeaconState.hashTreeRoot - 512 full validator 15.110 ms/op 10.523 ms/op 1.44
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 158.05 us/op 125.69 us/op 1.26
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.9570 ms/op 1.5622 ms/op 1.25
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 30.587 ms/op 27.840 ms/op 1.10
BeaconState.hashTreeRoot - 1 balances 107.01 us/op 82.283 us/op 1.30
BeaconState.hashTreeRoot - 32 balances 810.63 us/op 1.0130 ms/op 0.80
BeaconState.hashTreeRoot - 512 balances 9.0996 ms/op 10.494 ms/op 0.87
BeaconState.hashTreeRoot - 250000 balances 143.34 ms/op 178.60 ms/op 0.80
aggregationBits - 2048 els - zipIndexesInBitList 25.546 us/op 20.546 us/op 1.24
byteArrayEquals 32 55.974 ns/op 49.003 ns/op 1.14
Buffer.compare 32 18.330 ns/op 16.161 ns/op 1.13
byteArrayEquals 1024 1.6304 us/op 1.2888 us/op 1.27
Buffer.compare 1024 27.056 ns/op 24.238 ns/op 1.12
byteArrayEquals 16384 26.075 us/op 20.385 us/op 1.28
Buffer.compare 16384 210.40 ns/op 185.87 ns/op 1.13
byteArrayEquals 123687377 197.52 ms/op 152.20 ms/op 1.30
Buffer.compare 123687377 7.5833 ms/op 4.2070 ms/op 1.80
byteArrayEquals 32 - diff last byte 54.835 ns/op 48.243 ns/op 1.14
Buffer.compare 32 - diff last byte 18.110 ns/op 16.944 ns/op 1.07
byteArrayEquals 1024 - diff last byte 1.6629 us/op 1.2880 us/op 1.29
Buffer.compare 1024 - diff last byte 26.317 ns/op 23.946 ns/op 1.10
byteArrayEquals 16384 - diff last byte 26.148 us/op 20.477 us/op 1.28
Buffer.compare 16384 - diff last byte 214.79 ns/op 215.31 ns/op 1.00
byteArrayEquals 123687377 - diff last byte 195.17 ms/op 151.04 ms/op 1.29
Buffer.compare 123687377 - diff last byte 6.9362 ms/op 4.9965 ms/op 1.39
byteArrayEquals 32 - random bytes 5.1690 ns/op 5.0290 ns/op 1.03
Buffer.compare 32 - random bytes 17.199 ns/op 16.653 ns/op 1.03
byteArrayEquals 1024 - random bytes 5.1870 ns/op 4.9890 ns/op 1.04
Buffer.compare 1024 - random bytes 17.119 ns/op 16.974 ns/op 1.01
byteArrayEquals 16384 - random bytes 5.1610 ns/op 5.0290 ns/op 1.03
Buffer.compare 16384 - random bytes 17.138 ns/op 16.573 ns/op 1.03
byteArrayEquals 123687377 - random bytes 6.5800 ns/op 8.0200 ns/op 0.82
Buffer.compare 123687377 - random bytes 18.740 ns/op 20.010 ns/op 0.94
regular array get 100000 times 44.014 us/op 31.522 us/op 1.40
wrappedArray get 100000 times 33.468 us/op 31.526 us/op 1.06
arrayWithProxy get 100000 times 14.159 ms/op 11.120 ms/op 1.27
ssz.Root.equals 46.734 ns/op 44.719 ns/op 1.05
byteArrayEquals 46.916 ns/op 44.238 ns/op 1.06
Buffer.compare 10.729 ns/op 9.9170 ns/op 1.08
shuffle list - 16384 els 6.3350 ms/op 5.5744 ms/op 1.14
shuffle list - 250000 els 93.492 ms/op 81.378 ms/op 1.15
processSlot - 1 slots 11.723 us/op 15.230 us/op 0.77
processSlot - 32 slots 2.6621 ms/op 3.1004 ms/op 0.86
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 38.644 ms/op 38.122 ms/op 1.01
getCommitteeAssignments - req 1 vs - 250000 vc 2.1476 ms/op 1.7527 ms/op 1.23
getCommitteeAssignments - req 100 vs - 250000 vc 4.1956 ms/op 3.4437 ms/op 1.22
getCommitteeAssignments - req 1000 vs - 250000 vc 4.6067 ms/op 3.6663 ms/op 1.26
findModifiedValidators - 10000 modified validators 254.35 ms/op 238.22 ms/op 1.07
findModifiedValidators - 1000 modified validators 169.96 ms/op 156.00 ms/op 1.09
findModifiedValidators - 100 modified validators 156.08 ms/op 138.06 ms/op 1.13
findModifiedValidators - 10 modified validators 158.21 ms/op 136.05 ms/op 1.16
findModifiedValidators - 1 modified validators 147.10 ms/op 145.25 ms/op 1.01
findModifiedValidators - no difference 172.98 ms/op 148.01 ms/op 1.17
compare ViewDUs 3.1560 s/op 3.3983 s/op 0.93
compare each validator Uint8Array 1.5218 s/op 799.17 ms/op 1.90
compare ViewDU to Uint8Array 1.2295 s/op 705.81 ms/op 1.74
migrate state 1000000 validators, 24 modified, 0 new 961.08 ms/op 797.34 ms/op 1.21
migrate state 1000000 validators, 1700 modified, 1000 new 1.2572 s/op 1.0750 s/op 1.17
migrate state 1000000 validators, 3400 modified, 2000 new 1.2881 s/op 1.1947 s/op 1.08
migrate state 1500000 validators, 24 modified, 0 new 952.66 ms/op 817.64 ms/op 1.17
migrate state 1500000 validators, 1700 modified, 1000 new 1.1644 s/op 1.0937 s/op 1.06
migrate state 1500000 validators, 3400 modified, 2000 new 1.2450 s/op 1.3017 s/op 0.96
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.7800 ns/op 6.5700 ns/op 0.73
state getBlockRootAtSlot - 250000 vs - 7PWei 485.36 ns/op 993.34 ns/op 0.49
computeProposers - vc 250000 6.9036 ms/op 7.4911 ms/op 0.92
computeEpochShuffling - vc 250000 94.551 ms/op 83.022 ms/op 1.14
getNextSyncCommittee - vc 250000 122.51 ms/op 145.01 ms/op 0.84
computeSigningRoot for AttestationData 17.266 us/op 19.660 us/op 0.88
hash AttestationData serialized data then Buffer.toString(base64) 1.6496 us/op 1.2527 us/op 1.32
toHexString serialized data 929.22 ns/op 891.23 ns/op 1.04
Buffer.toString(base64) 170.80 ns/op 166.14 ns/op 1.03
nodejs block root to RootHex using toHex 162.37 ns/op 123.24 ns/op 1.32
nodejs block root to RootHex using toRootHex 101.21 ns/op 78.949 ns/op 1.28
browser block root to RootHex using the deprecated toHexString 234.09 ns/op 224.22 ns/op 1.04
browser block root to RootHex using toHex 187.12 ns/op 184.90 ns/op 1.01
browser block root to RootHex using toRootHex 182.53 ns/op 157.75 ns/op 1.16

by benchmarkbot/action

@nflaig nflaig marked this pull request as ready for review October 8, 2024 12:52
@nflaig nflaig requested a review from a team as a code owner October 8, 2024 12:52
Copy link
Contributor

@twoeths twoeths left a comment

Choose a reason for hiding this comment

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

historical state regen is not efficient until state diff strategy is implemented, even for state has just finalized
in the worse case we may have to reprocess 31 epochs which could be up to 3 minutes just to regen given 120ms to process a block and 2s to process an epoch, which could be too much (I'm not sure the performance of other clients)

instead of that we can think about a caching strategy similar to our balances cache:

processState(blockRootHex: RootHex, state: CachedBeaconStateAllForks): void {

this shares the same proposers memory with CachedBeaconState so does not cost us much

@nflaig
Copy link
Member Author

nflaig commented Oct 9, 2024

instead of that we can think about a caching strategy similar to our balances cache

I was looking at extending the caches and storing proposers by epoch in EpochCache, but I felt like it was a sub optimal solution as well because we can't serve data that is far in the past and it adds complexity and overhead for something that is not required during normal operation.

historical state regen is not efficient until #7005 is implemented

For the most common case, i.e. querying the finalized state we don't even need to trigger historical regen and it only takes around 2 seconds.

For earlier states, you are right it takes a bit but at least we can serve this data, so depending on the use case it might be fine to wait 2 minutes for the response, we have the same limitation currently when serving the state via getStateV2.

Imo we should use the same pattern everywhere to serve historical data and once we have #7005 it solves all the limitations.

@nflaig nflaig requested a review from twoeths October 9, 2024 09:39
twoeths
twoeths previously approved these changes Oct 11, 2024
@nflaig nflaig merged commit cbc7c90 into unstable Oct 11, 2024
20 checks passed
@nflaig nflaig deleted the nflaig/historical-proposer-duties branch October 11, 2024 15:53
philknows pushed a commit that referenced this pull request Oct 18, 2024
* feat: support fetching historical proposer duties

* Clone state before creating cached beacon state

* Fix error message

* Update test cases

* Skip syncing pubkeys and sync committe cache

* Update proposers tests epoch

* Use switch/case instead of if/else

* Add comment to clarify when head state can be used

* Use loadState instead of creating a separate ViewDU

* Clarify not yet initialized error for prev proposer duties

* Assert loaded state epoch matches requested
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.

3 participants