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: add historical state regen #6033

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

Conversation

wemeetagain
Copy link
Member

@wemeetagain wemeetagain commented Oct 11, 2023

Motivation

Description

  • Add a historical state regen module which can regenerate old states
  • Optional to avoid breaking unrelated tests / mocks
  • Uses a dedicated worker thread with a JobFnQueue inside
  • nodejs, state transition, job queue metrics wired up
  • Add historical state dashboard, which includes VM, job queue, and stfn panels
  • Update VM dashboard to include historical state worker panels and update cross-worker panels
  • PubkeyIndexMap persisted between runs for faster repeated use
  • Deployed to feat3 on Jan 22

TODO

  • pull out any necessary configurability to CLI level - no CLI configurability is needed (?)
  • tests
  • dashboard

@wemeetagain wemeetagain requested a review from a team as a code owner October 11, 2023 16:57
@github-actions
Copy link
Contributor

github-actions bot commented Oct 11, 2023

Performance Report

✔️ no performance regression detected

🚀🚀 Significant benchmark improvement detected

Benchmark suite Current: b167627 Previous: 1f38b1b Ratio
BeaconState.hashTreeRoot - No change 358.00 ns/op 1.2540 us/op 0.29
Full benchmark results
Benchmark suite Current: b167627 Previous: 1f38b1b Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 607.45 us/op 888.25 us/op 0.68
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 89.862 us/op 66.636 us/op 1.35
BLS verify - blst-native 1.3085 ms/op 1.0853 ms/op 1.21
BLS verifyMultipleSignatures 3 - blst-native 2.7476 ms/op 2.3752 ms/op 1.16
BLS verifyMultipleSignatures 8 - blst-native 6.0206 ms/op 5.3113 ms/op 1.13
BLS verifyMultipleSignatures 32 - blst-native 21.903 ms/op 19.337 ms/op 1.13
BLS verifyMultipleSignatures 64 - blst-native 43.394 ms/op 37.029 ms/op 1.17
BLS verifyMultipleSignatures 128 - blst-native 85.183 ms/op 73.119 ms/op 1.16
BLS deserializing 10000 signatures 917.98 ms/op 782.55 ms/op 1.17
BLS deserializing 100000 signatures 9.2617 s/op 8.1411 s/op 1.14
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.3431 ms/op 1.1279 ms/op 1.19
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.6256 ms/op 1.2921 ms/op 1.26
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.9273 ms/op 2.0150 ms/op 1.45
BLS verifyMultipleSignatures - same message - 64 - blst-native 4.4043 ms/op 3.8250 ms/op 1.15
BLS verifyMultipleSignatures - same message - 128 - blst-native 7.9956 ms/op 4.9247 ms/op 1.62
BLS aggregatePubkeys 32 - blst-native 26.327 us/op 22.841 us/op 1.15
BLS aggregatePubkeys 128 - blst-native 102.90 us/op 88.120 us/op 1.17
getAttestationsForBlock 45.450 ms/op 33.443 ms/op 1.36
getSlashingsAndExits - default max 169.40 us/op 107.34 us/op 1.58
getSlashingsAndExits - 2k 509.05 us/op 318.15 us/op 1.60
proposeBlockBody type=full, size=empty 5.4678 ms/op 3.6290 ms/op 1.51
isKnown best case - 1 super set check 420.00 ns/op 272.00 ns/op 1.54
isKnown normal case - 2 super set checks 362.00 ns/op 315.00 ns/op 1.15
isKnown worse case - 16 super set checks 355.00 ns/op 317.00 ns/op 1.12
CheckpointStateCache - add get delete 5.2100 us/op 3.9090 us/op 1.33
validate api signedAggregateAndProof - struct 2.8331 ms/op 2.5383 ms/op 1.12
validate gossip signedAggregateAndProof - struct 2.8500 ms/op 2.3571 ms/op 1.21
validate gossip attestation - vc 640000 1.3778 ms/op 1.1411 ms/op 1.21
batch validate gossip attestation - vc 640000 - chunk 32 166.42 us/op 140.45 us/op 1.18
batch validate gossip attestation - vc 640000 - chunk 64 147.01 us/op 122.56 us/op 1.20
batch validate gossip attestation - vc 640000 - chunk 128 143.34 us/op 119.26 us/op 1.20
batch validate gossip attestation - vc 640000 - chunk 256 135.51 us/op 127.77 us/op 1.06
pickEth1Vote - no votes 1.2964 ms/op 913.06 us/op 1.42
pickEth1Vote - max votes 10.429 ms/op 11.204 ms/op 0.93
pickEth1Vote - Eth1Data hashTreeRoot value x2048 18.092 ms/op 16.726 ms/op 1.08
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 31.783 ms/op 22.479 ms/op 1.41
pickEth1Vote - Eth1Data fastSerialize value x2048 644.20 us/op 419.62 us/op 1.54
pickEth1Vote - Eth1Data fastSerialize tree x2048 8.4745 ms/op 5.5436 ms/op 1.53
bytes32 toHexString 652.00 ns/op 527.00 ns/op 1.24
bytes32 Buffer.toString(hex) 307.00 ns/op 334.00 ns/op 0.92
bytes32 Buffer.toString(hex) from Uint8Array 502.00 ns/op 463.00 ns/op 1.08
bytes32 Buffer.toString(hex) + 0x 296.00 ns/op 307.00 ns/op 0.96
Object access 1 prop 0.18800 ns/op 0.18700 ns/op 1.01
Map access 1 prop 0.15600 ns/op 0.18300 ns/op 0.85
Object get x1000 7.2180 ns/op 5.0370 ns/op 1.43
Map get x1000 0.84300 ns/op 0.75600 ns/op 1.12
Object set x1000 54.194 ns/op 26.289 ns/op 2.06
Map set x1000 41.501 ns/op 18.071 ns/op 2.30
Return object 10000 times 0.24400 ns/op 0.22440 ns/op 1.09
Throw Error 10000 times 3.8913 us/op 2.7518 us/op 1.41
fastMsgIdFn sha256 / 200 bytes 3.3040 us/op 1.9890 us/op 1.66
fastMsgIdFn h32 xxhash / 200 bytes 310.00 ns/op 292.00 ns/op 1.06
fastMsgIdFn h64 xxhash / 200 bytes 355.00 ns/op 339.00 ns/op 1.05
fastMsgIdFn sha256 / 1000 bytes 11.478 us/op 5.9680 us/op 1.92
fastMsgIdFn h32 xxhash / 1000 bytes 472.00 ns/op 406.00 ns/op 1.16
fastMsgIdFn h64 xxhash / 1000 bytes 444.00 ns/op 404.00 ns/op 1.10
fastMsgIdFn sha256 / 10000 bytes 104.58 us/op 51.386 us/op 2.04
fastMsgIdFn h32 xxhash / 10000 bytes 2.0130 us/op 1.8430 us/op 1.09
fastMsgIdFn h64 xxhash / 10000 bytes 1.3670 us/op 1.2230 us/op 1.12
send data - 1000 256B messages 18.944 ms/op 11.680 ms/op 1.62
send data - 1000 512B messages 26.461 ms/op 15.552 ms/op 1.70
send data - 1000 1024B messages 40.044 ms/op 26.928 ms/op 1.49
send data - 1000 1200B messages 37.091 ms/op 29.174 ms/op 1.27
send data - 1000 2048B messages 48.237 ms/op 35.123 ms/op 1.37
send data - 1000 4096B messages 41.749 ms/op 33.521 ms/op 1.25
send data - 1000 16384B messages 123.83 ms/op 91.125 ms/op 1.36
send data - 1000 65536B messages 463.90 ms/op 391.31 ms/op 1.19
enrSubnets - fastDeserialize 64 bits 1.4950 us/op 1.0660 us/op 1.40
enrSubnets - ssz BitVector 64 bits 499.00 ns/op 434.00 ns/op 1.15
enrSubnets - fastDeserialize 4 bits 217.00 ns/op 196.00 ns/op 1.11
enrSubnets - ssz BitVector 4 bits 456.00 ns/op 422.00 ns/op 1.08
prioritizePeers score -10:0 att 32-0.1 sync 2-0 104.53 us/op 68.704 us/op 1.52
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 131.45 us/op 82.103 us/op 1.60
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 171.60 us/op 113.53 us/op 1.51
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 317.97 us/op 184.68 us/op 1.72
prioritizePeers score 0:0 att 64-1 sync 4-1 343.16 us/op 213.40 us/op 1.61
array of 16000 items push then shift 1.6370 us/op 1.2426 us/op 1.32
LinkedList of 16000 items push then shift 9.0240 ns/op 6.0880 ns/op 1.48
array of 16000 items push then pop 98.491 ns/op 45.908 ns/op 2.15
LinkedList of 16000 items push then pop 8.8990 ns/op 5.9700 ns/op 1.49
array of 24000 items push then shift 2.4733 us/op 1.9877 us/op 1.24
LinkedList of 24000 items push then shift 8.8250 ns/op 6.7300 ns/op 1.31
array of 24000 items push then pop 132.80 ns/op 149.87 ns/op 0.89
LinkedList of 24000 items push then pop 8.8010 ns/op 10.003 ns/op 0.88
intersect bitArray bitLen 8 6.5400 ns/op 5.5050 ns/op 1.19
intersect array and set length 8 67.007 ns/op 54.055 ns/op 1.24
intersect bitArray bitLen 128 33.903 ns/op 29.177 ns/op 1.16
intersect array and set length 128 939.30 ns/op 773.55 ns/op 1.21
bitArray.getTrueBitIndexes() bitLen 128 1.6280 us/op 2.0190 us/op 0.81
bitArray.getTrueBitIndexes() bitLen 248 2.8900 us/op 2.8370 us/op 1.02
bitArray.getTrueBitIndexes() bitLen 512 5.5490 us/op 5.1000 us/op 1.09
Buffer.concat 32 items 1.0290 us/op 1.0310 us/op 1.00
Uint8Array.set 32 items 1.6890 us/op 2.3800 us/op 0.71
Set add up to 64 items then delete first 4.7747 us/op 1.8335 us/op 2.60
OrderedSet add up to 64 items then delete first 5.7349 us/op 2.7942 us/op 2.05
Set add up to 64 items then delete last 4.8884 us/op 2.2164 us/op 2.21
OrderedSet add up to 64 items then delete last 5.9686 us/op 3.2026 us/op 1.86
Set add up to 64 items then delete middle 4.8198 us/op 2.1799 us/op 2.21
OrderedSet add up to 64 items then delete middle 7.3761 us/op 4.6366 us/op 1.59
Set add up to 128 items then delete first 9.5504 us/op 4.1938 us/op 2.28
OrderedSet add up to 128 items then delete first 12.709 us/op 6.5310 us/op 1.95
Set add up to 128 items then delete last 9.6284 us/op 3.9991 us/op 2.41
OrderedSet add up to 128 items then delete last 11.851 us/op 5.9526 us/op 1.99
Set add up to 128 items then delete middle 10.055 us/op 5.3009 us/op 1.90
OrderedSet add up to 128 items then delete middle 17.838 us/op 13.603 us/op 1.31
Set add up to 256 items then delete first 19.747 us/op 10.978 us/op 1.80
OrderedSet add up to 256 items then delete first 25.961 us/op 17.037 us/op 1.52
Set add up to 256 items then delete last 19.141 us/op 9.7715 us/op 1.96
OrderedSet add up to 256 items then delete last 24.224 us/op 12.928 us/op 1.87
Set add up to 256 items then delete middle 18.698 us/op 10.462 us/op 1.79
OrderedSet add up to 256 items then delete middle 46.130 us/op 36.162 us/op 1.28
transfer serialized Status (84 B) 1.8200 us/op 1.7600 us/op 1.03
copy serialized Status (84 B) 1.3680 us/op 1.4220 us/op 0.96
transfer serialized SignedVoluntaryExit (112 B) 1.9740 us/op 1.9580 us/op 1.01
copy serialized SignedVoluntaryExit (112 B) 1.4890 us/op 1.4330 us/op 1.04
transfer serialized ProposerSlashing (416 B) 3.2470 us/op 2.5330 us/op 1.28
copy serialized ProposerSlashing (416 B) 3.2300 us/op 2.4300 us/op 1.33
transfer serialized Attestation (485 B) 3.3990 us/op 2.5800 us/op 1.32
copy serialized Attestation (485 B) 2.9260 us/op 2.5150 us/op 1.16
transfer serialized AttesterSlashing (33232 B) 2.3070 us/op 2.3070 us/op 1.00
copy serialized AttesterSlashing (33232 B) 8.3470 us/op 5.0070 us/op 1.67
transfer serialized Small SignedBeaconBlock (128000 B) 2.9200 us/op 2.9980 us/op 0.97
copy serialized Small SignedBeaconBlock (128000 B) 14.050 us/op 11.817 us/op 1.19
transfer serialized Avg SignedBeaconBlock (200000 B) 3.0010 us/op 2.8530 us/op 1.05
copy serialized Avg SignedBeaconBlock (200000 B) 20.697 us/op 13.084 us/op 1.58
transfer serialized BlobsSidecar (524380 B) 2.9270 us/op 2.8110 us/op 1.04
copy serialized BlobsSidecar (524380 B) 77.953 us/op 71.234 us/op 1.09
transfer serialized Big SignedBeaconBlock (1000000 B) 3.0310 us/op 2.9570 us/op 1.03
copy serialized Big SignedBeaconBlock (1000000 B) 176.22 us/op 132.93 us/op 1.33
pass gossip attestations to forkchoice per slot 4.3527 ms/op 2.6846 ms/op 1.62
forkChoice updateHead vc 100000 bc 64 eq 0 685.16 us/op 506.53 us/op 1.35
forkChoice updateHead vc 600000 bc 64 eq 0 4.2661 ms/op 2.6126 ms/op 1.63
forkChoice updateHead vc 1000000 bc 64 eq 0 7.6558 ms/op 4.2950 ms/op 1.78
forkChoice updateHead vc 600000 bc 320 eq 0 4.1516 ms/op 2.6271 ms/op 1.58
forkChoice updateHead vc 600000 bc 1200 eq 0 4.3579 ms/op 2.6710 ms/op 1.63
forkChoice updateHead vc 600000 bc 7200 eq 0 5.5496 ms/op 3.2257 ms/op 1.72
forkChoice updateHead vc 600000 bc 64 eq 1000 11.305 ms/op 10.317 ms/op 1.10
forkChoice updateHead vc 600000 bc 64 eq 10000 11.804 ms/op 9.8840 ms/op 1.19
forkChoice updateHead vc 600000 bc 64 eq 300000 16.124 ms/op 11.989 ms/op 1.34
computeDeltas 500000 validators 300 proto nodes 6.8014 ms/op 3.2539 ms/op 2.09
computeDeltas 500000 validators 1200 proto nodes 6.6022 ms/op 3.2669 ms/op 2.02
computeDeltas 500000 validators 7200 proto nodes 6.2275 ms/op 3.2229 ms/op 1.93
computeDeltas 750000 validators 300 proto nodes 9.4407 ms/op 5.0066 ms/op 1.89
computeDeltas 750000 validators 1200 proto nodes 9.7017 ms/op 4.9262 ms/op 1.97
computeDeltas 750000 validators 7200 proto nodes 9.5571 ms/op 4.7785 ms/op 2.00
computeDeltas 1400000 validators 300 proto nodes 18.755 ms/op 9.2269 ms/op 2.03
computeDeltas 1400000 validators 1200 proto nodes 18.725 ms/op 9.4064 ms/op 1.99
computeDeltas 1400000 validators 7200 proto nodes 19.179 ms/op 9.0230 ms/op 2.13
computeDeltas 2100000 validators 300 proto nodes 27.528 ms/op 16.331 ms/op 1.69
computeDeltas 2100000 validators 1200 proto nodes 28.085 ms/op 16.967 ms/op 1.66
computeDeltas 2100000 validators 7200 proto nodes 28.827 ms/op 16.767 ms/op 1.72
altair processAttestation - 250000 vs - 7PWei normalcase 2.3447 ms/op 3.8095 ms/op 0.62
altair processAttestation - 250000 vs - 7PWei worstcase 3.2020 ms/op 4.4148 ms/op 0.73
altair processAttestation - setStatus - 1/6 committees join 175.41 us/op 147.43 us/op 1.19
altair processAttestation - setStatus - 1/3 committees join 341.65 us/op 282.40 us/op 1.21
altair processAttestation - setStatus - 1/2 committees join 471.79 us/op 387.80 us/op 1.22
altair processAttestation - setStatus - 2/3 committees join 605.17 us/op 458.42 us/op 1.32
altair processAttestation - setStatus - 4/5 committees join 781.94 us/op 718.92 us/op 1.09
altair processAttestation - setStatus - 100% committees join 930.72 us/op 811.37 us/op 1.15
altair processBlock - 250000 vs - 7PWei normalcase 10.780 ms/op 8.1716 ms/op 1.32
altair processBlock - 250000 vs - 7PWei normalcase hashState 33.182 ms/op 29.892 ms/op 1.11
altair processBlock - 250000 vs - 7PWei worstcase 37.839 ms/op 35.042 ms/op 1.08
altair processBlock - 250000 vs - 7PWei worstcase hashState 92.333 ms/op 92.648 ms/op 1.00
phase0 processBlock - 250000 vs - 7PWei normalcase 3.0167 ms/op 2.4828 ms/op 1.22
phase0 processBlock - 250000 vs - 7PWei worstcase 30.227 ms/op 24.017 ms/op 1.26
altair processEth1Data - 250000 vs - 7PWei normalcase 565.97 us/op 344.12 us/op 1.64
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 13.010 us/op 9.2290 us/op 1.41
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 66.212 us/op 58.127 us/op 1.14
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 23.328 us/op 13.334 us/op 1.75
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 8.1120 us/op 8.9980 us/op 0.90
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 184.22 us/op 167.32 us/op 1.10
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.5243 ms/op 829.47 us/op 1.84
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 2.2167 ms/op 877.76 us/op 2.53
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.8486 ms/op 1.3854 ms/op 1.33
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 4.0097 ms/op 1.9430 ms/op 2.06
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.3618 ms/op 1.4106 ms/op 1.67
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 5.6814 ms/op 3.3006 ms/op 1.72
Tree 40 250000 create 371.41 ms/op 265.38 ms/op 1.40
Tree 40 250000 get(125000) 203.24 ns/op 109.49 ns/op 1.86
Tree 40 250000 set(125000) 1.0725 us/op 767.63 ns/op 1.40
Tree 40 250000 toArray() 20.815 ms/op 9.3384 ms/op 2.23
Tree 40 250000 iterate all - toArray() + loop 18.808 ms/op 9.4738 ms/op 1.99
Tree 40 250000 iterate all - get(i) 67.078 ms/op 38.640 ms/op 1.74
MutableVector 250000 create 12.032 ms/op 11.106 ms/op 1.08
MutableVector 250000 get(125000) 6.5790 ns/op 5.6960 ns/op 1.16
MutableVector 250000 set(125000) 261.54 ns/op 207.25 ns/op 1.26
MutableVector 250000 toArray() 3.2520 ms/op 2.2867 ms/op 1.42
MutableVector 250000 iterate all - toArray() + loop 3.2771 ms/op 2.5387 ms/op 1.29
MutableVector 250000 iterate all - get(i) 1.5650 ms/op 1.3313 ms/op 1.18
Array 250000 create 3.1050 ms/op 2.1814 ms/op 1.42
Array 250000 clone - spread 1.2826 ms/op 1.0809 ms/op 1.19
Array 250000 get(125000) 1.1090 ns/op 0.97800 ns/op 1.13
Array 250000 set(125000) 4.5240 ns/op 1.1710 ns/op 3.86
Array 250000 iterate all - loop 170.15 us/op 144.84 us/op 1.17
effectiveBalanceIncrements clone Uint8Array 300000 30.499 us/op 20.718 us/op 1.47
effectiveBalanceIncrements clone MutableVector 300000 375.00 ns/op 391.00 ns/op 0.96
effectiveBalanceIncrements rw all Uint8Array 300000 201.71 us/op 174.13 us/op 1.16
effectiveBalanceIncrements rw all MutableVector 300000 86.891 ms/op 64.650 ms/op 1.34
phase0 afterProcessEpoch - 250000 vs - 7PWei 113.15 ms/op 74.624 ms/op 1.52
phase0 beforeProcessEpoch - 250000 vs - 7PWei 52.876 ms/op 42.468 ms/op 1.25
altair processEpoch - mainnet_e81889 482.18 ms/op 415.42 ms/op 1.16
mainnet_e81889 - altair beforeProcessEpoch 80.681 ms/op 73.424 ms/op 1.10
mainnet_e81889 - altair processJustificationAndFinalization 13.717 us/op 13.769 us/op 1.00
mainnet_e81889 - altair processInactivityUpdates 5.8472 ms/op 5.1934 ms/op 1.13
mainnet_e81889 - altair processRewardsAndPenalties 60.898 ms/op 59.846 ms/op 1.02
mainnet_e81889 - altair processRegistryUpdates 2.7740 us/op 1.6670 us/op 1.66
mainnet_e81889 - altair processSlashings 448.00 ns/op 569.00 ns/op 0.79
mainnet_e81889 - altair processEth1DataReset 501.00 ns/op 773.00 ns/op 0.65
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.4388 ms/op 1.0815 ms/op 1.33
mainnet_e81889 - altair processSlashingsReset 3.2620 us/op 2.9270 us/op 1.11
mainnet_e81889 - altair processRandaoMixesReset 6.6930 us/op 3.5580 us/op 1.88
mainnet_e81889 - altair processHistoricalRootsUpdate 1.0740 us/op 1.5930 us/op 0.67
mainnet_e81889 - altair processParticipationFlagUpdates 2.3490 us/op 1.5440 us/op 1.52
mainnet_e81889 - altair processSyncCommitteeUpdates 673.00 ns/op 829.00 ns/op 0.81
mainnet_e81889 - altair afterProcessEpoch 117.46 ms/op 79.577 ms/op 1.48
capella processEpoch - mainnet_e217614 2.2517 s/op 2.2503 s/op 1.00
mainnet_e217614 - capella beforeProcessEpoch 494.15 ms/op 595.03 ms/op 0.83
mainnet_e217614 - capella processJustificationAndFinalization 16.582 us/op 26.954 us/op 0.62
mainnet_e217614 - capella processInactivityUpdates 17.134 ms/op 30.070 ms/op 0.57
mainnet_e217614 - capella processRewardsAndPenalties 443.40 ms/op 484.17 ms/op 0.92
mainnet_e217614 - capella processRegistryUpdates 19.244 us/op 31.044 us/op 0.62
mainnet_e217614 - capella processSlashings 463.00 ns/op 902.00 ns/op 0.51
mainnet_e217614 - capella processEth1DataReset 394.00 ns/op 973.00 ns/op 0.40
mainnet_e217614 - capella processEffectiveBalanceUpdates 5.6273 ms/op 4.0649 ms/op 1.38
mainnet_e217614 - capella processSlashingsReset 2.9230 us/op 4.7800 us/op 0.61
mainnet_e217614 - capella processRandaoMixesReset 4.5740 us/op 10.227 us/op 0.45
mainnet_e217614 - capella processHistoricalRootsUpdate 593.00 ns/op 1.0280 us/op 0.58
mainnet_e217614 - capella processParticipationFlagUpdates 1.7750 us/op 3.2970 us/op 0.54
mainnet_e217614 - capella afterProcessEpoch 299.70 ms/op 303.27 ms/op 0.99
phase0 processEpoch - mainnet_e58758 431.18 ms/op 697.08 ms/op 0.62
mainnet_e58758 - phase0 beforeProcessEpoch 124.95 ms/op 235.43 ms/op 0.53
mainnet_e58758 - phase0 processJustificationAndFinalization 14.215 us/op 23.800 us/op 0.60
mainnet_e58758 - phase0 processRewardsAndPenalties 53.374 ms/op 72.749 ms/op 0.73
mainnet_e58758 - phase0 processRegistryUpdates 10.131 us/op 20.737 us/op 0.49
mainnet_e58758 - phase0 processSlashings 534.00 ns/op 1.0390 us/op 0.51
mainnet_e58758 - phase0 processEth1DataReset 369.00 ns/op 1.1230 us/op 0.33
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.1457 ms/op 1.0518 ms/op 1.09
mainnet_e58758 - phase0 processSlashingsReset 2.9420 us/op 7.9310 us/op 0.37
mainnet_e58758 - phase0 processRandaoMixesReset 4.1380 us/op 9.9010 us/op 0.42
mainnet_e58758 - phase0 processHistoricalRootsUpdate 382.00 ns/op 1.2020 us/op 0.32
mainnet_e58758 - phase0 processParticipationRecordUpdates 3.9780 us/op 8.4210 us/op 0.47
mainnet_e58758 - phase0 afterProcessEpoch 94.853 ms/op 84.138 ms/op 1.13
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.3494 ms/op 1.4748 ms/op 0.91
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.4329 ms/op 1.5192 ms/op 0.94
altair processInactivityUpdates - 250000 normalcase 22.586 ms/op 39.520 ms/op 0.57
altair processInactivityUpdates - 250000 worstcase 22.876 ms/op 47.876 ms/op 0.48
phase0 processRegistryUpdates - 250000 normalcase 12.024 us/op 16.728 us/op 0.72
phase0 processRegistryUpdates - 250000 badcase_full_deposits 369.83 us/op 397.40 us/op 0.93
phase0 processRegistryUpdates - 250000 worstcase 0.5 137.57 ms/op 192.64 ms/op 0.71
altair processRewardsAndPenalties - 250000 normalcase 59.836 ms/op 79.513 ms/op 0.75
altair processRewardsAndPenalties - 250000 worstcase 58.205 ms/op 80.061 ms/op 0.73
phase0 getAttestationDeltas - 250000 normalcase 9.0968 ms/op 11.888 ms/op 0.77
phase0 getAttestationDeltas - 250000 worstcase 8.8939 ms/op 11.378 ms/op 0.78
phase0 processSlashings - 250000 worstcase 81.407 us/op 105.40 us/op 0.77
altair processSyncCommitteeUpdates - 250000 151.71 ms/op 185.21 ms/op 0.82
BeaconState.hashTreeRoot - No change 358.00 ns/op 1.2540 us/op 0.29
BeaconState.hashTreeRoot - 1 full validator 144.74 us/op 296.83 us/op 0.49
BeaconState.hashTreeRoot - 32 full validator 1.2884 ms/op 2.3832 ms/op 0.54
BeaconState.hashTreeRoot - 512 full validator 14.798 ms/op 29.430 ms/op 0.50
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 152.09 us/op 297.85 us/op 0.51
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.9281 ms/op 4.1413 ms/op 0.47
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 24.323 ms/op 53.865 ms/op 0.45
BeaconState.hashTreeRoot - 1 balances 110.84 us/op 186.07 us/op 0.60
BeaconState.hashTreeRoot - 32 balances 998.74 us/op 1.2087 ms/op 0.83
BeaconState.hashTreeRoot - 512 balances 9.4241 ms/op 24.402 ms/op 0.39
BeaconState.hashTreeRoot - 250000 balances 181.24 ms/op 319.60 ms/op 0.57
aggregationBits - 2048 els - zipIndexesInBitList 17.767 us/op 107.83 us/op 0.16
byteArrayEquals 32 76.727 ns/op 65.528 ns/op 1.17
Buffer.compare 32 61.145 ns/op 41.170 ns/op 1.49
byteArrayEquals 1024 2.0824 us/op 1.7875 us/op 1.16
Buffer.compare 1024 72.170 ns/op 44.157 ns/op 1.63
byteArrayEquals 16384 33.010 us/op 27.952 us/op 1.18
Buffer.compare 16384 275.56 ns/op 234.93 ns/op 1.17
byteArrayEquals 123687377 247.72 ms/op 214.89 ms/op 1.15
Buffer.compare 123687377 6.6219 ms/op 6.3071 ms/op 1.05
byteArrayEquals 32 - diff last byte 78.359 ns/op 62.327 ns/op 1.26
Buffer.compare 32 - diff last byte 56.813 ns/op 38.192 ns/op 1.49
byteArrayEquals 1024 - diff last byte 2.0817 us/op 1.6744 us/op 1.24
Buffer.compare 1024 - diff last byte 70.833 ns/op 44.331 ns/op 1.60
byteArrayEquals 16384 - diff last byte 33.041 us/op 28.603 us/op 1.16
Buffer.compare 16384 - diff last byte 276.62 ns/op 227.12 ns/op 1.22
byteArrayEquals 123687377 - diff last byte 250.96 ms/op 210.47 ms/op 1.19
Buffer.compare 123687377 - diff last byte 6.3626 ms/op 4.1697 ms/op 1.53
byteArrayEquals 32 - random bytes 5.3520 ns/op 4.5880 ns/op 1.17
Buffer.compare 32 - random bytes 61.697 ns/op 38.929 ns/op 1.58
byteArrayEquals 1024 - random bytes 5.2950 ns/op 4.5150 ns/op 1.17
Buffer.compare 1024 - random bytes 60.129 ns/op 36.751 ns/op 1.64
byteArrayEquals 16384 - random bytes 5.2960 ns/op 4.5220 ns/op 1.17
Buffer.compare 16384 - random bytes 60.893 ns/op 36.553 ns/op 1.67
byteArrayEquals 123687377 - random bytes 8.7100 ns/op 8.2200 ns/op 1.06
Buffer.compare 123687377 - random bytes 63.640 ns/op 40.540 ns/op 1.57
regular array get 100000 times 43.641 us/op 41.259 us/op 1.06
wrappedArray get 100000 times 44.423 us/op 41.335 us/op 1.07
arrayWithProxy get 100000 times 14.474 ms/op 9.8318 ms/op 1.47
ssz.Root.equals 54.200 ns/op 56.160 ns/op 0.97
byteArrayEquals 53.502 ns/op 54.905 ns/op 0.97
Buffer.compare 11.186 ns/op 9.5830 ns/op 1.17
shuffle list - 16384 els 6.9972 ms/op 4.5089 ms/op 1.55
shuffle list - 250000 els 102.55 ms/op 66.777 ms/op 1.54
processSlot - 1 slots 15.767 us/op 13.281 us/op 1.19
processSlot - 32 slots 2.8616 ms/op 2.7711 ms/op 1.03
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 54.681 ms/op 58.284 ms/op 0.94
getCommitteeAssignments - req 1 vs - 250000 vc 2.6098 ms/op 2.2597 ms/op 1.15
getCommitteeAssignments - req 100 vs - 250000 vc 3.8419 ms/op 3.3902 ms/op 1.13
getCommitteeAssignments - req 1000 vs - 250000 vc 4.2413 ms/op 3.6760 ms/op 1.15
findModifiedValidators - 10000 modified validators 548.76 ms/op 417.24 ms/op 1.32
findModifiedValidators - 1000 modified validators 453.59 ms/op 298.42 ms/op 1.52
findModifiedValidators - 100 modified validators 475.27 ms/op 320.46 ms/op 1.48
findModifiedValidators - 10 modified validators 463.90 ms/op 325.03 ms/op 1.43
findModifiedValidators - 1 modified validators 426.15 ms/op 321.36 ms/op 1.33
findModifiedValidators - no difference 455.94 ms/op 286.52 ms/op 1.59
compare ViewDUs 4.6840 s/op 3.9070 s/op 1.20
compare each validator Uint8Array 1.7004 s/op 1.6100 s/op 1.06
compare ViewDU to Uint8Array 1.4221 s/op 1.0016 s/op 1.42
migrate state 1000000 validators, 24 modified, 0 new 776.20 ms/op 773.32 ms/op 1.00
migrate state 1000000 validators, 1700 modified, 1000 new 1.0995 s/op 1.0288 s/op 1.07
migrate state 1000000 validators, 3400 modified, 2000 new 1.2997 s/op 1.1480 s/op 1.13
migrate state 1500000 validators, 24 modified, 0 new 789.75 ms/op 730.21 ms/op 1.08
migrate state 1500000 validators, 1700 modified, 1000 new 1.0554 s/op 1.0372 s/op 1.02
migrate state 1500000 validators, 3400 modified, 2000 new 1.2514 s/op 1.2389 s/op 1.01
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.6100 ns/op 4.3100 ns/op 1.07
state getBlockRootAtSlot - 250000 vs - 7PWei 539.99 ns/op 852.78 ns/op 0.63
computeProposers - vc 250000 8.9774 ms/op 7.1046 ms/op 1.26
computeEpochShuffling - vc 250000 104.04 ms/op 68.334 ms/op 1.52
getNextSyncCommittee - vc 250000 156.96 ms/op 112.85 ms/op 1.39
computeSigningRoot for AttestationData 30.910 us/op 27.545 us/op 1.12
hash AttestationData serialized data then Buffer.toString(base64) 2.3149 us/op 1.2385 us/op 1.87
toHexString serialized data 1.0788 us/op 720.66 ns/op 1.50
Buffer.toString(base64) 217.33 ns/op 156.71 ns/op 1.39

