Restart support for fixturenet-lotus #499

Merged
prathamesh0 merged 4 commits from pm-lotus-restarts into main 2023-08-14 07:16:05 +00:00
9 changed files with 54 additions and 30 deletions

View File

@ -11,6 +11,7 @@ services:
- ../config/fixturenet-lotus/fund-account.sh:/fund-account.sh - ../config/fixturenet-lotus/fund-account.sh:/fund-account.sh
- lotus_miner_params:/var/tmp/filecoin-proof-parameters - lotus_miner_params:/var/tmp/filecoin-proof-parameters
- lotus-shared:/root/.lotus-shared - lotus-shared:/root/.lotus-shared
- lotus_miner_data:/root/data
entrypoint: ["sh", "/docker-entrypoint-scripts.d/setup-miner.sh"] entrypoint: ["sh", "/docker-entrypoint-scripts.d/setup-miner.sh"]
ports: ports:
- "1234" - "1234"
@ -30,6 +31,7 @@ services:
- ../config/fixturenet-lotus/setup-node.sh:/docker-entrypoint-scripts.d/setup-node.sh - ../config/fixturenet-lotus/setup-node.sh:/docker-entrypoint-scripts.d/setup-node.sh
- lotus_node_1_params:/var/tmp/filecoin-proof-parameters - lotus_node_1_params:/var/tmp/filecoin-proof-parameters
- lotus-shared:/root/.lotus-shared - lotus-shared:/root/.lotus-shared
- lotus_node_1_data:/root/data
healthcheck: healthcheck:
test: ["CMD", "nc", "-vz", "localhost", "1234"] test: ["CMD", "nc", "-vz", "localhost", "1234"]
interval: 30s interval: 30s
@ -57,6 +59,7 @@ services:
- ../config/fixturenet-lotus/setup-node.sh:/docker-entrypoint-scripts.d/setup-node.sh - ../config/fixturenet-lotus/setup-node.sh:/docker-entrypoint-scripts.d/setup-node.sh
- lotus_node_2_params:/var/tmp/filecoin-proof-parameters - lotus_node_2_params:/var/tmp/filecoin-proof-parameters
- lotus-shared:/root/.lotus-shared - lotus-shared:/root/.lotus-shared
- lotus_node_2_data:/root/data
healthcheck: healthcheck:
test: ["CMD", "nc", "-vz", "localhost", "1234"] test: ["CMD", "nc", "-vz", "localhost", "1234"]
interval: 30s interval: 30s
@ -77,3 +80,6 @@ volumes:
lotus_node_1_params: lotus_node_1_params:
lotus_node_2_params: lotus_node_2_params:
lotus-shared: lotus-shared:
lotus_miner_data:
lotus_node_1_data:
lotus_node_2_data:

View File

@ -1,5 +1,5 @@
LOTUS_PATH=/root/.lotus-local-net LOTUS_PATH=/root/data/.lotus-local-net
LOTUS_MINER_PATH=/root/.lotus-miner-local-net LOTUS_MINER_PATH=/root/data/.lotus-miner-local-net
LOTUS_SKIP_GENESIS_CHECK=_yes_ LOTUS_SKIP_GENESIS_CHECK=_yes_
LOTUS_FEVM_ENABLEETHRPC=true LOTUS_FEVM_ENABLEETHRPC=true
CGO_CFLAGS_ALLOW="-D__BLST_PORTABLE__" CGO_CFLAGS_ALLOW="-D__BLST_PORTABLE__"

View File

