diff --git a/app/data/compose/docker-compose-fixturenet-lotus.yml b/app/data/compose/docker-compose-fixturenet-lotus.yml index 85a5f624..9c99406d 100644 --- a/app/data/compose/docker-compose-fixturenet-lotus.yml +++ b/app/data/compose/docker-compose-fixturenet-lotus.yml @@ -11,15 +11,13 @@ services: - ../config/fixturenet-lotus/genesis/devgen.car:/devgen.car - $HOME/stack-orchestrator/app/data/config/fixturenet-lotus/genesis/.genesis-sectors:/root/.genesis-sectors - lotus-shared:/root/.lotus-shared -# - lotus-local-net-shared:/root/.lotus-local-net healthcheck: - test: ["CMD-SHELL", "grep 'started ChainNotify channel' /var/log/lotus.log"] +# test: ["CMD-SHELL", "grep 'started ChainNotify channel' /var/log/lotus.log"] + test: ["CMD-SHELL", "[ -f /root/.lotus-shared/miner.addr ]"] interval: 10s timeout: 10s - retries: 5 - start_period: 30s -# depends_on: -# - fixturenet-lotus-bootnode + retries: 10 + start_period: 60s entrypoint: ["sh", "/docker-entrypoint-scripts.d/setup-miner.sh"] ports: - "1234" @@ -35,22 +33,11 @@ services: volumes: - ../config/fixturenet-lotus/setup-node.sh:/docker-entrypoint-scripts.d/setup-node.sh - ../config/fixturenet-lotus/genesis/devgen.car:/devgen.car -# - ../config/fixturenet-lotus/genesis/.genesis-sectors:/root/.genesis-sectors -# - ./myscripts/pre-seal-t01000.key:/root/.genesis-sectors/pre-seal-t01000.key -# - ./myscripts/pre-seal-t01000.json:/root/.genesis-sectors/pre-seal-t01000.json -# - lotus-local-net-shared:/root/.lotus-local-net - lotus-shared:/root/.lotus-shared -# healthcheck: -# test: ["CMD", "nc", "-v", "localhost", "8545"] -# interval: 30s -# timeout: 10s -# retries: 10 -# start_period: 3s depends_on: lotus-miner: condition: service_healthy entrypoint: ["sh", "/docker-entrypoint-scripts.d/setup-node.sh"] -# entrypoint: ["lotus", "--version"] ports: - "1234" - "2345" @@ -65,27 +52,16 @@ services: volumes: - ../config/fixturenet-lotus/setup-node.sh:/docker-entrypoint-scripts.d/setup-node.sh - ../config/fixturenet-lotus/genesis/devgen.car:/devgen.car -# - ../config/fixturenet-lotus/genesis/.genesis-sectors:/root/.genesis-sectors -# - ./myscripts/pre-seal-t01000.key:/root/.genesis-sectors/pre-seal-t01000.key -# - ./myscripts/pre-seal-t01000.json:/root/.genesis-sectors/pre-seal-t01000.json -# - lotus-local-net-shared:/root/.lotus-local-net - lotus-shared:/root/.lotus-shared -# healthcheck: -# test: ["CMD", "nc", "-v", "localhost", "8545"] -# interval: 30s -# timeout: 10s -# retries: 10 -# start_period: 3s depends_on: lotus-miner: condition: service_healthy entrypoint: ["sh", "/docker-entrypoint-scripts.d/setup-node.sh"] -# entrypoint: ["lotus", "--version"] ports: - "1234" - "2345" - "3456" - "1777" - volumes: - lotus-shared: \ No newline at end of file +volumes: + lotus-shared: \ No newline at end of file diff --git a/app/data/config/fixturenet-lotus/setup-miner.sh b/app/data/config/fixturenet-lotus/setup-miner.sh index 3ef48dc9..e87fc1e1 100644 --- a/app/data/config/fixturenet-lotus/setup-miner.sh +++ b/app/data/config/fixturenet-lotus/setup-miner.sh @@ -1,9 +1,26 @@ #!/bin/bash lotus --version -#lotus daemon --genesis=/devgen.car --profile=bootstrapper --bootstrap=false > /var/log/lotus.log 2>&1 -#lotus daemon --genesis=/devgen.car --bootstrap=false nohup lotus daemon --genesis=/devgen.car --profile=bootstrapper --bootstrap=false > /var/log/lotus.log 2>&1 & -# initialization check here +# Loop until the daemon is started +echo "Waiting for daemon to start..." +while ! grep -q "started ChainNotify channel" /var/log/lotus.log ; do + sleep 5 +done +echo "Daemon started." + +# if not already initialized +if [ ! -f /root/.lotus-shared/miner.addr ]; then + # initialize miner + lotus wallet import --as-default ~/.genesis-sectors/pre-seal-t01000.key + 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 + + # publish miner address to shared volume + lotus net listen | awk 'NR==1{print}' > /root/.lotus-shared/miner.addr +fi + +nohup lotus-miner run --nosync & + +tail -f /dev/null diff --git a/app/data/config/fixturenet-lotus/setup-node.sh b/app/data/config/fixturenet-lotus/setup-node.sh index fe9f17d2..0bcd4717 100644 --- a/app/data/config/fixturenet-lotus/setup-node.sh +++ b/app/data/config/fixturenet-lotus/setup-node.sh @@ -1,4 +1,24 @@ #!/bin/bash lotus --version -lotus daemon --genesis=/devgen.car + +##TODO: paths can use values from lotus-env.env file + +# if not already initialized +if [ ! -f /root/.lotus-local-net/config.toml ]; then + # init node config + mkdir $HOME/.lotus-local-net + lotus config default > $HOME/.lotus-local-net/config.toml + + # add bootstrap peer info if available + if [ -f /root/.lotus-shared/miner.addr ]; then + MINER_ADDR=\"$(cat /root/.lotus-shared/miner.addr)\" + # add bootstrap peer id to config file + sed -i "/^\[Libp2p\]/a \ \ BootstrapPeers = [$MINER_ADDR]" $HOME/.lotus-local-net/config.toml + else + echo "Bootstrap peer info not found, unable to configure. Manual peering will be required." + fi +fi + +# start node +lotus daemon --genesis=/devgen.car diff --git a/build/lib/app/data/build_tag.txt b/build/lib/app/data/build_tag.txt index f1a675f1..86b67fce 100644 --- a/build/lib/app/data/build_tag.txt +++ b/build/lib/app/data/build_tag.txt @@ -1,2 +1,2 @@ # This file should be re-generated running: scripts/create_build_tag_file.sh script -1.1.0-882374a-202305060108 +1.1.0-a6a1399-202305092241 diff --git a/build/lib/app/data/compose/docker-compose-fixturenet-lotus.yml b/build/lib/app/data/compose/docker-compose-fixturenet-lotus.yml index b07784dd..9c99406d 100644 --- a/build/lib/app/data/compose/docker-compose-fixturenet-lotus.yml +++ b/build/lib/app/data/compose/docker-compose-fixturenet-lotus.yml @@ -10,15 +10,14 @@ services: - ../config/fixturenet-lotus/setup-miner.sh:/docker-entrypoint-scripts.d/setup-miner.sh - ../config/fixturenet-lotus/genesis/devgen.car:/devgen.car - $HOME/stack-orchestrator/app/data/config/fixturenet-lotus/genesis/.genesis-sectors:/root/.genesis-sectors -# - lotus-local-net-shared:/root/.lotus-local-net - # healthcheck: - # test: ["CMD-SHELL", "grep 'started ChainNotify channel' /var/log/lotus.log"] - # interval: 10s - # timeout: 10s - # retries: 5 - # start_period: 30s -# depends_on: -# - fixturenet-lotus-bootnode + - lotus-shared:/root/.lotus-shared + healthcheck: +# test: ["CMD-SHELL", "grep 'started ChainNotify channel' /var/log/lotus.log"] + test: ["CMD-SHELL", "[ -f /root/.lotus-shared/miner.addr ]"] + interval: 10s + timeout: 10s + retries: 10 + start_period: 60s entrypoint: ["sh", "/docker-entrypoint-scripts.d/setup-miner.sh"] ports: - "1234" @@ -34,20 +33,11 @@ services: volumes: - ../config/fixturenet-lotus/setup-node.sh:/docker-entrypoint-scripts.d/setup-node.sh - ../config/fixturenet-lotus/genesis/devgen.car:/devgen.car - - ../config/fixturenet-lotus/genesis/.genesis-sectors:/root/.genesis-sectors -# - ./myscripts/pre-seal-t01000.key:/root/.genesis-sectors/pre-seal-t01000.key -# - ./myscripts/pre-seal-t01000.json:/root/.genesis-sectors/pre-seal-t01000.json -# - lotus-local-net-shared:/root/.lotus-local-net -# healthcheck: -# test: ["CMD", "nc", "-v", "localhost", "8545"] -# interval: 30s -# timeout: 10s -# retries: 10 -# start_period: 3s -# depends_on: -# - fixturenet-lotus-1 + - lotus-shared:/root/.lotus-shared + depends_on: + lotus-miner: + condition: service_healthy entrypoint: ["sh", "/docker-entrypoint-scripts.d/setup-node.sh"] -# entrypoint: ["lotus", "--version"] ports: - "1234" - "2345" @@ -62,22 +52,16 @@ services: volumes: - ../config/fixturenet-lotus/setup-node.sh:/docker-entrypoint-scripts.d/setup-node.sh - ../config/fixturenet-lotus/genesis/devgen.car:/devgen.car - - ../config/fixturenet-lotus/genesis/.genesis-sectors:/root/.genesis-sectors -# - ./myscripts/pre-seal-t01000.key:/root/.genesis-sectors/pre-seal-t01000.key -# - ./myscripts/pre-seal-t01000.json:/root/.genesis-sectors/pre-seal-t01000.json -# - lotus-local-net-shared:/root/.lotus-local-net -# healthcheck: -# test: ["CMD", "nc", "-v", "localhost", "8545"] -# interval: 30s -# timeout: 10s -# retries: 10 -# start_period: 3s -# depends_on: -# - fixturenet-lotus-1 + - lotus-shared:/root/.lotus-shared + depends_on: + lotus-miner: + condition: service_healthy entrypoint: ["sh", "/docker-entrypoint-scripts.d/setup-node.sh"] -# entrypoint: ["lotus", "--version"] ports: - "1234" - "2345" - "3456" - "1777" + +volumes: + lotus-shared: \ No newline at end of file diff --git a/build/lib/app/data/config/fixturenet-lotus/setup-miner.sh b/build/lib/app/data/config/fixturenet-lotus/setup-miner.sh index 802ed8f5..e87fc1e1 100644 --- a/build/lib/app/data/config/fixturenet-lotus/setup-miner.sh +++ b/build/lib/app/data/config/fixturenet-lotus/setup-miner.sh @@ -1,5 +1,26 @@ #!/bin/bash lotus --version -#lotus daemon --genesis=/devgen.car --profile=bootstrapper --bootstrap=false > /var/log/lotus.log 2>&1 -lotus daemon --genesis=/devgen.car --bootstrap=false + +nohup lotus daemon --genesis=/devgen.car --profile=bootstrapper --bootstrap=false > /var/log/lotus.log 2>&1 & + +# Loop until the daemon is started +echo "Waiting for daemon to start..." +while ! grep -q "started ChainNotify channel" /var/log/lotus.log ; do + sleep 5 +done +echo "Daemon started." + +# if not already initialized +if [ ! -f /root/.lotus-shared/miner.addr ]; then + # initialize miner + lotus wallet import --as-default ~/.genesis-sectors/pre-seal-t01000.key + 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 + + # publish miner address to shared volume + lotus net listen | awk 'NR==1{print}' > /root/.lotus-shared/miner.addr +fi + +nohup lotus-miner run --nosync & + +tail -f /dev/null diff --git a/build/lib/app/data/config/fixturenet-lotus/setup-node.sh b/build/lib/app/data/config/fixturenet-lotus/setup-node.sh index fe9f17d2..0bcd4717 100644 --- a/build/lib/app/data/config/fixturenet-lotus/setup-node.sh +++ b/build/lib/app/data/config/fixturenet-lotus/setup-node.sh @@ -1,4 +1,24 @@ #!/bin/bash lotus --version -lotus daemon --genesis=/devgen.car + +##TODO: paths can use values from lotus-env.env file + +# if not already initialized +if [ ! -f /root/.lotus-local-net/config.toml ]; then + # init node config + mkdir $HOME/.lotus-local-net + lotus config default > $HOME/.lotus-local-net/config.toml + + # add bootstrap peer info if available + if [ -f /root/.lotus-shared/miner.addr ]; then + MINER_ADDR=\"$(cat /root/.lotus-shared/miner.addr)\" + # add bootstrap peer id to config file + sed -i "/^\[Libp2p\]/a \ \ BootstrapPeers = [$MINER_ADDR]" $HOME/.lotus-local-net/config.toml + else + echo "Bootstrap peer info not found, unable to configure. Manual peering will be required." + fi +fi + +# start node +lotus daemon --genesis=/devgen.car