by benchmarkbot/action

@wemeetagain
Copy link
Member Author

Running into issues opening the db in the worker thread.

It seems the leveldb way of allowing concurrency is have the consumer pass the pointer to the db handle to another thread. That's not currently possible with the leveldb package as it currently exists.

@wemeetagain
Copy link
Member Author

Converting to draft until the multithreaded database access issue is resolved

@wemeetagain wemeetagain marked this pull request as draft October 17, 2023 14:51
@wemeetagain wemeetagain marked this pull request as ready for review January 22, 2024 23:28
Copy link

codecov bot commented Jan 22, 2024

Codecov Report

Merging #6033 (03a241c) into unstable (6f35ac6) will decrease coverage by 16.46%.
Report is 5 commits behind head on unstable.
The diff coverage is n/a.

❗ Current head 03a241c differs from pull request most recent head 6001521. Consider uploading reports for the commit 6001521 to get more accurate results

Additional details and impacted files
@@              Coverage Diff              @@
##           unstable    #6033       +/-   ##
=============================================
- Coverage     76.60%   60.14%   -16.46%     
=============================================
  Files           248      407      +159     
  Lines         25908    46464    +20556     
  Branches       1448     1534       +86     
=============================================
+ Hits          19846    27947     +8101     
- Misses         6032    18487    +12455     
  Partials         30       30               