@ -15,12 +15,16 @@ else
echo "Existing proof params found" echo "Existing proof params found"
fi fi
lotus-seed pre-seal --sector-size 2KiB --num-sectors 2 # if genesis is not already setup
lotus-seed genesis new localnet.json if [ ! -f /root/data/localnet.json ]; then
lotus-seed genesis add-miner localnet.json ~/.genesis-sectors/pre-seal-t01000.json lotus-seed --sector-dir /root/data/.genesis-sectors pre-seal --sector-size 2KiB --num-sectors 2
lotus-seed --sector-dir /root/data/.genesis-sectors genesis new /root/data/localnet.json
lotus-seed --sector-dir /root/data/.genesis-sectors genesis add-miner /root/data/localnet.json /root/data/.genesis-sectors/pre-seal-t01000.json
fi
# start daemon # start daemon
nohup lotus daemon --lotus-make-genesis=devgen.car --profile=bootstrapper --genesis-template=localnet.json --bootstrap=false > /var/log/lotus.log 2>&1 & # /root/.lotus-shared/devgen.car path
nohup lotus daemon --lotus-make-genesis=/root/.lotus-shared/devgen.car --profile=bootstrapper --genesis-template=/root/data/localnet.json --bootstrap=false > /var/log/lotus.log 2>&1 &
# Loop until the daemon is started # Loop until the daemon is started
echo "Waiting for daemon to start..." echo "Waiting for daemon to start..."
@ -29,22 +33,18 @@ while ! grep -q "started ChainNotify channel" /var/log/lotus.log ; do
done done
echo "Daemon started." echo "Daemon started."
# copy genesis file to shared volume
cp /devgen.car /root/.lotus-shared
# publish bootnode peer info to shared volume # publish bootnode peer info to shared volume
# TODO: Improve exporting public address to shared volume lotus net listen | grep "$(ip addr | grep inet | grep -v '127.0.0.1' | sort | head -1 | awk '{print $2}' | cut -d '/' -f1)" | head -1 > /root/.lotus-shared/miner.addr
lotus net listen | awk 'NR==4{print}' > /root/.lotus-shared/miner.addr
# if miner not already initialized # if miner not already initialized
if [ ! -d $LOTUS_MINER_PATH ]; then if [ ! -d $LOTUS_MINER_PATH ]; then
# initialize miner # initialize miner
lotus wallet import --as-default ~/.genesis-sectors/pre-seal-t01000.key lotus wallet import --as-default /root/data/.genesis-sectors/pre-seal-t01000.key
# fund a known account for usage # fund a known account for usage
/fund-account.sh /fund-account.sh
lotus-miner init --genesis-miner --actor=t01000 --sector-size=2KiB --pre-sealed-sectors=~/.genesis-sectors --pre-sealed-metadata=~/.genesis-sectors/pre-seal-t01000.json --nosync lotus-miner init --genesis-miner --actor=t01000 --sector-size=2KiB --pre-sealed-sectors=/root/data/.genesis-sectors --pre-sealed-metadata=/root/data/.genesis-sectors/pre-seal-t01000.json --nosync
fi fi
# start miner # start miner

View File

@ -9,20 +9,17 @@ while [ ! -f /root/.lotus-shared/miner.addr ]; do
done done
echo "Resuming..." echo "Resuming..."
# if not already initialized # init node config
if [ ! -f $LOTUS_PATH/config.toml ]; then mkdir -p $LOTUS_PATH
# init node config lotus config default > $LOTUS_PATH/config.toml
mkdir $LOTUS_PATH
lotus config default > $LOTUS_PATH/config.toml
# add bootstrap peer info if available # add bootstrap peer info if available
if [ -f /root/.lotus-shared/miner.addr ]; then if [ -f /root/.lotus-shared/miner.addr ]; then
MINER_ADDR=\"$(cat /root/.lotus-shared/miner.addr)\" MINER_ADDR=\"$(cat /root/.lotus-shared/miner.addr)\"
# add bootstrap peer id to config file # add bootstrap peer id to config file
sed -i "/^\[Libp2p\]/a \ \ BootstrapPeers = [$MINER_ADDR]" $LOTUS_PATH/config.toml sed -i "/^\[Libp2p\]/a \ \ BootstrapPeers = [$MINER_ADDR]" $LOTUS_PATH/config.toml
else else
echo "Bootstrap peer info not found, unable to configure. Manual peering will be required." echo "Bootstrap peer info not found, unable to configure. Manual peering will be required."
fi
fi fi
# start node # start node

