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: use @chainsafe/blst directly #6706

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

Conversation

wemeetagain
Copy link
Member

Motivation

In order to do some optimizations, we want to remove the @chainsafe/bls abstraction layer. We know we won't be running the beacon node or validator in node only. In the future, we may relax this restriction if a usecase presents itself.

Description

  • Replace all uses of @chainsafe/bls throughout the monorepo, with the exception of the light client package
  • Notable changes:
    • .toBytes() -> .serialize()
      • serialize defaults to compressed
      • there is no longer a third param to do validation, it needs to be done afterwards with a .keyValidate() or .sigValidate()
    • .fromBytes() -> .deserialize()
    • Pubkey.aggregate, bls.aggregatePubkeys -> aggregatePubkeys
      • same for signatures
    • Signature.verifyAggregate -> fastVerifyAggregate
    • all verification functions into (msg(s), pubkey(s), sig(s)) order -- <- very important to get right

@wemeetagain wemeetagain requested a review from a team as a code owner April 24, 2024 22:43
Copy link

codecov bot commented Apr 30, 2024

Codecov Report

Attention: Patch coverage is 59.09091% with 18 lines in your changes are missing coverage. Please review.

Project coverage is 61.87%. Comparing base (09e4b9c) to head (e79ebad).
Report is 22 commits behind head on unstable.

❗ Current head e79ebad differs from pull request most recent head 90a9272. Consider uploading reports for the commit 90a9272 to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #6706      +/-   ##
============================================
- Coverage     61.87%   61.87%   -0.01%     
============================================
  Files           557      562       +5     
  Lines         59209    59305      +96     
  Branches       1915     1916       +1     
============================================
+ Hits          36635    36694      +59     
- Misses        22531    22568      +37     
  Partials         43       43              

Copy link
Contributor

github-actions bot commented Apr 30, 2024

Performance Report

✔️ no performance regression detected

🚀🚀 Significant benchmark improvement detected