packages/api/src/beacon/routes/debug.ts Show resolved Hide resolved
}

async function resolveStateIdOrNull(
Copy link
Member

Choose a reason for hiding this comment

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

I like this being renamed. good call!

return state;
}

export async function getStateResponseWithRegen(
Copy link
Member

Choose a reason for hiding this comment

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

Should this be combined with getStateResponse. can pass a third arg allowRegen that passes to the getStateByStateRoot, getStateBySlot and gates getHistoricalStateBySlot

Copy link
Member Author

Choose a reason for hiding this comment

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

sounds good

if (stateId === "head") {
// TODO: This is not OK, head and headState must be fetched atomically
Copy link
Member

Choose a reason for hiding this comment

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

Two questions:

  1. is the issue about mutability in case there is a slot boundary while this resolves? Or is the issue that getHeadState can mutate state during its run?

  2. If there is risk, should we leave this comment here, maybe move to getStateResponse or perhaps convert it to a TODO to make sure this doesn't get papered over?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the issue before was that the calls were unlinked and also async.
eg:

const head = chain.forkChoice.getHead();
// what happens if the head changes before this next line
const headState = await chain.getHeadState();

Then they were unlinked but sync (no problem, stale comment).

const head = chain.forkChoice.getHead();
// no chance for the head to change before this next line
const headState = chain.getHeadState();

Now they are linked / looked up by state root

const head = chain.forkChoice.getHead();
// ...
// the head may change, but the head _at the time of request_ can still be fetched
const headState = chain.getStateByRoot(head.stateRoot);

}

return stateRes;
export function deserializeBeaconStateSerialized(config: ChainForkConfig, data: Uint8Array): allForks.BeaconState {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
export function deserializeBeaconStateSerialized(config: ChainForkConfig, data: Uint8Array): allForks.BeaconState {
export function deserializeBeaconState(config: ChainForkConfig, data: Uint8Array): allForks.BeaconState {


const db = new BeaconDb(config, await LevelDbController.create({name: workerData.dbLocation}, {logger}));

const abortController = new AbortController();
Copy link
Member

Choose a reason for hiding this comment

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

36vli2-723574080

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 actually need this AbortController here if it will not be synchronized with the main thread. The kill signal comes from the outside

config,
metrics,
logger: logger.child({module: LoggerModule.chain}),
});
Copy link
Member

Choose a reason for hiding this comment

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

Should the abort controller above get passed into HistoricalStateRegen.init so this shutdown is coordinated with the rest of the application? Im a bit fuzzy on how cleanup happens so this may not be correct though....

Comment on lines +41 to +46
const closeMetrics = collectNodeJSMetrics(metricsRegister, "lodestar_historical_state_worker_");
abortController.signal.addEventListener("abort", closeMetrics, {once: true});

stateTransitionMetrics = {
epochTransitionTime: metricsRegister.histogram({
name: "lodestar_historical_state_stfn_epoch_transition_seconds",
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't lodestar_historical_state_worker_ get prepended to all of these metric names? If so we will have some super long names and the lodestar_historical_state_ will be redundant on all of them

Comment on lines +62 to +64
export function getBlocksBetween(from: number, to: number, db: IBeaconDb): AsyncIterable<SignedBeaconBlock> {
return db.blockArchive.valuesStream({gt: from, lte: to});
}
Copy link
Member

Choose a reason for hiding this comment

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

Is there a specific reason you broke this out? Can we just directly call db.blockArchive.valuesStream in the for await below and save a stack frame?

Copy link
Member Author

Choose a reason for hiding this comment

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

no reason, just started the implementation of getHistoricalState in pseudocode and this stuck around. I can remove

workerData,
} as ConstructorParameters<typeof Worker>[1]);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Copy link
Member

Choose a reason for hiding this comment

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

I didn't notice that this needs to be here. Deleted with no issue

@philknows
Copy link
Member

Any update on the status of this PR? Are we blocked on it somewhere externally?

@wemeetagain
Copy link
Member Author

Any update on the status of this PR?

waiting on me to fix this in response to @matthewkeil 's review

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.

None yet

6 participants