Eridian
eridian.xyzx.comGitHub
  • 📖Eridian Docs
  • Ethereum Dev
    • ✏️Ethereum Notes
      • 🎛️Technical Basics
      • 🪧Ethereum Addresses
      • 📚Ethereum State Explained
      • ⛽Gas Fees Explained
    • 🔧Useful Tools
      • ☁️Ethers
      • *️⃣Ethernal
    • 📝Solidity Notes
      • ❔Interview Questions
        • 🟢1. Easy - Interview Questions
        • 🟠2. Medium - Interview Questions
        • 🟡3. Hard - Interview Questions
        • 🔴4. Advanced - Interview Questions
      • 💡Note Ideas
      • ABI
      • abi.encodePacked
      • Abstract Contracts
      • Arrays
      • Casting
      • CEI - Checks, Effects, Interactions
      • Comments (NATSPEC)
      • Constructor
      • Contract Structure & Versions
      • Data - Storage vs Memory
      • Data - Storage Layout
      • Enum
      • Errors (require & revert)
      • Events
      • EVM Opcodes
      • External Contract Interaction
      • 🏗️External Dependencies
      • Functions
      • Function Modifiers
      • If / Else / For / While Loops
      • Inheritance
      • Interfaces
      • Keccak256
      • Library
      • Mappings
      • msg.sender
      • Objects & Types
      • OpenZeppelin
      • Payable
      • Public State Variable vs Function
      • Receive & Fallback
      • Security
      • Self Destruct
      • Send ETH (transfer, send, call)
      • Stack Too Deep
      • Structs
      • Style Guide
      • Time Units
      • Try / Catch
      • Typecasting
      • Using Directive
      • Variables, Consts & Immutable
      • Withdraws
    • ⚒️Foundry Notes
      • 📖Docs & GitHub Pages
      • 🤝Useful Commands
        • 🔨Anvil
        • 🪄Cast
        • 🔥Forge
      • 🧪Tests
        • Cheatcodes
      • 📝Useful Scripts
        • Deploy Contract Using Hex
    • 👾DeFi Challenges
      • 👨‍🚀Ethernaut
        • Ethernaut - Template
        • Level 1 - Fallback ⏺
        • Level 2 - Fallout ⏺
        • Level 3 - Coin Flip ⏺⏺
        • Level 4 - Telephone ⏺
        • Level 5 - Token ⏺⏺
        • Level 6 - Delegation ⏺⏺
        • Level 7 - Force ⏺⏺⏺
        • Level 8 - Vault ⏺⏺
        • Level 9 - King ⏺⏺⏺
        • Level 10 - Re-entrancy ⏺⏺⏺
        • Level 11 - Elevator ⏺⏺
        • Level 12 - Privacy ⏺⏺⏺
        • Level 13 - Gatekeeper 1 ⏺⏺⏺⏺
        • Level 14 - Gatekeeper 2 ⏺⏺⏺
        • Level 15 - Naught Coin ⏺⏺⏺
        • Level 16 - Preservation ⏺⏺⏺⏺
        • Level 17 - Recovery ⏺⏺⏺
        • Level 18 - Magic Number ⏺⏺⏺
        • Level 19 - Alien Codex ⏺⏺⏺⏺
        • Level 20 - Denial ⏺⏺⏺
        • Level 21 - Shop ⏺⏺
        • Level 22 - Dex ⏺⏺
        • Level 23 - Dex Two ⏺⏺
        • Level 24 - Puzzle Wallet ⏺⏺⏺⏺
        • Level 25 - Motorbike ⏺⏺⏺
        • Level 26 - DoubleEntryPoint ⏺⏺
        • Level 27 - Good Samaritan ⏺⏺⏺
        • Level 28 - Gatekeeper 3 ⏺⏺⏺
        • Level 29 - Switch ⏺⏺⏺⏺
        • Level 30 - Higher Order ⏺⏺⏺⏺
        • Level 31 - Stake ⏺⏺⏺
      • 💸Damn Vulnerable DeFi
    • 🔍Auditing
      • 🗞️Exploit Resources
      • 🔧Audit Tools
    • 🤖MEV
  • Infrastructure Docs
    • 💻Hardware
    • 🐧Linux
      • 📖Linux Glossary
      • ⌨️Linux Commands
      • 💾Installation
      • 🏗️Maintenance
      • 🖥️Ubuntu Desktop
      • 🛜ZeroTier
      • 🎞️TMUX
      • 🔵Bluetooth
    • ⛓️Ethereum Clients
      • ⚙️Execution Clients
        • ⛏️Geth
          • 💾Installation
          • ⌨️Useful Commands
          • 🏗️Maintenance
        • 🐻Erigon
          • 💾Installation
          • ⌨️Useful Commands
          • 🏗️Maintenance
        • 🧶Besu
          • 💾Installation
          • ⌨️Useful Commands
          • 🏗️Maintenance
      • 🤝Beacon Clients
        • 💡Lighthouse
          • 💾Installation
          • ⌨️Useful Commands
          • 🏗️Maintenance
        • 🪅Teku
          • 💾Installation
          • ⌨️Useful Commands
          • 🏗️Maintenance
      • 💎Validator Clients
        • 💡Lighthouse
          • 💾Installation
          • ⌨️Useful Commands
          • 🏗️Maintenance
      • ➕L2 Clients
        • 🔵Base
          • 💾Installation
          • ⌨️Useful Commands
          • 🏗️Maintenance
      • 💰MEV Boost
        • 💾Installation
        • 🏗️Maintenance
    • 🚨Alerting and Monitoring
      • 🔥Prometheus
      • 🌡️HealthChecks.io
      • 📟PagerDuty
  • General Dev
    • 💾Git Notes
      • Repos
      • Committing changes
      • Branches
      • Merging & Rebasing
      • PRs
Powered by GitBook
On this page
  • Create Aliases
  • Dependency - Install Rust
  • Lighthouse - Install
  • Firewall Configuration
  • Lighthouse BN - Configure Service
  • Command Aliases
  • Lighthouse - Update Scripts
Edit on GitHub
  1. Infrastructure Docs
  2. Ethereum Clients
  3. Beacon Clients
  4. Lighthouse

Installation

Lighthouse client installation guide.

Create Aliases

echo "alias lighthouse-version-current='/usr/local/bin/lighthouse --version'" >> ~/.bashrc
echo "alias lighthouse-build='~/lighthouse-build.sh'" >> ~/.bashrc
echo "alias lighthouse-version-new='~/.cargo/bin/lighthouse --version'" >> ~/.bashrc
echo "alias lighthouse-deploy='~/lighthouse-deploy.sh'" >> ~/.bashrc

echo "alias lighthouse-beacon-log='journalctl -f -u lighthousebeacon.service -o cat | ccze -A'" >> ~/.bashrc
echo "alias lighthouse-beacon-start='sudo systemctl start lighthousebeacon.service'" >> ~/.bashrc
echo "alias lighthouse-beacon-stop='sudo systemctl stop lighthousebeacon.service'" >> ~/.bashrc
echo "alias lighthouse-beacon-restart='sudo systemctl restart lighthousebeacon.service'" >> ~/.bashrc
echo "alias lighthouse-beacon-status='sudo systemctl status lighthousebeacon.service'" >> ~/.bashrc
echo "alias lighthouse-beacon-config='sudo vim /etc/systemd/system/lighthousebeacon.service'" >> ~/.bashrc
echo "alias lighthouse-beacon-enable='sudo systemctl enable lighthousebeacon.service'" >> ~/.bashrc
echo "alias lighthouse-beacon-disable='sudo systemctl disable lighthousebeacon.service'" >> ~/.bashrc
echo "alias lighthouse-beacon-delete-data='sudo rm -rf /var/lib/lighthouse/beacon; sudo mkdir -p /var/lib/lighthouse/beacon; sudo chown -R lighthousebeacon:lighthousebeacon /var/lib/lighthouse/beacon'" >> ~/.bashrc

source ~/.bashrc

Dependency - Install Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

<1>
<ENTER>

source $HOME/.cargo/env

Make sure protoc is installed otherwise the build will fail.

sudo apt-get install -y protobuf-compiler
protoc --version

Lighthouse - Install

Build the latest version of Lighthouse.

LIGHTHOUSE_VERSION_COMMIT_HASH=        # e.g.441fc16 

cd ~
git clone https://github.com/sigp/lighthouse.git
cd ~/lighthouse
git checkout ${LIGHTHOUSE_VERSION_COMMIT_HASH}
make

Move the compiled Lighthouse build to a new directory.

sudo cp ~/.cargo/bin/lighthouse /usr/local/bin

Check version.

/usr/local/bin/lighthouse --version

Create Lighthouse directory.

sudo mkdir -p /var/lib/lighthouse

Firewall Configuration

Lighthouse BN - Configure Service

Create lighthousebeacon user and set permissions.

sudo useradd --no-create-home --shell /bin/false lighthousebeacon
sudo mkdir -p /var/lib/lighthouse/beacon
sudo chown -R lighthousebeacon:lighthousebeacon /var/lib/lighthouse/beacon

Configure lighthousebeacon service using the command line flags.

sudo vim /etc/systemd/system/lighthousebeacon.service
lighthousebeacon.service
[Unit]
Description=Lighthouse Ethereum Client - Beacon Node
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=lighthousebeacon
Group=lighthousebeacon
Restart=always
RestartSec=5

EnvironmentFile=/etc/default/beacon-variables.env

ExecStart=/usr/local/bin/lighthouse bn \
    --network ${NETWORK} \
    --datadir /var/lib/lighthouse \
    --jwt-secrets="/var/lib/jwtsecret" \
    --execution-endpoints ${BEACON_EXECUTION_ENDPOINTS} \
    --port ${BEACON_P2P_PORT} \
    \
    --http \
    --http-address=${BEACON_HTTP_ADDRESS} \
    --http-port=${BEACON_HTTP_PORT} \
    --http-allow-origin "*" \
    \
    --metrics \
    --metrics-address ${BEACON_METRICS_ADDR} \
    --metrics-port ${BEACON_METRICS_PORT} \
    --metrics-allow-origin "*" \
    --validator-monitor-auto \
    \
    --suggested-fee-recipient ${BEACON_SUGGESTED_FEE_RECIPIENT} \
    --checkpoint-sync-url ${BEACON_CHECKPOINT_SYNC_URL} \
    --builder ${BEACON_BUILDER} \
    --reconstruct-historic-states

[Install]
WantedBy=multi-user.target

/usr/local/bin/lighthouse bn

Starts the Beacon node.

--network

Name of the chain Lighthouse will sync and follow (e.g. mainnet or goerli).

--datadir

Used to specify a custom root data directory for lighthouse keys and databases.

--port

The TCP/UDP port to listen on for peer discovery.

--http

Enable the RESTful HTTP API server.

  • Disabled by default.

--http-address

Specify the listening address of the server.

--http-port

Specify the listening port of the server.

--metrics

Enable the Prometheus metrics HTTP server.

  • Disabled by default.

--validator-monitor-auto

When the --validator-monitor-auto flag is supplied, any validator which uses the beacon_committee_subscriptions API endpoint will be enrolled for additional monitoring.

  • All active validators will use this endpoint each epoch, so you can expect it to detect all local and active validators within several minutes after start up.

--monitoring-endpoint (Not curreclty used)

Enables the monitoring service for sending system metrics to a remote endpoint.

  • This flag sets the endpoint where the beacon node metrics will be sent.

  • Note: This will send information to a remote server which may identify and associate your validators, IP address, and other personal information.

  • Always use a HTTPS connection and never provide an untrusted URL.

--execution-endpoints

One or more comma-delimited server endpoints for HTTP JSON-RPC connection.

  • If multiple endpoints are given the endpoints are used as fallback in the given order.

--jwt-secrets

The JWT secret is automatically generated when Geth is first run and added to /var/lib/goethereum/

  • This is same location that is pointed to in both the Geth and Lighthouse configuration so that they use the same JWT secret and can talk to each other.

--suggested-fee-recipient

This address receives transaction fees collected from any blocks produced by this node.

  • The --suggested-fee-recipient can be provided to the Beacon Node to act as a default value when the validator client does not transmit a suggested_fee_recipient to the Beacon Node

--checkpoint-sync-url

Used to fast sync the chain rather than starting at genesis.

  • Only needed for the initial sync, I can remove it after.

--builder

Used to query the provided URL during block production for a block payload with stubbed-out transactions.

  • If this request fails, Lighthouse will fall back to the local execution engine and produce a block using transactions gathered and verified locally.

--reconstruct-historic-states

Used to reconstruct the history of the beacon chain when checkpoint sync was used.

  • Allows access to all historical data.

--purge-db

Add this flag to delete the existing database.

Start the service and check it's working as expected.

Command Aliases

daemon-reload     # Reload any changes made to the lighthousebeacon.service
lighthouse-beacon-enable     # Enable the lighthousebeacon.service
lighthouse-beacon-start      # Start the lighthousebeacon.service
lighthouse-beacon-status     # View the status of the lighthousebeacon.service

lighthouse-beacon-log        # View the lighthousebeacon.service logs

Lighthouse - Update Scripts

Create Lighthouse build script.

vim ~/lighthouse-build.sh
~/lighthouse-build.sh
#!/bin/bash
set -e
cd ~/lighthouse

read -p "Enter the commit hash you want to checkout: " commit_hash

git fetch
git checkout $commit_hash

echo
echo "********************"
echo "Making Lighthouse..."
echo "********************"
make

Create Lighthouse deploy script.

vim ~/lighthouse-deploy.sh
~/lighthouse-deploy.sh
#!/bin/bash
# set -e     # This isn't working correctly, so comment out for now

while true; do
    read -p "Are you sure you want to deploy Lighthouse? (Y/N) " yn
    case $yn in
        [Yy]* ) break;;
        [Nn]* ) exit;;
        * ) echo "Please answer Y or N.";;
    esac
done

# Check if the services exist before checking their status
if systemctl list-units --full -all | grep -Fq lighthousebeacon.service; then
    beacon_status=$(sudo systemctl is-active lighthousebeacon.service)
else
    beacon_status="not_installed"
fi

if systemctl list-units --full -all | grep -Fq lighthousevalidator.service; then
    validator_status=$(sudo systemctl is-active lighthousevalidator.service)
else
    validator_status="not_installed"
fi

echo "**********************"

if [ "$beacon_status" = "active" ]; then
    echo "Stopping Lighthouse Beacon..."
    sudo systemctl stop lighthousebeacon.service
elif [ "$beacon_status" = "not_installed" ]; then
    echo "Warning: Lighthouse Beacon service is not installed."
fi

if [ "$validator_status" = "active" ]; then
    echo "Stopping Lighthouse Validator..."
    sudo systemctl stop lighthousevalidator.service
elif [ "$validator_status" = "not_installed" ]; then
    echo "Warning: Lighthouse Validator service is not installed."
fi

echo "Replacing previous version..."

# Check if the file exists before trying to remove it
if [ -f /usr/local/bin/lighthouse ]; then
    sudo rm /usr/local/bin/lighthouse
fi

# Check if the source file exists before copying
if [ -f ~/.cargo/bin/lighthouse ]; then
    sudo cp ~/.cargo/bin/lighthouse /usr/local/bin
else
    echo "Error: Source file does not exist. Installation aborted."
    exit 1
fi

if [ "$beacon_status" = "active" ]; then
    echo "Restarting Lighthouse Beacon..."
    sudo systemctl start lighthousebeacon.service
fi

if [ "$validator_status" = "active" ]; then
    echo "Restarting Lighthouse Validator..."
    sudo systemctl start lighthousevalidator.service
fi

Make all scripts executable.

chmod u+x ~/lighthouse-build.sh
chmod u+x ~/lighthouse-deploy.sh

Last updated 1 year ago

Configure the firewall using generic Beacon client UFW settings:

Configure .

This can be used to monitor your setup on certain services (e.g. ).

⛓️
🤝
💡
💾
https://lighthouse-book.sigmaprime.io/validator-monitoring.html#automatic
https://beaconcha.in/user/settings#app
https://lighthouse-book.sigmaprime.io/checkpoint-sync.html#automatic-checkpoint-sync
https://lighthouse-book.sigmaprime.io/checkpoint-sync.html#reconstructing-states
UFW Config
Beacon Service Environment Variables