**Motivation** - while investigating #8519 I found a performance issue with `computeDeltas()` where we check for `Set.has()` for every item in the big validator index loop **Description** - sort the `equivocatingIndices` set then track equivocatingValidatorIndex to avoid `Set.has()` there - fix perf test to include some equivocating indices **Benchmark on my local environment** - NodeJS: it's 1.53x faster before ``` computeDeltas ✔ computeDeltas 1400000 validators 300 proto nodes 73.65370 ops/s 13.57705 ms/op - 931 runs 30.1 s ✔ computeDeltas 1400000 validators 1200 proto nodes 73.44709 ops/s 13.61524 ms/op - 922 runs 30.0 s ✔ computeDeltas 1400000 validators 7200 proto nodes 73.59195 ops/s 13.58844 ms/op - 937 runs 30.0 s ✔ computeDeltas 2100000 validators 300 proto nodes 49.27426 ops/s 20.29457 ms/op - 623 runs 30.1 s ✔ computeDeltas 2100000 validators 1200 proto nodes 49.11422 ops/s 20.36070 ms/op - 614 runs 30.1 s ✔ computeDeltas 2100000 validators 7200 proto nodes 48.75805 ops/s 20.50943 ms/op - 619 runs 30.1 s ``` after ``` computeDeltas ✔ computeDeltas 1400000 validators 300 proto nodes 113.6256 ops/s 8.800830 ms/op - 1076 runs 30.1 s ✔ computeDeltas 1400000 validators 1200 proto nodes 112.0909 ops/s 8.921329 ms/op - 1079 runs 30.0 s ✔ computeDeltas 1400000 validators 7200 proto nodes 111.5792 ops/s 8.962247 ms/op - 1068 runs 30.1 s ✔ computeDeltas 2100000 validators 300 proto nodes 75.48259 ops/s 13.24809 ms/op - 727 runs 30.1 s ✔ computeDeltas 2100000 validators 1200 proto nodes 74.93052 ops/s 13.34570 ms/op - 707 runs 30.1 s ✔ computeDeltas 2100000 validators 7200 proto nodes 74.82280 ops/s 13.36491 ms/op - 751 runs 30.0 s ``` - Bun: it's 3.88x faster before ``` computeDeltas ✔ computeDeltas 1400000 validators 300 proto nodes 103.6817 ops/s 9.644905 ms/op x1.578 1791 runs 30.0 s ✔ computeDeltas 1400000 validators 1200 proto nodes 103.4132 ops/s 9.669949 ms/op x1.580 1800 runs 30.1 s ✔ computeDeltas 1400000 validators 7200 proto nodes 103.7312 ops/s 9.640297 ms/op x1.578 1745 runs 30.1 s ✔ computeDeltas 2100000 validators 300 proto nodes 68.86443 ops/s 14.52128 ms/op x1.583 1188 runs 30.0 s ✔ computeDeltas 2100000 validators 1200 proto nodes 68.66082 ops/s 14.56435 ms/op x1.585 1195 runs 30.1 s ✔ computeDeltas 2100000 validators 7200 proto nodes 68.49115 ops/s 14.60043 ms/op x1.592 1194 runs 30.1 s ``` after ``` computeDeltas ✔ computeDeltas 1400000 validators 300 proto nodes 407.0697 ops/s 2.456582 ms/op x0.255 3117 runs 30.1 s ✔ computeDeltas 1400000 validators 1200 proto nodes 402.2402 ops/s 2.486077 ms/op x0.257 2838 runs 30.0 s ✔ computeDeltas 1400000 validators 7200 proto nodes 401.5803 ops/s 2.490162 ms/op x0.258 2852 runs 30.0 s ✔ computeDeltas 2100000 validators 300 proto nodes 265.5509 ops/s 3.765757 ms/op x0.259 1988 runs 30.1 s ✔ computeDeltas 2100000 validators 1200 proto nodes 267.6306 ops/s 3.736494 ms/op x0.257 2026 runs 30.0 s ✔ computeDeltas 2100000 validators 7200 proto nodes 266.0949 ops/s 3.758058 ms/op x0.257 2035 runs 30.1 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.