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

fix: use toRootHex where applicable #7021

Merged
merged 4 commits into from
Aug 15, 2024
Merged

fix: use toRootHex where applicable #7021

merged 4 commits into from
Aug 15, 2024

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Aug 14, 2024

Motivation

Description

  • find toHex() and replace by toRootHex() (previously I missed them because I only searched for toHexString())
  • also blockHash are 32 bytes, we can just use the same util
  • make toRootHex() compliant to the old apis

Copy link
Contributor

github-actions bot commented Aug 14, 2024

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: fb0e237 Previous: 44b2156 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 2.0386 ms/op 1.9590 ms/op 1.04
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 57.567 us/op 46.281 us/op 1.24
BLS verify - blst 783.66 us/op 972.89 us/op 0.81
BLS verifyMultipleSignatures 3 - blst 1.1860 ms/op 1.3127 ms/op 0.90
BLS verifyMultipleSignatures 8 - blst 1.6261 ms/op 2.7331 ms/op 0.59
BLS verifyMultipleSignatures 32 - blst 4.7179 ms/op 5.7513 ms/op 0.82
BLS verifyMultipleSignatures 64 - blst 8.8630 ms/op 10.740 ms/op 0.83
BLS verifyMultipleSignatures 128 - blst 16.895 ms/op 17.450 ms/op 0.97
BLS deserializing 10000 signatures 677.07 ms/op 685.81 ms/op 0.99
BLS deserializing 100000 signatures 6.7841 s/op 6.7876 s/op 1.00
BLS verifyMultipleSignatures - same message - 3 - blst 878.67 us/op 989.51 us/op 0.89
BLS verifyMultipleSignatures - same message - 8 - blst 1.0703 ms/op 1.1029 ms/op 0.97
BLS verifyMultipleSignatures - same message - 32 - blst 1.6859 ms/op 1.7297 ms/op 0.97
BLS verifyMultipleSignatures - same message - 64 - blst 2.6229 ms/op 2.6244 ms/op 1.00
BLS verifyMultipleSignatures - same message - 128 - blst 4.3200 ms/op 4.4438 ms/op 0.97
BLS aggregatePubkeys 32 - blst 20.225 us/op 20.411 us/op 0.99
BLS aggregatePubkeys 128 - blst 72.702 us/op 70.806 us/op 1.03
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 65.657 ms/op 55.740 ms/op 1.18
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 50.748 ms/op 58.814 ms/op 0.86
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 30.619 ms/op 43.064 ms/op 0.71
getSlashingsAndExits - default max 88.578 us/op 102.27 us/op 0.87
getSlashingsAndExits - 2k 274.69 us/op 315.71 us/op 0.87
proposeBlockBody type=full, size=empty 5.7075 ms/op 5.9005 ms/op 0.97
isKnown best case - 1 super set check 296.00 ns/op 344.00 ns/op 0.86
isKnown normal case - 2 super set checks 285.00 ns/op 305.00 ns/op 0.93
isKnown worse case - 16 super set checks 281.00 ns/op 304.00 ns/op 0.92
InMemoryCheckpointStateCache - add get delete 2.8820 us/op 3.5060 us/op 0.82
validate api signedAggregateAndProof - struct 1.3360 ms/op 1.4184 ms/op 0.94
validate gossip signedAggregateAndProof - struct 1.3849 ms/op 1.4589 ms/op 0.95
validate gossip attestation - vc 640000 853.76 us/op 1.0471 ms/op 0.82
batch validate gossip attestation - vc 640000 - chunk 32 121.94 us/op 135.04 us/op 0.90
batch validate gossip attestation - vc 640000 - chunk 64 107.64 us/op 116.85 us/op 0.92
batch validate gossip attestation - vc 640000 - chunk 128 101.73 us/op 106.93 us/op 0.95
batch validate gossip attestation - vc 640000 - chunk 256 96.860 us/op 102.59 us/op 0.94
pickEth1Vote - no votes 1.0349 ms/op 1.0423 ms/op 0.99
pickEth1Vote - max votes 5.5718 ms/op 10.840 ms/op 0.51
pickEth1Vote - Eth1Data hashTreeRoot value x2048 15.391 ms/op 16.639 ms/op 0.93
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 18.162 ms/op 25.490 ms/op 0.71
pickEth1Vote - Eth1Data fastSerialize value x2048 450.40 us/op 497.20 us/op 0.91
pickEth1Vote - Eth1Data fastSerialize tree x2048 3.3213 ms/op 7.2266 ms/op 0.46
bytes32 toHexString 455.00 ns/op 426.00 ns/op 1.07
bytes32 Buffer.toString(hex) 250.00 ns/op 248.00 ns/op 1.01
bytes32 Buffer.toString(hex) from Uint8Array 382.00 ns/op 394.00 ns/op 0.97
bytes32 Buffer.toString(hex) + 0x 249.00 ns/op 252.00 ns/op 0.99
Object access 1 prop 0.13600 ns/op 0.12500 ns/op 1.09
Map access 1 prop 0.13100 ns/op 0.12200 ns/op 1.07
Object get x1000 5.7220 ns/op 5.8060 ns/op 0.99
Map get x1000 6.5730 ns/op 6.2710 ns/op 1.05
Object set x1000 32.805 ns/op 31.958 ns/op 1.03
Map set x1000 22.216 ns/op 21.484 ns/op 1.03
Return object 10000 times 0.29010 ns/op 0.28620 ns/op 1.01
Throw Error 10000 times 3.3558 us/op 3.2846 us/op 1.02
toHex 138.54 ns/op 149.60 ns/op 0.93
Buffer.from 127.63 ns/op 138.10 ns/op 0.92
shared Buffer 82.675 ns/op 92.252 ns/op 0.90
fastMsgIdFn sha256 / 200 bytes 2.2670 us/op 2.1690 us/op 1.05
fastMsgIdFn h32 xxhash / 200 bytes 236.00 ns/op 229.00 ns/op 1.03
fastMsgIdFn h64 xxhash / 200 bytes 257.00 ns/op 276.00 ns/op 0.93
fastMsgIdFn sha256 / 1000 bytes 7.3420 us/op 7.1800 us/op 1.02
fastMsgIdFn h32 xxhash / 1000 bytes 363.00 ns/op 348.00 ns/op 1.04
fastMsgIdFn h64 xxhash / 1000 bytes 326.00 ns/op 338.00 ns/op 0.96
fastMsgIdFn sha256 / 10000 bytes 64.041 us/op 63.259 us/op 1.01
fastMsgIdFn h32 xxhash / 10000 bytes 1.8270 us/op 1.7750 us/op 1.03
fastMsgIdFn h64 xxhash / 10000 bytes 1.1840 us/op 1.1840 us/op 1.00
send data - 1000 256B messages 11.187 ms/op 13.083 ms/op 0.86
send data - 1000 512B messages 16.010 ms/op 16.863 ms/op 0.95
send data - 1000 1024B messages 24.894 ms/op 25.975 ms/op 0.96
send data - 1000 1200B messages 18.137 ms/op 27.766 ms/op 0.65
send data - 1000 2048B messages 31.185 ms/op 32.313 ms/op 0.97
send data - 1000 4096B messages 30.263 ms/op 31.138 ms/op 0.97
send data - 1000 16384B messages 68.075 ms/op 73.084 ms/op 0.93
send data - 1000 65536B messages 201.39 ms/op 216.93 ms/op 0.93
enrSubnets - fastDeserialize 64 bits 1.0280 us/op 1.0440 us/op 0.98
enrSubnets - ssz BitVector 64 bits 340.00 ns/op 351.00 ns/op 0.97
enrSubnets - fastDeserialize 4 bits 141.00 ns/op 149.00 ns/op 0.95
enrSubnets - ssz BitVector 4 bits 346.00 ns/op 359.00 ns/op 0.96
prioritizePeers score -10:0 att 32-0.1 sync 2-0 141.57 us/op 142.12 us/op 1.00
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 157.16 us/op 157.14 us/op 1.00
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 241.93 us/op 317.74 us/op 0.76
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 389.73 us/op 598.86 us/op 0.65
prioritizePeers score 0:0 att 64-1 sync 4-1 624.98 us/op 786.92 us/op 0.79
array of 16000 items push then shift 1.5894 us/op 1.5993 us/op 0.99
LinkedList of 16000 items push then shift 6.9890 ns/op 6.9320 ns/op 1.01
array of 16000 items push then pop 115.00 ns/op 103.37 ns/op 1.11
LinkedList of 16000 items push then pop 6.8410 ns/op 6.8100 ns/op 1.00
array of 24000 items push then shift 2.4286 us/op 2.3516 us/op 1.03
LinkedList of 24000 items push then shift 7.5250 ns/op 6.9940 ns/op 1.08
array of 24000 items push then pop 161.21 ns/op 132.45 ns/op 1.22
LinkedList of 24000 items push then pop 7.1660 ns/op 6.7780 ns/op 1.06
intersect bitArray bitLen 8 6.4620 ns/op 6.2410 ns/op 1.04
intersect array and set length 8 48.998 ns/op 42.565 ns/op 1.15
intersect bitArray bitLen 128 29.800 ns/op 29.270 ns/op 1.02
intersect array and set length 128 685.95 ns/op 640.68 ns/op 1.07
bitArray.getTrueBitIndexes() bitLen 128 1.8740 us/op 2.1120 us/op 0.89
bitArray.getTrueBitIndexes() bitLen 248 3.4670 us/op 3.9030 us/op 0.89
bitArray.getTrueBitIndexes() bitLen 512 6.3320 us/op 9.1720 us/op 0.69
Buffer.concat 32 items 969.00 ns/op 1.0040 us/op 0.97
Uint8Array.set 32 items 1.5870 us/op 1.5180 us/op 1.05
Buffer.copy 2.5840 us/op 1.7540 us/op 1.47
Uint8Array.set - with subarray 2.4600 us/op 2.4750 us/op 0.99
Uint8Array.set - without subarray 1.3130 us/op 1.3820 us/op 0.95
getUint32 - dataview 229.00 ns/op 220.00 ns/op 1.04
getUint32 - manual 158.00 ns/op 149.00 ns/op 1.06
Set add up to 64 items then delete first 2.2424 us/op 2.1145 us/op 1.06
OrderedSet add up to 64 items then delete first 3.4136 us/op 3.2732 us/op 1.04
Set add up to 64 items then delete last 2.5529 us/op 2.4122 us/op 1.06
OrderedSet add up to 64 items then delete last 4.0596 us/op 3.5126 us/op 1.16
Set add up to 64 items then delete middle 2.6014 us/op 2.4670 us/op 1.05
OrderedSet add up to 64 items then delete middle 5.3781 us/op 5.0407 us/op 1.07
Set add up to 128 items then delete first 5.0404 us/op 5.0045 us/op 1.01
OrderedSet add up to 128 items then delete first 7.4927 us/op 7.5310 us/op 0.99
Set add up to 128 items then delete last 5.2803 us/op 4.8128 us/op 1.10
OrderedSet add up to 128 items then delete last 7.9860 us/op 7.0736 us/op 1.13
Set add up to 128 items then delete middle 5.3685 us/op 4.7660 us/op 1.13
OrderedSet add up to 128 items then delete middle 14.905 us/op 13.204 us/op 1.13
Set add up to 256 items then delete first 10.820 us/op 10.331 us/op 1.05
OrderedSet add up to 256 items then delete first 15.931 us/op 15.525 us/op 1.03
Set add up to 256 items then delete last 10.545 us/op 9.8579 us/op 1.07
OrderedSet add up to 256 items then delete last 16.670 us/op 14.068 us/op 1.19
Set add up to 256 items then delete middle 9.8305 us/op 9.4902 us/op 1.04
OrderedSet add up to 256 items then delete middle 41.377 us/op 39.828 us/op 1.04
transfer serialized Status (84 B) 1.4660 us/op 1.3250 us/op 1.11
copy serialized Status (84 B) 1.1690 us/op 1.0660 us/op 1.10
transfer serialized SignedVoluntaryExit (112 B) 1.4050 us/op 1.4030 us/op 1.00
copy serialized SignedVoluntaryExit (112 B) 1.2800 us/op 1.1030 us/op 1.16
transfer serialized ProposerSlashing (416 B) 2.2990 us/op 1.6410 us/op 1.40
copy serialized ProposerSlashing (416 B) 1.9890 us/op 1.6440 us/op 1.21
transfer serialized Attestation (485 B) 2.2710 us/op 1.6110 us/op 1.41
copy serialized Attestation (485 B) 2.1160 us/op 1.7570 us/op 1.20
transfer serialized AttesterSlashing (33232 B) 2.6660 us/op 2.2900 us/op 1.16
copy serialized AttesterSlashing (33232 B) 8.3840 us/op 4.9120 us/op 1.71
transfer serialized Small SignedBeaconBlock (128000 B) 3.3360 us/op 2.4640 us/op 1.35
copy serialized Small SignedBeaconBlock (128000 B) 24.258 us/op 13.920 us/op 1.74
transfer serialized Avg SignedBeaconBlock (200000 B) 3.7440 us/op 2.8700 us/op 1.30
copy serialized Avg SignedBeaconBlock (200000 B) 34.655 us/op 21.493 us/op 1.61
transfer serialized BlobsSidecar (524380 B) 4.1320 us/op 3.8550 us/op 1.07
copy serialized BlobsSidecar (524380 B) 124.66 us/op 83.281 us/op 1.50
transfer serialized Big SignedBeaconBlock (1000000 B) 5.4350 us/op 3.7640 us/op 1.44
copy serialized Big SignedBeaconBlock (1000000 B) 232.95 us/op 349.45 us/op 0.67
pass gossip attestations to forkchoice per slot 2.9328 ms/op 2.7715 ms/op 1.06
forkChoice updateHead vc 100000 bc 64 eq 0 498.59 us/op 491.62 us/op 1.01
forkChoice updateHead vc 600000 bc 64 eq 0 3.1470 ms/op 3.1007 ms/op 1.01
forkChoice updateHead vc 1000000 bc 64 eq 0 5.7438 ms/op 5.2833 ms/op 1.09
forkChoice updateHead vc 600000 bc 320 eq 0 4.9819 ms/op 3.0324 ms/op 1.64
forkChoice updateHead vc 600000 bc 1200 eq 0 3.3775 ms/op 3.0453 ms/op 1.11
forkChoice updateHead vc 600000 bc 7200 eq 0 3.8075 ms/op 3.4924 ms/op 1.09
forkChoice updateHead vc 600000 bc 64 eq 1000 11.248 ms/op 10.571 ms/op 1.06
forkChoice updateHead vc 600000 bc 64 eq 10000 10.984 ms/op 10.549 ms/op 1.04
forkChoice updateHead vc 600000 bc 64 eq 300000 20.934 ms/op 15.234 ms/op 1.37
computeDeltas 500000 validators 300 proto nodes 3.9637 ms/op 3.4841 ms/op 1.14
computeDeltas 500000 validators 1200 proto nodes 3.9700 ms/op 3.5321 ms/op 1.12
computeDeltas 500000 validators 7200 proto nodes 4.1155 ms/op 3.4393 ms/op 1.20
computeDeltas 750000 validators 300 proto nodes 6.2470 ms/op 5.2497 ms/op 1.19
computeDeltas 750000 validators 1200 proto nodes 5.8295 ms/op 5.2264 ms/op 1.12
computeDeltas 750000 validators 7200 proto nodes 5.5571 ms/op 5.2975 ms/op 1.05
computeDeltas 1400000 validators 300 proto nodes 10.142 ms/op 10.045 ms/op 1.01
computeDeltas 1400000 validators 1200 proto nodes 10.328 ms/op 10.169 ms/op 1.02
computeDeltas 1400000 validators 7200 proto nodes 10.108 ms/op 10.195 ms/op 0.99
computeDeltas 2100000 validators 300 proto nodes 15.057 ms/op 15.281 ms/op 0.99
computeDeltas 2100000 validators 1200 proto nodes 15.029 ms/op 15.428 ms/op 0.97
computeDeltas 2100000 validators 7200 proto nodes 15.014 ms/op 15.570 ms/op 0.96
altair processAttestation - 250000 vs - 7PWei normalcase 1.8988 ms/op 1.9685 ms/op 0.96
altair processAttestation - 250000 vs - 7PWei worstcase 2.7064 ms/op 2.7677 ms/op 0.98
altair processAttestation - setStatus - 1/6 committees join 97.583 us/op 124.56 us/op 0.78
altair processAttestation - setStatus - 1/3 committees join 191.68 us/op 237.98 us/op 0.81
altair processAttestation - setStatus - 1/2 committees join 261.89 us/op 332.55 us/op 0.79
altair processAttestation - setStatus - 2/3 committees join 342.07 us/op 423.52 us/op 0.81
altair processAttestation - setStatus - 4/5 committees join 482.05 us/op 567.68 us/op 0.85
altair processAttestation - setStatus - 100% committees join 553.85 us/op 672.15 us/op 0.82
altair processBlock - 250000 vs - 7PWei normalcase 4.1878 ms/op 4.8210 ms/op 0.87
altair processBlock - 250000 vs - 7PWei normalcase hashState 26.951 ms/op 27.050 ms/op 1.00
altair processBlock - 250000 vs - 7PWei worstcase 35.347 ms/op 46.701 ms/op 0.76
altair processBlock - 250000 vs - 7PWei worstcase hashState 64.961 ms/op 73.121 ms/op 0.89
phase0 processBlock - 250000 vs - 7PWei normalcase 1.8803 ms/op 2.3527 ms/op 0.80
phase0 processBlock - 250000 vs - 7PWei worstcase 20.255 ms/op 25.684 ms/op 0.79
altair processEth1Data - 250000 vs - 7PWei normalcase 280.41 us/op 297.75 us/op 0.94
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 4.7530 us/op 6.8080 us/op 0.70
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 20.057 us/op 26.253 us/op 0.76
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 7.1070 us/op 11.352 us/op 0.63
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 5.4890 us/op 5.5820 us/op 0.98
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 92.982 us/op 132.47 us/op 0.70
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 690.13 us/op 764.77 us/op 0.90
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 939.42 us/op 1.6529 ms/op 0.57
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 932.73 us/op 1.1007 ms/op 0.85
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 2.4708 ms/op 2.5217 ms/op 0.98
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.6775 ms/op 1.7969 ms/op 0.93
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 3.8803 ms/op 3.9080 ms/op 0.99
Tree 40 250000 create 212.21 ms/op 243.07 ms/op 0.87
Tree 40 250000 get(125000) 146.60 ns/op 148.78 ns/op 0.99
Tree 40 250000 set(125000) 638.76 ns/op 664.33 ns/op 0.96
Tree 40 250000 toArray() 15.350 ms/op 15.686 ms/op 0.98
Tree 40 250000 iterate all - toArray() + loop 15.514 ms/op 15.308 ms/op 1.01
Tree 40 250000 iterate all - get(i) 51.850 ms/op 52.357 ms/op 0.99
MutableVector 250000 create 7.7410 ms/op 11.139 ms/op 0.69
MutableVector 250000 get(125000) 6.1040 ns/op 6.9560 ns/op 0.88
MutableVector 250000 set(125000) 234.09 ns/op 198.96 ns/op 1.18
MutableVector 250000 toArray() 3.9133 ms/op 3.7430 ms/op 1.05
MutableVector 250000 iterate all - toArray() + loop 4.1273 ms/op 3.7670 ms/op 1.10
MutableVector 250000 iterate all - get(i) 1.8304 ms/op 1.6276 ms/op 1.12
Array 250000 create 3.2770 ms/op 3.1830 ms/op 1.03
Array 250000 clone - spread 1.6867 ms/op 1.4801 ms/op 1.14
Array 250000 get(125000) 0.44500 ns/op 0.40200 ns/op 1.11
Array 250000 set(125000) 0.47400 ns/op 0.42500 ns/op 1.12
Array 250000 iterate all - loop 108.01 us/op 81.543 us/op 1.32
effectiveBalanceIncrements clone Uint8Array 300000 35.432 us/op 31.396 us/op 1.13
effectiveBalanceIncrements clone MutableVector 300000 135.00 ns/op 117.00 ns/op 1.15
effectiveBalanceIncrements rw all Uint8Array 300000 201.20 us/op 196.67 us/op 1.02
effectiveBalanceIncrements rw all MutableVector 300000 70.363 ms/op 65.295 ms/op 1.08
phase0 afterProcessEpoch - 250000 vs - 7PWei 86.246 ms/op 84.627 ms/op 1.02
Array.fill - length 1000000 3.3664 ms/op 3.6730 ms/op 0.92
Array push - length 1000000 16.637 ms/op 16.914 ms/op 0.98
Array.get 0.27343 ns/op 0.27006 ns/op 1.01
Uint8Array.get 0.43327 ns/op 0.43547 ns/op 0.99
phase0 beforeProcessEpoch - 250000 vs - 7PWei 14.925 ms/op 15.012 ms/op 0.99
altair processEpoch - mainnet_e81889 285.72 ms/op 358.06 ms/op 0.80
mainnet_e81889 - altair beforeProcessEpoch 16.878 ms/op 18.362 ms/op 0.92
mainnet_e81889 - altair processJustificationAndFinalization 11.306 us/op 12.903 us/op 0.88
mainnet_e81889 - altair processInactivityUpdates 5.2304 ms/op 5.3351 ms/op 0.98
mainnet_e81889 - altair processRewardsAndPenalties 44.899 ms/op 61.537 ms/op 0.73
mainnet_e81889 - altair processRegistryUpdates 2.0170 us/op 3.1440 us/op 0.64
mainnet_e81889 - altair processSlashings 394.00 ns/op 653.00 ns/op 0.60
mainnet_e81889 - altair processEth1DataReset 282.00 ns/op 991.00 ns/op 0.28
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2347 ms/op 1.9234 ms/op 0.64
mainnet_e81889 - altair processSlashingsReset 3.7420 us/op 5.7890 us/op 0.65
mainnet_e81889 - altair processRandaoMixesReset 3.8660 us/op 6.8030 us/op 0.57
mainnet_e81889 - altair processHistoricalRootsUpdate 523.00 ns/op 829.00 ns/op 0.63
mainnet_e81889 - altair processParticipationFlagUpdates 2.0370 us/op 2.7740 us/op 0.73
mainnet_e81889 - altair processSyncCommitteeUpdates 457.00 ns/op 692.00 ns/op 0.66
mainnet_e81889 - altair afterProcessEpoch 88.955 ms/op 95.585 ms/op 0.93
capella processEpoch - mainnet_e217614 1.2552 s/op 1.1978 s/op 1.05
mainnet_e217614 - capella beforeProcessEpoch 69.011 ms/op 69.947 ms/op 0.99
mainnet_e217614 - capella processJustificationAndFinalization 18.656 us/op 22.334 us/op 0.84
mainnet_e217614 - capella processInactivityUpdates 18.184 ms/op 17.669 ms/op 1.03
mainnet_e217614 - capella processRewardsAndPenalties 221.53 ms/op 285.62 ms/op 0.78
mainnet_e217614 - capella processRegistryUpdates 13.766 us/op 18.388 us/op 0.75
mainnet_e217614 - capella processSlashings 425.00 ns/op 518.00 ns/op 0.82
mainnet_e217614 - capella processEth1DataReset 339.00 ns/op 549.00 ns/op 0.62
mainnet_e217614 - capella processEffectiveBalanceUpdates 9.9280 ms/op 11.979 ms/op 0.83
mainnet_e217614 - capella processSlashingsReset 4.1700 us/op 5.2060 us/op 0.80
mainnet_e217614 - capella processRandaoMixesReset 5.8740 us/op 6.7850 us/op 0.87
mainnet_e217614 - capella processHistoricalRootsUpdate 658.00 ns/op 544.00 ns/op 1.21
mainnet_e217614 - capella processParticipationFlagUpdates 2.2070 us/op 2.5870 us/op 0.85
mainnet_e217614 - capella afterProcessEpoch 239.85 ms/op 234.39 ms/op 1.02
phase0 processEpoch - mainnet_e58758 415.49 ms/op 441.84 ms/op 0.94
mainnet_e58758 - phase0 beforeProcessEpoch 79.230 ms/op 93.381 ms/op 0.85
mainnet_e58758 - phase0 processJustificationAndFinalization 24.700 us/op 21.817 us/op 1.13
mainnet_e58758 - phase0 processRewardsAndPenalties 30.278 ms/op 39.237 ms/op 0.77
mainnet_e58758 - phase0 processRegistryUpdates 7.9780 us/op 11.394 us/op 0.70
mainnet_e58758 - phase0 processSlashings 365.00 ns/op 527.00 ns/op 0.69
mainnet_e58758 - phase0 processEth1DataReset 339.00 ns/op 546.00 ns/op 0.62
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.1096 ms/op 2.6070 ms/op 0.43
mainnet_e58758 - phase0 processSlashingsReset 3.7680 us/op 3.2090 us/op 1.17
mainnet_e58758 - phase0 processRandaoMixesReset 6.2040 us/op 5.9460 us/op 1.04
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.1300 us/op 921.00 ns/op 1.23
mainnet_e58758 - phase0 processParticipationRecordUpdates 3.5310 us/op 3.3200 us/op 1.06
mainnet_e58758 - phase0 afterProcessEpoch 79.062 ms/op 77.279 ms/op 1.02
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.3375 ms/op 1.0979 ms/op 1.22
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.7957 ms/op 1.9427 ms/op 0.92
altair processInactivityUpdates - 250000 normalcase 17.391 ms/op 23.879 ms/op 0.73
altair processInactivityUpdates - 250000 worstcase 15.457 ms/op 25.791 ms/op 0.60
phase0 processRegistryUpdates - 250000 normalcase 10.308 us/op 9.8920 us/op 1.04
phase0 processRegistryUpdates - 250000 badcase_full_deposits 296.47 us/op 456.79 us/op 0.65
phase0 processRegistryUpdates - 250000 worstcase 0.5 106.87 ms/op 129.33 ms/op 0.83
altair processRewardsAndPenalties - 250000 normalcase 27.281 ms/op 48.382 ms/op 0.56
altair processRewardsAndPenalties - 250000 worstcase 38.829 ms/op 54.469 ms/op 0.71
phase0 getAttestationDeltas - 250000 normalcase 8.4050 ms/op 7.4189 ms/op 1.13
phase0 getAttestationDeltas - 250000 worstcase 8.0432 ms/op 7.3482 ms/op 1.09
phase0 processSlashings - 250000 worstcase 98.253 us/op 123.14 us/op 0.80
altair processSyncCommitteeUpdates - 250000 125.32 ms/op 118.07 ms/op 1.06
BeaconState.hashTreeRoot - No change 331.00 ns/op 267.00 ns/op 1.24
BeaconState.hashTreeRoot - 1 full validator 92.028 us/op 113.22 us/op 0.81
BeaconState.hashTreeRoot - 32 full validator 884.08 us/op 1.2300 ms/op 0.72
BeaconState.hashTreeRoot - 512 full validator 9.0953 ms/op 12.822 ms/op 0.71
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 104.92 us/op 138.79 us/op 0.76
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.4002 ms/op 2.0273 ms/op 0.69
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 18.149 ms/op 29.670 ms/op 0.61
BeaconState.hashTreeRoot - 1 balances 83.400 us/op 110.39 us/op 0.76
BeaconState.hashTreeRoot - 32 balances 1.1241 ms/op 1.3334 ms/op 0.84
BeaconState.hashTreeRoot - 512 balances 9.5631 ms/op 9.6819 ms/op 0.99
BeaconState.hashTreeRoot - 250000 balances 143.73 ms/op 168.89 ms/op 0.85
aggregationBits - 2048 els - zipIndexesInBitList 24.916 us/op 24.670 us/op 1.01
byteArrayEquals 32 54.642 ns/op 55.393 ns/op 0.99
Buffer.compare 32 17.740 ns/op 17.623 ns/op 1.01
byteArrayEquals 1024 1.6147 us/op 1.6149 us/op 1.00
Buffer.compare 1024 26.892 ns/op 26.333 ns/op 1.02
byteArrayEquals 16384 25.691 us/op 25.928 us/op 0.99
Buffer.compare 16384 203.91 ns/op 196.81 ns/op 1.04
byteArrayEquals 123687377 193.32 ms/op 192.16 ms/op 1.01
Buffer.compare 123687377 8.5001 ms/op 6.1811 ms/op 1.38
byteArrayEquals 32 - diff last byte 53.521 ns/op 53.257 ns/op 1.00
Buffer.compare 32 - diff last byte 17.478 ns/op 17.353 ns/op 1.01
byteArrayEquals 1024 - diff last byte 1.6159 us/op 1.5961 us/op 1.01
Buffer.compare 1024 - diff last byte 25.836 ns/op 26.226 ns/op 0.99
byteArrayEquals 16384 - diff last byte 25.777 us/op 25.399 us/op 1.01
Buffer.compare 16384 - diff last byte 193.52 ns/op 208.86 ns/op 0.93
byteArrayEquals 123687377 - diff last byte 193.51 ms/op 191.68 ms/op 1.01
Buffer.compare 123687377 - diff last byte 8.2585 ms/op 6.1438 ms/op 1.34
byteArrayEquals 32 - random bytes 5.3420 ns/op 5.1040 ns/op 1.05
Buffer.compare 32 - random bytes 17.425 ns/op 16.991 ns/op 1.03
byteArrayEquals 1024 - random bytes 5.4630 ns/op 5.1500 ns/op 1.06
Buffer.compare 1024 - random bytes 17.495 ns/op 17.502 ns/op 1.00
byteArrayEquals 16384 - random bytes 5.2940 ns/op 5.0370 ns/op 1.05
Buffer.compare 16384 - random bytes 17.697 ns/op 16.960 ns/op 1.04
byteArrayEquals 123687377 - random bytes 6.7500 ns/op 6.3600 ns/op 1.06
Buffer.compare 123687377 - random bytes 19.870 ns/op 18.220 ns/op 1.09
regular array get 100000 times 35.875 us/op 32.536 us/op 1.10
wrappedArray get 100000 times 33.890 us/op 32.851 us/op 1.03
arrayWithProxy get 100000 times 14.158 ms/op 13.980 ms/op 1.01
ssz.Root.equals 49.411 ns/op 46.153 ns/op 1.07
byteArrayEquals 47.065 ns/op 45.727 ns/op 1.03
Buffer.compare 11.060 ns/op 10.454 ns/op 1.06
shuffle list - 16384 els 6.8570 ms/op 6.3395 ms/op 1.08
shuffle list - 250000 els 97.387 ms/op 92.764 ms/op 1.05
processSlot - 1 slots 17.700 us/op 13.748 us/op 1.29
processSlot - 32 slots 3.3599 ms/op 3.0642 ms/op 1.10
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 38.607 ms/op 43.314 ms/op 0.89
getCommitteeAssignments - req 1 vs - 250000 vc 2.2279 ms/op 2.1050 ms/op 1.06
getCommitteeAssignments - req 100 vs - 250000 vc 4.2848 ms/op 4.0806 ms/op 1.05
getCommitteeAssignments - req 1000 vs - 250000 vc 4.4880 ms/op 4.3683 ms/op 1.03
findModifiedValidators - 10000 modified validators 345.86 ms/op 228.82 ms/op 1.51
findModifiedValidators - 1000 modified validators 205.01 ms/op 161.53 ms/op 1.27
findModifiedValidators - 100 modified validators 182.23 ms/op 138.52 ms/op 1.32
findModifiedValidators - 10 modified validators 239.25 ms/op 132.32 ms/op 1.81
findModifiedValidators - 1 modified validators 199.07 ms/op 142.52 ms/op 1.40
findModifiedValidators - no difference 240.97 ms/op 144.40 ms/op 1.67
compare ViewDUs 3.6180 s/op 3.0804 s/op 1.17
compare each validator Uint8Array 1.3810 s/op 1.6767 s/op 0.82
compare ViewDU to Uint8Array 1.1616 s/op 958.97 ms/op 1.21
migrate state 1000000 validators, 24 modified, 0 new 557.67 ms/op 633.30 ms/op 0.88
migrate state 1000000 validators, 1700 modified, 1000 new 805.27 ms/op 913.31 ms/op 0.88
migrate state 1000000 validators, 3400 modified, 2000 new 942.66 ms/op 1.0948 s/op 0.86
migrate state 1500000 validators, 24 modified, 0 new 626.12 ms/op 643.59 ms/op 0.97
migrate state 1500000 validators, 1700 modified, 1000 new 828.65 ms/op 909.21 ms/op 0.91
migrate state 1500000 validators, 3400 modified, 2000 new 952.56 ms/op 1.0869 s/op 0.88
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.3000 ns/op 4.4100 ns/op 0.98
state getBlockRootAtSlot - 250000 vs - 7PWei 571.94 ns/op 793.31 ns/op 0.72
computeProposers - vc 250000 8.0850 ms/op 7.4416 ms/op 1.09
computeEpochShuffling - vc 250000 92.429 ms/op 90.245 ms/op 1.02
getNextSyncCommittee - vc 250000 121.70 ms/op 120.26 ms/op 1.01
computeSigningRoot for AttestationData 17.484 us/op 25.671 us/op 0.68
hash AttestationData serialized data then Buffer.toString(base64) 1.6060 us/op 1.5348 us/op 1.05
toHexString serialized data 899.14 ns/op 876.45 ns/op 1.03
Buffer.toString(base64) 178.89 ns/op 182.29 ns/op 0.98
block root to RootHex using toHex 152.97 ns/op 137.33 ns/op 1.11
block root to RootHex using toRootHex 88.145 ns/op 95.156 ns/op 0.93

