lotus-stack/stack-orchestrator/stacks/lotus-node
2024-05-28 18:36:22 +05:30
..
README.md Remove git stash from Dockerfile 2024-05-28 18:36:22 +05:30
stack.yml Remove git stash from Dockerfile 2024-05-28 18:36:22 +05:30

lotus-node

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

Prerequisite

Downloaded chain snapshot

  • For Mainnet

    aria2c -o mainnet-snapshot.car.zst -x5 https://forest-archive.chainsafe.dev/latest/mainnet/
    
    # or using wget
    wget -O mainnet-snapshot.car.zst https://forest-archive.chainsafe.dev/latest/mainnet/
    
  • For Calibration Testnet

    aria2c -o calibnet-snapshot.car.zst -x5 https://forest-archive.chainsafe.dev/latest/calibnet/
    
    # or using wget
    wget -O calibnet-snapshot.car.zst https://forest-archive.chainsafe.dev/latest/calibnet/
    

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 --branches git.vdb.to/cerc-io/lotus@v1.27.0-rc3-interal-0.0.1

Build the Lotus containers

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

Create a deployment

  • Create deployment spec file

    • For Mainnet

      $ laconic-so --stack ~/cerc/lotus-stack/stack-orchestrator/stacks/lotus-node deploy init --map-ports-to-host any-same --output lotus-node.yml --config CERC_LOTUS_NETWORK=mainnet,CERC_LOTUS_SNAPSHOT_PATH=/path-to-file/mainnet-snapshot.car.zst
      
    • For Calibration

      $ laconic-so --stack ~/cerc/lotus-stack/stack-orchestrator/stacks/lotus-node deploy init --map-ports-to-host any-same --output lotus-node.yml --config CERC_LOTUS_NETWORK=calibration,CERC_LOTUS_SNAPSHOT_PATH=/path-to-file/calibnet-snapshot.car.zst
      

    NOTE: In commands above, set CERC_LOTUS_SNAPSHOT_PATH to the absolute file path of the downloaded snapshot (Prerequisite)

  • Create deployment directory

    $ 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

Environment variables for Lotus node can be configured by setting them in config.env inside deployment directory

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 imports the snapshot

  • 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

    • 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
      

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