这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@wemeetagain
Copy link
Member

@wemeetagain wemeetagain commented Sep 22, 2025

Motivation

Description

  • combined with chore: add bun exports to packages #8448, surpressTranspileTS: true is needed for workers to use typescript source directly without transpiling it (and incorrectly loading it via a commonjs loader)
  • avoid worker resourceLimits - Bun doesn't implement it, it throws if you use it
  • use datastore-fs instead of datastore-level for backing our libp2p database -- Note this is changed unilaterally (affecting current nodejs usage)
  • use assemblyscript chacha20-poly1305 - bun doesn't support the native crypto implementation

@wemeetagain wemeetagain requested a review from a team as a code owner September 22, 2025 22:05
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @wemeetagain, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces several adjustments primarily aimed at improving compatibility and performance when running the application with Bun, a new JavaScript runtime. It addresses how TypeScript source files are handled by workers, gracefully manages platform-specific worker options like resourceLimits, and updates the underlying data storage mechanism for libp2p to use a file system-based solution. These changes ensure smoother operation and better resource management across different runtime environments.

Highlights

  • Bun Worker Compatibility: Enabled suppressTranspileTS for Bun workers across several modules (historicalStateRegen.ts, multithread/index.ts, networkCoreWorkerHandler.ts, discv5/index.ts) to allow them to directly use TypeScript source files without incorrect CommonJS loading issues.
  • Conditional Resource Limits: Implemented conditional handling for resourceLimits in worker configurations within networkCoreWorkerHandler.ts, ensuring this option is only applied when not running on Bun, as Bun does not support it and would otherwise throw an error.
  • Datastore Migration: Switched the libp2p database backing from datastore-level to datastore-fs in datastore.ts, which impacts both Bun and existing Node.js environments by changing the underlying storage mechanism for peer data.
  • Dependency Updates: Updated yarn.lock to reflect the addition of datastore-fs and its associated dependencies, along with the removal of several unused packages (dns-over-http-resolver, get-func-name, native-fetch, receptacle, undici) and updates to elliptic and nan.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several adjustments for Bun runtime compatibility and updates the datastore implementation. The changes are well-aligned with the description, particularly the conditional handling of worker options for Bun and the switch to datastore-fs. I've provided a few suggestions to improve consistency in how Bun-specific worker options are configured across different files, which should enhance maintainability.

Comment on lines 40 to 43
const worker = new Worker(path.join(WORKER_DIR, "worker.js"), {
suppressTranspileTS: Boolean(globalThis.Bun),
workerData,
} as ConstructorParameters<typeof Worker>[1]);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with the changes in networkCoreWorkerHandler.ts, consider creating the worker options object separately and then conditionally adding the suppressTranspileTS property. This improves readability and maintainability by making the pattern for handling Bun-specific options consistent across the codebase.

    const workerOpts: ConstructorParameters<typeof Worker>[1] = {
      workerData,
    };
    if (globalThis.Bun) {
      workerOpts.suppressTranspileTS = true;
    }
    const worker = new Worker(path.join(WORKER_DIR, "worker.js"), workerOpts);

Comment on lines 266 to 269
const worker = new Worker(path.join(workerDir, "worker.js"), {
suppressTranspileTS: Boolean(globalThis.Bun),
workerData,
} as ConstructorParameters<typeof Worker>[1]);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with the changes in networkCoreWorkerHandler.ts, consider creating the worker options object separately and then conditionally adding the suppressTranspileTS property. This improves readability and maintainability by making the pattern for handling Bun-specific options consistent across the codebase.

      const workerOpts: ConstructorParameters<typeof Worker>[1] = {
        workerData,
      };
      if (globalThis.Bun) {
        workerOpts.suppressTranspileTS = true;
      }
      const worker = new Worker(path.join(workerDir, "worker.js"), workerOpts);

Comment on lines +54 to +57
const worker = new Worker("./worker.js", {
suppressTranspileTS: Boolean(globalThis.Bun),
workerData,
} as ConstructorParameters<typeof Worker>[1]);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with the changes in networkCoreWorkerHandler.ts, consider creating the worker options object separately and then conditionally adding the suppressTranspileTS property. This improves readability and maintainability by making the pattern for handling Bun-specific options consistent across the codebase.

    const workerOpts: ConstructorParameters<typeof Worker>[1] = {
      workerData,
    };
    if (globalThis.Bun) {
      workerOpts.suppressTranspileTS = true;
    }
    const worker = new Worker("./worker.js", workerOpts);

@codecov
Copy link

codecov bot commented Sep 22, 2025

Codecov Report

❌ Patch coverage is 18.51852% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.24%. Comparing base (c0078a1) to head (1d6a58f).
⚠️ Report is 3 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #8449      +/-   ##
============================================
- Coverage     52.24%   52.24%   -0.01%     
============================================
  Files           853      853              
  Lines         64770    64788      +18     
  Branches       4764     4766       +2     