by benchmarkbot/action

Copy link

codecov bot commented Aug 14, 2024

Codecov Report

Attention: Patch coverage is 36.11111% with 23 lines in your changes missing coverage. Please review.

Project coverage is 49.24%. Comparing base (44b2156) to head (4e1286b).
Report is 1 commits behind head on unstable.

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #7021   +/-   ##
=========================================
  Coverage     49.24%   49.24%           
=========================================
  Files           578      578           
  Lines         37438    37443    +5     
  Branches       2162     2168    +6     
=========================================
+ Hits          18435    18440    +5     
  Misses        18963    18963           
  Partials         40       40           

@twoeths twoeths marked this pull request as ready for review August 14, 2024 06:18
@twoeths twoeths requested a review from a team as a code owner August 14, 2024 06:18

// this is to compliant to toHex() or toHexString() behavior
// in case unit tests, or consumers pass in a Uint8Array that is not 32 bytes accidentally
return toHex(root);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wemeetagain @nflaig I want to make it compliant to the old apis so we don't have to worry about the wrong usage

Copy link
Member

@nflaig nflaig Aug 14, 2024

Choose a reason for hiding this comment

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

Are we calling this in any unit tests? since performance is not relevant there we might be fine with just throwing an error if byte length is invalid. So either the test values have to be adapted or can use toHex there instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree to throw error here if it's not 32
my other thought is should we append "0x" here? we mostly use it for internal track and log
the down side with appending "0x" is almost 40% more memory allocation

