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

Conversation

@nazarhussain
Copy link
Contributor

Motivation

Make sure the Lodestar starts running in Bun runtime.

Description

  • Add subpath imports supported in Bun and NodeJS.

Steps to test or reproduce

Run all tests

Note

The CLI finally starts to run, next go with command by command to see what's breaking, starting the beacon cmd.

bun run --bun bin/lodestar.js --help 
🌟 Lodestar: TypeScript Implementation of the Ethereum Consensus Beacon Chain.

 * Version: v1.33.0/nh/bun-wrappers/07d2010
  * by ChainSafe Systems, 2018-2025

Commands:
  beacon       Run a beacon chain node
  validator    Run one or multiple validator clients
  lightclient  Run lightclient
  dev          Quickly bootstrap a beacon node and multiple validators. Use for
               development and testing
  bootnode     Run a discv5 bootnode. This will NOT perform any beacon node func
               tions, rather, it will run a discv5 service that allows nodes on
               the network to discover one another.

Options:
      --dataDir                             Lodestar root data directory[string]
      --network                             Name of the Ethereum Consensus chain
                                             network to join
  [string] [choices: "mainnet", "gnosis", "sepolia", "holesky", "hoodi", "chiado
                                        ", "ephemery", "dev"] [default: mainnet]
      --paramsFile                          Network configuration file  [string]
      --rcConfig                            RC file to supplement command line a
                                            rgs, accepted formats: .yml, .yaml,
                                            .json                       [string]
      --supernode                           Subscribe to and custody all data co
                                            lumn sidecar subnets       [boolean]
      --terminal-total-difficulty-override  Terminal PoW block TTD override
                                                                        [string]
      --terminal-block-hash-override        Terminal PoW block hash override
                                                                        [string]
      --terminal-block-hash-epoch-override  Terminal PoW block hash override act
                                            ivation epoch               [string]
  -h, --help                                Show help                  [boolean]
  -v, --version                             Show version number        [boolean]

📖 For more information, check the CLI reference:
  * https://chainsafe.github.io/lodestar/reference/cli

✍️ Give feedback and report issues on GitHub:
  * https://github.com/ChainSafe/lodestar

@nazarhussain nazarhussain requested a review from a team as a code owner September 4, 2025 14:13
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.

Summary of Changes

Hello @nazarhussain, 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 focuses on enhancing the Lodestar project's compatibility with the Bun JavaScript runtime. It involves significant updates to module resolution, dependency handling, and TypeScript configurations to ensure the application can successfully initialize and run in a Bun environment. The changes are foundational for broader multi-runtime support, allowing the project to leverage the performance and features of different JavaScript runtimes.

Highlights

  • Bun Runtime Compatibility: The primary goal of this pull request is to enable Lodestar to run correctly within the Bun JavaScript runtime environment, addressing compatibility issues.
  • Subpath Imports for Runtime Specificity: Introduced a new imports field in package.json to allow for runtime-specific package resolutions, specifically for prometheus-gc-stats, enabling a Bun-specific wrapper.
  • TypeScript Configuration Updates: Modified tsconfig.json and tsconfig.build.json files to set module and moduleResolution to node16, which is crucial for modern module resolution in Node.js and Bun environments.
  • Dependency Import Path Adjustments: Updated import paths for several internal and external dependencies, including @chainsafe/libp2p-gossipsub and @chainsafe/discv5, to ensure correct module resolution.
  • Type Assertions and Explicit Typing: Added explicit type assertions (as any) and type annotations in various files to resolve TypeScript compilation issues, particularly related to moduleResolution: node16 and third-party library types.
  • New Bun-Specific GC Stats Wrapper: A new file packages/beacon-node/src/bun-wrappers/prometheus-gc-stats.ts was added, providing a no-op gcStats function specifically for the Bun runtime, to avoid issues with the Node.js-specific prometheus-gc-stats.
  • Custom Type Declarations for Threads: A new type declaration file types/@chainsafe/threads/index.d.ts was added to provide correct type definitions for the @chainsafe/threads library, improving type checking and compatibility.
  • New Type Export: The ExecutionAddressType has been exported from packages/types/src/index.ts, making it available for broader use within the project.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

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 support for the Bun runtime by leveraging conditional imports in package.json. This allows for runtime-specific dependencies, demonstrated by providing a mock for prometheus-gc-stats which is not compatible with Bun. A significant part of this change involves updating the TypeScript configuration to use module: "node16" and moduleResolution: "node16", which is a good step towards modernizing the codebase for native ES modules. The subsequent changes across various files are mostly necessary adjustments to satisfy the stricter type checking that comes with this new configuration. My review found one area in the thread pool implementation where a type cast seems incorrect and could hide potential issues.

Comment on lines 35 to 37
"./fulu": {
"import": "./lib/fulu/index.js"
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Module resolution node16 does not check for directories if subpath exports are available.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2025

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 15e6ade Previous: 200e244 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.0633 ms/op 1.0837 ms/op 0.98
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 37.373 us/op 40.416 us/op 0.92
BLS verify - blst 779.39 us/op 1.0065 ms/op 0.77
BLS verifyMultipleSignatures 3 - blst 1.4371 ms/op 1.6630 ms/op 0.86
BLS verifyMultipleSignatures 8 - blst 1.7034 ms/op 2.4232 ms/op 0.70
BLS verifyMultipleSignatures 32 - blst 5.0563 ms/op 6.4837 ms/op 0.78
BLS verifyMultipleSignatures 64 - blst 9.6208 ms/op 11.248 ms/op 0.86
BLS verifyMultipleSignatures 128 - blst 17.677 ms/op 18.357 ms/op 0.96
BLS deserializing 10000 signatures 703.76 ms/op 717.31 ms/op 0.98
BLS deserializing 100000 signatures 7.1131 s/op 7.0175 s/op 1.01
BLS verifyMultipleSignatures - same message - 3 - blst 977.42 us/op 868.36 us/op 1.13
BLS verifyMultipleSignatures - same message - 8 - blst 1.1080 ms/op 1.3316 ms/op 0.83
BLS verifyMultipleSignatures - same message - 32 - blst 1.7843 ms/op 1.8510 ms/op 0.96
BLS verifyMultipleSignatures - same message - 64 - blst 2.7114 ms/op 2.5508 ms/op 1.06
BLS verifyMultipleSignatures - same message - 128 - blst 4.4548 ms/op 4.2884 ms/op 1.04
BLS aggregatePubkeys 32 - blst 19.880 us/op 19.440 us/op 1.02
BLS aggregatePubkeys 128 - blst 71.599 us/op 69.611 us/op 1.03
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 52.182 ms/op 58.935 ms/op 0.89
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 48.884 ms/op 63.064 ms/op 0.78
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 41.304 ms/op 48.686 ms/op 0.85
getSlashingsAndExits - default max 76.322 us/op 88.626 us/op 0.86
getSlashingsAndExits - 2k 331.97 us/op 360.28 us/op 0.92
isKnown best case - 1 super set check 249.00 ns/op 217.00 ns/op 1.15
isKnown normal case - 2 super set checks 246.00 ns/op 213.00 ns/op 1.15
isKnown worse case - 16 super set checks 244.00 ns/op 225.00 ns/op 1.08
InMemoryCheckpointStateCache - add get delete 2.4100 us/op 2.5520 us/op 0.94
validate api signedAggregateAndProof - struct 1.4703 ms/op 1.5745 ms/op 0.93
validate gossip signedAggregateAndProof - struct 1.4588 ms/op 1.4939 ms/op 0.98
batch validate gossip attestation - vc 640000 - chunk 32 118.88 us/op 137.87 us/op 0.86
batch validate gossip attestation - vc 640000 - chunk 64 105.93 us/op 115.99 us/op 0.91
batch validate gossip attestation - vc 640000 - chunk 128 97.972 us/op 115.44 us/op 0.85
batch validate gossip attestation - vc 640000 - chunk 256 101.72 us/op 117.63 us/op 0.86
pickEth1Vote - no votes 966.45 us/op 1.0442 ms/op 0.93
pickEth1Vote - max votes 6.0787 ms/op 11.028 ms/op 0.55
pickEth1Vote - Eth1Data hashTreeRoot value x2048 11.529 ms/op 14.351 ms/op 0.80
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 16.635 ms/op 21.785 ms/op 0.76
pickEth1Vote - Eth1Data fastSerialize value x2048 443.16 us/op 492.55 us/op 0.90
pickEth1Vote - Eth1Data fastSerialize tree x2048 2.1426 ms/op 4.2384 ms/op 0.51
bytes32 toHexString 379.00 ns/op 399.00 ns/op 0.95
bytes32 Buffer.toString(hex) 250.00 ns/op 273.00 ns/op 0.92
bytes32 Buffer.toString(hex) from Uint8Array 339.00 ns/op 441.00 ns/op 0.77
bytes32 Buffer.toString(hex) + 0x 252.00 ns/op 280.00 ns/op 0.90
Object access 1 prop 0.12800 ns/op 0.15900 ns/op 0.81
Map access 1 prop 0.13300 ns/op 0.13400 ns/op 0.99
Object get x1000 6.0020 ns/op 6.0900 ns/op 0.99
Map get x1000 6.4030 ns/op 6.5530 ns/op 0.98
Object set x1000 30.004 ns/op 35.693 ns/op 0.84
Map set x1000 20.682 ns/op 25.289 ns/op 0.82
Return object 10000 times 0.29230 ns/op 0.32520 ns/op 0.90
Throw Error 10000 times 4.5392 us/op 4.7855 us/op 0.95
toHex 131.69 ns/op 154.75 ns/op 0.85
Buffer.from 116.58 ns/op 151.06 ns/op 0.77
shared Buffer 85.416 ns/op 99.077 ns/op 0.86
fastMsgIdFn sha256 / 200 bytes 2.2000 us/op 2.2850 us/op 0.96
fastMsgIdFn h32 xxhash / 200 bytes 209.00 ns/op 243.00 ns/op 0.86
fastMsgIdFn h64 xxhash / 200 bytes 270.00 ns/op 384.00 ns/op 0.70
fastMsgIdFn sha256 / 1000 bytes 7.4710 us/op 8.1230 us/op 0.92
fastMsgIdFn h32 xxhash / 1000 bytes 345.00 ns/op 418.00 ns/op 0.83
fastMsgIdFn h64 xxhash / 1000 bytes 344.00 ns/op 383.00 ns/op 0.90
fastMsgIdFn sha256 / 10000 bytes 66.191 us/op 68.299 us/op 0.97
fastMsgIdFn h32 xxhash / 10000 bytes 1.8550 us/op 2.1320 us/op 0.87
fastMsgIdFn h64 xxhash / 10000 bytes 1.2290 us/op 1.4070 us/op 0.87
send data - 1000 256B messages 18.466 ms/op 22.152 ms/op 0.83
send data - 1000 512B messages 22.171 ms/op 26.662 ms/op 0.83
send data - 1000 1024B messages 30.015 ms/op 38.909 ms/op 0.77
send data - 1000 1200B messages 26.513 ms/op 33.892 ms/op 0.78
send data - 1000 2048B messages 30.512 ms/op 32.688 ms/op 0.93
send data - 1000 4096B messages 30.518 ms/op 38.599 ms/op 0.79
send data - 1000 16384B messages 51.299 ms/op 55.200 ms/op 0.93
send data - 1000 65536B messages 123.87 ms/op 159.50 ms/op 0.78
enrSubnets - fastDeserialize 64 bits 920.00 ns/op 1.0400 us/op 0.88
enrSubnets - ssz BitVector 64 bits 330.00 ns/op 360.00 ns/op 0.92
enrSubnets - fastDeserialize 4 bits 133.00 ns/op 167.00 ns/op 0.80
enrSubnets - ssz BitVector 4 bits 346.00 ns/op 479.00 ns/op 0.72
prioritizePeers score -10:0 att 32-0.1 sync 2-0 243.33 us/op 261.53 us/op 0.93
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 265.53 us/op 458.73 us/op 0.58
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 396.57 us/op 478.40 us/op 0.83
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 753.52 us/op 917.30 us/op 0.82
prioritizePeers score 0:0 att 64-1 sync 4-1 888.86 us/op 961.94 us/op 0.92
array of 16000 items push then shift 1.6568 us/op 1.7157 us/op 0.97
LinkedList of 16000 items push then shift 8.1800 ns/op 9.7190 ns/op 0.84
array of 16000 items push then pop 83.015 ns/op 91.918 ns/op 0.90
LinkedList of 16000 items push then pop 7.9180 ns/op 9.3580 ns/op 0.85
array of 24000 items push then shift 2.4478 us/op 2.5592 us/op 0.96
LinkedList of 24000 items push then shift 8.3090 ns/op 10.700 ns/op 0.78
array of 24000 items push then pop 115.85 ns/op 139.32 ns/op 0.83
LinkedList of 24000 items push then pop 7.6940 ns/op 10.185 ns/op 0.76
intersect bitArray bitLen 8 6.5360 ns/op 6.7310 ns/op 0.97
intersect array and set length 8 39.865 ns/op 47.326 ns/op 0.84
intersect bitArray bitLen 128 30.547 ns/op 31.673 ns/op 0.96
intersect array and set length 128 643.89 ns/op 700.40 ns/op 0.92
bitArray.getTrueBitIndexes() bitLen 128 1.0550 us/op 1.1360 us/op 0.93
bitArray.getTrueBitIndexes() bitLen 248 1.8580 us/op 2.1490 us/op 0.86
bitArray.getTrueBitIndexes() bitLen 512 3.8710 us/op 4.9940 us/op 0.78
Buffer.concat 32 items 629.00 ns/op 802.00 ns/op 0.78
Uint8Array.set 32 items 933.00 ns/op 1.5210 us/op 0.61
Buffer.copy 2.0320 us/op 2.7790 us/op 0.73
Uint8Array.set - with subarray 1.5670 us/op 3.0630 us/op 0.51
Uint8Array.set - without subarray 1.0470 us/op 1.4650 us/op 0.71
getUint32 - dataview 210.00 ns/op 227.00 ns/op 0.93
getUint32 - manual 127.00 ns/op 142.00 ns/op 0.89
Set add up to 64 items then delete first 2.0927 us/op 3.6057 us/op 0.58
OrderedSet add up to 64 items then delete first 4.6757 us/op 7.5069 us/op 0.62
Set add up to 64 items then delete last 2.3714 us/op 4.4666 us/op 0.53
OrderedSet add up to 64 items then delete last 4.9455 us/op 7.0913 us/op 0.70
Set add up to 64 items then delete middle 3.4015 us/op 3.6992 us/op 0.92
OrderedSet add up to 64 items then delete middle 7.8079 us/op 9.4395 us/op 0.83
Set add up to 128 items then delete first 6.6572 us/op 8.2365 us/op 0.81
OrderedSet add up to 128 items then delete first 10.381 us/op 11.752 us/op 0.88
Set add up to 128 items then delete last 6.5206 us/op 11.046 us/op 0.59
OrderedSet add up to 128 items then delete last 10.511 us/op 13.888 us/op 0.76
Set add up to 128 items then delete middle 6.6271 us/op 8.7816 us/op 0.75
OrderedSet add up to 128 items then delete middle 18.489 us/op 21.606 us/op 0.86
Set add up to 256 items then delete first 14.046 us/op 16.171 us/op 0.87
OrderedSet add up to 256 items then delete first 21.705 us/op 25.587 us/op 0.85
Set add up to 256 items then delete last 14.232 us/op 16.267 us/op 0.87
OrderedSet add up to 256 items then delete last 22.683 us/op 30.641 us/op 0.74
Set add up to 256 items then delete middle 14.582 us/op 17.851 us/op 0.82
OrderedSet add up to 256 items then delete middle 51.363 us/op 59.367 us/op 0.87
transfer serialized Status (84 B) 2.2460 us/op 2.4280 us/op 0.93
copy serialized Status (84 B) 1.1760 us/op 1.3070 us/op 0.90
transfer serialized SignedVoluntaryExit (112 B) 2.2800 us/op 2.5490 us/op 0.89
copy serialized SignedVoluntaryExit (112 B) 1.1740 us/op 1.3390 us/op 0.88
transfer serialized ProposerSlashing (416 B) 2.3100 us/op 2.6280 us/op 0.88
copy serialized ProposerSlashing (416 B) 1.2550 us/op 2.1530 us/op 0.58
transfer serialized Attestation (485 B) 2.3310 us/op 2.9660 us/op 0.79
copy serialized Attestation (485 B) 1.4680 us/op 2.0390 us/op 0.72
transfer serialized AttesterSlashing (33232 B) 2.3570 us/op 2.6170 us/op 0.90
copy serialized AttesterSlashing (33232 B) 4.1910 us/op 5.9920 us/op 0.70
transfer serialized Small SignedBeaconBlock (128000 B) 2.8120 us/op 3.1460 us/op 0.89
copy serialized Small SignedBeaconBlock (128000 B) 11.772 us/op 17.357 us/op 0.68
transfer serialized Avg SignedBeaconBlock (200000 B) 3.2550 us/op 3.8920 us/op 0.84
copy serialized Avg SignedBeaconBlock (200000 B) 16.278 us/op 39.726 us/op 0.41
transfer serialized BlobsSidecar (524380 B) 3.6160 us/op 4.6620 us/op 0.78
copy serialized BlobsSidecar (524380 B) 100.35 us/op 138.51 us/op 0.72
transfer serialized Big SignedBeaconBlock (1000000 B) 3.8300 us/op 5.0610 us/op 0.76
copy serialized Big SignedBeaconBlock (1000000 B) 123.44 us/op 169.10 us/op 0.73
pass gossip attestations to forkchoice per slot 2.9482 ms/op 3.7258 ms/op 0.79
forkChoice updateHead vc 100000 bc 64 eq 0 479.68 us/op 653.60 us/op 0.73
forkChoice updateHead vc 600000 bc 64 eq 0 3.0498 ms/op 6.9387 ms/op 0.44
forkChoice updateHead vc 1000000 bc 64 eq 0 5.3687 ms/op 13.355 ms/op 0.40
forkChoice updateHead vc 600000 bc 320 eq 0 3.0166 ms/op 4.3070 ms/op 0.70
forkChoice updateHead vc 600000 bc 1200 eq 0 3.1323 ms/op 6.1338 ms/op 0.51
forkChoice updateHead vc 600000 bc 7200 eq 0 3.4345 ms/op 5.3167 ms/op 0.65
forkChoice updateHead vc 600000 bc 64 eq 1000 10.685 ms/op 12.207 ms/op 0.88
forkChoice updateHead vc 600000 bc 64 eq 10000 10.599 ms/op 12.210 ms/op 0.87
forkChoice updateHead vc 600000 bc 64 eq 300000 14.880 ms/op 27.784 ms/op 0.54
computeDeltas 500000 validators 300 proto nodes 4.1338 ms/op 4.5948 ms/op 0.90
computeDeltas 500000 validators 1200 proto nodes 4.2626 ms/op 4.6966 ms/op 0.91
computeDeltas 500000 validators 7200 proto nodes 4.5510 ms/op 4.6905 ms/op 0.97
computeDeltas 750000 validators 300 proto nodes 6.5414 ms/op 6.4159 ms/op 1.02
computeDeltas 750000 validators 1200 proto nodes 6.4344 ms/op 6.0438 ms/op 1.06
computeDeltas 750000 validators 7200 proto nodes 6.1284 ms/op 5.9954 ms/op 1.02
computeDeltas 1400000 validators 300 proto nodes 11.467 ms/op 11.234 ms/op 1.02
computeDeltas 1400000 validators 1200 proto nodes 11.156 ms/op 11.179 ms/op 1.00
computeDeltas 1400000 validators 7200 proto nodes 11.226 ms/op 11.175 ms/op 1.00
computeDeltas 2100000 validators 300 proto nodes 17.124 ms/op 17.114 ms/op 1.00
computeDeltas 2100000 validators 1200 proto nodes 16.623 ms/op 17.279 ms/op 0.96
computeDeltas 2100000 validators 7200 proto nodes 16.648 ms/op 17.298 ms/op 0.96
altair processAttestation - 250000 vs - 7PWei normalcase 2.6545 ms/op 2.3635 ms/op 1.12
altair processAttestation - 250000 vs - 7PWei worstcase 3.3726 ms/op 3.2176 ms/op 1.05
altair processAttestation - setStatus - 1/6 committees join 138.76 us/op 127.08 us/op 1.09
altair processAttestation - setStatus - 1/3 committees join 250.80 us/op 261.52 us/op 0.96
altair processAttestation - setStatus - 1/2 committees join 347.96 us/op 355.50 us/op 0.98
altair processAttestation - setStatus - 2/3 committees join 443.60 us/op 515.29 us/op 0.86
altair processAttestation - setStatus - 4/5 committees join 610.69 us/op 625.64 us/op 0.98
altair processAttestation - setStatus - 100% committees join 747.73 us/op 739.91 us/op 1.01
altair processBlock - 250000 vs - 7PWei normalcase 4.4676 ms/op 5.1543 ms/op 0.87
altair processBlock - 250000 vs - 7PWei normalcase hashState 34.612 ms/op 35.213 ms/op 0.98
altair processBlock - 250000 vs - 7PWei worstcase 34.438 ms/op 44.412 ms/op 0.78
altair processBlock - 250000 vs - 7PWei worstcase hashState 70.881 ms/op 88.785 ms/op 0.80
phase0 processBlock - 250000 vs - 7PWei normalcase 1.6430 ms/op 2.3575 ms/op 0.70
phase0 processBlock - 250000 vs - 7PWei worstcase 22.394 ms/op 28.729 ms/op 0.78
altair processEth1Data - 250000 vs - 7PWei normalcase 394.66 us/op 410.32 us/op 0.96
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 5.9400 us/op 8.9310 us/op 0.67
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 34.976 us/op 55.635 us/op 0.63
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 10.041 us/op 11.941 us/op 0.84
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 6.8540 us/op 8.7230 us/op 0.79
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 164.37 us/op 225.34 us/op 0.73
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.8707 ms/op 2.2904 ms/op 0.82
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 2.3437 ms/op 2.5014 ms/op 0.94
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 2.3330 ms/op 2.4588 ms/op 0.95
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 4.6011 ms/op 4.8735 ms/op 0.94
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.4083 ms/op 2.4647 ms/op 0.98
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 4.6065 ms/op 4.7500 ms/op 0.97
Tree 40 250000 create 429.33 ms/op 587.63 ms/op 0.73
Tree 40 250000 get(125000) 143.34 ns/op 149.48 ns/op 0.96
Tree 40 250000 set(125000) 1.4598 us/op 1.6123 us/op 0.91
Tree 40 250000 toArray() 19.925 ms/op 19.618 ms/op 1.02
Tree 40 250000 iterate all - toArray() + loop 19.179 ms/op 23.611 ms/op 0.81
Tree 40 250000 iterate all - get(i) 53.676 ms/op 63.092 ms/op 0.85
Array 250000 create 3.0662 ms/op 2.8787 ms/op 1.07
Array 250000 clone - spread 798.80 us/op 1.7696 ms/op 0.45
Array 250000 get(125000) 0.39000 ns/op 0.45000 ns/op 0.87
Array 250000 set(125000) 0.41500 ns/op 0.45800 ns/op 0.91
Array 250000 iterate all - loop 80.043 us/op 102.38 us/op 0.78
phase0 afterProcessEpoch - 250000 vs - 7PWei 41.020 ms/op 44.319 ms/op 0.93
Array.fill - length 1000000 3.3733 ms/op 4.7991 ms/op 0.70
Array push - length 1000000 13.187 ms/op 20.269 ms/op 0.65
Array.get 0.28285 ns/op 0.29139 ns/op 0.97
Uint8Array.get 0.44059 ns/op 0.46581 ns/op 0.95
phase0 beforeProcessEpoch - 250000 vs - 7PWei 16.989 ms/op 19.862 ms/op 0.86
altair processEpoch - mainnet_e81889 262.04 ms/op 253.68 ms/op 1.03
mainnet_e81889 - altair beforeProcessEpoch 19.636 ms/op 19.385 ms/op 1.01
mainnet_e81889 - altair processJustificationAndFinalization 5.7130 us/op 5.8000 us/op 0.98
mainnet_e81889 - altair processInactivityUpdates 4.8607 ms/op 4.5595 ms/op 1.07
mainnet_e81889 - altair processRewardsAndPenalties 38.974 ms/op 44.768 ms/op 0.87
mainnet_e81889 - altair processRegistryUpdates 712.00 ns/op 747.00 ns/op 0.95
mainnet_e81889 - altair processSlashings 187.00 ns/op 190.00 ns/op 0.98
mainnet_e81889 - altair processEth1DataReset 177.00 ns/op 187.00 ns/op 0.95
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2158 ms/op 1.1871 ms/op 1.02
mainnet_e81889 - altair processSlashingsReset 879.00 ns/op 969.00 ns/op 0.91
mainnet_e81889 - altair processRandaoMixesReset 1.1480 us/op 1.2220 us/op 0.94
mainnet_e81889 - altair processHistoricalRootsUpdate 178.00 ns/op 194.00 ns/op 0.92
mainnet_e81889 - altair processParticipationFlagUpdates 520.00 ns/op 554.00 ns/op 0.94
mainnet_e81889 - altair processSyncCommitteeUpdates 141.00 ns/op 138.00 ns/op 1.02
mainnet_e81889 - altair afterProcessEpoch 44.833 ms/op 44.517 ms/op 1.01
capella processEpoch - mainnet_e217614 924.71 ms/op 968.85 ms/op 0.95
mainnet_e217614 - capella beforeProcessEpoch 61.285 ms/op 59.819 ms/op 1.02
mainnet_e217614 - capella processJustificationAndFinalization 5.2420 us/op 5.8120 us/op 0.90
mainnet_e217614 - capella processInactivityUpdates 14.335 ms/op 17.938 ms/op 0.80
mainnet_e217614 - capella processRewardsAndPenalties 189.02 ms/op 204.58 ms/op 0.92
mainnet_e217614 - capella processRegistryUpdates 6.4550 us/op 9.0720 us/op 0.71
mainnet_e217614 - capella processSlashings 175.00 ns/op 230.00 ns/op 0.76
mainnet_e217614 - capella processEth1DataReset 173.00 ns/op 199.00 ns/op 0.87
mainnet_e217614 - capella processEffectiveBalanceUpdates 4.2428 ms/op 4.3094 ms/op 0.98
mainnet_e217614 - capella processSlashingsReset 889.00 ns/op 1.0470 us/op 0.85
mainnet_e217614 - capella processRandaoMixesReset 1.1790 us/op 1.4600 us/op 0.81
mainnet_e217614 - capella processHistoricalRootsUpdate 179.00 ns/op 191.00 ns/op 0.94
mainnet_e217614 - capella processParticipationFlagUpdates 524.00 ns/op 576.00 ns/op 0.91
mainnet_e217614 - capella afterProcessEpoch 116.71 ms/op 117.57 ms/op 0.99
phase0 processEpoch - mainnet_e58758 301.23 ms/op 303.67 ms/op 0.99
mainnet_e58758 - phase0 beforeProcessEpoch 77.959 ms/op 77.240 ms/op 1.01
mainnet_e58758 - phase0 processJustificationAndFinalization 5.6530 us/op 7.9560 us/op 0.71
mainnet_e58758 - phase0 processRewardsAndPenalties 36.106 ms/op 36.199 ms/op 1.00
mainnet_e58758 - phase0 processRegistryUpdates 3.2880 us/op 3.3260 us/op 0.99
mainnet_e58758 - phase0 processSlashings 183.00 ns/op 181.00 ns/op 1.01
mainnet_e58758 - phase0 processEth1DataReset 182.00 ns/op 201.00 ns/op 0.91
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.2550 ms/op 1.2019 ms/op 1.04
mainnet_e58758 - phase0 processSlashingsReset 1.0940 us/op 964.00 ns/op 1.13
mainnet_e58758 - phase0 processRandaoMixesReset 1.1860 us/op 1.1720 us/op 1.01
mainnet_e58758 - phase0 processHistoricalRootsUpdate 210.00 ns/op 177.00 ns/op 1.19
mainnet_e58758 - phase0 processParticipationRecordUpdates 894.00 ns/op 871.00 ns/op 1.03
mainnet_e58758 - phase0 afterProcessEpoch 37.973 ms/op 35.187 ms/op 1.08
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.3743 ms/op 1.3505 ms/op 1.02
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.1352 ms/op 1.7955 ms/op 1.19
altair processInactivityUpdates - 250000 normalcase 18.600 ms/op 22.789 ms/op 0.82
altair processInactivityUpdates - 250000 worstcase 18.425 ms/op 22.095 ms/op 0.83
phase0 processRegistryUpdates - 250000 normalcase 8.5500 us/op 9.5060 us/op 0.90
phase0 processRegistryUpdates - 250000 badcase_full_deposits 287.00 us/op 258.45 us/op 1.11
phase0 processRegistryUpdates - 250000 worstcase 0.5 113.27 ms/op 113.42 ms/op 1.00
altair processRewardsAndPenalties - 250000 normalcase 27.641 ms/op 32.893 ms/op 0.84
altair processRewardsAndPenalties - 250000 worstcase 26.060 ms/op 36.679 ms/op 0.71
phase0 getAttestationDeltas - 250000 normalcase 10.938 ms/op 7.1909 ms/op 1.52
phase0 getAttestationDeltas - 250000 worstcase 8.4123 ms/op 6.5620 ms/op 1.28
phase0 processSlashings - 250000 worstcase 123.69 us/op 128.85 us/op 0.96
altair processSyncCommitteeUpdates - 250000 13.254 ms/op 10.990 ms/op 1.21
BeaconState.hashTreeRoot - No change 243.00 ns/op 220.00 ns/op 1.10
BeaconState.hashTreeRoot - 1 full validator 86.299 us/op 97.120 us/op 0.89
BeaconState.hashTreeRoot - 32 full validator 1.0569 ms/op 863.08 us/op 1.22
BeaconState.hashTreeRoot - 512 full validator 12.012 ms/op 12.254 ms/op 0.98
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 114.94 us/op 109.65 us/op 1.05
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.6936 ms/op 1.9809 ms/op 0.85
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 28.489 ms/op 25.411 ms/op 1.12
BeaconState.hashTreeRoot - 1 balances 75.857 us/op 69.337 us/op 1.09
BeaconState.hashTreeRoot - 32 balances 675.18 us/op 817.31 us/op 0.83
BeaconState.hashTreeRoot - 512 balances 8.9007 ms/op 8.0402 ms/op 1.11
BeaconState.hashTreeRoot - 250000 balances 209.22 ms/op 187.13 ms/op 1.12
aggregationBits - 2048 els - zipIndexesInBitList 23.094 us/op 20.935 us/op 1.10
byteArrayEquals 32 55.979 ns/op 51.918 ns/op 1.08
Buffer.compare 32 18.377 ns/op 16.629 ns/op 1.11
byteArrayEquals 1024 1.6541 us/op 1.5352 us/op 1.08
Buffer.compare 1024 26.185 ns/op 23.763 ns/op 1.10
byteArrayEquals 16384 27.018 us/op 24.483 us/op 1.10
Buffer.compare 16384 216.93 ns/op 203.44 ns/op 1.07
byteArrayEquals 123687377 193.53 ms/op 186.86 ms/op 1.04
Buffer.compare 123687377 8.1669 ms/op 6.6764 ms/op 1.22
byteArrayEquals 32 - diff last byte 53.904 ns/op 51.676 ns/op 1.04
Buffer.compare 32 - diff last byte 17.650 ns/op 16.797 ns/op 1.05
byteArrayEquals 1024 - diff last byte 1.6299 us/op 1.5665 us/op 1.04
Buffer.compare 1024 - diff last byte 25.773 ns/op 25.228 ns/op 1.02
byteArrayEquals 16384 - diff last byte 25.952 us/op 24.657 us/op 1.05
Buffer.compare 16384 - diff last byte 202.66 ns/op 196.70 ns/op 1.03
byteArrayEquals 123687377 - diff last byte 195.96 ms/op 187.98 ms/op 1.04
Buffer.compare 123687377 - diff last byte 8.0901 ms/op 6.4337 ms/op 1.26
byteArrayEquals 32 - random bytes 5.2370 ns/op 5.2960 ns/op 0.99
Buffer.compare 32 - random bytes 17.701 ns/op 16.832 ns/op 1.05
byteArrayEquals 1024 - random bytes 5.1750 ns/op 5.2440 ns/op 0.99
Buffer.compare 1024 - random bytes 17.733 ns/op 16.740 ns/op 1.06
byteArrayEquals 16384 - random bytes 5.3090 ns/op 5.2580 ns/op 1.01
Buffer.compare 16384 - random bytes 17.714 ns/op 16.688 ns/op 1.06
byteArrayEquals 123687377 - random bytes 6.5700 ns/op 6.5300 ns/op 1.01
Buffer.compare 123687377 - random bytes 18.920 ns/op 18.660 ns/op 1.01
regular array get 100000 times 33.907 us/op 44.261 us/op 0.77
wrappedArray get 100000 times 33.575 us/op 33.142 us/op 1.01
arrayWithProxy get 100000 times 12.170 ms/op 12.855 ms/op 0.95
ssz.Root.equals 46.531 ns/op 47.300 ns/op 0.98
byteArrayEquals 45.937 ns/op 46.185 ns/op 0.99
Buffer.compare 10.811 ns/op 10.634 ns/op 1.02
processSlot - 1 slots 10.778 us/op 10.436 us/op 1.03
processSlot - 32 slots 2.6503 ms/op 2.4595 ms/op 1.08
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 3.3495 ms/op 2.9007 ms/op 1.15
getCommitteeAssignments - req 1 vs - 250000 vc 2.1608 ms/op 2.1015 ms/op 1.03
getCommitteeAssignments - req 100 vs - 250000 vc 4.1772 ms/op 4.0629 ms/op 1.03
getCommitteeAssignments - req 1000 vs - 250000 vc 4.4557 ms/op 4.3246 ms/op 1.03
findModifiedValidators - 10000 modified validators 738.98 ms/op 741.37 ms/op 1.00
findModifiedValidators - 1000 modified validators 764.64 ms/op 720.42 ms/op 1.06
findModifiedValidators - 100 modified validators 242.11 ms/op 187.48 ms/op 1.29
findModifiedValidators - 10 modified validators 165.52 ms/op 156.94 ms/op 1.05
findModifiedValidators - 1 modified validators 176.00 ms/op 163.71 ms/op 1.08
findModifiedValidators - no difference 191.94 ms/op 148.49 ms/op 1.29
compare ViewDUs 6.2847 s/op 6.6678 s/op 0.94
compare each validator Uint8Array 1.5002 s/op 1.7856 s/op 0.84
compare ViewDU to Uint8Array 1.2482 s/op 1.3654 s/op 0.91
migrate state 1000000 validators, 24 modified, 0 new 888.85 ms/op 1.0012 s/op 0.89
migrate state 1000000 validators, 1700 modified, 1000 new 1.1505 s/op 1.2394 s/op 0.93
migrate state 1000000 validators, 3400 modified, 2000 new 1.4153 s/op 1.4457 s/op 0.98
migrate state 1500000 validators, 24 modified, 0 new 962.66 ms/op 907.79 ms/op 1.06
migrate state 1500000 validators, 1700 modified, 1000 new 1.0278 s/op 1.2170 s/op 0.84
migrate state 1500000 validators, 3400 modified, 2000 new 1.3351 s/op 1.4344 s/op 0.93
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.3400 ns/op 4.5300 ns/op 0.96
state getBlockRootAtSlot - 250000 vs - 7PWei 694.39 ns/op 683.31 ns/op 1.02
naive computeProposerIndex 100000 validators 56.524 ms/op 82.372 ms/op 0.69
computeProposerIndex 100000 validators 1.5688 ms/op 1.9086 ms/op 0.82
naiveGetNextSyncCommitteeIndices 1000 validators 8.7404 s/op 11.128 s/op 0.79
getNextSyncCommitteeIndices 1000 validators 115.75 ms/op 148.60 ms/op 0.78
naiveGetNextSyncCommitteeIndices 10000 validators 7.5824 s/op 11.181 s/op 0.68
getNextSyncCommitteeIndices 10000 validators 114.08 ms/op 133.75 ms/op 0.85
naiveGetNextSyncCommitteeIndices 100000 validators 6.9937 s/op 8.4391 s/op 0.83
getNextSyncCommitteeIndices 100000 validators 114.61 ms/op 115.70 ms/op 0.99
naive computeShuffledIndex 100000 validators 24.514 s/op 27.020 s/op 0.91
cached computeShuffledIndex 100000 validators 547.44 ms/op 582.81 ms/op 0.94
naive computeShuffledIndex 2000000 validators 501.57 s/op 541.27 s/op 0.93
cached computeShuffledIndex 2000000 validators 36.041 s/op 42.588 s/op 0.85
computeProposers - vc 250000 632.00 us/op 622.41 us/op 1.02
computeEpochShuffling - vc 250000 42.288 ms/op 42.067 ms/op 1.01
getNextSyncCommittee - vc 250000 10.906 ms/op 10.327 ms/op 1.06
computeSigningRoot for AttestationData 18.657 us/op 29.733 us/op 0.63
hash AttestationData serialized data then Buffer.toString(base64) 1.5540 us/op 1.6733 us/op 0.93
toHexString serialized data 1.1415 us/op 1.3297 us/op 0.86
Buffer.toString(base64) 160.76 ns/op 182.96 ns/op 0.88
nodejs block root to RootHex using toHex 149.45 ns/op 168.80 ns/op 0.89
nodejs block root to RootHex using toRootHex 86.007 ns/op 92.665 ns/op 0.93
nodejs fromhex(blob) 109.34 ms/op 124.95 ms/op 0.88
nodejs fromHexInto(blob) 94.362 ms/op 105.16 ms/op 0.90
browser block root to RootHex using the deprecated toHexString 211.59 ns/op 223.62 ns/op 0.95
browser block root to RootHex using toHex 170.05 ns/op 183.63 ns/op 0.93
browser block root to RootHex using toRootHex 159.90 ns/op 162.27 ns/op 0.99
browser fromHexInto(blob) 818.84 us/op 977.07 us/op 0.84
browser fromHex(blob) 786.89 ms/op 930.29 ms/op 0.85

by benchmarkbot/action

@codecov
Copy link

codecov bot commented Sep 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.26%. Comparing base (5e2a800) to head (79262c9).
⚠️ Report is 8 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #8320      +/-   ##
============================================
- Coverage     52.27%   52.26%   -0.01%     
============================================
  Files           853      853              
  Lines         64742    64780      +38     
  Branches       4765     4766       +1     
============================================
+ Hits          33842    33858      +16     
- Misses        30830    30852      +22     
  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.

wemeetagain
wemeetagain previously approved these changes Sep 12, 2025
Copy link
Member

@wemeetagain wemeetagain 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 now :)

nazarhussain added a commit that referenced this pull request Sep 16, 2025
**Motivation**

Upgrade typescript to latest version. 

**Description**

- Upgrade typescript to latest version. 
- Need this version upgrade to be used in #8320 to allow `module:
node20>`

**Steps to test or reproduce**

Run all tests
wemeetagain added a commit that referenced this pull request Sep 18, 2025
**Motivation**

Use latest `module` and `moduleResolution` for TS.

**Description**

- To use [subpath
imports](https://nodejs.org/api/packages.html#subpath-imports) in the PR
#8320 we need to update the module solution strategy for TS.
- That requires to change the `module` for the TS as well. 
- Earlier tried to stay with `node18` or `node20`, but the `ts-node`
does not work with that.
- Maintaining different tsconfig for ts-node is more of hassle on wrong
run.
- So decided to stick with `nodenext` strategy for `moduleResolution` 

**Steps to test or reproduce**

Run all tests

---------

Co-authored-by: Cayman <caymannava@gmail.com>
} as ConstructorParameters<typeof Worker>[1]);
// Bun does not support resourceLimits
const workerOptions = (
"bun" in process.versions
Copy link
Member

Choose a reason for hiding this comment

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

Should we use globalThis.Bun check instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't safely use that because in some context we get

Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature

We have to define type signature fo globalThis. Let's do that in a separate PR and update all occurrences of "bun" in process.versions

Copy link
Member

Choose a reason for hiding this comment

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

then this specific diff can be removed (it doesn't have anything to do with the internal package import pattern)

Copy link
Contributor Author

@nazarhussain nazarhussain Sep 19, 2025

Choose a reason for hiding this comment

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

Ok removed from this PR.

@nazarhussain nazarhussain merged commit 7a3b3a9 into unstable Sep 19, 2025
17 of 20 checks passed
@nazarhussain nazarhussain deleted the nh/bun-wrappers branch September 19, 2025 14:10
@wemeetagain
Copy link
Member

this pattern doesn't work with bun 😂

@wemeetagain
Copy link
Member

Nevermind, this pattern does work with bun! The problem I'd seen had to do with the referenced import file not being found (not being built)

wemeetagain added a commit that referenced this pull request Sep 25, 2025
**Motivation**

- #7280 

**Description**

- update `@types/node` to the latest node v22 version
- add `@lodestar/bun` dependency using git+https (for now! so that we
don't have to republish a bazillion times)
- keep in mind that this requires a manual build/rebuild of the so (via
`cd node_modules/@lodestar/bun && zig build`)
- Add a bun-specific `LevelDbController` which uses
[`@lodestar/bun`](https://github.com/ChainSafe/lodestar-bun)
- Only expose the leveldb controller via a subpath export (and for
tests, as a custom import, like in #8320 )
- add bun bun global override types
@wemeetagain
Copy link
Member

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