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

refactor: reuse command types/utils across packages #6441

Merged
merged 10 commits into from
Feb 22, 2024

Conversation

nflaig
Copy link
Member

@nflaig nflaig commented Feb 16, 2024

Motivation

Noticed we copy-pasted command types/utils in different packages but we only really maintain the ones in the CLI package.

This PR aims to consolidate types by moving those into the utils package to improve consistency and reduce future maintenance.

Description

  • Move command types/utils to @lodestar/utils package
  • Fix type issues that came up in prover package after reusing stricter types
  • Demand option (demandOption: true) if arg must be provided instead of checking separately

@nflaig nflaig requested a review from a team as a code owner February 16, 2024 13:58
@@ -49,6 +49,7 @@
"devDependencies": {
"@types/js-yaml": "^4.0.5",
"@types/triple-beam": "^1.3.2",
"@types/yargs": "^17.0.24",
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 added yargs types as dev dependency to the package as I want to avoid having this as a dependency but this might lead to the case where yargs types result in any if the consuming project does not install them.

e.g. something like this would not throw an type error

registerCommandToYargs({}, { command: "", describe: "" });

but if you install @types/yargs as dependency in that project it will complain that first param is not correct

Argument of type '{}' is not assignable to parameter of type 'Argv<{}>'.
  Type '{}' is missing the following properties from type 'Argv<{}>': alias, argv, array, boolean, and 66 more.ts(2345

Since this is just an edge use case and all our packages have the types installed, I opted for not adding types as a dependency.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's find to add types as dev dependency. If we are reexporting the types from this package then we may try duplicating those for now in our source.

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 don't think duplicating types for this use case makes sense, and consumers can always install the types if they want to.

@@ -2,6 +2,7 @@ export * from "./yaml/index.js";
export * from "./assert.js";
export * from "./base64.js";
export * from "./bytes.js";
export * from "./command.js";
Copy link
Contributor

Choose a reason for hiding this comment

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

The @lodestar/utils package is integral to be used in lightclient and prover. So would be nice if it remains browser compatible and adding yargs and CLI utils may break the bundlers.

We should try to export Node.js specific utils from a different names export and avoid from default export. May be @lodestar/utils/cli could be an option.

Copy link
Member Author

Choose a reason for hiding this comment

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

These are just types, and a utils function which takes in yargs as an argument. I don't see a reason why we would have to export this separately

Copy link
Member Author

Choose a reason for hiding this comment

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

We should try to export Node.js specific utils from a different names export and avoid from default export. May be @lodestar/utils/cli could be an option.

I do agree that this is something we should consider, we already use this pattern in the api package.

But for the changes in this PR it is not relevant as it only adds shared types, there is no risk of breaking browser compatibility

packages/prover/src/cli/cmds/start/options.ts Outdated Show resolved Hide resolved
packages/prover/src/cli/cmds/start/options.ts Outdated Show resolved Hide resolved
Copy link

codecov bot commented Feb 16, 2024

Codecov Report

Merging #6441 (fbfc547) into unstable (1943346) will increase coverage by 0.01%.
Report is 1 commits behind head on unstable.
The diff coverage is 86.95%.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #6441      +/-   ##
============================================
+ Coverage     61.70%   61.72%   +0.01%     
============================================
  Files           553      554       +1     
  Lines         57848    57939      +91     
  Branches       1829     1829              
============================================
+ Hits          35696    35763      +67     
- Misses        22115    22139      +24     
  Partials         37       37              

@@ -51,7 +52,6 @@ export const exportCmd: CliCommand<ExportArgs, ISlashingProtectionArgs & Account

handler: async (args) => {
const {file} = args;
if (!file) throw new YargsError("must provide file arg");
Copy link
Member Author

Choose a reason for hiding this comment

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

demandOption: true already ensures that a file arg is provided

@@ -49,6 +49,7 @@
"devDependencies": {
"@types/js-yaml": "^4.0.5",
"@types/triple-beam": "^1.3.2",
"@types/yargs": "^17.0.24",
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 don't think duplicating types for this use case makes sense, and consumers can always install the types if they want to.

@@ -2,6 +2,7 @@ export * from "./yaml/index.js";
export * from "./assert.js";
export * from "./base64.js";
export * from "./bytes.js";
export * from "./command.js";
Copy link
Member Author

Choose a reason for hiding this comment

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

We should try to export Node.js specific utils from a different names export and avoid from default export. May be @lodestar/utils/cli could be an option.

I do agree that this is something we should consider, we already use this pattern in the api package.

But for the changes in this PR it is not relevant as it only adds shared types, there is no risk of breaking browser compatibility

Copy link
Contributor

github-actions bot commented Feb 16, 2024

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: d257461 Previous: 1943346 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 796.18 us/op 783.71 us/op 1.02
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 80.556 us/op 82.172 us/op 0.98
BLS verify - blst-native 1.2896 ms/op 1.3033 ms/op 0.99
BLS verifyMultipleSignatures 3 - blst-native 2.7103 ms/op 2.7049 ms/op 1.00
BLS verifyMultipleSignatures 8 - blst-native 5.9367 ms/op 5.9917 ms/op 0.99
BLS verifyMultipleSignatures 32 - blst-native 21.669 ms/op 21.853 ms/op 0.99
BLS verifyMultipleSignatures 64 - blst-native 42.919 ms/op 43.019 ms/op 1.00
BLS verifyMultipleSignatures 128 - blst-native 84.763 ms/op 85.336 ms/op 0.99
BLS deserializing 10000 signatures 916.13 ms/op 932.91 ms/op 0.98
BLS deserializing 100000 signatures 9.0509 s/op 9.4799 s/op 0.95
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.2521 ms/op 1.3638 ms/op 0.92
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.5737 ms/op 1.5394 ms/op 1.02
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.8056 ms/op 2.3699 ms/op 1.18
BLS verifyMultipleSignatures - same message - 64 - blst-native 4.4878 ms/op 4.6589 ms/op 0.96
BLS verifyMultipleSignatures - same message - 128 - blst-native 7.5472 ms/op 7.4250 ms/op 1.02
BLS aggregatePubkeys 32 - blst-native 26.032 us/op 28.361 us/op 0.92
BLS aggregatePubkeys 128 - blst-native 98.697 us/op 102.45 us/op 0.96
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 52.313 ms/op 52.971 ms/op 0.99
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 46.539 ms/op 50.450 ms/op 0.92
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 29.861 ms/op 30.839 ms/op 0.97
getSlashingsAndExits - default max 179.73 us/op 201.21 us/op 0.89
getSlashingsAndExits - 2k 433.46 us/op 317.98 us/op 1.36
proposeBlockBody type=full, size=empty 5.0054 ms/op 5.1125 ms/op 0.98
isKnown best case - 1 super set check 313.00 ns/op 316.00 ns/op 0.99
isKnown normal case - 2 super set checks 295.00 ns/op 346.00 ns/op 0.85
isKnown worse case - 16 super set checks 296.00 ns/op 304.00 ns/op 0.97
CheckpointStateCache - add get delete 5.4920 us/op 6.1520 us/op 0.89
validate api signedAggregateAndProof - struct 2.6681 ms/op 2.7588 ms/op 0.97
validate gossip signedAggregateAndProof - struct 2.6078 ms/op 2.8761 ms/op 0.91
validate gossip attestation - vc 640000 1.3259 ms/op 1.3877 ms/op 0.96
batch validate gossip attestation - vc 640000 - chunk 32 155.24 us/op 167.83 us/op 0.92
batch validate gossip attestation - vc 640000 - chunk 64 135.71 us/op 147.80 us/op 0.92
batch validate gossip attestation - vc 640000 - chunk 128 127.65 us/op 144.88 us/op 0.88
batch validate gossip attestation - vc 640000 - chunk 256 127.22 us/op 141.14 us/op 0.90
pickEth1Vote - no votes 1.2269 ms/op 1.4754 ms/op 0.83
pickEth1Vote - max votes 9.0026 ms/op 12.447 ms/op 0.72
pickEth1Vote - Eth1Data hashTreeRoot value x2048 17.444 ms/op 21.092 ms/op 0.83
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 28.268 ms/op 30.932 ms/op 0.91
pickEth1Vote - Eth1Data fastSerialize value x2048 558.55 us/op 835.45 us/op 0.67
pickEth1Vote - Eth1Data fastSerialize tree x2048 6.3327 ms/op 5.8592 ms/op 1.08
bytes32 toHexString 465.00 ns/op 808.00 ns/op 0.58
bytes32 Buffer.toString(hex) 273.00 ns/op 324.00 ns/op 0.84
bytes32 Buffer.toString(hex) from Uint8Array 386.00 ns/op 549.00 ns/op 0.70
bytes32 Buffer.toString(hex) + 0x 270.00 ns/op 322.00 ns/op 0.84
Object access 1 prop 0.14500 ns/op 0.21000 ns/op 0.69
Map access 1 prop 0.14400 ns/op 0.16300 ns/op 0.88
Object get x1000 6.8600 ns/op 7.8730 ns/op 0.87
Map get x1000 0.70200 ns/op 0.82800 ns/op 0.85
Object set x1000 46.775 ns/op 59.944 ns/op 0.78
Map set x1000 36.526 ns/op 51.138 ns/op 0.71
Return object 10000 times 0.22360 ns/op 0.25400 ns/op 0.88
Throw Error 10000 times 3.6412 us/op 3.8963 us/op 0.93
fastMsgIdFn sha256 / 200 bytes 3.0610 us/op 3.4480 us/op 0.89
fastMsgIdFn h32 xxhash / 200 bytes 247.00 ns/op 314.00 ns/op 0.79
fastMsgIdFn h64 xxhash / 200 bytes 314.00 ns/op 380.00 ns/op 0.83
fastMsgIdFn sha256 / 1000 bytes 10.650 us/op 11.640 us/op 0.91
fastMsgIdFn h32 xxhash / 1000 bytes 367.00 ns/op 437.00 ns/op 0.84
fastMsgIdFn h64 xxhash / 1000 bytes 386.00 ns/op 464.00 ns/op 0.83
fastMsgIdFn sha256 / 10000 bytes 97.582 us/op 107.50 us/op 0.91
fastMsgIdFn h32 xxhash / 10000 bytes 1.7720 us/op 2.0270 us/op 0.87
fastMsgIdFn h64 xxhash / 10000 bytes 1.2050 us/op 1.4140 us/op 0.85
send data - 1000 256B messages 17.861 ms/op 19.308 ms/op 0.93
send data - 1000 512B messages 23.907 ms/op 28.968 ms/op 0.83
send data - 1000 1024B messages 36.174 ms/op 44.725 ms/op 0.81
send data - 1000 1200B messages 35.833 ms/op 39.109 ms/op 0.92
send data - 1000 2048B messages 47.811 ms/op 51.802 ms/op 0.92
send data - 1000 4096B messages 41.473 ms/op 44.083 ms/op 0.94
send data - 1000 16384B messages 114.22 ms/op 120.59 ms/op 0.95
send data - 1000 65536B messages 473.08 ms/op 492.04 ms/op 0.96
enrSubnets - fastDeserialize 64 bits 1.2150 us/op 1.3600 us/op 0.89
enrSubnets - ssz BitVector 64 bits 400.00 ns/op 448.00 ns/op 0.89
enrSubnets - fastDeserialize 4 bits 159.00 ns/op 193.00 ns/op 0.82
enrSubnets - ssz BitVector 4 bits 404.00 ns/op 470.00 ns/op 0.86
prioritizePeers score -10:0 att 32-0.1 sync 2-0 99.492 us/op 103.74 us/op 0.96
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 116.02 us/op 126.92 us/op 0.91
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 157.90 us/op 163.18 us/op 0.97
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 279.93 us/op 289.20 us/op 0.97
prioritizePeers score 0:0 att 64-1 sync 4-1 329.14 us/op 346.21 us/op 0.95
array of 16000 items push then shift 1.5737 us/op 1.6413 us/op 0.96
LinkedList of 16000 items push then shift 8.6330 ns/op 8.9060 ns/op 0.97
array of 16000 items push then pop 79.263 ns/op 87.662 ns/op 0.90
LinkedList of 16000 items push then pop 8.4390 ns/op 8.8400 ns/op 0.95
array of 24000 items push then shift 2.3212 us/op 2.4697 us/op 0.94
LinkedList of 24000 items push then shift 8.5690 ns/op 9.0490 ns/op 0.95
array of 24000 items push then pop 96.596 ns/op 134.94 ns/op 0.72
LinkedList of 24000 items push then pop 8.3710 ns/op 8.7610 ns/op 0.96
intersect bitArray bitLen 8 5.5440 ns/op 5.7320 ns/op 0.97
intersect array and set length 8 59.915 ns/op 62.223 ns/op 0.96
intersect bitArray bitLen 128 34.313 ns/op 35.650 ns/op 0.96
intersect array and set length 128 832.91 ns/op 872.95 ns/op 0.95
bitArray.getTrueBitIndexes() bitLen 128 1.3130 us/op 1.6660 us/op 0.79
bitArray.getTrueBitIndexes() bitLen 248 2.3800 us/op 2.6940 us/op 0.88
bitArray.getTrueBitIndexes() bitLen 512 4.5180 us/op 5.1780 us/op 0.87
Buffer.concat 32 items 919.00 ns/op 1.0480 us/op 0.88
Uint8Array.set 32 items 1.7150 us/op 2.8790 us/op 0.60
Set add up to 64 items then delete first 4.1544 us/op 4.4754 us/op 0.93
OrderedSet add up to 64 items then delete first 5.2547 us/op 5.6399 us/op 0.93
Set add up to 64 items then delete last 4.6062 us/op 5.0679 us/op 0.91
OrderedSet add up to 64 items then delete last 5.6723 us/op 6.0830 us/op 0.93
Set add up to 64 items then delete middle 4.5736 us/op 4.8776 us/op 0.94
OrderedSet add up to 64 items then delete middle 6.9549 us/op 7.8044 us/op 0.89
Set add up to 128 items then delete first 9.1933 us/op 9.4421 us/op 0.97
OrderedSet add up to 128 items then delete first 12.212 us/op 12.819 us/op 0.95
Set add up to 128 items then delete last 9.0388 us/op 9.5047 us/op 0.95
OrderedSet add up to 128 items then delete last 11.451 us/op 12.150 us/op 0.94
Set add up to 128 items then delete middle 9.0755 us/op 9.4962 us/op 0.96
OrderedSet add up to 128 items then delete middle 16.827 us/op 17.631 us/op 0.95
Set add up to 256 items then delete first 18.792 us/op 20.978 us/op 0.90
OrderedSet add up to 256 items then delete first 24.888 us/op 25.974 us/op 0.96
Set add up to 256 items then delete last 18.127 us/op 18.933 us/op 0.96
OrderedSet add up to 256 items then delete last 23.007 us/op 24.140 us/op 0.95
Set add up to 256 items then delete middle 18.077 us/op 18.942 us/op 0.95
OrderedSet add up to 256 items then delete middle 44.645 us/op 47.184 us/op 0.95
transfer serialized Status (84 B) 1.6290 us/op 1.9080 us/op 0.85
copy serialized Status (84 B) 1.2750 us/op 1.3600 us/op 0.94
transfer serialized SignedVoluntaryExit (112 B) 1.7520 us/op 1.9500 us/op 0.90
copy serialized SignedVoluntaryExit (112 B) 1.3640 us/op 1.5100 us/op 0.90
transfer serialized ProposerSlashing (416 B) 2.2590 us/op 3.1590 us/op 0.72
copy serialized ProposerSlashing (416 B) 2.0570 us/op 2.0620 us/op 1.00
transfer serialized Attestation (485 B) 2.6500 us/op 2.1460 us/op 1.23
copy serialized Attestation (485 B) 2.0280 us/op 1.8490 us/op 1.10
transfer serialized AttesterSlashing (33232 B) 2.5370 us/op 2.9530 us/op 0.86
copy serialized AttesterSlashing (33232 B) 5.6800 us/op 6.6760 us/op 0.85
transfer serialized Small SignedBeaconBlock (128000 B) 2.9380 us/op 2.6740 us/op 1.10
copy serialized Small SignedBeaconBlock (128000 B) 15.224 us/op 15.474 us/op 0.98
transfer serialized Avg SignedBeaconBlock (200000 B) 2.8280 us/op 2.9380 us/op 0.96
copy serialized Avg SignedBeaconBlock (200000 B) 22.100 us/op 64.244 us/op 0.34
transfer serialized BlobsSidecar (524380 B) 2.6530 us/op 2.8210 us/op 0.94
copy serialized BlobsSidecar (524380 B) 128.29 us/op 74.717 us/op 1.72
transfer serialized Big SignedBeaconBlock (1000000 B) 2.6560 us/op 3.0280 us/op 0.88
copy serialized Big SignedBeaconBlock (1000000 B) 168.70 us/op 130.00 us/op 1.30
pass gossip attestations to forkchoice per slot 3.6650 ms/op 4.4042 ms/op 0.83
forkChoice updateHead vc 100000 bc 64 eq 0 745.60 us/op 708.23 us/op 1.05
forkChoice updateHead vc 600000 bc 64 eq 0 4.1442 ms/op 4.9689 ms/op 0.83
forkChoice updateHead vc 1000000 bc 64 eq 0 6.6213 ms/op 7.3928 ms/op 0.90
forkChoice updateHead vc 600000 bc 320 eq 0 4.1248 ms/op 4.3579 ms/op 0.95
forkChoice updateHead vc 600000 bc 1200 eq 0 4.2811 ms/op 4.5022 ms/op 0.95
forkChoice updateHead vc 600000 bc 7200 eq 0 5.3642 ms/op 5.5654 ms/op 0.96
forkChoice updateHead vc 600000 bc 64 eq 1000 10.923 ms/op 11.511 ms/op 0.95
forkChoice updateHead vc 600000 bc 64 eq 10000 11.292 ms/op 12.328 ms/op 0.92
forkChoice updateHead vc 600000 bc 64 eq 300000 15.139 ms/op 16.385 ms/op 0.92
computeDeltas 500000 validators 300 proto nodes 6.4400 ms/op 6.5712 ms/op 0.98
computeDeltas 500000 validators 1200 proto nodes 6.3461 ms/op 6.5341 ms/op 0.97
computeDeltas 500000 validators 7200 proto nodes 6.2535 ms/op 6.4909 ms/op 0.96
computeDeltas 750000 validators 300 proto nodes 9.5731 ms/op 9.8244 ms/op 0.97
computeDeltas 750000 validators 1200 proto nodes 9.3343 ms/op 9.7568 ms/op 0.96
computeDeltas 750000 validators 7200 proto nodes 9.4680 ms/op 10.010 ms/op 0.95
computeDeltas 1400000 validators 300 proto nodes 18.392 ms/op 20.110 ms/op 0.91
computeDeltas 1400000 validators 1200 proto nodes 19.229 ms/op 19.617 ms/op 0.98
computeDeltas 1400000 validators 7200 proto nodes 18.125 ms/op 19.555 ms/op 0.93
computeDeltas 2100000 validators 300 proto nodes 27.142 ms/op 28.794 ms/op 0.94
computeDeltas 2100000 validators 1200 proto nodes 27.526 ms/op 29.097 ms/op 0.95
computeDeltas 2100000 validators 7200 proto nodes 27.430 ms/op 28.197 ms/op 0.97
altair processAttestation - 250000 vs - 7PWei normalcase 2.0314 ms/op 2.3921 ms/op 0.85
altair processAttestation - 250000 vs - 7PWei worstcase 3.0849 ms/op 3.5155 ms/op 0.88
altair processAttestation - setStatus - 1/6 committees join 138.18 us/op 196.04 us/op 0.70
altair processAttestation - setStatus - 1/3 committees join 280.27 us/op 369.91 us/op 0.76
altair processAttestation - setStatus - 1/2 committees join 366.75 us/op 498.69 us/op 0.74
altair processAttestation - setStatus - 2/3 committees join 481.04 us/op 621.79 us/op 0.77
altair processAttestation - setStatus - 4/5 committees join 652.85 us/op 814.52 us/op 0.80
altair processAttestation - setStatus - 100% committees join 787.11 us/op 950.32 us/op 0.83
altair processBlock - 250000 vs - 7PWei normalcase 9.2565 ms/op 10.447 ms/op 0.89
altair processBlock - 250000 vs - 7PWei normalcase hashState 34.545 ms/op 34.717 ms/op 1.00
altair processBlock - 250000 vs - 7PWei worstcase 36.543 ms/op 43.856 ms/op 0.83
altair processBlock - 250000 vs - 7PWei worstcase hashState 88.418 ms/op 94.114 ms/op 0.94
phase0 processBlock - 250000 vs - 7PWei normalcase 2.3183 ms/op 2.6278 ms/op 0.88
phase0 processBlock - 250000 vs - 7PWei worstcase 28.853 ms/op 31.194 ms/op 0.92
altair processEth1Data - 250000 vs - 7PWei normalcase 502.16 us/op 520.39 us/op 0.96
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 7.1120 us/op 12.616 us/op 0.56
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 58.798 us/op 68.803 us/op 0.85
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 15.533 us/op 25.199 us/op 0.62
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 6.8960 us/op 15.330 us/op 0.45
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 126.04 us/op 179.65 us/op 0.70
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.0496 ms/op 1.2304 ms/op 0.85
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.5054 ms/op 1.7008 ms/op 0.89
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.4391 ms/op 1.7887 ms/op 0.80
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 3.3801 ms/op 3.3132 ms/op 1.02
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.2843 ms/op 2.4991 ms/op 0.91
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 5.0794 ms/op 5.1479 ms/op 0.99
Tree 40 250000 create 337.03 ms/op 407.15 ms/op 0.83
Tree 40 250000 get(125000) 184.91 ns/op 211.17 ns/op 0.88
Tree 40 250000 set(125000) 895.42 ns/op 1.0888 us/op 0.82
Tree 40 250000 toArray() 18.941 ms/op 22.050 ms/op 0.86
Tree 40 250000 iterate all - toArray() + loop 19.216 ms/op 21.100 ms/op 0.91
Tree 40 250000 iterate all - get(i) 62.691 ms/op 72.228 ms/op 0.87
MutableVector 250000 create 12.286 ms/op 13.510 ms/op 0.91
MutableVector 250000 get(125000) 6.4970 ns/op 6.7700 ns/op 0.96
MutableVector 250000 set(125000) 266.84 ns/op 294.72 ns/op 0.91
MutableVector 250000 toArray() 3.1807 ms/op 3.6887 ms/op 0.86
MutableVector 250000 iterate all - toArray() + loop 3.2979 ms/op 3.5912 ms/op 0.92
MutableVector 250000 iterate all - get(i) 1.4905 ms/op 1.5608 ms/op 0.95
Array 250000 create 2.6225 ms/op 2.8146 ms/op 0.93
Array 250000 clone - spread 1.3030 ms/op 1.4288 ms/op 0.91
Array 250000 get(125000) 1.0370 ns/op 1.1960 ns/op 0.87
Array 250000 set(125000) 3.9910 ns/op 4.3160 ns/op 0.92
Array 250000 iterate all - loop 158.87 us/op 171.17 us/op 0.93
effectiveBalanceIncrements clone Uint8Array 300000 28.022 us/op 34.550 us/op 0.81
effectiveBalanceIncrements clone MutableVector 300000 392.00 ns/op 354.00 ns/op 1.11
effectiveBalanceIncrements rw all Uint8Array 300000 190.62 us/op 206.04 us/op 0.93
effectiveBalanceIncrements rw all MutableVector 300000 83.303 ms/op 84.949 ms/op 0.98
phase0 afterProcessEpoch - 250000 vs - 7PWei 120.18 ms/op 127.15 ms/op 0.95
phase0 beforeProcessEpoch - 250000 vs - 7PWei 35.329 ms/op 38.575 ms/op 0.92
altair processEpoch - mainnet_e81889 512.22 ms/op 518.25 ms/op 0.99
mainnet_e81889 - altair beforeProcessEpoch 82.387 ms/op 82.688 ms/op 1.00
mainnet_e81889 - altair processJustificationAndFinalization 13.991 us/op 15.409 us/op 0.91
mainnet_e81889 - altair processInactivityUpdates 5.3716 ms/op 6.3891 ms/op 0.84
mainnet_e81889 - altair processRewardsAndPenalties 61.503 ms/op 65.145 ms/op 0.94
mainnet_e81889 - altair processRegistryUpdates 2.6910 us/op 2.4140 us/op 1.11
mainnet_e81889 - altair processSlashings 418.00 ns/op 427.00 ns/op 0.98
mainnet_e81889 - altair processEth1DataReset 445.00 ns/op 502.00 ns/op 0.89
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.4019 ms/op 1.4387 ms/op 0.97
mainnet_e81889 - altair processSlashingsReset 3.3530 us/op 3.7320 us/op 0.90
mainnet_e81889 - altair processRandaoMixesReset 4.5250 us/op 4.8120 us/op 0.94
mainnet_e81889 - altair processHistoricalRootsUpdate 661.00 ns/op 737.00 ns/op 0.90
mainnet_e81889 - altair processParticipationFlagUpdates 1.8920 us/op 4.5090 us/op 0.42
mainnet_e81889 - altair processSyncCommitteeUpdates 948.00 ns/op 2.0530 us/op 0.46
mainnet_e81889 - altair afterProcessEpoch 115.36 ms/op 123.44 ms/op 0.93
capella processEpoch - mainnet_e217614 2.0778 s/op 2.0967 s/op 0.99
mainnet_e217614 - capella beforeProcessEpoch 466.56 ms/op 483.69 ms/op 0.96
mainnet_e217614 - capella processJustificationAndFinalization 13.852 us/op 15.343 us/op 0.90
mainnet_e217614 - capella processInactivityUpdates 20.342 ms/op 21.729 ms/op 0.94
mainnet_e217614 - capella processRewardsAndPenalties 418.30 ms/op 424.31 ms/op 0.99
mainnet_e217614 - capella processRegistryUpdates 16.131 us/op 20.200 us/op 0.80
mainnet_e217614 - capella processSlashings 523.00 ns/op 529.00 ns/op 0.99
mainnet_e217614 - capella processEth1DataReset 400.00 ns/op 461.00 ns/op 0.87
mainnet_e217614 - capella processEffectiveBalanceUpdates 4.3229 ms/op 4.4803 ms/op 0.96
mainnet_e217614 - capella processSlashingsReset 3.5440 us/op 2.9750 us/op 1.19
mainnet_e217614 - capella processRandaoMixesReset 4.2300 us/op 4.7340 us/op 0.89
mainnet_e217614 - capella processHistoricalRootsUpdate 556.00 ns/op 909.00 ns/op 0.61
mainnet_e217614 - capella processParticipationFlagUpdates 1.2900 us/op 1.5730 us/op 0.82
mainnet_e217614 - capella afterProcessEpoch 285.42 ms/op 327.83 ms/op 0.87
phase0 processEpoch - mainnet_e58758 424.28 ms/op 434.21 ms/op 0.98
mainnet_e58758 - phase0 beforeProcessEpoch 119.72 ms/op 120.74 ms/op 0.99
mainnet_e58758 - phase0 processJustificationAndFinalization 14.292 us/op 16.573 us/op 0.86
mainnet_e58758 - phase0 processRewardsAndPenalties 34.465 ms/op 50.938 ms/op 0.68
mainnet_e58758 - phase0 processRegistryUpdates 9.2710 us/op 9.3610 us/op 0.99
mainnet_e58758 - phase0 processSlashings 545.00 ns/op 468.00 ns/op 1.16
mainnet_e58758 - phase0 processEth1DataReset 374.00 ns/op 460.00 ns/op 0.81
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.1347 ms/op 1.1423 ms/op 0.99
mainnet_e58758 - phase0 processSlashingsReset 3.4070 us/op 2.9930 us/op 1.14
mainnet_e58758 - phase0 processRandaoMixesReset 4.0570 us/op 4.6790 us/op 0.87
mainnet_e58758 - phase0 processHistoricalRootsUpdate 615.00 ns/op 491.00 ns/op 1.25
mainnet_e58758 - phase0 processParticipationRecordUpdates 3.8380 us/op 3.4770 us/op 1.10
mainnet_e58758 - phase0 afterProcessEpoch 93.346 ms/op 98.011 ms/op 0.95
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.3606 ms/op 1.4101 ms/op 0.96
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.9409 ms/op 1.5016 ms/op 1.29
altair processInactivityUpdates - 250000 normalcase 22.648 ms/op 23.229 ms/op 0.98
altair processInactivityUpdates - 250000 worstcase 23.070 ms/op 24.415 ms/op 0.94
phase0 processRegistryUpdates - 250000 normalcase 8.6460 us/op 9.0790 us/op 0.95
phase0 processRegistryUpdates - 250000 badcase_full_deposits 376.57 us/op 424.06 us/op 0.89
phase0 processRegistryUpdates - 250000 worstcase 0.5 135.56 ms/op 146.57 ms/op 0.92
altair processRewardsAndPenalties - 250000 normalcase 55.155 ms/op 55.431 ms/op 1.00
altair processRewardsAndPenalties - 250000 worstcase 58.581 ms/op 58.665 ms/op 1.00
phase0 getAttestationDeltas - 250000 normalcase 8.8965 ms/op 10.200 ms/op 0.87
phase0 getAttestationDeltas - 250000 worstcase 8.9379 ms/op 9.1303 ms/op 0.98
phase0 processSlashings - 250000 worstcase 80.981 us/op 91.013 us/op 0.89
altair processSyncCommitteeUpdates - 250000 147.61 ms/op 156.44 ms/op 0.94
BeaconState.hashTreeRoot - No change 371.00 ns/op 351.00 ns/op 1.06
BeaconState.hashTreeRoot - 1 full validator 158.09 us/op 151.75 us/op 1.04
BeaconState.hashTreeRoot - 32 full validator 1.6707 ms/op 1.6548 ms/op 1.01
BeaconState.hashTreeRoot - 512 full validator 15.895 ms/op 20.891 ms/op 0.76
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 161.99 us/op 220.92 us/op 0.73
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.9768 ms/op 2.9851 ms/op 0.66
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 25.857 ms/op 37.254 ms/op 0.69
BeaconState.hashTreeRoot - 1 balances 126.32 us/op 169.40 us/op 0.75
BeaconState.hashTreeRoot - 32 balances 1.2228 ms/op 1.6465 ms/op 0.74
BeaconState.hashTreeRoot - 512 balances 11.559 ms/op 14.842 ms/op 0.78
BeaconState.hashTreeRoot - 250000 balances 214.35 ms/op 196.99 ms/op 1.09
aggregationBits - 2048 els - zipIndexesInBitList 16.195 us/op 18.714 us/op 0.87
byteArrayEquals 32 74.045 ns/op 75.551 ns/op 0.98
Buffer.compare 32 55.770 ns/op 56.258 ns/op 0.99
byteArrayEquals 1024 2.0218 us/op 2.0543 us/op 0.98
Buffer.compare 1024 69.706 ns/op 72.189 ns/op 0.97
byteArrayEquals 16384 32.211 us/op 32.728 us/op 0.98
Buffer.compare 16384 248.81 ns/op 238.65 ns/op 1.04
byteArrayEquals 123687377 245.69 ms/op 254.87 ms/op 0.96
Buffer.compare 123687377 6.7443 ms/op 6.6818 ms/op 1.01
byteArrayEquals 32 - diff last byte 71.472 ns/op 74.831 ns/op 0.96
Buffer.compare 32 - diff last byte 56.677 ns/op 56.413 ns/op 1.00
byteArrayEquals 1024 - diff last byte 2.0422 us/op 2.1006 us/op 0.97
Buffer.compare 1024 - diff last byte 78.648 ns/op 73.605 ns/op 1.07
byteArrayEquals 16384 - diff last byte 32.577 us/op 33.123 us/op 0.98
Buffer.compare 16384 - diff last byte 274.47 ns/op 285.75 ns/op 0.96
byteArrayEquals 123687377 - diff last byte 244.53 ms/op 249.58 ms/op 0.98
Buffer.compare 123687377 - diff last byte 6.1727 ms/op 6.8618 ms/op 0.90
byteArrayEquals 32 - random bytes 6.4980 ns/op 5.4180 ns/op 1.20
Buffer.compare 32 - random bytes 61.342 ns/op 62.294 ns/op 0.98
byteArrayEquals 1024 - random bytes 6.0640 ns/op 5.3350 ns/op 1.14
Buffer.compare 1024 - random bytes 60.395 ns/op 60.930 ns/op 0.99
byteArrayEquals 16384 - random bytes 5.9550 ns/op 5.2690 ns/op 1.13
Buffer.compare 16384 - random bytes 60.300 ns/op 60.653 ns/op 0.99
byteArrayEquals 123687377 - random bytes 9.4500 ns/op 8.5500 ns/op 1.11
Buffer.compare 123687377 - random bytes 64.100 ns/op 68.230 ns/op 0.94
regular array get 100000 times 47.409 us/op 45.819 us/op 1.03
wrappedArray get 100000 times 64.722 us/op 45.600 us/op 1.42
arrayWithProxy get 100000 times 14.593 ms/op 15.090 ms/op 0.97
ssz.Root.equals 55.724 ns/op 55.387 ns/op 1.01
byteArrayEquals 80.086 ns/op 54.457 ns/op 1.47
Buffer.compare 12.580 ns/op 11.091 ns/op 1.13
shuffle list - 16384 els 6.9518 ms/op 7.1184 ms/op 0.98
shuffle list - 250000 els 101.86 ms/op 104.78 ms/op 0.97
processSlot - 1 slots 15.509 us/op 16.660 us/op 0.93
processSlot - 32 slots 2.8762 ms/op 3.9964 ms/op 0.72
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 55.817 ms/op 57.948 ms/op 0.96
getCommitteeAssignments - req 1 vs - 250000 vc 2.4904 ms/op 2.5709 ms/op 0.97
getCommitteeAssignments - req 100 vs - 250000 vc 3.6846 ms/op 3.6520 ms/op 1.01
getCommitteeAssignments - req 1000 vs - 250000 vc 4.0063 ms/op 4.0659 ms/op 0.99
findModifiedValidators - 10000 modified validators 525.88 ms/op 542.23 ms/op 0.97
findModifiedValidators - 1000 modified validators 403.93 ms/op 429.50 ms/op 0.94
findModifiedValidators - 100 modified validators 422.34 ms/op 395.75 ms/op 1.07
findModifiedValidators - 10 modified validators 438.48 ms/op 403.24 ms/op 1.09
findModifiedValidators - 1 modified validators 404.69 ms/op 392.47 ms/op 1.03
findModifiedValidators - no difference 408.40 ms/op 397.84 ms/op 1.03
compare ViewDUs 4.2133 s/op 4.2310 s/op 1.00
compare each validator Uint8Array 1.8227 s/op 1.6579 s/op 1.10
compare ViewDU to Uint8Array 1.0884 s/op 1.2010 s/op 0.91
migrate state 1000000 validators, 24 modified, 0 new 780.93 ms/op 823.51 ms/op 0.95
migrate state 1000000 validators, 1700 modified, 1000 new 1.0997 s/op 1.0385 s/op 1.06
migrate state 1000000 validators, 3400 modified, 2000 new 1.3217 s/op 1.3038 s/op 1.01
migrate state 1500000 validators, 24 modified, 0 new 796.29 ms/op 793.82 ms/op 1.00
migrate state 1500000 validators, 1700 modified, 1000 new 1.0989 s/op 1.0792 s/op 1.02
migrate state 1500000 validators, 3400 modified, 2000 new 1.3318 s/op 1.3399 s/op 0.99
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.0600 ns/op 4.5900 ns/op 0.88
state getBlockRootAtSlot - 250000 vs - 7PWei 913.89 ns/op 587.55 ns/op 1.56
computeProposers - vc 250000 9.7623 ms/op 9.6385 ms/op 1.01
computeEpochShuffling - vc 250000 101.24 ms/op 105.12 ms/op 0.96
getNextSyncCommittee - vc 250000 151.07 ms/op 153.47 ms/op 0.98
computeSigningRoot for AttestationData 26.758 us/op 25.459 us/op 1.05
hash AttestationData serialized data then Buffer.toString(base64) 2.2166 us/op 2.2792 us/op 0.97
toHexString serialized data 1.0369 us/op 1.0770 us/op 0.96
Buffer.toString(base64) 200.78 ns/op 223.72 ns/op 0.90

by benchmarkbot/action

@nazarhussain nazarhussain merged commit 8959bda into unstable Feb 22, 2024
18 of 20 checks passed
@nazarhussain nazarhussain deleted the nflaig/reuse-cli-utils branch February 22, 2024 14:26
@wemeetagain
Copy link
Member

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