// Bytes32 Buffer.toString(hex) + 0x - 121.7 bytes / instance

Copy link
Member

Choose a reason for hiding this comment

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

don't we have toMemoryEfficientHexStr for that?

function toMemoryEfficientHexStr(hex: Uint8Array | string): string {

I would like to have hex values prefixed with 0x in logs and we also use this on the api which needs 0x-prefix on all hex strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok then let's just keep 0x

Copy link
Member

@nflaig nflaig Aug 14, 2024

Choose a reason for hiding this comment

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

aren't most / all of these hex strings transient anyways?

nflaig
nflaig previously approved these changes Aug 14, 2024
@twoeths
Copy link
Contributor Author

twoeths commented Aug 14, 2024

not ready until unit test is fixed see #7025

@nflaig
Copy link
Member

nflaig commented Aug 14, 2024

not ready until unit test is fixed see #7025

should be fixed

@twoeths twoeths merged commit 20c18ad into unstable Aug 15, 2024
20 checks passed
@twoeths twoeths deleted the te/more_to_root_hex branch August 15, 2024 01:02
philknows pushed a commit that referenced this pull request Sep 3, 2024
* fix: use toRootHex where applicable

* fix: toRootHex() to handle different lengths

* fix: throw error if root is not 32 bytes

* Fix eth1MergeBlockTracker unit test

---------

Co-authored-by: Nico Flaig <nflaig@protonmail.com>
@wemeetagain
Copy link
Member

🎉 This PR is included in v1.22.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