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

chore: refactor block and state api utils #6963

Merged
merged 10 commits into from
Jul 18, 2024

Conversation

wemeetagain
Copy link
Member

Motivation

Description

  • refactor block and state api utils (resolveBlockId and resolveStateId)
    • now the resolve* functions return a concrete slot or root which can be fetched using the chain
  • fetching blocks and states in the API is now done with getBlockResponse and getStateResponse
  • in preparation for feat: add historical state regen #6033, a separate getStateResponseWithRegen is created with unimplemented logic and a special return type.
    • This is a separate function to simplify consumer code (not have to handle the Uint8Array case) and to prevent accidental usage of a dangerous / expensive operation.

@wemeetagain wemeetagain requested a review from a team as a code owner July 17, 2024 16:54
Copy link

codecov bot commented Jul 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.49%. Comparing base (5f37580) to head (677a314).

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #6963      +/-   ##
============================================
- Coverage     62.52%   62.49%   -0.03%     
============================================
  Files           576      576              
  Lines         61171    61171              
  Branches       2140     2139       -1     
============================================
- Hits          38245    38231      -14     
- Misses        22888    22901      +13     
- Partials         38       39       +1     

Copy link
Contributor

github-actions bot commented Jul 17, 2024

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: fd46b8a Previous: c78b6ce Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 669.77 us/op 424.93 us/op 1.58
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 37.869 us/op 45.310 us/op 0.84
BLS verify - blst-native 1.1202 ms/op 1.2121 ms/op 0.92
BLS verifyMultipleSignatures 3 - blst-native 2.3879 ms/op 2.5738 ms/op 0.93
BLS verifyMultipleSignatures 8 - blst-native 5.2840 ms/op 5.6723 ms/op 0.93
BLS verifyMultipleSignatures 32 - blst-native 19.414 ms/op 20.910 ms/op 0.93
BLS verifyMultipleSignatures 64 - blst-native 38.239 ms/op 41.140 ms/op 0.93
BLS verifyMultipleSignatures 128 - blst-native 75.831 ms/op 81.603 ms/op 0.93
BLS deserializing 10000 signatures 789.13 ms/op 844.87 ms/op 0.93
BLS deserializing 100000 signatures 7.7810 s/op 8.6245 s/op 0.90
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.1233 ms/op 1.2286 ms/op 0.91
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.2113 ms/op 1.4601 ms/op 0.83
BLS verifyMultipleSignatures - same message - 32 - blst-native 1.9128 ms/op 2.1924 ms/op 0.87
BLS verifyMultipleSignatures - same message - 64 - blst-native 2.8277 ms/op 3.3856 ms/op 0.84
BLS verifyMultipleSignatures - same message - 128 - blst-native 6.3426 ms/op 5.4524 ms/op 1.16
BLS aggregatePubkeys 32 - blst-native 22.597 us/op 24.986 us/op 0.90
BLS aggregatePubkeys 128 - blst-native 87.936 us/op 97.038 us/op 0.91
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 65.348 ms/op 57.533 ms/op 1.14
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 46.345 ms/op 49.092 ms/op 0.94
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 30.716 ms/op 31.379 ms/op 0.98
getSlashingsAndExits - default max 75.733 us/op 98.159 us/op 0.77
getSlashingsAndExits - 2k 267.04 us/op 254.54 us/op 1.05
proposeBlockBody type=full, size=empty 5.1803 ms/op 5.7126 ms/op 0.91
isKnown best case - 1 super set check 506.00 ns/op 281.00 ns/op 1.80
isKnown normal case - 2 super set checks 490.00 ns/op 273.00 ns/op 1.79
isKnown worse case - 16 super set checks 488.00 ns/op 274.00 ns/op 1.78
InMemoryCheckpointStateCache - add get delete 5.0990 us/op 4.8890 us/op 1.04
validate api signedAggregateAndProof - struct 2.4786 ms/op 2.5854 ms/op 0.96
validate gossip signedAggregateAndProof - struct 2.4535 ms/op 2.5590 ms/op 0.96
validate gossip attestation - vc 640000 1.1351 ms/op 1.2374 ms/op 0.92
batch validate gossip attestation - vc 640000 - chunk 32 128.49 us/op 148.03 us/op 0.87
batch validate gossip attestation - vc 640000 - chunk 64 113.13 us/op 130.12 us/op 0.87
batch validate gossip attestation - vc 640000 - chunk 128 107.85 us/op 118.56 us/op 0.91
batch validate gossip attestation - vc 640000 - chunk 256 104.52 us/op 115.51 us/op 0.90
pickEth1Vote - no votes 847.28 us/op 984.16 us/op 0.86
pickEth1Vote - max votes 7.7215 ms/op 6.1356 ms/op 1.26
pickEth1Vote - Eth1Data hashTreeRoot value x2048 13.874 ms/op 11.279 ms/op 1.23
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 20.028 ms/op 18.241 ms/op 1.10
pickEth1Vote - Eth1Data fastSerialize value x2048 369.48 us/op 472.77 us/op 0.78
pickEth1Vote - Eth1Data fastSerialize tree x2048 5.3180 ms/op 6.4417 ms/op 0.83
bytes32 toHexString 589.00 ns/op 417.00 ns/op 1.41
bytes32 Buffer.toString(hex) 435.00 ns/op 252.00 ns/op 1.73
bytes32 Buffer.toString(hex) from Uint8Array 589.00 ns/op 363.00 ns/op 1.62
bytes32 Buffer.toString(hex) + 0x 451.00 ns/op 249.00 ns/op 1.81
Object access 1 prop 0.33700 ns/op 0.13900 ns/op 2.42
Map access 1 prop 0.33200 ns/op 0.13800 ns/op 2.41
Object get x1000 5.2190 ns/op 5.8620 ns/op 0.89
Map get x1000 5.9030 ns/op 6.5020 ns/op 0.91
Object set x1000 22.263 ns/op 31.484 ns/op 0.71
Map set x1000 18.747 ns/op 21.865 ns/op 0.86
Return object 10000 times 0.29510 ns/op 0.28620 ns/op 1.03
Throw Error 10000 times 2.6383 us/op 3.3336 us/op 0.79
fastMsgIdFn sha256 / 200 bytes 1.9300 us/op 2.1420 us/op 0.90
fastMsgIdFn h32 xxhash / 200 bytes 417.00 ns/op 218.00 ns/op 1.91
fastMsgIdFn h64 xxhash / 200 bytes 449.00 ns/op 260.00 ns/op 1.73
fastMsgIdFn sha256 / 1000 bytes 5.8650 us/op 7.0900 us/op 0.83
fastMsgIdFn h32 xxhash / 1000 bytes 574.00 ns/op 344.00 ns/op 1.67
fastMsgIdFn h64 xxhash / 1000 bytes 551.00 ns/op 332.00 ns/op 1.66
fastMsgIdFn sha256 / 10000 bytes 51.687 us/op 63.699 us/op 0.81
fastMsgIdFn h32 xxhash / 10000 bytes 1.9570 us/op 1.8440 us/op 1.06
fastMsgIdFn h64 xxhash / 10000 bytes 1.3370 us/op 1.1990 us/op 1.12
send data - 1000 256B messages 10.657 ms/op 11.791 ms/op 0.90
send data - 1000 512B messages 14.136 ms/op 16.238 ms/op 0.87
send data - 1000 1024B messages 25.104 ms/op 25.157 ms/op 1.00
send data - 1000 1200B messages 25.268 ms/op 18.493 ms/op 1.37
send data - 1000 2048B messages 30.563 ms/op 31.124 ms/op 0.98
send data - 1000 4096B messages 27.649 ms/op 32.260 ms/op 0.86
send data - 1000 16384B messages 65.966 ms/op 69.567 ms/op 0.95
send data - 1000 65536B messages 256.47 ms/op 216.58 ms/op 1.18
enrSubnets - fastDeserialize 64 bits 1.1730 us/op 1.0990 us/op 1.07
enrSubnets - ssz BitVector 64 bits 607.00 ns/op 350.00 ns/op 1.73
enrSubnets - fastDeserialize 4 bits 396.00 ns/op 142.00 ns/op 2.79
enrSubnets - ssz BitVector 4 bits 610.00 ns/op 365.00 ns/op 1.67
prioritizePeers score -10:0 att 32-0.1 sync 2-0 145.19 us/op 160.77 us/op 0.90
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 146.87 us/op 142.09 us/op 1.03
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 336.23 us/op 257.33 us/op 1.31
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 545.46 us/op 382.24 us/op 1.43
prioritizePeers score 0:0 att 64-1 sync 4-1 709.01 us/op 603.37 us/op 1.18
array of 16000 items push then shift 1.2740 us/op 1.6306 us/op 0.78
LinkedList of 16000 items push then shift 7.8020 ns/op 7.2440 ns/op 1.08
array of 16000 items push then pop 114.41 ns/op 132.43 ns/op 0.86
LinkedList of 16000 items push then pop 6.3830 ns/op 7.1690 ns/op 0.89
array of 24000 items push then shift 1.8648 us/op 2.4005 us/op 0.78
LinkedList of 24000 items push then shift 7.1950 ns/op 7.2810 ns/op 0.99
array of 24000 items push then pop 152.45 ns/op 146.01 ns/op 1.04
LinkedList of 24000 items push then pop 6.1910 ns/op 7.3070 ns/op 0.85
intersect bitArray bitLen 8 5.4240 ns/op 6.3390 ns/op 0.86
intersect array and set length 8 38.813 ns/op 46.753 ns/op 0.83
intersect bitArray bitLen 128 26.569 ns/op 29.296 ns/op 0.91
intersect array and set length 128 578.88 ns/op 662.87 ns/op 0.87
bitArray.getTrueBitIndexes() bitLen 128 2.1890 us/op 1.7790 us/op 1.23
bitArray.getTrueBitIndexes() bitLen 248 4.0020 us/op 3.3340 us/op 1.20
bitArray.getTrueBitIndexes() bitLen 512 9.5850 us/op 5.9730 us/op 1.60
Buffer.concat 32 items 1.0310 us/op 906.00 ns/op 1.14
Uint8Array.set 32 items 1.4830 us/op 1.6360 us/op 0.91
Buffer.copy 1.6390 us/op 1.7320 us/op 0.95
Uint8Array.set - with subarray 2.3950 us/op 2.5370 us/op 0.94
Uint8Array.set - without subarray 1.6100 us/op 1.3830 us/op 1.16
getUint32 - dataview 426.00 ns/op 230.00 ns/op 1.85
getUint32 - manual 366.00 ns/op 153.00 ns/op 2.39
Set add up to 64 items then delete first 1.7063 us/op 2.2483 us/op 0.76
OrderedSet add up to 64 items then delete first 2.6590 us/op 3.3048 us/op 0.80
Set add up to 64 items then delete last 1.9287 us/op 2.5828 us/op 0.75
OrderedSet add up to 64 items then delete last 2.8678 us/op 3.9376 us/op 0.73
Set add up to 64 items then delete middle 1.9174 us/op 2.5547 us/op 0.75
OrderedSet add up to 64 items then delete middle 4.2803 us/op 5.3783 us/op 0.80
Set add up to 128 items then delete first 3.8533 us/op 5.1481 us/op 0.75
OrderedSet add up to 128 items then delete first 5.9438 us/op 7.5047 us/op 0.79
Set add up to 128 items then delete last 3.6015 us/op 5.3854 us/op 0.67
OrderedSet add up to 128 items then delete last 5.6046 us/op 7.8546 us/op 0.71
Set add up to 128 items then delete middle 3.6727 us/op 5.0432 us/op 0.73
OrderedSet add up to 128 items then delete middle 11.609 us/op 13.747 us/op 0.84
Set add up to 256 items then delete first 7.4853 us/op 10.608 us/op 0.71
OrderedSet add up to 256 items then delete first 12.072 us/op 15.650 us/op 0.77
Set add up to 256 items then delete last 7.2695 us/op 10.243 us/op 0.71
OrderedSet add up to 256 items then delete last 11.514 us/op 16.182 us/op 0.71
Set add up to 256 items then delete middle 7.1722 us/op 10.056 us/op 0.71
OrderedSet add up to 256 items then delete middle 33.021 us/op 40.182 us/op 0.82
transfer serialized Status (84 B) 1.4000 us/op 1.4430 us/op 0.97
copy serialized Status (84 B) 1.2020 us/op 1.1850 us/op 1.01
transfer serialized SignedVoluntaryExit (112 B) 1.3850 us/op 1.6060 us/op 0.86
copy serialized SignedVoluntaryExit (112 B) 1.1640 us/op 1.2810 us/op 0.91
transfer serialized ProposerSlashing (416 B) 2.0850 us/op 2.5650 us/op 0.81
copy serialized ProposerSlashing (416 B) 1.6530 us/op 1.7820 us/op 0.93
transfer serialized Attestation (485 B) 2.1530 us/op 2.0160 us/op 1.07
copy serialized Attestation (485 B) 1.9160 us/op 1.7920 us/op 1.07
transfer serialized AttesterSlashing (33232 B) 2.5300 us/op 2.3280 us/op 1.09
copy serialized AttesterSlashing (33232 B) 4.1220 us/op 5.4780 us/op 0.75
transfer serialized Small SignedBeaconBlock (128000 B) 2.6000 us/op 2.9090 us/op 0.89
copy serialized Small SignedBeaconBlock (128000 B) 9.3080 us/op 16.427 us/op 0.57
transfer serialized Avg SignedBeaconBlock (200000 B) 3.1420 us/op 3.4940 us/op 0.90
copy serialized Avg SignedBeaconBlock (200000 B) 12.772 us/op 21.356 us/op 0.60
transfer serialized BlobsSidecar (524380 B) 3.0040 us/op 2.9660 us/op 1.01
copy serialized BlobsSidecar (524380 B) 71.136 us/op 90.393 us/op 0.79
transfer serialized Big SignedBeaconBlock (1000000 B) 3.2830 us/op 2.9690 us/op 1.11
copy serialized Big SignedBeaconBlock (1000000 B) 254.26 us/op 152.52 us/op 1.67
pass gossip attestations to forkchoice per slot 2.8708 ms/op 3.3089 ms/op 0.87
forkChoice updateHead vc 100000 bc 64 eq 0 408.96 us/op 489.39 us/op 0.84
forkChoice updateHead vc 600000 bc 64 eq 0 2.4605 ms/op 3.0268 ms/op 0.81
forkChoice updateHead vc 1000000 bc 64 eq 0 4.1344 ms/op 5.2419 ms/op 0.79
forkChoice updateHead vc 600000 bc 320 eq 0 2.4369 ms/op 3.0206 ms/op 0.81
forkChoice updateHead vc 600000 bc 1200 eq 0 2.4952 ms/op 3.0986 ms/op 0.81
forkChoice updateHead vc 600000 bc 7200 eq 0 3.0327 ms/op 4.0095 ms/op 0.76
forkChoice updateHead vc 600000 bc 64 eq 1000 9.0551 ms/op 10.635 ms/op 0.85
forkChoice updateHead vc 600000 bc 64 eq 10000 9.1784 ms/op 10.499 ms/op 0.87
forkChoice updateHead vc 600000 bc 64 eq 300000 11.667 ms/op 14.670 ms/op 0.80
computeDeltas 500000 validators 300 proto nodes 2.9924 ms/op 3.5686 ms/op 0.84
computeDeltas 500000 validators 1200 proto nodes 2.9897 ms/op 3.5413 ms/op 0.84
computeDeltas 500000 validators 7200 proto nodes 3.0066 ms/op 3.6541 ms/op 0.82
computeDeltas 750000 validators 300 proto nodes 4.3860 ms/op 5.2773 ms/op 0.83
computeDeltas 750000 validators 1200 proto nodes 4.4874 ms/op 5.1986 ms/op 0.86
computeDeltas 750000 validators 7200 proto nodes 4.3651 ms/op 5.2705 ms/op 0.83
computeDeltas 1400000 validators 300 proto nodes 8.1125 ms/op 9.8809 ms/op 0.82
computeDeltas 1400000 validators 1200 proto nodes 8.2071 ms/op 9.8313 ms/op 0.83
computeDeltas 1400000 validators 7200 proto nodes 8.2002 ms/op 9.9885 ms/op 0.82
computeDeltas 2100000 validators 300 proto nodes 12.594 ms/op 15.055 ms/op 0.84
computeDeltas 2100000 validators 1200 proto nodes 12.685 ms/op 15.056 ms/op 0.84
computeDeltas 2100000 validators 7200 proto nodes 12.422 ms/op 16.291 ms/op 0.76
altair processAttestation - 250000 vs - 7PWei normalcase 1.4103 ms/op 2.2251 ms/op 0.63
altair processAttestation - 250000 vs - 7PWei worstcase 2.1109 ms/op 3.0197 ms/op 0.70
altair processAttestation - setStatus - 1/6 committees join 66.204 us/op 136.25 us/op 0.49
altair processAttestation - setStatus - 1/3 committees join 130.50 us/op 255.22 us/op 0.51
altair processAttestation - setStatus - 1/2 committees join 187.79 us/op 357.30 us/op 0.53
altair processAttestation - setStatus - 2/3 committees join 252.57 us/op 438.75 us/op 0.58
altair processAttestation - setStatus - 4/5 committees join 407.18 us/op 622.13 us/op 0.65
altair processAttestation - setStatus - 100% committees join 461.83 us/op 705.34 us/op 0.65
altair processBlock - 250000 vs - 7PWei normalcase 3.2584 ms/op 5.0800 ms/op 0.64
altair processBlock - 250000 vs - 7PWei normalcase hashState 22.862 ms/op 25.977 ms/op 0.88
altair processBlock - 250000 vs - 7PWei worstcase 35.877 ms/op 40.581 ms/op 0.88
altair processBlock - 250000 vs - 7PWei worstcase hashState 57.691 ms/op 81.842 ms/op 0.70
phase0 processBlock - 250000 vs - 7PWei normalcase 1.6774 ms/op 2.3709 ms/op 0.71
phase0 processBlock - 250000 vs - 7PWei worstcase 25.399 ms/op 27.589 ms/op 0.92
altair processEth1Data - 250000 vs - 7PWei normalcase 256.74 us/op 330.02 us/op 0.78
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 5.0210 us/op 6.2400 us/op 0.80
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 18.443 us/op 29.274 us/op 0.63
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 4.5500 us/op 9.5680 us/op 0.48
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 6.3770 us/op 6.4330 us/op 0.99
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 83.140 us/op 116.03 us/op 0.72
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 741.79 us/op 669.13 us/op 1.11
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 651.25 us/op 907.10 us/op 0.72
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.1374 ms/op 900.64 us/op 1.26
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 2.0739 ms/op 2.6501 ms/op 0.78
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.2124 ms/op 1.5756 ms/op 0.77
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 3.0140 ms/op 3.9513 ms/op 0.76
Tree 40 250000 create 175.86 ms/op 244.79 ms/op 0.72
Tree 40 250000 get(125000) 118.00 ns/op 147.79 ns/op 0.80
Tree 40 250000 set(125000) 538.59 ns/op 648.72 ns/op 0.83
Tree 40 250000 toArray() 13.380 ms/op 19.490 ms/op 0.69
Tree 40 250000 iterate all - toArray() + loop 14.906 ms/op 20.113 ms/op 0.74
Tree 40 250000 iterate all - get(i) 39.125 ms/op 54.607 ms/op 0.72
MutableVector 250000 create 5.9835 ms/op 10.496 ms/op 0.57
MutableVector 250000 get(125000) 5.6920 ns/op 7.6470 ns/op 0.74
MutableVector 250000 set(125000) 184.93 ns/op 228.03 ns/op 0.81
MutableVector 250000 toArray() 3.4336 ms/op 4.4183 ms/op 0.78
MutableVector 250000 iterate all - toArray() + loop 3.7616 ms/op 4.0432 ms/op 0.93
MutableVector 250000 iterate all - get(i) 1.4883 ms/op 1.8191 ms/op 0.82
Array 250000 create 2.6193 ms/op 3.1904 ms/op 0.82
Array 250000 clone - spread 1.3689 ms/op 1.5408 ms/op 0.89
Array 250000 get(125000) 0.59000 ns/op 0.40700 ns/op 1.45
Array 250000 set(125000) 0.62300 ns/op 0.43400 ns/op 1.44
Array 250000 iterate all - loop 78.299 us/op 104.71 us/op 0.75
effectiveBalanceIncrements clone Uint8Array 300000 15.653 us/op 44.884 us/op 0.35
effectiveBalanceIncrements clone MutableVector 300000 328.00 ns/op 127.00 ns/op 2.58
effectiveBalanceIncrements rw all Uint8Array 300000 169.32 us/op 200.06 us/op 0.85
effectiveBalanceIncrements rw all MutableVector 300000 58.992 ms/op 73.792 ms/op 0.80
phase0 afterProcessEpoch - 250000 vs - 7PWei 74.793 ms/op 89.244 ms/op 0.84
Array.fill - length 1000000 2.6731 ms/op 4.0005 ms/op 0.67
Array push - length 1000000 14.428 ms/op 18.336 ms/op 0.79
Array.get 0.26079 ns/op 0.28317 ns/op 0.92
Uint8Array.get 0.33426 ns/op 0.44751 ns/op 0.75
phase0 beforeProcessEpoch - 250000 vs - 7PWei 20.840 ms/op 25.506 ms/op 0.82
altair processEpoch - mainnet_e81889 262.07 ms/op 335.55 ms/op 0.78
mainnet_e81889 - altair beforeProcessEpoch 25.849 ms/op 32.985 ms/op 0.78
mainnet_e81889 - altair processJustificationAndFinalization 11.455 us/op 11.598 us/op 0.99
mainnet_e81889 - altair processInactivityUpdates 4.1641 ms/op 6.2564 ms/op 0.67
mainnet_e81889 - altair processRewardsAndPenalties 54.171 ms/op 38.008 ms/op 1.43
mainnet_e81889 - altair processRegistryUpdates 2.1310 us/op 1.7590 us/op 1.21
mainnet_e81889 - altair processSlashings 775.00 ns/op 455.00 ns/op 1.70
mainnet_e81889 - altair processEth1DataReset 744.00 ns/op 352.00 ns/op 2.11
mainnet_e81889 - altair processEffectiveBalanceUpdates 857.44 us/op 1.7776 ms/op 0.48
mainnet_e81889 - altair processSlashingsReset 3.0820 us/op 2.6320 us/op 1.17
mainnet_e81889 - altair processRandaoMixesReset 3.8160 us/op 4.2590 us/op 0.90
mainnet_e81889 - altair processHistoricalRootsUpdate 738.00 ns/op 552.00 ns/op 1.34
mainnet_e81889 - altair processParticipationFlagUpdates 4.0430 us/op 2.0040 us/op 2.02
mainnet_e81889 - altair processSyncCommitteeUpdates 777.00 ns/op 452.00 ns/op 1.72
mainnet_e81889 - altair afterProcessEpoch 77.291 ms/op 93.223 ms/op 0.83
capella processEpoch - mainnet_e217614 1.0626 s/op 1.1217 s/op 0.95
mainnet_e217614 - capella beforeProcessEpoch 129.85 ms/op 111.59 ms/op 1.16
mainnet_e217614 - capella processJustificationAndFinalization 12.874 us/op 13.061 us/op 0.99
mainnet_e217614 - capella processInactivityUpdates 15.748 ms/op 16.795 ms/op 0.94
mainnet_e217614 - capella processRewardsAndPenalties 253.53 ms/op 218.26 ms/op 1.16
mainnet_e217614 - capella processRegistryUpdates 14.304 us/op 12.270 us/op 1.17
mainnet_e217614 - capella processSlashings 798.00 ns/op 364.00 ns/op 2.19
mainnet_e217614 - capella processEth1DataReset 759.00 ns/op 288.00 ns/op 2.64
mainnet_e217614 - capella processEffectiveBalanceUpdates 13.683 ms/op 10.077 ms/op 1.36
mainnet_e217614 - capella processSlashingsReset 3.0330 us/op 3.4360 us/op 0.88
mainnet_e217614 - capella processRandaoMixesReset 3.8500 us/op 3.3220 us/op 1.16
mainnet_e217614 - capella processHistoricalRootsUpdate 808.00 ns/op 877.00 ns/op 0.92
mainnet_e217614 - capella processParticipationFlagUpdates 1.7310 us/op 1.6810 us/op 1.03
mainnet_e217614 - capella afterProcessEpoch 251.49 ms/op 255.91 ms/op 0.98
phase0 processEpoch - mainnet_e58758 335.21 ms/op 334.18 ms/op 1.00
mainnet_e58758 - phase0 beforeProcessEpoch 78.479 ms/op 76.460 ms/op 1.03
mainnet_e58758 - phase0 processJustificationAndFinalization 14.416 us/op 12.923 us/op 1.12
mainnet_e58758 - phase0 processRewardsAndPenalties 36.589 ms/op 31.046 ms/op 1.18
mainnet_e58758 - phase0 processRegistryUpdates 10.281 us/op 7.3610 us/op 1.40
mainnet_e58758 - phase0 processSlashings 940.00 ns/op 305.00 ns/op 3.08
mainnet_e58758 - phase0 processEth1DataReset 863.00 ns/op 305.00 ns/op 2.83
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 779.34 us/op 942.90 us/op 0.83
mainnet_e58758 - phase0 processSlashingsReset 6.3680 us/op 3.4530 us/op 1.84
mainnet_e58758 - phase0 processRandaoMixesReset 8.8780 us/op 3.5650 us/op 2.49
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.0780 us/op 302.00 ns/op 3.57
mainnet_e58758 - phase0 processParticipationRecordUpdates 6.7460 us/op 2.2730 us/op 2.97
mainnet_e58758 - phase0 afterProcessEpoch 72.202 ms/op 79.269 ms/op 0.91
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.0933 ms/op 1.1943 ms/op 0.92
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.1839 ms/op 1.9392 ms/op 1.13
altair processInactivityUpdates - 250000 normalcase 19.214 ms/op 15.148 ms/op 1.27
altair processInactivityUpdates - 250000 worstcase 18.589 ms/op 14.165 ms/op 1.31
phase0 processRegistryUpdates - 250000 normalcase 11.547 us/op 7.0470 us/op 1.64
phase0 processRegistryUpdates - 250000 badcase_full_deposits 312.81 us/op 268.54 us/op 1.16
phase0 processRegistryUpdates - 250000 worstcase 0.5 125.76 ms/op 100.33 ms/op 1.25
altair processRewardsAndPenalties - 250000 normalcase 47.211 ms/op 35.771 ms/op 1.32
altair processRewardsAndPenalties - 250000 worstcase 41.111 ms/op 39.777 ms/op 1.03
phase0 getAttestationDeltas - 250000 normalcase 6.8938 ms/op 7.6626 ms/op 0.90
phase0 getAttestationDeltas - 250000 worstcase 10.287 ms/op 8.1922 ms/op 1.26
phase0 processSlashings - 250000 worstcase 94.838 us/op 97.890 us/op 0.97
altair processSyncCommitteeUpdates - 250000 93.043 ms/op 135.34 ms/op 0.69
BeaconState.hashTreeRoot - No change 601.00 ns/op 278.00 ns/op 2.16
BeaconState.hashTreeRoot - 1 full validator 95.947 us/op 120.10 us/op 0.80
BeaconState.hashTreeRoot - 32 full validator 1.4833 ms/op 1.4433 ms/op 1.03
BeaconState.hashTreeRoot - 512 full validator 15.145 ms/op 8.9866 ms/op 1.69
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 176.67 us/op 119.68 us/op 1.48
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.3787 ms/op 1.5775 ms/op 1.51
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 23.692 ms/op 19.449 ms/op 1.22
BeaconState.hashTreeRoot - 1 balances 92.250 us/op 100.09 us/op 0.92
BeaconState.hashTreeRoot - 32 balances 852.66 us/op 895.70 us/op 0.95
BeaconState.hashTreeRoot - 512 balances 7.9783 ms/op 12.482 ms/op 0.64
BeaconState.hashTreeRoot - 250000 balances 177.45 ms/op 169.05 ms/op 1.05
aggregationBits - 2048 els - zipIndexesInBitList 32.329 us/op 22.192 us/op 1.46
byteArrayEquals 32 48.849 ns/op 51.374 ns/op 0.95
Buffer.compare 32 15.500 ns/op 16.502 ns/op 0.94
byteArrayEquals 1024 1.2786 us/op 1.5184 us/op 0.84
Buffer.compare 1024 23.837 ns/op 23.538 ns/op 1.01
byteArrayEquals 16384 20.481 us/op 24.169 us/op 0.85
Buffer.compare 16384 214.05 ns/op 196.66 ns/op 1.09
byteArrayEquals 123687377 155.27 ms/op 189.28 ms/op 0.82
Buffer.compare 123687377 6.6689 ms/op 6.7854 ms/op 0.98
byteArrayEquals 32 - diff last byte 47.586 ns/op 52.426 ns/op 0.91
Buffer.compare 32 - diff last byte 15.696 ns/op 17.032 ns/op 0.92
byteArrayEquals 1024 - diff last byte 1.2518 us/op 1.5823 us/op 0.79
Buffer.compare 1024 - diff last byte 24.390 ns/op 25.520 ns/op 0.96
byteArrayEquals 16384 - diff last byte 20.296 us/op 25.109 us/op 0.81
Buffer.compare 16384 - diff last byte 201.50 ns/op 183.63 ns/op 1.10
byteArrayEquals 123687377 - diff last byte 154.41 ms/op 191.88 ms/op 0.80
Buffer.compare 123687377 - diff last byte 6.9998 ms/op 7.6787 ms/op 0.91
byteArrayEquals 32 - random bytes 5.0650 ns/op 5.3140 ns/op 0.95
Buffer.compare 32 - random bytes 16.165 ns/op 17.598 ns/op 0.92
byteArrayEquals 1024 - random bytes 5.4730 ns/op 5.2430 ns/op 1.04
Buffer.compare 1024 - random bytes 16.016 ns/op 17.274 ns/op 0.93
byteArrayEquals 16384 - random bytes 5.1170 ns/op 5.1790 ns/op 0.99
Buffer.compare 16384 - random bytes 15.975 ns/op 17.342 ns/op 0.92
byteArrayEquals 123687377 - random bytes 8.0600 ns/op 6.4900 ns/op 1.24
Buffer.compare 123687377 - random bytes 18.960 ns/op 18.910 ns/op 1.00
regular array get 100000 times 31.842 us/op 40.806 us/op 0.78
wrappedArray get 100000 times 31.667 us/op 33.831 us/op 0.94
arrayWithProxy get 100000 times 9.9593 ms/op 13.098 ms/op 0.76
ssz.Root.equals 40.582 ns/op 46.916 ns/op 0.86
byteArrayEquals 43.885 ns/op 46.513 ns/op 0.94
Buffer.compare 9.3110 ns/op 10.725 ns/op 0.87
shuffle list - 16384 els 5.7318 ms/op 6.4002 ms/op 0.90
shuffle list - 250000 els 85.361 ms/op 93.423 ms/op 0.91
processSlot - 1 slots 11.008 us/op 12.576 us/op 0.88
processSlot - 32 slots 3.4411 ms/op 2.2084 ms/op 1.56
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 39.670 ms/op 37.064 ms/op 1.07
getCommitteeAssignments - req 1 vs - 250000 vc 1.8276 ms/op 2.1829 ms/op 0.84
getCommitteeAssignments - req 100 vs - 250000 vc 3.6242 ms/op 4.1990 ms/op 0.86
getCommitteeAssignments - req 1000 vs - 250000 vc 3.8713 ms/op 4.6256 ms/op 0.84
findModifiedValidators - 10000 modified validators 240.56 ms/op 294.42 ms/op 0.82
findModifiedValidators - 1000 modified validators 143.70 ms/op 201.75 ms/op 0.71
findModifiedValidators - 100 modified validators 146.82 ms/op 189.92 ms/op 0.77
findModifiedValidators - 10 modified validators 135.43 ms/op 178.71 ms/op 0.76
findModifiedValidators - 1 modified validators 130.65 ms/op 183.58 ms/op 0.71
findModifiedValidators - no difference 150.70 ms/op 153.91 ms/op 0.98
compare ViewDUs 3.2501 s/op 3.2741 s/op 0.99
compare each validator Uint8Array 1.5311 s/op 1.8873 s/op 0.81
compare ViewDU to Uint8Array 622.95 ms/op 1.2589 s/op 0.49
migrate state 1000000 validators, 24 modified, 0 new 576.19 ms/op 696.75 ms/op 0.83
migrate state 1000000 validators, 1700 modified, 1000 new 811.52 ms/op 1.2122 s/op 0.67
migrate state 1000000 validators, 3400 modified, 2000 new 1.0974 s/op 1.2095 s/op 0.91
migrate state 1500000 validators, 24 modified, 0 new 547.70 ms/op 650.00 ms/op 0.84
migrate state 1500000 validators, 1700 modified, 1000 new 754.25 ms/op 850.98 ms/op 0.89
migrate state 1500000 validators, 3400 modified, 2000 new 972.24 ms/op 1.0843 s/op 0.90
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 6.3400 ns/op 4.9400 ns/op 1.28
state getBlockRootAtSlot - 250000 vs - 7PWei 364.08 ns/op 929.41 ns/op 0.39
computeProposers - vc 250000 5.4187 ms/op 7.4343 ms/op 0.73
computeEpochShuffling - vc 250000 85.002 ms/op 93.564 ms/op 0.91
getNextSyncCommittee - vc 250000 93.136 ms/op 128.66 ms/op 0.72
computeSigningRoot for AttestationData 17.273 us/op 21.596 us/op 0.80
hash AttestationData serialized data then Buffer.toString(base64) 1.1509 us/op 1.6208 us/op 0.71
toHexString serialized data 761.37 ns/op 1.0919 us/op 0.70
Buffer.toString(base64) 132.95 ns/op 213.51 ns/op 0.62

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.

