Lighthouse Ethereum Consensus Client

repository·stable·Indexed 25 days ago

https://github.com/sigp/lighthouse

A high-performance, security-focused Ethereum consensus client implemented in Rust. The project includes the Lighthouse Account Manager for cryptographic key generation and secure storage, lcli for state transition replaying, and a BuilderHttpClient for interacting with MEV builders. It provides tools for managing database schema migrations and a local testnet environment using Docker, Kurtosis, and yq.

Tokens
72.3K
Snippets
152
Records
433
Agent score
85%

What's inside Lighthouse

  1. Overview of Lighthouse Ethereum Consensus Client

    stable
    Lighthouse is an open-source Ethereum consensus client written in Rust. It is designed for security and performance, suitable for use on the Ethereum consensus mainnet. It is licensed under Apache 2.0.
  2. Overview of Lighthouse Account Manager roles

    stable

    The Lighthouse Account Manager (AM) is a stand-alone binary used to manage cryptographic keys for Ethereum Serenity. Its primary responsibilities include:

    • Generation of cryptographic key pairs: Securely generating keys using sufficient entropy.
    • Secure storage of private keys: Encrypting keys at rest on disk in a format compatible with the validator client.
    • Staking initiation: Producing the messages and transactions required to initiate staking on Ethereum 1.x.
  3. Overview of the Lighthouse validator-manager tool

    stable

    The lighthouse validator-manager tool is used to manage validators on a running Lighthouse Validator Client (VC). Unlike the account-manager tool, which creates files to be read upon the next VC restart, the validator-manager performs operations via the HTTP API to make instant changes to a live VC.

    Key features include:

    • Moving validators between two VCs while maintaining the slashing protection database.
    • Generating deposit files compatible with the Ethereum Staking Launchpad.
    • Minimizing downtime during validator operations.
    • Preserving the "key cache" when adding validators to prevent long startup waits.
  4. Understand Lighthouse Database Architecture (Hot vs. Cold DB)

    stable

    Lighthouse employs a "split" database schema to manage state efficiency:

    • Hot DB: Stores recent, unfinalized states and all blocks. Full BeaconState structures are stored once per epoch to maintain performance for recent data.
    • Freezer DB (or Cold DB): Stores finalized states. It uses a sparser format where full BeaconState structures (snapshots) are stored periodically, and intermediate states are reconstructed by replaying blocks or applying hierarchical state diffs (hdiffs).
    • Split Slot: The specific slot that marks the boundary between the freezer DB (slots less than the split slot) and the hot DB (slots greater than or equal to the split slot).
  5. Understand slashing protection effectiveness and limitations

    stable

    Lighthouse uses an SQLite database located at $datadir/validators/slashing_protection.sqlite to record signed messages and prevent double-signing.

    What it PROTECTS against:

    • Duplicate clients: Running two Lighthouse clients on the same machine with the same datadir (the second client will fail to start due to the database lock).
    • Deep re-orgs: Prevents re-attesting in an epoch where you have already attested.
    • Migration errors: Prevents signing if the slashing_protection.sqlite file is missing during a datadir change.

    What it DOES NOT protect against:

    • Simultaneous instances: Running two different clients (e.g., Lighthouse and Prysm) or two Lighthouse instances with different datadirs on the same machine or different machines. You are responsible for ensuring your keys never run in two places at once.
    • Incomplete imports: Importing keys without also importing the voting/signing history.
    • Manual recreation: Using the --init-slashing-protection flag to wipe the history.
  6. Identify available Lighthouse APIs

    stable

    Lighthouse provides two distinct RESTful HTTP/JSON APIs for querying the Ethereum consensus state:

    1. Beacon Node API: Used for interacting with the beacon node (e.g., querying attestations, blocks, and consensus state).
    2. Validator Client API: Used for interacting with the validator client (e.g., managing validator keys, checking staking status, and performing withdrawals).
  7. Backfill historical blob data

    stable

    To retrieve historical blob data beyond the standard 18-day availability period, you can use the experimental flag --complete-blob-backfill.

    Critical Requirements & Risks:

    • This is an experimental feature.
    • It only works if the flag is present during a fresh checkpoint sync when the database is being initialized.
    • It will not work if the node is already running with an existing database.
    • During backfill, the node may experience issues such as blocking most of its peers.
    --complete-blob-backfill
  8. Recover EIP-2335 validator keystores from a mnemonic

    stable

    If you have lost your validator keystore files or passwords, you can regenerate them using a mnemonic via the lighthouse account validator recover command.

    ⚠️ Warning: Use this only as a last resort.

    • Your mnemonic is not encrypted and is highly vulnerable to theft when entered into a computer.
    • Regenerating keys can result in duplicate keypairs. Running the same keypairs on two different validator clients will likely result in slashing.

    Each recovered index creates a directory in the --validator-dir location (default ~/.lighthouse/{network}/validators) containing the necessary information to run a validator with lighthouse vc. The new keystore password is saved in the --secrets-dir (default ~/.lighthouse/{network}/secrets).

    Note: {network} refers to the value passed to the --network parameter (default is mainnet).