Convert Figma logo to code with AI

ChainSafe logolodestar

🌟 TypeScript Implementation of Ethereum Consensus

1,137
278
1,137
296

Top Related Projects

3,462

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

  1. 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();
  1. 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);
});
  1. 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:

  1. Install Lodestar:
npm install @chainsafe/lodestar
  1. 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));
  1. 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

3,462

Go implementation of Ethereum proof of stake

Pros of Prysm

  • Written in Go, which is known for its simplicity and efficiency
  • Extensive documentation and active community support
  • Well-established and widely adopted in the Ethereum ecosystem

Cons of Prysm

  • Larger codebase, potentially more complex to navigate
  • Higher resource consumption compared to Lodestar
  • Slower development cycle for new features

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 repositories implement Ethereum 2.0 clients, but with different approaches. Prysm, written in Go, offers a more mature and widely adopted solution with extensive documentation. Lodestar, implemented in TypeScript, provides a lighter-weight alternative with potentially faster development cycles for new features.

The code comparison shows similar functionality for starting services, with Prysm using goroutines for concurrent execution, while Lodestar leverages async/await for asynchronous operations. This reflects the different programming paradigms of Go and TypeScript.

Ultimately, the choice between Prysm and Lodestar depends on specific project requirements, team expertise, and performance considerations.

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 Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Lodestar Ethereum Consensus Implementation

GitHub release (latest by date) Docker Image Version (latest by date) Eth Consensus Spec v1.4.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

  • :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.
PackageVersionLicenseDocsDescription
@chainsafe/lodestarnpmLicense: LGPL v3documentation:computer: Command-line tool for Lodestar
@lodestar/apinpmLicensedocumentation:clipboard: REST Client for the Ethereum Beacon API
@lodestar/beacon-nodenpmLicense: LGPL v3documentation:rotating_light: Beacon-chain client
@lodestar/confignpmLicensedocumentation:spiral_notepad: Eth Consensus types and params bundled together
@lodestar/dbnpmLicensedocumentation:floppy_disk: Read/write persistent Eth Consensus data
@lodestar/flarenpmLicensedocumentation:boom: Command tool for triggering non-standard actions
@lodestar/fork-choicenpmLicensedocumentation:fork_and_knife: Beacon-chain fork choice
@lodestar/light-clientnpmLicensedocumentation:bird: Ethereum Light client
@lodestar/loggernpmLicensedocumentation:memo: NodeJS logger for Lodestar binaries
@lodestar/paramsnpmLicensedocumentation:spider_web: Eth Consensus network parameters
@lodestar/provernpmLicensedocumentation:white_check_mark: Ethereum Light client verifier for execution JSON-RPC calls
@lodestar/reqrespnpmLicensedocumentation:telephone_receiver: Eth Consensus Req/Resp protocol
@lodestar/spec-test-utilnpmLicensedocumentation:test_tube: Test harness for Eth Consensus spec tests
@lodestar/state-transitionnpmLicensedocumentation:mag_right: Eth Consensus beacon-state transition
@lodestar/typesnpmLicensedocumentation:spiral_notepad: Eth Consensus TypeScript and SSZ types
@lodestar/utilsnpmLicensedocumentation:toolbox: Miscellaneous utility functions used across Lodestar
@lodestar/validatornpmLicense: LGPL v3documentation:bank: Validator client

Contributors

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

Meetings

Weekly contributor meetings are public and announced on Discord. 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 send us ETH at the following address: lodestar.chainsafe.eth

NPM DownloadsLast 30 Days