Benchmark suite Current: f411caf Previous: 122a0f8 Ratio
altair processEth1Data - 250000 vs - 7PWei normalcase 258.42 us/op 815.49 us/op 0.32
Full benchmark results
Benchmark suite Current: f411caf Previous: 122a0f8 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 484.06 us/op 1.0790 ms/op 0.45
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 62.069 us/op 114.56 us/op 0.54
BLS verify - blst-native 1.0658 ms/op 1.1910 ms/op 0.89
BLS verifyMultipleSignatures 3 - blst-native 2.1363 ms/op 2.2326 ms/op 0.96
BLS verifyMultipleSignatures 8 - blst-native 4.6543 ms/op 4.8429 ms/op 0.96
BLS verifyMultipleSignatures 32 - blst-native 16.950 ms/op 17.594 ms/op 0.96
BLS verifyMultipleSignatures 64 - blst-native 33.435 ms/op 34.651 ms/op 0.96
BLS verifyMultipleSignatures 128 - blst-native 66.227 ms/op 68.023 ms/op 0.97
BLS deserializing 10000 signatures 750.25 ms/op 800.76 ms/op 0.94
BLS deserializing 100000 signatures 7.8772 s/op 8.0409 s/op 0.98
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.1536 ms/op 1.1576 ms/op 1.00
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.3123 ms/op 1.3079 ms/op 1.00
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.0701 ms/op 2.0881 ms/op 0.99
BLS verifyMultipleSignatures - same message - 64 - blst-native 3.0684 ms/op 3.0689 ms/op 1.00
BLS verifyMultipleSignatures - same message - 128 - blst-native 5.0294 ms/op 5.2310 ms/op 0.96
BLS aggregatePubkeys 32 - blst-native 24.892 us/op 25.353 us/op 0.98
BLS aggregatePubkeys 128 - blst-native 94.992 us/op 97.229 us/op 0.98
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 43.433 ms/op 62.870 ms/op 0.69
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 41.843 ms/op 55.046 ms/op 0.76
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 25.961 ms/op 26.389 ms/op 0.98
getSlashingsAndExits - default max 184.24 us/op 110.98 us/op 1.66
getSlashingsAndExits - 2k 363.30 us/op 313.15 us/op 1.16
proposeBlockBody type=full, size=empty 4.4271 ms/op 4.1791 ms/op 1.06
isKnown best case - 1 super set check 348.00 ns/op 232.00 ns/op 1.50
isKnown normal case - 2 super set checks 340.00 ns/op 240.00 ns/op 1.42
isKnown worse case - 16 super set checks 340.00 ns/op 226.00 ns/op 1.50
InMemoryCheckpointStateCache - add get delete 4.8410 us/op 4.6480 us/op 1.04
validate api signedAggregateAndProof - struct 2.3413 ms/op 2.0567 ms/op 1.14
validate gossip signedAggregateAndProof - struct 2.2411 ms/op 1.9741 ms/op 1.14
validate gossip attestation - vc 640000 1.0711 ms/op 1.1516 ms/op 0.93
batch validate gossip attestation - vc 640000 - chunk 32 134.84 us/op 140.15 us/op 0.96
batch validate gossip attestation - vc 640000 - chunk 64 118.11 us/op 124.65 us/op 0.95
batch validate gossip attestation - vc 640000 - chunk 128 113.74 us/op 127.76 us/op 0.89
batch validate gossip attestation - vc 640000 - chunk 256 114.50 us/op 113.01 us/op 1.01
pickEth1Vote - no votes 868.70 us/op 852.93 us/op 1.02
pickEth1Vote - max votes 7.8906 ms/op 5.8054 ms/op 1.36
pickEth1Vote - Eth1Data hashTreeRoot value x2048 16.726 ms/op 11.095 ms/op 1.51
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 24.162 ms/op 21.925 ms/op 1.10
pickEth1Vote - Eth1Data fastSerialize value x2048 449.48 us/op 391.70 us/op 1.15
pickEth1Vote - Eth1Data fastSerialize tree x2048 7.0656 ms/op 5.8481 ms/op 1.21
bytes32 toHexString 428.00 ns/op 329.00 ns/op 1.30
bytes32 Buffer.toString(hex) 297.00 ns/op 194.00 ns/op 1.53
bytes32 Buffer.toString(hex) from Uint8Array 410.00 ns/op 287.00 ns/op 1.43
bytes32 Buffer.toString(hex) + 0x 308.00 ns/op 190.00 ns/op 1.62
Object access 1 prop 0.19200 ns/op 0.10600 ns/op 1.81
Map access 1 prop 0.18000 ns/op 0.096000 ns/op 1.88
Object get x1000 4.8270 ns/op 4.9260 ns/op 0.98
Map get x1000 0.71100 ns/op 0.64700 ns/op 1.10
Object set x1000 26.346 ns/op 26.861 ns/op 0.98
Map set x1000 17.699 ns/op 17.663 ns/op 1.00
Return object 10000 times 0.21560 ns/op 0.22960 ns/op 0.94
Throw Error 10000 times 2.6671 us/op 3.0211 us/op 0.88
fastMsgIdFn sha256 / 200 bytes 1.9310 us/op 2.0210 us/op 0.96
fastMsgIdFn h32 xxhash / 200 bytes 282.00 ns/op 209.00 ns/op 1.35
fastMsgIdFn h64 xxhash / 200 bytes 331.00 ns/op 242.00 ns/op 1.37
fastMsgIdFn sha256 / 1000 bytes 6.0700 us/op 6.2180 us/op 0.98
fastMsgIdFn h32 xxhash / 1000 bytes 400.00 ns/op 312.00 ns/op 1.28
fastMsgIdFn h64 xxhash / 1000 bytes 389.00 ns/op 287.00 ns/op 1.36
fastMsgIdFn sha256 / 10000 bytes 50.375 us/op 49.889 us/op 1.01
fastMsgIdFn h32 xxhash / 10000 bytes 1.7640 us/op 1.6310 us/op 1.08
fastMsgIdFn h64 xxhash / 10000 bytes 1.1850 us/op 1.0660 us/op 1.11
send data - 1000 256B messages 11.052 ms/op 11.065 ms/op 1.00
send data - 1000 512B messages 16.738 ms/op 14.780 ms/op 1.13
send data - 1000 1024B messages 21.820 ms/op 21.887 ms/op 1.00
send data - 1000 1200B messages 29.906 ms/op 15.875 ms/op 1.88
send data - 1000 2048B messages 37.646 ms/op 36.855 ms/op 1.02
send data - 1000 4096B messages 32.834 ms/op 33.150 ms/op 0.99
send data - 1000 16384B messages 91.513 ms/op 84.062 ms/op 1.09
send data - 1000 65536B messages 390.52 ms/op 387.17 ms/op 1.01
enrSubnets - fastDeserialize 64 bits 953.00 ns/op 831.00 ns/op 1.15
enrSubnets - ssz BitVector 64 bits 439.00 ns/op 319.00 ns/op 1.38
enrSubnets - fastDeserialize 4 bits 206.00 ns/op 119.00 ns/op 1.73
enrSubnets - ssz BitVector 4 bits 436.00 ns/op 305.00 ns/op 1.43
prioritizePeers score -10:0 att 32-0.1 sync 2-0 133.69 us/op 141.45 us/op 0.95
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 170.57 us/op 171.99 us/op 0.99
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 226.02 us/op 226.10 us/op 1.00
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 354.46 us/op 384.00 us/op 0.92
prioritizePeers score 0:0 att 64-1 sync 4-1 426.71 us/op 478.26 us/op 0.89
array of 16000 items push then shift 1.2515 us/op 1.2568 us/op 1.00
LinkedList of 16000 items push then shift 6.9940 ns/op 6.8900 ns/op 1.02
array of 16000 items push then pop 72.685 ns/op 84.228 ns/op 0.86
LinkedList of 16000 items push then pop 5.7950 ns/op 5.5980 ns/op 1.04
array of 24000 items push then shift 1.8201 us/op 1.9373 us/op 0.94
LinkedList of 24000 items push then shift 6.9190 ns/op 5.7160 ns/op 1.21
array of 24000 items push then pop 93.213 ns/op 74.248 ns/op 1.26
LinkedList of 24000 items push then pop 6.5560 ns/op 5.6080 ns/op 1.17
intersect bitArray bitLen 8 5.0480 ns/op 4.6630 ns/op 1.08
intersect array and set length 8 49.961 ns/op 48.483 ns/op 1.03
intersect bitArray bitLen 128 32.768 ns/op 29.067 ns/op 1.13
intersect array and set length 128 721.80 ns/op 678.30 ns/op 1.06
bitArray.getTrueBitIndexes() bitLen 128 1.4340 us/op 1.1900 us/op 1.21
bitArray.getTrueBitIndexes() bitLen 248 2.3090 us/op 1.8370 us/op 1.26
bitArray.getTrueBitIndexes() bitLen 512 4.0500 us/op 3.3900 us/op 1.19
Buffer.concat 32 items 885.00 ns/op 785.00 ns/op 1.13
Uint8Array.set 32 items 2.1510 us/op 1.6470 us/op 1.31
Set add up to 64 items then delete first 1.7192 us/op 1.7403 us/op 0.99
OrderedSet add up to 64 items then delete first 2.5727 us/op 2.6673 us/op 0.96
Set add up to 64 items then delete last 1.9570 us/op 1.9821 us/op 0.99
OrderedSet add up to 64 items then delete last 2.8480 us/op 2.9548 us/op 0.96
Set add up to 64 items then delete middle 1.8953 us/op 1.9746 us/op 0.96
OrderedSet add up to 64 items then delete middle 4.7778 us/op 4.1848 us/op 1.14
Set add up to 128 items then delete first 3.8976 us/op 3.9207 us/op 0.99
OrderedSet add up to 128 items then delete first 5.9682 us/op 6.3588 us/op 0.94
Set add up to 128 items then delete last 3.8220 us/op 3.8032 us/op 1.00
OrderedSet add up to 128 items then delete last 5.7012 us/op 5.7808 us/op 0.99
Set add up to 128 items then delete middle 3.8279 us/op 3.7777 us/op 1.01
OrderedSet add up to 128 items then delete middle 10.748 us/op 10.023 us/op 1.07
Set add up to 256 items then delete first 7.6378 us/op 7.5130 us/op 1.02
OrderedSet add up to 256 items then delete first 11.970 us/op 12.135 us/op 0.99
Set add up to 256 items then delete last 7.4723 us/op 7.9511 us/op 0.94
OrderedSet add up to 256 items then delete last 11.387 us/op 11.359 us/op 1.00
Set add up to 256 items then delete middle 7.4909 us/op 7.3651 us/op 1.02
OrderedSet add up to 256 items then delete middle 32.273 us/op 30.037 us/op 1.07
transfer serialized Status (84 B) 1.4080 us/op 1.3440 us/op 1.05
copy serialized Status (84 B) 1.1990 us/op 1.0580 us/op 1.13
transfer serialized SignedVoluntaryExit (112 B) 1.5770 us/op 1.4040 us/op 1.12
copy serialized SignedVoluntaryExit (112 B) 1.2090 us/op 1.1550 us/op 1.05
transfer serialized ProposerSlashing (416 B) 1.8210 us/op 1.9590 us/op 0.93
copy serialized ProposerSlashing (416 B) 2.0730 us/op 2.2470 us/op 0.92
transfer serialized Attestation (485 B) 1.8090 us/op 2.2360 us/op 0.81
copy serialized Attestation (485 B) 1.7630 us/op 2.3050 us/op 0.76
transfer serialized AttesterSlashing (33232 B) 1.8690 us/op 2.5590 us/op 0.73
copy serialized AttesterSlashing (33232 B) 3.6740 us/op 6.4950 us/op 0.57
transfer serialized Small SignedBeaconBlock (128000 B) 1.8370 us/op 2.7070 us/op 0.68
copy serialized Small SignedBeaconBlock (128000 B) 8.3870 us/op 13.622 us/op 0.62
transfer serialized Avg SignedBeaconBlock (200000 B) 2.5170 us/op 2.5900 us/op 0.97
copy serialized Avg SignedBeaconBlock (200000 B) 12.603 us/op 19.413 us/op 0.65
transfer serialized BlobsSidecar (524380 B) 2.8190 us/op 2.4060 us/op 1.17
copy serialized BlobsSidecar (524380 B) 124.59 us/op 70.760 us/op 1.76
transfer serialized Big SignedBeaconBlock (1000000 B) 2.9570 us/op 2.6180 us/op 1.13
copy serialized Big SignedBeaconBlock (1000000 B) 133.44 us/op 293.71 us/op 0.45
pass gossip attestations to forkchoice per slot 2.8056 ms/op 2.7738 ms/op 1.01
forkChoice updateHead vc 100000 bc 64 eq 0 433.98 us/op 412.40 us/op 1.05
forkChoice updateHead vc 600000 bc 64 eq 0 2.6942 ms/op 2.7482 ms/op 0.98
forkChoice updateHead vc 1000000 bc 64 eq 0 4.2674 ms/op 4.3423 ms/op 0.98
forkChoice updateHead vc 600000 bc 320 eq 0 2.5957 ms/op 2.5606 ms/op 1.01
forkChoice updateHead vc 600000 bc 1200 eq 0 2.6676 ms/op 2.7329 ms/op 0.98
forkChoice updateHead vc 600000 bc 7200 eq 0 3.4250 ms/op 3.2746 ms/op 1.05
forkChoice updateHead vc 600000 bc 64 eq 1000 9.7457 ms/op 9.6687 ms/op 1.01
forkChoice updateHead vc 600000 bc 64 eq 10000 9.8873 ms/op 9.9105 ms/op 1.00
forkChoice updateHead vc 600000 bc 64 eq 300000 12.103 ms/op 11.629 ms/op 1.04
computeDeltas 500000 validators 300 proto nodes 3.0648 ms/op 3.0430 ms/op 1.01
computeDeltas 500000 validators 1200 proto nodes 3.0203 ms/op 2.9638 ms/op 1.02
computeDeltas 500000 validators 7200 proto nodes 2.9712 ms/op 2.9068 ms/op 1.02
computeDeltas 750000 validators 300 proto nodes 4.7256 ms/op 4.5073 ms/op 1.05
computeDeltas 750000 validators 1200 proto nodes 4.4713 ms/op 4.4572 ms/op 1.00
computeDeltas 750000 validators 7200 proto nodes 4.4164 ms/op 4.5181 ms/op 0.98
computeDeltas 1400000 validators 300 proto nodes 8.7920 ms/op 8.7585 ms/op 1.00
computeDeltas 1400000 validators 1200 proto nodes 8.9790 ms/op 9.2125 ms/op 0.97
computeDeltas 1400000 validators 7200 proto nodes 8.9342 ms/op 9.0377 ms/op 0.99
computeDeltas 2100000 validators 300 proto nodes 12.766 ms/op 13.234 ms/op 0.96
computeDeltas 2100000 validators 1200 proto nodes 12.583 ms/op 13.351 ms/op 0.94
computeDeltas 2100000 validators 7200 proto nodes 12.524 ms/op 16.380 ms/op 0.76
altair processAttestation - 250000 vs - 7PWei normalcase 1.5185 ms/op 1.8546 ms/op 0.82
altair processAttestation - 250000 vs - 7PWei worstcase 2.2842 ms/op 2.6955 ms/op 0.85
altair processAttestation - setStatus - 1/6 committees join 96.855 us/op 97.689 us/op 0.99
altair processAttestation - setStatus - 1/3 committees join 194.44 us/op 217.68 us/op 0.89
altair processAttestation - setStatus - 1/2 committees join 287.03 us/op 286.87 us/op 1.00
altair processAttestation - setStatus - 2/3 committees join 359.95 us/op 357.46 us/op 1.01
altair processAttestation - setStatus - 4/5 committees join 492.37 us/op 499.16 us/op 0.99
altair processAttestation - setStatus - 100% committees join 596.51 us/op 592.28 us/op 1.01
altair processBlock - 250000 vs - 7PWei normalcase 6.8495 ms/op 6.2674 ms/op 1.09
altair processBlock - 250000 vs - 7PWei normalcase hashState 31.666 ms/op 31.383 ms/op 1.01
altair processBlock - 250000 vs - 7PWei worstcase 32.522 ms/op 47.523 ms/op 0.68
altair processBlock - 250000 vs - 7PWei worstcase hashState 74.502 ms/op 89.671 ms/op 0.83
phase0 processBlock - 250000 vs - 7PWei normalcase 2.0635 ms/op 3.1749 ms/op 0.65
phase0 processBlock - 250000 vs - 7PWei worstcase 22.895 ms/op 40.579 ms/op 0.56
altair processEth1Data - 250000 vs - 7PWei normalcase 258.42 us/op 815.49 us/op 0.32
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 9.8250 us/op 17.223 us/op 0.57
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 64.895 us/op 67.649 us/op 0.96
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 23.426 us/op 20.498 us/op 1.14
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 11.048 us/op 20.550 us/op 0.54
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 178.76 us/op 213.43 us/op 0.84
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.0952 ms/op 1.8294 ms/op 0.60
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 840.58 us/op 2.1209 ms/op 0.40
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 806.90 us/op 1.3540 ms/op 0.60
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 2.4924 ms/op 2.9178 ms/op 0.85
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.6330 ms/op 1.6592 ms/op 0.98
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 3.3857 ms/op 6.8396 ms/op 0.50
Tree 40 250000 create 262.77 ms/op 278.18 ms/op 0.94
Tree 40 250000 get(125000) 112.75 ns/op 126.71 ns/op 0.89
Tree 40 250000 set(125000) 763.72 ns/op 1.4781 us/op 0.52
Tree 40 250000 toArray() 9.9369 ms/op 31.101 ms/op 0.32
Tree 40 250000 iterate all - toArray() + loop 9.6612 ms/op 23.313 ms/op 0.41
Tree 40 250000 iterate all - get(i) 43.075 ms/op 57.963 ms/op 0.74
MutableVector 250000 create 8.8300 ms/op 12.964 ms/op 0.68
MutableVector 250000 get(125000) 5.8100 ns/op 5.9750 ns/op 0.97
MutableVector 250000 set(125000) 202.14 ns/op 223.37 ns/op 0.90
MutableVector 250000 toArray() 2.4408 ms/op 2.3423 ms/op 1.04
MutableVector 250000 iterate all - toArray() + loop 2.5788 ms/op 3.5940 ms/op 0.72
MutableVector 250000 iterate all - get(i) 1.3616 ms/op 1.3482 ms/op 1.01
Array 250000 create 2.4261 ms/op 3.3975 ms/op 0.71
Array 250000 clone - spread 1.1105 ms/op 1.2019 ms/op 0.92
Array 250000 get(125000) 1.0410 ns/op 0.99800 ns/op 1.04
Array 250000 set(125000) 1.2600 ns/op 1.1910 ns/op 1.06
Array 250000 iterate all - loop 160.50 us/op 158.32 us/op 1.01
effectiveBalanceIncrements clone Uint8Array 300000 13.397 us/op 20.227 us/op 0.66
effectiveBalanceIncrements clone MutableVector 300000 403.00 ns/op 364.00 ns/op 1.11
effectiveBalanceIncrements rw all Uint8Array 300000 190.71 us/op 195.61 us/op 0.97
effectiveBalanceIncrements rw all MutableVector 300000 65.883 ms/op 75.671 ms/op 0.87
phase0 afterProcessEpoch - 250000 vs - 7PWei 78.418 ms/op 98.144 ms/op 0.80
phase0 beforeProcessEpoch - 250000 vs - 7PWei 46.234 ms/op 69.782 ms/op 0.66
altair processEpoch - mainnet_e81889 457.42 ms/op 670.93 ms/op 0.68
mainnet_e81889 - altair beforeProcessEpoch 67.636 ms/op 84.859 ms/op 0.80
mainnet_e81889 - altair processJustificationAndFinalization 13.909 us/op 23.242 us/op 0.60
mainnet_e81889 - altair processInactivityUpdates 6.3500 ms/op 8.5196 ms/op 0.75
mainnet_e81889 - altair processRewardsAndPenalties 48.899 ms/op 66.376 ms/op 0.74
mainnet_e81889 - altair processRegistryUpdates 3.4460 us/op 8.9230 us/op 0.39
mainnet_e81889 - altair processSlashings 727.00 ns/op 2.1120 us/op 0.34
mainnet_e81889 - altair processEth1DataReset 601.00 ns/op 1.1070 us/op 0.54
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2492 ms/op 1.8357 ms/op 0.68
mainnet_e81889 - altair processSlashingsReset 4.6440 us/op 9.5180 us/op 0.49
mainnet_e81889 - altair processRandaoMixesReset 8.7820 us/op 9.7100 us/op 0.90
mainnet_e81889 - altair processHistoricalRootsUpdate 1.3360 us/op 555.00 ns/op 2.41
mainnet_e81889 - altair processParticipationFlagUpdates 4.2050 us/op 1.5170 us/op 2.77
mainnet_e81889 - altair processSyncCommitteeUpdates 1.8630 us/op 1.0980 us/op 1.70
mainnet_e81889 - altair afterProcessEpoch 86.786 ms/op 93.805 ms/op 0.93
capella processEpoch - mainnet_e217614 1.8153 s/op 1.9683 s/op 0.92
mainnet_e217614 - capella beforeProcessEpoch 406.81 ms/op 401.95 ms/op 1.01
mainnet_e217614 - capella processJustificationAndFinalization 11.997 us/op 10.792 us/op 1.11
mainnet_e217614 - capella processInactivityUpdates 14.182 ms/op 16.685 ms/op 0.85
mainnet_e217614 - capella processRewardsAndPenalties 438.22 ms/op 466.92 ms/op 0.94
mainnet_e217614 - capella processRegistryUpdates 17.391 us/op 17.637 us/op 0.99
mainnet_e217614 - capella processSlashings 620.00 ns/op 497.00 ns/op 1.25
mainnet_e217614 - capella processEth1DataReset 580.00 ns/op 483.00 ns/op 1.20
mainnet_e217614 - capella processEffectiveBalanceUpdates 11.909 ms/op 3.4535 ms/op 3.45
mainnet_e217614 - capella processSlashingsReset 3.4990 us/op 1.7820 us/op 1.96
mainnet_e217614 - capella processRandaoMixesReset 2.1890 us/op 3.7480 us/op 0.58
mainnet_e217614 - capella processHistoricalRootsUpdate 849.00 ns/op 551.00 ns/op 1.54
mainnet_e217614 - capella processParticipationFlagUpdates 1.2850 us/op 1.5620 us/op 0.82
mainnet_e217614 - capella afterProcessEpoch 224.28 ms/op 229.28 ms/op 0.98
phase0 processEpoch - mainnet_e58758 463.38 ms/op 445.66 ms/op 1.04
mainnet_e58758 - phase0 beforeProcessEpoch 132.26 ms/op 113.89 ms/op 1.16
mainnet_e58758 - phase0 processJustificationAndFinalization 12.394 us/op 15.274 us/op 0.81
mainnet_e58758 - phase0 processRewardsAndPenalties 55.159 ms/op 58.353 ms/op 0.95
mainnet_e58758 - phase0 processRegistryUpdates 4.2030 us/op 4.0850 us/op 1.03
mainnet_e58758 - phase0 processSlashings 343.00 ns/op 401.00 ns/op 0.86
mainnet_e58758 - phase0 processEth1DataReset 544.00 ns/op 372.00 ns/op 1.46
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 837.90 us/op 1.3541 ms/op 0.62
mainnet_e58758 - phase0 processSlashingsReset 3.9470 us/op 2.7400 us/op 1.44
mainnet_e58758 - phase0 processRandaoMixesReset 2.8750 us/op 4.3290 us/op 0.66
mainnet_e58758 - phase0 processHistoricalRootsUpdate 558.00 ns/op 356.00 ns/op 1.57
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.6040 us/op 3.1960 us/op 1.44
mainnet_e58758 - phase0 afterProcessEpoch 73.639 ms/op 66.940 ms/op 1.10
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.0374 ms/op 984.82 us/op 1.05
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.1470 ms/op 1.0434 ms/op 1.10
altair processInactivityUpdates - 250000 normalcase 27.470 ms/op 23.290 ms/op 1.18
altair processInactivityUpdates - 250000 worstcase 23.943 ms/op 23.993 ms/op 1.00
phase0 processRegistryUpdates - 250000 normalcase 7.2620 us/op 7.0610 us/op 1.03
phase0 processRegistryUpdates - 250000 badcase_full_deposits 476.53 us/op 438.73 us/op 1.09
phase0 processRegistryUpdates - 250000 worstcase 0.5 120.07 ms/op 113.86 ms/op 1.05
altair processRewardsAndPenalties - 250000 normalcase 69.425 ms/op 67.247 ms/op 1.03
altair processRewardsAndPenalties - 250000 worstcase 69.606 ms/op 72.725 ms/op 0.96
phase0 getAttestationDeltas - 250000 normalcase 5.9646 ms/op 5.0376 ms/op 1.18
phase0 getAttestationDeltas - 250000 worstcase 6.3086 ms/op 5.7400 ms/op 1.10
phase0 processSlashings - 250000 worstcase 88.541 us/op 81.373 us/op 1.09
altair processSyncCommitteeUpdates - 250000 111.70 ms/op 104.57 ms/op 1.07
BeaconState.hashTreeRoot - No change 441.00 ns/op 303.00 ns/op 1.46
BeaconState.hashTreeRoot - 1 full validator 152.19 us/op 96.752 us/op 1.57
BeaconState.hashTreeRoot - 32 full validator 1.7499 ms/op 888.55 us/op 1.97
BeaconState.hashTreeRoot - 512 full validator 13.500 ms/op 11.405 ms/op 1.18
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 149.16 us/op 125.69 us/op 1.19
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.2994 ms/op 1.5208 ms/op 1.51
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 31.782 ms/op 27.267 ms/op 1.17
BeaconState.hashTreeRoot - 1 balances 93.294 us/op 118.92 us/op 0.78
BeaconState.hashTreeRoot - 32 balances 769.58 us/op 1.1091 ms/op 0.69
BeaconState.hashTreeRoot - 512 balances 7.1836 ms/op 10.319 ms/op 0.70
BeaconState.hashTreeRoot - 250000 balances 133.76 ms/op 187.71 ms/op 0.71
aggregationBits - 2048 els - zipIndexesInBitList 20.846 us/op 18.991 us/op 1.10
byteArrayEquals 32 65.763 ns/op 63.367 ns/op 1.04
Buffer.compare 32 40.387 ns/op 37.042 ns/op 1.09
byteArrayEquals 1024 1.7895 us/op 1.7259 us/op 1.04
Buffer.compare 1024 48.527 ns/op 43.950 ns/op 1.10
byteArrayEquals 16384 28.626 us/op 27.510 us/op 1.04
Buffer.compare 16384 232.10 ns/op 223.89 ns/op 1.04
byteArrayEquals 123687377 215.78 ms/op 199.48 ms/op 1.08
Buffer.compare 123687377 5.7376 ms/op 3.7169 ms/op 1.54
byteArrayEquals 32 - diff last byte 65.234 ns/op 61.532 ns/op 1.06
Buffer.compare 32 - diff last byte 39.742 ns/op 38.381 ns/op 1.04
byteArrayEquals 1024 - diff last byte 1.6440 us/op 1.7295 us/op 0.95
Buffer.compare 1024 - diff last byte 42.566 ns/op 46.314 ns/op 0.92
byteArrayEquals 16384 - diff last byte 26.649 us/op 27.565 us/op 0.97
Buffer.compare 16384 - diff last byte 199.12 ns/op 215.73 ns/op 0.92
byteArrayEquals 123687377 - diff last byte 206.21 ms/op 200.54 ms/op 1.03
Buffer.compare 123687377 - diff last byte 4.7013 ms/op 4.3579 ms/op 1.08
byteArrayEquals 32 - random bytes 4.4840 ns/op 4.5640 ns/op 0.98
Buffer.compare 32 - random bytes 38.673 ns/op 40.996 ns/op 0.94
byteArrayEquals 1024 - random bytes 4.1240 ns/op 4.4160 ns/op 0.93
Buffer.compare 1024 - random bytes 32.286 ns/op 38.279 ns/op 0.84
byteArrayEquals 16384 - random bytes 4.0530 ns/op 4.4550 ns/op 0.91
Buffer.compare 16384 - random bytes 32.573 ns/op 36.714 ns/op 0.89
byteArrayEquals 123687377 - random bytes 7.0900 ns/op 7.3300 ns/op 0.97
Buffer.compare 123687377 - random bytes 35.150 ns/op 43.240 ns/op 0.81
regular array get 100000 times 37.418 us/op 40.870 us/op 0.92
wrappedArray get 100000 times 37.432 us/op 40.928 us/op 0.91
arrayWithProxy get 100000 times 10.382 ms/op 9.8070 ms/op 1.06
ssz.Root.equals 54.494 ns/op 54.592 ns/op 1.00
byteArrayEquals 53.317 ns/op 54.366 ns/op 0.98
Buffer.compare 9.2850 ns/op 9.4430 ns/op 0.98
shuffle list - 16384 els 5.7398 ms/op 5.9307 ms/op 0.97
shuffle list - 250000 els 84.247 ms/op 88.800 ms/op 0.95
processSlot - 1 slots 14.272 us/op 12.636 us/op 1.13
processSlot - 32 slots 3.6796 ms/op 2.3121 ms/op 1.59
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 57.055 ms/op 55.691 ms/op 1.02
getCommitteeAssignments - req 1 vs - 250000 vc 2.3949 ms/op 2.2723 ms/op 1.05
getCommitteeAssignments - req 100 vs - 250000 vc 3.5483 ms/op 3.3592 ms/op 1.06
getCommitteeAssignments - req 1000 vs - 250000 vc 3.8179 ms/op 3.6544 ms/op 1.04
findModifiedValidators - 10000 modified validators 294.32 ms/op 289.67 ms/op 1.02
findModifiedValidators - 1000 modified validators 161.96 ms/op 158.46 ms/op 1.02
findModifiedValidators - 100 modified validators 123.52 ms/op 141.07 ms/op 0.88
findModifiedValidators - 10 modified validators 125.91 ms/op 142.14 ms/op 0.89
findModifiedValidators - 1 modified validators 131.32 ms/op 139.31 ms/op 0.94
findModifiedValidators - no difference 141.05 ms/op 164.11 ms/op 0.86
compare ViewDUs 3.7683 s/op 3.8955 s/op 0.97
compare each validator Uint8Array 1.1954 s/op 1.9431 s/op 0.62
compare ViewDU to Uint8Array 766.79 ms/op 878.22 ms/op 0.87
migrate state 1000000 validators, 24 modified, 0 new 691.40 ms/op 690.46 ms/op 1.00
migrate state 1000000 validators, 1700 modified, 1000 new 896.82 ms/op 1.1159 s/op 0.80
migrate state 1000000 validators, 3400 modified, 2000 new 1.1644 s/op 1.4338 s/op 0.81
migrate state 1500000 validators, 24 modified, 0 new 749.61 ms/op 747.08 ms/op 1.00
migrate state 1500000 validators, 1700 modified, 1000 new 889.45 ms/op 1.0252 s/op 0.87
migrate state 1500000 validators, 3400 modified, 2000 new 1.2023 s/op 1.2771 s/op 0.94
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.5300 ns/op 3.4700 ns/op 1.31
state getBlockRootAtSlot - 250000 vs - 7PWei 464.99 ns/op 410.56 ns/op 1.13
computeProposers - vc 250000 5.9998 ms/op 5.7496 ms/op 1.04
computeEpochShuffling - vc 250000 86.359 ms/op 84.874 ms/op 1.02
getNextSyncCommittee - vc 250000 106.13 ms/op 101.57 ms/op 1.04
computeSigningRoot for AttestationData 21.055 us/op 16.651 us/op 1.26
hash AttestationData serialized data then Buffer.toString(base64) 1.2959 us/op 1.2346 us/op 1.05
toHexString serialized data 854.11 ns/op 779.74 ns/op 1.10
Buffer.toString(base64) 169.06 ns/op 154.41 ns/op 1.09

by benchmarkbot/action

@@ -31,7 +40,11 @@ export const testFnByType: Record<string, "skip" | ((data: any) => any)> = {
*/
function aggregate_verify(input: {pubkeys: string[]; messages: string[]; signature: string}): boolean {
const {pubkeys, messages, signature} = input;
return bls.verifyMultiple(pubkeys.map(fromHexString), messages.map(fromHexString), fromHexString(signature));
try {
Copy link
Member

Choose a reason for hiding this comment

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

@wemeetagain I added this try/catch for the spec tests but am updating the base lib to not throw for this so it better meets the spec.

Comment on lines +149 to +153
try {
return _verify(fromHexString(message), fromHexString(pubkey), fromHexString(signature));
} catch {
return 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 I added this try/catch for the spec tests but am updating the base lib to not throw for this so it better meets the spec.

Comment on lines +92 to +96
try {
return aggregateVerify(messages.map(fromHexString), pubkeys.map(fromHexString), fromHexString(signature));
} catch {
return 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 I added this try/catch for the spec tests but am updating the base lib to not throw for this so it better meets the spec.

Comment on lines +192 to +196
try {
return _verify(fromHexString(message), fromHexString(pubkey), fromHexString(signature));
} catch {
return 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 I added this try/catch for the spec tests but am updating the base lib to not throw for this so it better meets the spec.

@matthewkeil
Copy link
Member

Metrics on feat2-mainnet do not look great. They should be equal to unstable/stable but seems to be performing worse for some reason... Will try and swap for another feat group tomorrow and see if its the machine

@matthewkeil
Copy link
Member

After running for a while it seems like this branch is actually fine. @tuyennhv would love your opinion as well but I'm going to approve

twoeths
twoeths previously approved these changes May 8, 2024
Copy link
Contributor

@twoeths twoeths left a comment

Choose a reason for hiding this comment

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

Looks good to me, had a suggestion for signatureFromBytes() util
also signatureFromBytesNoCheck() should be moved to @lodestar/utils instead so that both could be consumed by different packages

@matthewkeil
Copy link
Member

Looks good to me, had a suggestion for signatureFromBytes() util also signatureFromBytesNoCheck() should be moved to @lodestar/utils instead so that both could be consumed by different packages

Added them both to @lodestar/utils

@matthewkeil
Copy link
Member

@twoeths @philknows Spoke with @wemeetagain and we will merge this one after interop. Should not be an issue but why add more complexity to an already moving target. Can sit for the week and get merged when we get back. All is ready and just waiting for reapproval after the last update for the comment @twoeths had

let isAllValid = true;
// validate signature = true
const signatures = sets.map((set) => {
try {
return bls.Signature.fromBytes(set.signature, CoordType.affine, true);
const sig = Signature.deserialize(set.signature, CoordType.affine);
sig.sigValidate();
Copy link
Contributor

Choose a reason for hiding this comment

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

use signatureFromBytes() here

pubkeys.map((hex) => bls.PublicKey.fromBytes(fromHexString(hex), CoordType.jacobian, true)),
fromHexString(message)
const sig = Signature.deserialize(fromHexString(signature), undefined);
sig.sigValidate();
Copy link
Contributor

Choose a reason for hiding this comment

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

need to search for all sigValidate() and replace with signatureFromBytes()

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Good idea!

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

3 participants