**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>
Lodestar Ethereum Consensus Implementation
Lodestar is a TypeScript implementation of the Ethereum Consensus specification developed by ChainSafe Systems.
Getting started
- ⚙️ Follow the instructions for build from source, binaries, or Docker to install Lodestar. Or use our Lodestar Quickstart scripts.
- 📚 Use Lodestar libraries in your next Ethereum Typescript project.
- 🌐 Run a beacon node on mainnet or a public testnet.
- 💻 Utilize the whole stack by starting a local testnet.
- 🗒️ View the Lodestar CLI commands and options.
- 🤓 View the Package and dependency structure.
- 📝 Prospective contributors can read the contributing section to understand how we develop and test on Lodestar.
- ✍️ If you have questions submit an issue or join us on Discord!
- 🚨 Please note our security policy.
- 🐦 Follow Lodestar on Twitter for announcements and updates!
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 |
💻 Command-line tool for Lodestar | |||
@lodestar/api |
📋 REST Client for the Ethereum Beacon API | |||
@lodestar/beacon-node |
🚨 Beacon-chain client | |||
@lodestar/config |
🗒️ Eth Consensus types and params bundled together | |||
@lodestar/db |
💾 Read/write persistent Eth Consensus data | |||
@lodestar/flare |
💥 Command tool for triggering non-standard actions | |||
@lodestar/fork-choice |
🍴 Beacon-chain fork choice | |||
@lodestar/light-client |
🐦 Ethereum Light client | |||
@lodestar/logger |
📝 NodeJS logger for Lodestar binaries | |||
@lodestar/params |
🕸️ Eth Consensus network parameters | |||
@lodestar/prover |
✅ Ethereum Light client verifier for execution JSON-RPC calls | |||
@lodestar/reqresp |
📞 Eth Consensus Req/Resp protocol | |||
@lodestar/spec-test-util |
🧪 Test harness for Eth Consensus spec tests | |||
@lodestar/state-transition |
🔎 Eth Consensus beacon-state transition | |||
@lodestar/types |
🗒️ Eth Consensus TypeScript and SSZ types | |||
@lodestar/utils |
🧰 Miscellaneous utility functions used across Lodestar | |||
@lodestar/validator |
🏦 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.