LGTM

@wemeetagain wemeetagain merged commit fed08fe into unstable Jul 18, 2024
18 of 20 checks passed
@wemeetagain wemeetagain deleted the cayman/get-state-response branch July 18, 2024 18:07
// TODO: This is not OK, head and headState must be fetched atomically
const head = chain.forkChoice.getHead();
const headState = chain.getHeadState();
return {state: headState, executionOptimistic: isOptimisticBlock(head), finalized: false};
Copy link
Member

Choose a reason for hiding this comment

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

@wemeetagain wondering here, we got the head state from getHeadState() which called getClosestHeadState

so we would previouly do this

this.checkpointStateCache.getLatest(head.blockRoot, Infinity, opts) ||

which queried both blockStateCache and checkpointStateCache

while now we would just query blockStateCache

getStateSync(stateRoot: RootHex): CachedBeaconStateAllForks | null {
return this.blockStateCache.get(stateRoot, {dontTransferCache: true});

Copy link
Contributor

Choose a reason for hiding this comment

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

@nflaig , the change actually made it better. Previously we also queried the head state pulled up to next epoch in the checkpointStateCache which is only necessary for block processing while the "getHeadState()" api only wants the real head state. So it's better to only query blockStateCache in this case

@wemeetagain
Copy link
Member Author

🎉 This PR is included in v1.21.0 🎉

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