View File

@ -99,7 +99,7 @@ CMD ["-help"]
FROM lotus-base AS lotus-all-in-one FROM lotus-base AS lotus-all-in-one
# Install netcat for healthcheck # Install netcat for healthcheck
RUN apt-get update && apt-get install -y netcat RUN apt-get update && apt-get install -y netcat && apt-get install -y iproute2
ENV FILECOIN_PARAMETER_CACHE /var/tmp/filecoin-proof-parameters ENV FILECOIN_PARAMETER_CACHE /var/tmp/filecoin-proof-parameters
ENV LOTUS_MINER_PATH /var/lib/lotus-miner ENV LOTUS_MINER_PATH /var/lib/lotus-miner

View File

@ -55,7 +55,7 @@ This should create the required docker images in the local image registry.
## Clean up ## Clean up
Stop all the services running in background run: Stop all the services running in background:
```bash ```bash
laconic-so --stack azimuth deploy-system down laconic-so --stack azimuth deploy-system down

View File

@ -14,6 +14,9 @@ $ laconic-so --stack fixturenet-lotus build-containers
``` ```
$ laconic-so --stack fixturenet-lotus deploy --cluster lotus up $ laconic-so --stack fixturenet-lotus deploy --cluster lotus up
``` ```
Note: When running for the first time (or after clean up), the services will take some time to start properly as the Lotus nodes download the proof params (which are persisted to volumes)
Correct operation should be verified by checking the container logs with: Correct operation should be verified by checking the container logs with:
``` ```
$ laconic-so --stack fixturenet-lotus deploy --cluster lotus logs lotus-miner $ laconic-so --stack fixturenet-lotus deploy --cluster lotus logs lotus-miner
@ -26,3 +29,19 @@ $ laconic-so --stack fixturenet-lotus deploy --cluster lotus exec lotus-miner "l
$ laconic-so --stack fixturenet-lotus deploy --cluster lotus exec lotus-node-1 "lotus status" $ laconic-so --stack fixturenet-lotus deploy --cluster lotus exec lotus-node-1 "lotus status"
$ laconic-so --stack fixturenet-lotus deploy --cluster lotus exec lotus-node-2 "lotus status" $ laconic-so --stack fixturenet-lotus deploy --cluster lotus exec lotus-node-2 "lotus status"
``` ```
## 4. Clean up
Stop all the services running in background:
```
$ laconic-so --stack fixturenet-lotus deploy --cluster lotus down
```
Clear volumes created by this stack:
```
# List all relevant volumes
$ docker volume ls -q --filter "name=lotus"
# Remove all the listed volumes
$ docker volume rm $(docker volume ls -q --filter "name=lotus")
```

View File

@ -93,7 +93,7 @@ Follow the [demo](./demo.md) to try out the MobyMask app with L2 chain
## Clean up ## Clean up
Stop all the services running in background run: Stop all the services running in background:
```bash ```bash
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 down 30 laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 down 30

View File

@ -22,13 +22,15 @@ Deploy the stack:
laconic-so --stack sushiswap deploy --cluster sushiswap up laconic-so --stack sushiswap deploy --cluster sushiswap up
``` ```
Note: When running for the first time (or after clean up), the services will take some time to start as Lotus nodes in the fixturenet download the proof params
## Tests ## Tests
Follow [smoke-tests.md](./smoke-tests.md) to run smoke tests Follow [smoke-tests.md](./smoke-tests.md) to run smoke tests
## Clean up ## Clean up
Stop all the services running in background run: Stop all the services running in background:
```bash ```bash
laconic-so --stack sushiswap deploy --cluster sushiswap down laconic-so --stack sushiswap deploy --cluster sushiswap down