twoeths afdf325ebf feat: fromHexInto() api (#8275)
**Motivation**

- improve the time to deserialize hex, especially for getBlobsV2() where
each blob is 131kb
- if the benchmark is correct, we can expect the time to deserialize
blob hex from `332.6842 ms/op` to more or less 2ms
- will apply it for getBlobsV2() in the next PR by preallocate some
memory and reuse it for all slots

**Description**

- implement `fromHexInto()` using `String.charCodeAt()` for browser and
use that for NodeJs as well
- the Buffer/NodeJS implementation is too bad that I only maintain it in
the benchmark

**Test result on a regular lodestar node**
- `browser fromHexInto(blob)` is 1000x faster than `browser
fromHex(blob)` and >100x faster than `nodejs fromHexInto(blob) `

```
packages/utils/test/perf/bytes.test.ts
  bytes utils
    ✔ nodejs block root to RootHex using toHex                             2817687 ops/s    354.9010 ns/op        -       1324 runs  0.897 s
    ✔ nodejs block root to RootHex using toRootHex                         4369044 ops/s    228.8830 ns/op        -       1793 runs  0.902 s
    ✔ nodejs fromhex(blob)                                                3.005854 ops/s    332.6842 ms/op        -         10 runs   4.18 s
    ✔ nodejs fromHexInto(blob)                                            3.617654 ops/s    276.4222 ms/op        -         10 runs   3.36 s
    ✔ browser block root to RootHex using the deprecated toHexString       1656696 ops/s    603.6110 ns/op        -        963 runs   1.34 s
    ✔ browser block root to RootHex using toHex                            2060611 ops/s    485.2930 ns/op        -        424 runs  0.812 s
    ✔ browser block root to RootHex using toRootHex                        2320476 ops/s    430.9460 ns/op        -        889 runs  0.841 s
    ✔ browser fromHexInto(blob)                                           503.7166 ops/s    1.985243 ms/op        -         10 runs   21.9 s
    ✔ browser fromHex(blob)                                              0.5095370 ops/s    1.962566  s/op        -         10 runs   21.7 s
```

---------

Co-authored-by: Tuyen Nguyen <twoeths@users.noreply.github.com>
2025-08-27 09:20:15 -04:00
2022-01-31 11:49:02 -06:00
2020-03-30 20:24:46 -04:00
2025-08-27 09:20:15 -04:00
2024-11-17 12:13:51 +07:00
2021-03-07 12:50:58 +01:00
2024-02-08 16:59:25 +01:00
2025-03-11 12:43:21 -07:00

Lodestar Ethereum Consensus Implementation

GitHub release (latest by date) Docker Image Version (latest by date) Eth Consensus Spec v1.5.0 ES Version Node Version codecov gitpoap badge

Lodestar is a TypeScript implementation of the Ethereum Consensus specification developed by ChainSafe Systems.

Getting started

Prerequisites

Developer Quickstart:
yarn install
yarn build
./lodestar --help

Architecture Overview

  • 📦 This mono-repository contains a suite of Ethereum Consensus packages.
  • ⚖️ The mono-repository is released under Apache-2.0 license. Note, that the packages contain their own licenses.
Package Version License Docs Description
@chainsafe/lodestar npm License documentation 💻 Command-line tool for Lodestar
@lodestar/api npm License documentation 📋 REST Client for the Ethereum Beacon API
@lodestar/beacon-node npm License documentation 🚨 Beacon-chain client
@lodestar/config npm License documentation 🗒️ Eth Consensus types and params bundled together
@lodestar/db npm License documentation 💾 Read/write persistent Eth Consensus data
@lodestar/flare npm License documentation 💥 Command tool for triggering non-standard actions
@lodestar/fork-choice npm License documentation 🍴 Beacon-chain fork choice
@lodestar/light-client npm License documentation 🐦 Ethereum Light client
@lodestar/logger npm License documentation 📝 NodeJS logger for Lodestar binaries
@lodestar/params npm License documentation 🕸️ Eth Consensus network parameters
@lodestar/prover npm License documentation Ethereum Light client verifier for execution JSON-RPC calls
@lodestar/reqresp npm License documentation 📞 Eth Consensus Req/Resp protocol
@lodestar/spec-test-util npm License documentation 🧪 Test harness for Eth Consensus spec tests
@lodestar/state-transition npm License documentation 🔎 Eth Consensus beacon-state transition
@lodestar/types npm License documentation 🗒️ Eth Consensus TypeScript and SSZ types
@lodestar/utils npm License documentation 🧰 Miscellaneous utility functions used across Lodestar
@lodestar/validator npm License documentation 🏦 Validator client

Contributors

Read our contributors document, submit an issue or talk to us on our Discord!

Meetings

Weekly contributor meetings are posted under Discussions and topics are welcomed by any participant in the relevant meeting thread. Feel free to check out our meeting notes and documents on HackMD. Post-September 2021, meeting notes can be found on the Lodestar Wiki Page.

Donations

We are a local group of Toronto open-source developers. As such, all of our open-source work is funded by grants. We all take the time out of our hectic lives to contribute to the Ethereum ecosystem. If you want to donate, you can find the ETH address under "Sponsor this project" on this repository.

Description
No description provided
Readme 507 MiB
Languages
TypeScript 98.9%
JavaScript 0.6%
Shell 0.4%