Top Related Projects
Go implementation of Ethereum proof of stake
Ethereum consensus client in Rust
Quick Overview
Lodestar is an open-source TypeScript implementation of the Ethereum consensus layer. It aims to provide a lightweight and efficient client for Ethereum 2.0, focusing on performance, modularity, and ease of use for developers and node operators.
Pros
- Written in TypeScript, offering type safety and improved developer experience
- Modular architecture allowing for easy customization and integration
- Actively maintained and regularly updated to align with Ethereum specifications
- Supports both beacon node and validator client functionalities
Cons
- Relatively newer compared to other Ethereum clients, potentially less battle-tested
- May have a smaller community and ecosystem compared to more established clients
- Performance might not be as optimized as clients written in lower-level languages
- Limited documentation for advanced use cases and customizations
Code Examples
- Creating a beacon node:
import {createBeaconNode} from "@chainsafe/lodestar";
const beaconNode = await createBeaconNode({
network: "mainnet",
dataDir: "./lodestar-data",
eth1: {provider: "http://localhost:8545"},
});
await beaconNode.start();
- Subscribing to beacon chain events:
import {createBeaconNode, ChainEvent} from "@chainsafe/lodestar";
const beaconNode = await createBeaconNode(/* ... */);
beaconNode.chain.emitter.on(ChainEvent.block, (block) => {
console.log("New block received:", block.message.slot);
});
- Creating and running a validator client:
import {createValidatorClient} from "@chainsafe/lodestar-validator";
const validatorClient = await createValidatorClient({
beaconNodeUrl: "http://localhost:9596",
keystoresDir: "./validator-keys",
});
await validatorClient.start();
Getting Started
To get started with Lodestar, follow these steps:
- Install Lodestar:
npm install @chainsafe/lodestar
- Create a basic beacon node:
import {createBeaconNode} from "@chainsafe/lodestar";
async function main() {
const beaconNode = await createBeaconNode({
network: "mainnet",
dataDir: "./lodestar-data",
eth1: {provider: "http://localhost:8545"},
});
await beaconNode.start();
console.log("Beacon node started");
}
main().catch((e) => console.error(e));
- Run the beacon node:
ts-node your-beacon-node-script.ts
For more detailed instructions and advanced configurations, refer to the official Lodestar documentation.
Competitor Comparisons
Go implementation of Ethereum proof of stake
Pros of Prysm
- More mature and widely adopted Ethereum 2.0 client
- Extensive documentation and community support
- Better performance and stability in production environments
Cons of Prysm
- Larger codebase, potentially more complex to maintain
- Written in Go, which may have a steeper learning curve for some developers
- Less modular architecture compared to Lodestar
Code Comparison
Prysm (Go):
func (s *Service) Start() error {
s.running = true
go s.run()
return nil
}
Lodestar (TypeScript):
async start(): Promise<void> {
this.state.running = true;
await this.run();
}
Both implementations show a start function, but Prysm uses Go's concurrency model with goroutines, while Lodestar leverages TypeScript's async/await pattern. Prysm's approach may offer better performance for concurrent operations, while Lodestar's code is more readable and easier to reason about for developers familiar with JavaScript/TypeScript.
Lodestar's TypeScript implementation provides stronger type safety and better tooling support, which can lead to fewer runtime errors and improved developer productivity. However, Prysm's Go implementation may offer better raw performance and lower resource usage in production environments.
Ethereum consensus client in Rust
Pros of Lighthouse
- Written in Rust, offering better performance and memory safety
- More mature and widely adopted in the Ethereum ecosystem
- Extensive documentation and community support
Cons of Lighthouse
- Steeper learning curve for developers not familiar with Rust
- Potentially slower development cycle due to Rust's strict compiler
Code Comparison
Lighthouse (Rust):
pub fn process_attestation(
state: &mut BeaconState<T>,
attestation: &Attestation<T>,
verify_signatures: bool,
) -> Result<(), AttestationProcessingError> {
// Implementation details
}
Lodestar (TypeScript):
export function processAttestation(
state: BeaconState,
attestation: phase0.Attestation,
verifySignature = true
): void {
// Implementation details
}
Additional Notes
Both Lighthouse and Lodestar are Ethereum consensus layer clients, but they differ in their implementation languages and design philosophies. Lighthouse focuses on performance and security, leveraging Rust's strengths, while Lodestar aims for accessibility and ease of development using TypeScript. The choice between them often depends on the team's expertise and specific project requirements.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Lodestar Ethereum Consensus Implementation
Lodestar is a TypeScript implementation of the Ethereum Consensus specification developed by ChainSafe Systems.
Getting started
- :gear: Follow the instructions for build from source, binaries, or Docker to install Lodestar. Or use our Lodestar Quickstart scripts.
- :books: Use Lodestar libraries in your next Ethereum Typescript project.
- :globe_with_meridians: Run a beacon node on mainnet or a public testnet.
- :computer: Utilize the whole stack by starting a local testnet.
- :spiral_notepad: View the Lodestar CLI commands and options.
- :nerd_face: View the Package and dependency structure.
- :memo: Prospective contributors can read the contributing section to understand how we develop and test on Lodestar.
- :writing_hand: If you have questions submit an issue or join us on Discord!
- :rotating_light: Please note our security policy.
- :bird: Follow Lodestar on Twitter for announcements and updates!
Prerequisites
Developer Quickstart:
yarn install
yarn build
./lodestar --help
Architecture Overview
- :package: This mono-repository contains a suite of Ethereum Consensus packages.
- :balance_scale: The mono-repository is released under LGPLv3 license. Note, that the packages contain their own licenses.
Package | Version | License | Docs | Description |
---|---|---|---|---|
@chainsafe/lodestar | :computer: Command-line tool for Lodestar | |||
@lodestar/api | :clipboard: REST Client for the Ethereum Beacon API | |||
@lodestar/beacon-node | :rotating_light: Beacon-chain client | |||
@lodestar/config | :spiral_notepad: Eth Consensus types and params bundled together | |||
@lodestar/db | :floppy_disk: Read/write persistent Eth Consensus data | |||
@lodestar/flare | :boom: Command tool for triggering non-standard actions | |||
@lodestar/fork-choice | :fork_and_knife: Beacon-chain fork choice | |||
@lodestar/light-client | :bird: Ethereum Light client | |||
@lodestar/logger | :memo: NodeJS logger for Lodestar binaries | |||
@lodestar/params | :spider_web: Eth Consensus network parameters | |||
@lodestar/prover | :white_check_mark: Ethereum Light client verifier for execution JSON-RPC calls | |||
@lodestar/reqresp | :telephone_receiver: Eth Consensus Req/Resp protocol | |||
@lodestar/spec-test-util | :test_tube: Test harness for Eth Consensus spec tests | |||
@lodestar/state-transition | :mag_right: Eth Consensus beacon-state transition | |||
@lodestar/types | :spiral_notepad: Eth Consensus TypeScript and SSZ types | |||
@lodestar/utils | :toolbox: Miscellaneous utility functions used across Lodestar | |||
@lodestar/validator | :bank: 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.
Top Related Projects
Go implementation of Ethereum proof of stake
Ethereum consensus client in Rust
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot