lotus-stack/stack-orchestrator/stacks/lotus-node
2024-05-23 16:27:16 +05:30
..
README.md Add steps to check lotus node status 2024-05-23 16:27:16 +05:30
stack.yml Create stack for snap synced node 2024-05-23 14:57:37 +05:30

lotus-node

Instructions for deploying a Lotus snap-synced node (for both mainnet and calibnet )

Prerequisite

Downloaded chain snapshot

aria2c -o snapshot -x5 https://forest-archive.chainsafe.dev/latest/mainnet/

# or using wget
wget -O snapshot https://forest-archive.chainsafe.dev/latest/mainnet/

Clone the stack repo

$ laconic-so fetch-stack git.vdb.to/cerc-io/lotus-stack

Clone required repositories

$ laconic-so --stack ~/cerc/lotus-stack/stack-orchestrator/stacks/lotus-node setup-repositories

Build the fixturenet-eth containers

$ laconic-so --stack ~/cerc/lotus-stack/stack-orchestrator/stacks/lotus-node build-containers

Create a deployment

$ laconic-so --stack ~/cerc/lotus-stack/stack-orchestrator/stacks/lotus-node deploy init --map-ports-to-host any-same --output lotus-node.yml
$ laconic-so --stack ~/cerc/lotus-stack/stack-orchestrator/stacks/lotus-node deploy create --spec-file lotus-node.yml --deployment-dir lotus-node-deployment

Setup config

Set filepath of downloaded snapshot in config.env Inside deployment directory, open the config.env file and set following env variables:

# Filepath of downloaded snapshot
CERC_LOTUS_SNAPSHOT_PATH=/path-to-file/snapshot

Start the container

$ laconic-so deployment --dir lotus-node-deployment up

Check status

  • Check if container is healthy

    docker ps | grep lotus
    

    NOTE: Starting node for the first time takes time (~20 mins) as it downloads latest snapshot and imports it

  • Get latest block using CURL

    curl -X POST \
    -H "Content-Type: application/json" \
    --data '{
        "jsonrpc": "2.0",
        "method": "eth_getBlockByNumber",
        "params": ["latest", false],
        "id": 1
      }' \
    http://localhost:1234/rpc/v1
    
  • To check whether Lotus node has synced till head

    laconic-so deployment --dir lotus-node-deployment exec lotus "lotus sync wait"
    
    # lotus sync wait
    # Worker: 78534; Base: 2403099; Target: 2403099 (diff: 0)
    # State: message sync; Current Epoch: 2403099; Todo: 0
    
    # Done!
    

    When the lotus sync wait command shows done you are fully synced with the chain

Clean up

Stop all services running in the background:

$ laconic-so deployment --dir lotus-node-deployment down

To stop all services and also delete data:

# Stop the docker containers
$ laconic-so deployment --dir lotus-node-deployment down --delete-volumes

# Remove deployment directory (deployment will have to be recreated for a re-run)
$ rm -r lotus-node-deployment