============================================
+ Hits          33841    33846       +5     
- Misses        30859    30872      +13     
  Partials         70       70              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 22, 2025

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 69a3b8d Previous: c0078a1 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 976.96 us/op 1.2437 ms/op 0.79
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 35.914 us/op 38.726 us/op 0.93
BLS verify - blst 826.99 us/op 1.0814 ms/op 0.76
BLS verifyMultipleSignatures 3 - blst 2.2333 ms/op 1.4463 ms/op 1.54
BLS verifyMultipleSignatures 8 - blst 1.9145 ms/op 2.1838 ms/op 0.88
BLS verifyMultipleSignatures 32 - blst 7.2011 ms/op 7.3518 ms/op 0.98
BLS verifyMultipleSignatures 64 - blst 10.735 ms/op 11.516 ms/op 0.93
BLS verifyMultipleSignatures 128 - blst 17.889 ms/op 18.774 ms/op 0.95
BLS deserializing 10000 signatures 702.85 ms/op 747.36 ms/op 0.94
BLS deserializing 100000 signatures 6.9572 s/op 7.4261 s/op 0.94
BLS verifyMultipleSignatures - same message - 3 - blst 1.5719 ms/op 1.1128 ms/op 1.41
BLS verifyMultipleSignatures - same message - 8 - blst 1.5389 ms/op 1.2361 ms/op 1.24
BLS verifyMultipleSignatures - same message - 32 - blst 1.7389 ms/op 1.9471 ms/op 0.89
BLS verifyMultipleSignatures - same message - 64 - blst 2.4406 ms/op 3.0423 ms/op 0.80
BLS verifyMultipleSignatures - same message - 128 - blst 4.1948 ms/op 4.8919 ms/op 0.86
BLS aggregatePubkeys 32 - blst 18.723 us/op 22.738 us/op 0.82
BLS aggregatePubkeys 128 - blst 66.986 us/op 74.896 us/op 0.89
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 47.755 ms/op 65.195 ms/op 0.73
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 41.953 ms/op 59.742 ms/op 0.70
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 45.414 ms/op 44.838 ms/op 1.01
getSlashingsAndExits - default max 71.017 us/op 109.31 us/op 0.65
getSlashingsAndExits - 2k 282.44 us/op 368.82 us/op 0.77
isKnown best case - 1 super set check 206.00 ns/op 229.00 ns/op 0.90
isKnown normal case - 2 super set checks 204.00 ns/op 227.00 ns/op 0.90
isKnown worse case - 16 super set checks 205.00 ns/op 230.00 ns/op 0.89
InMemoryCheckpointStateCache - add get delete 2.6380 us/op 2.4470 us/op 1.08
validate api signedAggregateAndProof - struct 2.6061 ms/op 1.4114 ms/op 1.85
validate gossip signedAggregateAndProof - struct 2.0752 ms/op 1.7525 ms/op 1.18
batch validate gossip attestation - vc 640000 - chunk 32 116.12 us/op 118.92 us/op 0.98
batch validate gossip attestation - vc 640000 - chunk 64 99.574 us/op 104.71 us/op 0.95
batch validate gossip attestation - vc 640000 - chunk 128 93.863 us/op 97.354 us/op 0.96
batch validate gossip attestation - vc 640000 - chunk 256 94.430 us/op 105.85 us/op 0.89
pickEth1Vote - no votes 952.97 us/op 1.0027 ms/op 0.95
pickEth1Vote - max votes 5.3610 ms/op 7.0464 ms/op 0.76
pickEth1Vote - Eth1Data hashTreeRoot value x2048 11.410 ms/op 13.434 ms/op 0.85
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 20.936 ms/op 19.825 ms/op 1.06
pickEth1Vote - Eth1Data fastSerialize value x2048 430.17 us/op 454.79 us/op 0.95
pickEth1Vote - Eth1Data fastSerialize tree x2048 3.2320 ms/op 3.8498 ms/op 0.84
bytes32 toHexString 350.00 ns/op 433.00 ns/op 0.81
bytes32 Buffer.toString(hex) 226.00 ns/op 296.00 ns/op 0.76
bytes32 Buffer.toString(hex) from Uint8Array 325.00 ns/op 339.00 ns/op 0.96
bytes32 Buffer.toString(hex) + 0x 236.00 ns/op 318.00 ns/op 0.74
Object access 1 prop 0.11700 ns/op 0.12200 ns/op 0.96
Map access 1 prop 0.12000 ns/op 0.14800 ns/op 0.81
Object get x1000 5.6300 ns/op 6.0430 ns/op 0.93
Map get x1000 6.0380 ns/op 6.6800 ns/op 0.90
Object set x1000 27.668 ns/op 31.039 ns/op 0.89
Map set x1000 18.473 ns/op 21.433 ns/op 0.86
Return object 10000 times 0.27870 ns/op 0.32170 ns/op 0.87
Throw Error 10000 times 4.1670 us/op 4.6449 us/op 0.90
toHex 125.95 ns/op 135.23 ns/op 0.93
Buffer.from 119.95 ns/op 120.68 ns/op 0.99
shared Buffer 77.826 ns/op 81.890 ns/op 0.95
fastMsgIdFn sha256 / 200 bytes 2.1580 us/op 2.2850 us/op 0.94
fastMsgIdFn h32 xxhash / 200 bytes 201.00 ns/op 221.00 ns/op 0.91
fastMsgIdFn h64 xxhash / 200 bytes 261.00 ns/op 306.00 ns/op 0.85
fastMsgIdFn sha256 / 1000 bytes 7.1390 us/op 7.6080 us/op 0.94
fastMsgIdFn h32 xxhash / 1000 bytes 341.00 ns/op 343.00 ns/op 0.99
fastMsgIdFn h64 xxhash / 1000 bytes 336.00 ns/op 350.00 ns/op 0.96
fastMsgIdFn sha256 / 10000 bytes 64.404 us/op 67.022 us/op 0.96
fastMsgIdFn h32 xxhash / 10000 bytes 1.7900 us/op 1.8960 us/op 0.94
fastMsgIdFn h64 xxhash / 10000 bytes 1.1500 us/op 1.2530 us/op 0.92
send data - 1000 256B messages 15.283 ms/op 19.244 ms/op 0.79
send data - 1000 512B messages 18.412 ms/op 22.516 ms/op 0.82
send data - 1000 1024B messages 25.887 ms/op 31.150 ms/op 0.83
send data - 1000 1200B messages 24.628 ms/op 29.678 ms/op 0.83
send data - 1000 2048B messages 24.804 ms/op 28.723 ms/op 0.86
send data - 1000 4096B messages 27.628 ms/op 33.917 ms/op 0.81
send data - 1000 16384B messages 43.968 ms/op 50.215 ms/op 0.88
send data - 1000 65536B messages 109.91 ms/op 132.38 ms/op 0.83
enrSubnets - fastDeserialize 64 bits 901.00 ns/op 908.00 ns/op 0.99
enrSubnets - ssz BitVector 64 bits 312.00 ns/op 342.00 ns/op 0.91
enrSubnets - fastDeserialize 4 bits 125.00 ns/op 131.00 ns/op 0.95
enrSubnets - ssz BitVector 4 bits 307.00 ns/op 351.00 ns/op 0.87
prioritizePeers score -10:0 att 32-0.1 sync 2-0 230.80 us/op 253.95 us/op 0.91
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 261.24 us/op 280.71 us/op 0.93
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 361.52 us/op 417.80 us/op 0.87
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 683.38 us/op 759.33 us/op 0.90
prioritizePeers score 0:0 att 64-1 sync 4-1 814.18 us/op 913.47 us/op 0.89
array of 16000 items push then shift 1.5363 us/op 1.6975 us/op 0.91
LinkedList of 16000 items push then shift 6.9380 ns/op 7.9700 ns/op 0.87
array of 16000 items push then pop 74.558 ns/op 86.142 ns/op 0.87
LinkedList of 16000 items push then pop 6.8210 ns/op 7.6430 ns/op 0.89
array of 24000 items push then shift 2.2849 us/op 2.5380 us/op 0.90
LinkedList of 24000 items push then shift 6.8780 ns/op 7.8450 ns/op 0.88
array of 24000 items push then pop 99.522 ns/op 113.79 ns/op 0.87
LinkedList of 24000 items push then pop 6.9030 ns/op 7.5070 ns/op 0.92
intersect bitArray bitLen 8 6.2870 ns/op 6.7580 ns/op 0.93
intersect array and set length 8 37.337 ns/op 41.367 ns/op 0.90
intersect bitArray bitLen 128 29.430 ns/op 30.484 ns/op 0.97
intersect array and set length 128 614.67 ns/op 635.34 ns/op 0.97
bitArray.getTrueBitIndexes() bitLen 128 970.00 ns/op 1.1370 us/op 0.85
bitArray.getTrueBitIndexes() bitLen 248 1.7020 us/op 1.9030 us/op 0.89
bitArray.getTrueBitIndexes() bitLen 512 3.4900 us/op 3.9600 us/op 0.88
Buffer.concat 32 items 596.00 ns/op 625.00 ns/op 0.95
Uint8Array.set 32 items 997.00 ns/op 1.6630 us/op 0.60
Buffer.copy 3.0550 us/op 2.6510 us/op 1.15
Uint8Array.set - with subarray 1.5610 us/op 1.6570 us/op 0.94
Uint8Array.set - without subarray 879.00 ns/op 1.1000 us/op 0.80
getUint32 - dataview 186.00 ns/op 201.00 ns/op 0.93
getUint32 - manual 115.00 ns/op 121.00 ns/op 0.95
Set add up to 64 items then delete first 2.1252 us/op 2.3474 us/op 0.91
OrderedSet add up to 64 items then delete first 3.1275 us/op 3.5812 us/op 0.87
Set add up to 64 items then delete last 2.3264 us/op 2.7094 us/op 0.86
OrderedSet add up to 64 items then delete last 3.4563 us/op 3.9637 us/op 0.87
Set add up to 64 items then delete middle 2.4028 us/op 2.4344 us/op 0.99
OrderedSet add up to 64 items then delete middle 5.1626 us/op 5.8293 us/op 0.89
Set add up to 128 items then delete first 4.8472 us/op 5.7916 us/op 0.84
OrderedSet add up to 128 items then delete first 7.3764 us/op 10.155 us/op 0.73
Set add up to 128 items then delete last 4.7268 us/op 5.3782 us/op 0.88
OrderedSet add up to 128 items then delete last 7.0589 us/op 8.1215 us/op 0.87
Set add up to 128 items then delete middle 4.7450 us/op 5.5263 us/op 0.86
OrderedSet add up to 128 items then delete middle 13.483 us/op 17.224 us/op 0.78
Set add up to 256 items then delete first 10.581 us/op 12.799 us/op 0.83
OrderedSet add up to 256 items then delete first 15.367 us/op 18.746 us/op 0.82
Set add up to 256 items then delete last 9.4113 us/op 12.895 us/op 0.73
OrderedSet add up to 256 items then delete last 14.466 us/op 16.020 us/op 0.90
Set add up to 256 items then delete middle 9.4518 us/op 11.585 us/op 0.82
OrderedSet add up to 256 items then delete middle 41.791 us/op 48.885 us/op 0.85
transfer serialized Status (84 B) 2.1810 us/op 2.4060 us/op 0.91
copy serialized Status (84 B) 1.1200 us/op 1.3380 us/op 0.84
transfer serialized SignedVoluntaryExit (112 B) 2.2350 us/op 2.4330 us/op 0.92
copy serialized SignedVoluntaryExit (112 B) 1.1900 us/op 1.5550 us/op 0.77
transfer serialized ProposerSlashing (416 B) 2.7580 us/op 2.6000 us/op 1.06
copy serialized ProposerSlashing (416 B) 1.2370 us/op 2.0570 us/op 0.60
transfer serialized Attestation (485 B) 2.2130 us/op 3.6310 us/op 0.61
copy serialized Attestation (485 B) 1.2050 us/op 1.6020 us/op 0.75
transfer serialized AttesterSlashing (33232 B) 2.3680 us/op 2.9960 us/op 0.79
copy serialized AttesterSlashing (33232 B) 3.2960 us/op 5.0750 us/op 0.65
transfer serialized Small SignedBeaconBlock (128000 B) 2.5440 us/op 3.3940 us/op 0.75
copy serialized Small SignedBeaconBlock (128000 B) 8.3400 us/op 10.466 us/op 0.80
transfer serialized Avg SignedBeaconBlock (200000 B) 2.8850 us/op 4.4140 us/op 0.65
copy serialized Avg SignedBeaconBlock (200000 B) 12.214 us/op 17.046 us/op 0.72
transfer serialized BlobsSidecar (524380 B) 2.9980 us/op 3.7650 us/op 0.80
copy serialized BlobsSidecar (524380 B) 61.061 us/op 68.485 us/op 0.89
transfer serialized Big SignedBeaconBlock (1000000 B) 3.1140 us/op 4.3290 us/op 0.72
copy serialized Big SignedBeaconBlock (1000000 B) 148.94 us/op 122.75 us/op 1.21
pass gossip attestations to forkchoice per slot 2.6585 ms/op 2.9792 ms/op 0.89
forkChoice updateHead vc 100000 bc 64 eq 0 429.66 us/op 474.00 us/op 0.91
forkChoice updateHead vc 600000 bc 64 eq 0 2.6555 ms/op 3.0227 ms/op 0.88
forkChoice updateHead vc 1000000 bc 64 eq 0 4.5871 ms/op 5.1763 ms/op 0.89
forkChoice updateHead vc 600000 bc 320 eq 0 2.6826 ms/op 3.0740 ms/op 0.87
forkChoice updateHead vc 600000 bc 1200 eq 0 2.7028 ms/op 3.7413 ms/op 0.72
forkChoice updateHead vc 600000 bc 7200 eq 0 2.9417 ms/op 4.6166 ms/op 0.64
forkChoice updateHead vc 600000 bc 64 eq 1000 9.8325 ms/op 10.763 ms/op 0.91
forkChoice updateHead vc 600000 bc 64 eq 10000 10.407 ms/op 10.714 ms/op 0.97
forkChoice updateHead vc 600000 bc 64 eq 300000 13.978 ms/op 16.044 ms/op 0.87
computeDeltas 500000 validators 300 proto nodes 3.7588 ms/op 4.1274 ms/op 0.91
computeDeltas 500000 validators 1200 proto nodes 3.9625 ms/op 4.3609 ms/op 0.91
computeDeltas 500000 validators 7200 proto nodes 4.3198 ms/op 4.0794 ms/op 1.06
computeDeltas 750000 validators 300 proto nodes 6.4118 ms/op 5.8772 ms/op 1.09
computeDeltas 750000 validators 1200 proto nodes 6.7830 ms/op 5.8235 ms/op 1.16
computeDeltas 750000 validators 7200 proto nodes 6.6837 ms/op 5.8386 ms/op 1.14
computeDeltas 1400000 validators 300 proto nodes 12.128 ms/op 10.942 ms/op 1.11
computeDeltas 1400000 validators 1200 proto nodes 11.841 ms/op 10.972 ms/op 1.08
computeDeltas 1400000 validators 7200 proto nodes 11.223 ms/op 11.226 ms/op 1.00
computeDeltas 2100000 validators 300 proto nodes 16.945 ms/op 17.722 ms/op 0.96
computeDeltas 2100000 validators 1200 proto nodes 16.404 ms/op 18.897 ms/op 0.87
computeDeltas 2100000 validators 7200 proto nodes 16.082 ms/op 22.095 ms/op 0.73
altair processAttestation - 250000 vs - 7PWei normalcase 2.0807 ms/op 2.2707 ms/op 0.92
altair processAttestation - 250000 vs - 7PWei worstcase 3.0479 ms/op 3.7610 ms/op 0.81
altair processAttestation - setStatus - 1/6 committees join 128.34 us/op 156.35 us/op 0.82
altair processAttestation - setStatus - 1/3 committees join 266.05 us/op 269.66 us/op 0.99
altair processAttestation - setStatus - 1/2 committees join 356.91 us/op 384.75 us/op 0.93
altair processAttestation - setStatus - 2/3 committees join 458.10 us/op 488.11 us/op 0.94
altair processAttestation - setStatus - 4/5 committees join 621.80 us/op 677.58 us/op 0.92
altair processAttestation - setStatus - 100% committees join 736.59 us/op 805.22 us/op 0.91
altair processBlock - 250000 vs - 7PWei normalcase 5.4683 ms/op 6.1598 ms/op 0.89
altair processBlock - 250000 vs - 7PWei normalcase hashState 34.558 ms/op 34.901 ms/op 0.99
altair processBlock - 250000 vs - 7PWei worstcase 46.382 ms/op 42.442 ms/op 1.09
altair processBlock - 250000 vs - 7PWei worstcase hashState 94.392 ms/op 92.145 ms/op 1.02
phase0 processBlock - 250000 vs - 7PWei normalcase 2.7701 ms/op 2.0377 ms/op 1.36
phase0 processBlock - 250000 vs - 7PWei worstcase 38.253 ms/op 29.786 ms/op 1.28
altair processEth1Data - 250000 vs - 7PWei normalcase 347.70 us/op 352.71 us/op 0.99
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 9.6640 us/op 7.2330 us/op 1.34
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 58.070 us/op 53.695 us/op 1.08
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 15.920 us/op 14.337 us/op 1.11
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 9.6270 us/op 7.8000 us/op 1.23
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 230.81 us/op 220.75 us/op 1.05
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.7917 ms/op 1.9338 ms/op 0.93
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 2.1457 ms/op 2.4630 ms/op 0.87
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 2.3381 ms/op 2.4457 ms/op 0.96
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 3.9514 ms/op 4.8189 ms/op 0.82
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.2999 ms/op 2.4481 ms/op 0.94
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 4.2735 ms/op 4.8150 ms/op 0.89
Tree 40 250000 create 433.20 ms/op 469.92 ms/op 0.92
Tree 40 250000 get(125000) 144.02 ns/op 144.16 ns/op 1.00
Tree 40 250000 set(125000) 1.4495 us/op 1.6425 us/op 0.88
Tree 40 250000 toArray() 15.800 ms/op 19.462 ms/op 0.81
Tree 40 250000 iterate all - toArray() + loop 17.394 ms/op 19.618 ms/op 0.89
Tree 40 250000 iterate all - get(i) 51.047 ms/op 54.694 ms/op 0.93
Array 250000 create 2.4868 ms/op 2.5124 ms/op 0.99
Array 250000 clone - spread 806.74 us/op 822.62 us/op 0.98
Array 250000 get(125000) 0.40300 ns/op 0.42700 ns/op 0.94
Array 250000 set(125000) 0.42900 ns/op 0.43700 ns/op 0.98
Array 250000 iterate all - loop 82.042 us/op 84.903 us/op 0.97
phase0 afterProcessEpoch - 250000 vs - 7PWei 42.057 ms/op 42.898 ms/op 0.98
Array.fill - length 1000000 3.6851 ms/op 3.6272 ms/op 1.02
Array push - length 1000000 12.836 ms/op 15.947 ms/op 0.80
Array.get 0.27293 ns/op 0.29349 ns/op 0.93
Uint8Array.get 0.43906 ns/op 0.45025 ns/op 0.98
phase0 beforeProcessEpoch - 250000 vs - 7PWei 16.226 ms/op 18.191 ms/op 0.89
altair processEpoch - mainnet_e81889 329.19 ms/op 302.62 ms/op 1.09
mainnet_e81889 - altair beforeProcessEpoch 18.145 ms/op 22.290 ms/op 0.81
mainnet_e81889 - altair processJustificationAndFinalization 5.7820 us/op 5.4610 us/op 1.06
mainnet_e81889 - altair processInactivityUpdates 4.2041 ms/op 4.8164 ms/op 0.87
mainnet_e81889 - altair processRewardsAndPenalties 42.701 ms/op 42.621 ms/op 1.00
mainnet_e81889 - altair processRegistryUpdates 740.00 ns/op 693.00 ns/op 1.07
mainnet_e81889 - altair processSlashings 205.00 ns/op 213.00 ns/op 0.96
mainnet_e81889 - altair processEth1DataReset 210.00 ns/op 216.00 ns/op 0.97
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.1723 ms/op 1.2207 ms/op 0.96
mainnet_e81889 - altair processSlashingsReset 1.0120 us/op 1.0260 us/op 0.99
mainnet_e81889 - altair processRandaoMixesReset 1.3060 us/op 1.2720 us/op 1.03
mainnet_e81889 - altair processHistoricalRootsUpdate 187.00 ns/op 206.00 ns/op 0.91
mainnet_e81889 - altair processParticipationFlagUpdates 607.00 ns/op 555.00 ns/op 1.09
mainnet_e81889 - altair processSyncCommitteeUpdates 145.00 ns/op 161.00 ns/op 0.90
mainnet_e81889 - altair afterProcessEpoch 44.161 ms/op 45.221 ms/op 0.98
capella processEpoch - mainnet_e217614 956.86 ms/op 987.40 ms/op 0.97
mainnet_e217614 - capella beforeProcessEpoch 66.652 ms/op 69.796 ms/op 0.95
mainnet_e217614 - capella processJustificationAndFinalization 5.6200 us/op 5.4850 us/op 1.02
mainnet_e217614 - capella processInactivityUpdates 15.832 ms/op 14.807 ms/op 1.07
mainnet_e217614 - capella processRewardsAndPenalties 211.25 ms/op 191.89 ms/op 1.10
mainnet_e217614 - capella processRegistryUpdates 6.8450 us/op 7.6720 us/op 0.89
mainnet_e217614 - capella processSlashings 198.00 ns/op 210.00 ns/op 0.94
mainnet_e217614 - capella processEth1DataReset 199.00 ns/op 195.00 ns/op 1.02
mainnet_e217614 - capella processEffectiveBalanceUpdates 4.2232 ms/op 15.166 ms/op 0.28
mainnet_e217614 - capella processSlashingsReset 948.00 ns/op 967.00 ns/op 0.98
mainnet_e217614 - capella processRandaoMixesReset 1.4440 us/op 1.3470 us/op 1.07
mainnet_e217614 - capella processHistoricalRootsUpdate 205.00 ns/op 203.00 ns/op 1.01
mainnet_e217614 - capella processParticipationFlagUpdates 580.00 ns/op 603.00 ns/op 0.96
mainnet_e217614 - capella afterProcessEpoch 123.22 ms/op 122.50 ms/op 1.01
phase0 processEpoch - mainnet_e58758 503.71 ms/op 316.93 ms/op 1.59
mainnet_e58758 - phase0 beforeProcessEpoch 169.98 ms/op 87.749 ms/op 1.94
mainnet_e58758 - phase0 processJustificationAndFinalization 10.108 us/op 6.3270 us/op 1.60
mainnet_e58758 - phase0 processRewardsAndPenalties 51.191 ms/op 42.066 ms/op 1.22
mainnet_e58758 - phase0 processRegistryUpdates 4.9090 us/op 4.0340 us/op 1.22
mainnet_e58758 - phase0 processSlashings 274.00 ns/op 323.00 ns/op 0.85
mainnet_e58758 - phase0 processEth1DataReset 261.00 ns/op 227.00 ns/op 1.15
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 4.8770 ms/op 1.3700 ms/op 3.56
mainnet_e58758 - phase0 processSlashingsReset 1.2310 us/op 976.00 ns/op 1.26
mainnet_e58758 - phase0 processRandaoMixesReset 1.5290 us/op 1.2870 us/op 1.19
mainnet_e58758 - phase0 processHistoricalRootsUpdate 284.00 ns/op 201.00 ns/op 1.41
mainnet_e58758 - phase0 processParticipationRecordUpdates 1.3710 us/op 990.00 ns/op 1.38
mainnet_e58758 - phase0 afterProcessEpoch 42.207 ms/op 36.623 ms/op 1.15
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.5053 ms/op 1.3838 ms/op 1.09
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 6.4529 ms/op 3.3172 ms/op 1.95
altair processInactivityUpdates - 250000 normalcase 24.864 ms/op 20.320 ms/op 1.22
altair processInactivityUpdates - 250000 worstcase 27.316 ms/op 19.231 ms/op 1.42
phase0 processRegistryUpdates - 250000 normalcase 14.179 us/op 6.5770 us/op 2.16
phase0 processRegistryUpdates - 250000 badcase_full_deposits 362.16 us/op 285.90 us/op 1.27
phase0 processRegistryUpdates - 250000 worstcase 0.5 162.13 ms/op 119.51 ms/op 1.36
altair processRewardsAndPenalties - 250000 normalcase 38.779 ms/op 37.875 ms/op 1.02
altair processRewardsAndPenalties - 250000 worstcase 45.236 ms/op 25.740 ms/op 1.76
phase0 getAttestationDeltas - 250000 normalcase 19.079 ms/op 8.5499 ms/op 2.23
phase0 getAttestationDeltas - 250000 worstcase 9.0091 ms/op 6.1334 ms/op 1.47
phase0 processSlashings - 250000 worstcase 157.35 us/op 131.30 us/op 1.20
altair processSyncCommitteeUpdates - 250000 19.183 ms/op 11.299 ms/op 1.70
BeaconState.hashTreeRoot - No change 458.00 ns/op 289.00 ns/op 1.58
BeaconState.hashTreeRoot - 1 full validator 180.87 us/op 75.302 us/op 2.40
BeaconState.hashTreeRoot - 32 full validator 1.5541 ms/op 876.61 us/op 1.77
BeaconState.hashTreeRoot - 512 full validator 21.763 ms/op 9.5722 ms/op 2.27
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 189.84 us/op 91.228 us/op 2.08
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.6350 ms/op 1.6963 ms/op 1.55
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 40.004 ms/op 29.283 ms/op 1.37
BeaconState.hashTreeRoot - 1 balances 129.83 us/op 75.922 us/op 1.71
BeaconState.hashTreeRoot - 32 balances 1.3658 ms/op 674.10 us/op 2.03
BeaconState.hashTreeRoot - 512 balances 10.952 ms/op 8.8320 ms/op 1.24
BeaconState.hashTreeRoot - 250000 balances 264.44 ms/op 166.76 ms/op 1.59
aggregationBits - 2048 els - zipIndexesInBitList 32.597 us/op 22.010 us/op 1.48
byteArrayEquals 32 59.067 ns/op 54.231 ns/op 1.09
Buffer.compare 32 25.908 ns/op 17.524 ns/op 1.48
byteArrayEquals 1024 1.7509 us/op 1.6104 us/op 1.09
Buffer.compare 1024 36.555 ns/op 25.066 ns/op 1.46
byteArrayEquals 16384 26.949 us/op 25.701 us/op 1.05
Buffer.compare 16384 228.24 ns/op 203.35 ns/op 1.12
byteArrayEquals 123687377 204.95 ms/op 193.24 ms/op 1.06
Buffer.compare 123687377 13.299 ms/op 7.9755 ms/op 1.67
byteArrayEquals 32 - diff last byte 58.077 ns/op 53.195 ns/op 1.09
Buffer.compare 32 - diff last byte 18.995 ns/op 17.392 ns/op 1.09
byteArrayEquals 1024 - diff last byte 1.7469 us/op 1.6108 us/op 1.08
Buffer.compare 1024 - diff last byte 35.099 ns/op 25.594 ns/op 1.37
byteArrayEquals 16384 - diff last byte 28.323 us/op 26.138 us/op 1.08
Buffer.compare 16384 - diff last byte 296.79 ns/op 204.38 ns/op 1.45
byteArrayEquals 123687377 - diff last byte 206.47 ms/op 195.67 ms/op 1.06
Buffer.compare 123687377 - diff last byte 11.250 ms/op 8.2003 ms/op 1.37
byteArrayEquals 32 - random bytes 5.4160 ns/op 5.1940 ns/op 1.04
Buffer.compare 32 - random bytes 18.318 ns/op 17.546 ns/op 1.04
byteArrayEquals 1024 - random bytes 5.4160 ns/op 5.2880 ns/op 1.02
Buffer.compare 1024 - random bytes 18.820 ns/op 17.449 ns/op 1.08
byteArrayEquals 16384 - random bytes 5.4200 ns/op 5.1500 ns/op 1.05
Buffer.compare 16384 - random bytes 18.707 ns/op 17.058 ns/op 1.10
byteArrayEquals 123687377 - random bytes 7.2700 ns/op 6.6000 ns/op 1.10
Buffer.compare 123687377 - random bytes 26.300 ns/op 19.050 ns/op 1.38
regular array get 100000 times 39.359 us/op 42.282 us/op 0.93
wrappedArray get 100000 times 34.293 us/op 45.439 us/op 0.75
arrayWithProxy get 100000 times 12.611 ms/op 12.482 ms/op 1.01
ssz.Root.equals 51.190 ns/op 47.935 ns/op 1.07
byteArrayEquals 50.202 ns/op 47.674 ns/op 1.05
Buffer.compare 11.618 ns/op 10.740 ns/op 1.08
processSlot - 1 slots 11.302 us/op 11.176 us/op 1.01
processSlot - 32 slots 4.3526 ms/op 2.7323 ms/op 1.59
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 6.1807 ms/op 3.5725 ms/op 1.73
getCommitteeAssignments - req 1 vs - 250000 vc 2.2467 ms/op 2.2179 ms/op 1.01
getCommitteeAssignments - req 100 vs - 250000 vc 4.4261 ms/op 4.2730 ms/op 1.04
getCommitteeAssignments - req 1000 vs - 250000 vc 4.7358 ms/op 4.5137 ms/op 1.05
findModifiedValidators - 10000 modified validators 1.0613 s/op 783.36 ms/op 1.35
findModifiedValidators - 1000 modified validators 928.67 ms/op 744.93 ms/op 1.25
findModifiedValidators - 100 modified validators 471.33 ms/op 282.58 ms/op 1.67
findModifiedValidators - 10 modified validators 358.07 ms/op 147.12 ms/op 2.43
findModifiedValidators - 1 modified validators 317.91 ms/op 154.18 ms/op 2.06
findModifiedValidators - no difference 266.54 ms/op 154.66 ms/op 1.72
compare ViewDUs 8.8436 s/op 6.6787 s/op 1.32
compare each validator Uint8Array 1.9379 s/op 1.8794 s/op 1.03
compare ViewDU to Uint8Array 1.8437 s/op 1.2292 s/op 1.50
migrate state 1000000 validators, 24 modified, 0 new 1.2913 s/op 896.91 ms/op 1.44
migrate state 1000000 validators, 1700 modified, 1000 new 1.6917 s/op 1.2120 s/op 1.40
migrate state 1000000 validators, 3400 modified, 2000 new 1.5185 s/op 1.4699 s/op 1.03
migrate state 1500000 validators, 24 modified, 0 new 902.23 ms/op 971.57 ms/op 0.93
migrate state 1500000 validators, 1700 modified, 1000 new 1.2078 s/op 1.2424 s/op 0.97
migrate state 1500000 validators, 3400 modified, 2000 new 1.3157 s/op 1.3291 s/op 0.99
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.7600 ns/op 4.1800 ns/op 1.14
state getBlockRootAtSlot - 250000 vs - 7PWei 597.81 ns/op 692.33 ns/op 0.86
naive computeProposerIndex 100000 validators 46.847 ms/op 52.115 ms/op 0.90
computeProposerIndex 100000 validators 1.4875 ms/op 1.5562 ms/op 0.96
naiveGetNextSyncCommitteeIndices 1000 validators 7.2869 s/op 8.3022 s/op 0.88
getNextSyncCommitteeIndices 1000 validators 113.42 ms/op 116.92 ms/op 0.97
naiveGetNextSyncCommitteeIndices 10000 validators 7.1579 s/op 7.7506 s/op 0.92
getNextSyncCommitteeIndices 10000 validators 113.37 ms/op 132.62 ms/op 0.85
naiveGetNextSyncCommitteeIndices 100000 validators 7.3105 s/op 8.8127 s/op 0.83
getNextSyncCommitteeIndices 100000 validators 113.55 ms/op 112.80 ms/op 1.01
naive computeShuffledIndex 100000 validators 24.407 s/op 26.645 s/op 0.92
cached computeShuffledIndex 100000 validators 559.03 ms/op 561.43 ms/op 1.00
naive computeShuffledIndex 2000000 validators 467.88 s/op 509.91 s/op 0.92
cached computeShuffledIndex 2000000 validators 33.132 s/op 39.765 s/op 0.83
computeProposers - vc 250000 630.55 us/op 620.00 us/op 1.02
computeEpochShuffling - vc 250000 42.098 ms/op 43.662 ms/op 0.96
getNextSyncCommittee - vc 250000 10.028 ms/op 10.859 ms/op 0.92
computeSigningRoot for AttestationData 18.506 us/op 23.505 us/op 0.79
hash AttestationData serialized data then Buffer.toString(base64) 1.5036 us/op 1.5771 us/op 0.95
toHexString serialized data 1.1763 us/op 1.2804 us/op 0.92
Buffer.toString(base64) 154.29 ns/op 155.38 ns/op 0.99
nodejs block root to RootHex using toHex 145.93 ns/op 142.53 ns/op 1.02
nodejs block root to RootHex using toRootHex 86.660 ns/op 86.528 ns/op 1.00
nodejs fromhex(blob) 117.57 ms/op 115.85 ms/op 1.01
nodejs fromHexInto(blob) 96.499 ms/op 94.326 ms/op 1.02
browser block root to RootHex using the deprecated toHexString 222.58 ns/op 214.50 ns/op 1.04
browser block root to RootHex using toHex 182.03 ns/op 172.22 ns/op 1.06
browser block root to RootHex using toRootHex 162.75 ns/op 165.65 ns/op 0.98
browser fromHexInto(blob) 866.92 us/op 828.66 us/op 1.05
browser fromHex(blob) 825.90 ms/op 790.68 ms/op 1.04

by benchmarkbot/action

@nflaig nflaig merged commit cec9bef into unstable Sep 23, 2025
35 of 41 checks passed
@nflaig nflaig deleted the cayman/bun-tweaks branch September 23, 2025 11:49
wemeetagain added a commit that referenced this pull request Oct 6, 2025
**Motivation**

- Review of #8468 metrics
- In #8449, use of
`datastore-level` was unilaterally removed in favor of the bun-supported
`datastore-fs`
- This caused a regression

**Description**
- use `datastore-level` by default, only use `datastore-fs` in bun

---------

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

🎉 This PR is included in v1.35.0 🎉

AbolareRoheemah pushed a commit to AbolareRoheemah/lodestar that referenced this pull request Oct 14, 2025
**Motivation**

- Review of ChainSafe#8468 metrics
- In ChainSafe#8449, use of
`datastore-level` was unilaterally removed in favor of the bun-supported
`datastore-fs`
- This caused a regression

**Description**
- use `datastore-level` by default, only use `datastore-fs` in bun

---------

Co-authored-by: Nico Flaig <nflaig@protonmail.com>
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.

4 participants