Skip to content

Commit d83a02d

Browse files
committed
Add config to start up a second miner on localnet so you can test things like replication between them
1 parent e332bc1 commit d83a02d

File tree

4 files changed

+187
-2
lines changed

4 files changed

+187
-2
lines changed

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ COPY boost/docker/devnet/booster-http/entrypoint.sh /app/entrypoint-booster-http
3939
COPY boost/docker/devnet/booster-bitswap/entrypoint.sh /app/entrypoint-booster-bitswap.sh
4040
COPY boost/docker/devnet/lotus/entrypoint.sh /app/entrypoint-lotus.sh
4141
COPY boost/docker/devnet/lotus-miner/entrypoint.sh /app/entrypoint-lotus-miner.sh
42+
COPY scripts/* /app/
4243

4344
## Test everything starts
4445
RUN lotus -v && lotus-miner -v && lotus-seed -v && \

docker-compose.yaml

+137-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ services:
4242
volumes:
4343
- ./data/lotus:/var/lib/lotus:rw
4444
- ./data/genesis:/var/lib/genesis:rw
45-
# - ${FIL_PROOFS_PARAMETER_CACHE}:/var/tmp/filecoin-proof-parameters:rw
45+
4646

4747
lotus-miner:
4848
container_name: lotus-miner
@@ -80,6 +80,42 @@ services:
8080
- ./data/genesis:/var/lib/genesis:ro
8181
# - ${FIL_PROOFS_PARAMETER_CACHE}:/var/tmp/filecoin-proof-parameters:rw
8282

83+
lotus-miner2:
84+
container_name: lotus-miner2
85+
image: ${IMAGE}
86+
entrypoint: ['/app/entrypoint-lotus-miner2.sh']
87+
profiles: ["replication"]
88+
healthcheck:
89+
test: >-
90+
curl -s http://lotus-miner2:2345 || exit 1
91+
interval: 20s
92+
retries: 5
93+
start_period: 6000s
94+
timeout: 10s
95+
depends_on:
96+
lotus-miner:
97+
condition: service_healthy
98+
ports:
99+
- "2346:2345"
100+
environment:
101+
- LOTUS_PATH=/var/lib/lotus
102+
- LOTUS_MINER_PATH=/var/lib/lotus-miner
103+
- LOTUS_API_LISTENADDRESS=/dns/lotus-miner2/tcp/2345/http
104+
- LOTUS_API_REMOTELISTENADDRESS=lotus-miner2:2345
105+
- LOTUS_SEALING_BATCHPRECOMMITS=false
106+
- LOTUS_SEALING_AGGREGATECOMMITS=false
107+
- LOTUS_SUBSYSTEMS_ENABLEMARKETS=false
108+
- LOTUS_SEALING_WAITDEALSDELAY=20s
109+
- GENESIS_PATH=/var/lib/genesis
110+
- SECTOR_SIZE=${SECTOR_SIZE}
111+
# - LOTUS_SKIP_GENESIS_CHECK=_yes_
112+
restart: unless-stopped
113+
logging: *default-logging
114+
volumes:
115+
- ./data/lotus-miner2:/var/lib/lotus-miner:rw
116+
- ./data/lotus:/var/lib/lotus:ro
117+
- ./data/genesis:/var/lib/genesis:ro
118+
83119
boost:
84120
container_name: boost
85121
image: ${IMAGE}
@@ -177,4 +213,103 @@ services:
177213
labels:
178214
- "com.docker-tc.enabled=1"
179215
- "com.docker-tc.delay=10ms"
180-
216+
217+
boost2:
218+
container_name: boost2
219+
image: ${IMAGE}
220+
profiles: ["replication"]
221+
entrypoint: ['/app/entrypoint-boost.sh']
222+
healthcheck:
223+
test: >-
224+
curl -s http://boost2:8080 || exit 1
225+
interval: 20s
226+
retries: 5
227+
start_period: 6000s
228+
timeout: 10s
229+
depends_on:
230+
lotus:
231+
condition: service_healthy
232+
lotus-miner2:
233+
condition: service_healthy
234+
ports:
235+
- "8081:8080"
236+
- "1289:1288" # For the /metrics endpoint
237+
- "50001:50000" # Exposed libp2p port
238+
environment:
239+
- LOTUS_API_LISTENADDRESS=/dns/boost2/tcp/1288/http
240+
- LOTUS_PATH=/var/lib/lotus
241+
- LOTUS_MINER_PATH=/var/lib/lotus-miner
242+
- LOTUS_TRACING_ENABLED=true
243+
- LOTUS_TRACING_SERVICENAME=boostd
244+
- LOTUS_TRACING_ENDPOINT=http://tempo:14268/api/traces
245+
restart: unless-stopped
246+
logging: *default-logging
247+
volumes:
248+
- ./data/boost2:/var/lib/boost:rw
249+
- ./data/lotus:/var/lib/lotus:ro
250+
- ./data/lotus-miner2:/var/lib/lotus-miner:ro
251+
- ./data/sample:/app/public:rw
252+
253+
booster-http2:
254+
container_name: booster-http2
255+
image: ${IMAGE}
256+
profiles: ["replication"]
257+
entrypoint: ['/app/entrypoint-booster-http.sh']
258+
healthcheck:
259+
test: >-
260+
curl http://127.0.0.1:7778/ || echo down
261+
interval: 20s
262+
retries: 5
263+
start_period: 6000s
264+
timeout: 10s
265+
depends_on:
266+
boost2:
267+
condition: service_healthy
268+
ports:
269+
- "7778:7777"
270+
environment:
271+
- BOOST_PATH=/var/lib/boost
272+
- LOTUS_PATH=/var/lib/lotus
273+
- LOTUS_MINER_PATH=/var/lib/lotus-miner
274+
restart: unless-stopped
275+
logging: *default-logging
276+
volumes:
277+
- ./data/boost2:/var/lib/boost:ro
278+
- ./data/lotus:/var/lib/lotus:ro
279+
- ./data/lotus-miner2:/var/lib/lotus-miner:ro
280+
labels:
281+
- "com.docker-tc.enabled=1"
282+
- "com.docker-tc.delay=10ms"
283+
284+
booster-bitswap2:
285+
container_name: booster-bitswap2
286+
image: ${IMAGE}
287+
profiles: ["replication"]
288+
entrypoint: ['/app/entrypoint-booster-bitswap.sh']
289+
healthcheck:
290+
test: >-
291+
printf "" > /dev/tcp/127.0.0.1/8889 || echo down
292+
interval: 20s
293+
retries: 5
294+
start_period: 6000s
295+
timeout: 10s
296+
depends_on:
297+
boost2:
298+
condition: service_healthy
299+
ports:
300+
- "8889:8888"
301+
environment:
302+
- BOOSTER_BITSWAP_REPO=/var/lib/booster-bitswap
303+
- BOOST_PATH=/var/lib/boost
304+
- LOTUS_PATH=/var/lib/lotus
305+
- LOTUS_MINER_PATH=/var/lib/lotus-miner
306+
restart: unless-stopped
307+
logging: *default-logging
308+
volumes:
309+
- ./data/booster-bitswap2:/var/lib/booster-bitswap:rw
310+
- ./data/boost2:/var/lib/boost:ro
311+
- ./data/lotus:/var/lib/lotus:ro
312+
- ./data/lotus-miner2:/var/lib/lotus-miner:ro
313+
labels:
314+
- "com.docker-tc.enabled=1"
315+
- "com.docker-tc.delay=10ms"

scripts/entrypoint-lotus-miner2.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
echo Wait for lotus is ready ...
4+
lotus wait-api
5+
echo Lotus ready. Lets go
6+
echo Sector size: $SECTOR_SIZE
7+
if [ ! -f $LOTUS_MINER_PATH/.init.miner ]; then
8+
echo Import the genesis miner key ...
9+
lotus wallet import --as-default $GENESIS_PATH/pre-seal-t01001.key || echo "Already imported"
10+
export DEFAULT_WALLET=`lotus wallet default`
11+
12+
echo Init wallets ...
13+
export OWNER_WALLET=`lotus wallet new bls`
14+
export WORKER_WALLET=`lotus wallet new bls`
15+
16+
lotus send --from $DEFAULT_WALLET $OWNER_WALLET 10
17+
lotus send --from $DEFAULT_WALLET $WORKER_WALLET 10
18+
19+
lotus-miner init --owner=$OWNER_WALLET --worker=$WORKER_WALLET --sector-size=$SECTOR_SIZE --no-local-storage --actor=t01001 --pre-sealed-sectors=$GENESIS_PATH --pre-sealed-metadata=$GENESIS_PATH/pre-seal-t01001.json
20+
touch $LOTUS_MINER_PATH/.init.miner
21+
echo Done
22+
fi
23+
24+
echo Starting lotus miner ...
25+
exec lotus-miner run

scripts/entrypoint-lotus.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
if [ ! -f $LOTUS_PATH/.init.params ]; then
4+
echo Initializing fetch params ...
5+
lotus fetch-params $SECTOR_SIZE
6+
touch $LOTUS_PATH/.init.params
7+
echo Done
8+
fi
9+
10+
if [ ! -f $LOTUS_PATH/.init.genesis ]; then
11+
echo Initializing pre seal ...
12+
lotus-seed --sector-dir $GENESIS_PATH pre-seal --sector-size $SECTOR_SIZE --miner-addr t01000 --num-sectors 1
13+
lotus-seed --sector-dir $GENESIS_PATH pre-seal --sector-size $SECTOR_SIZE --miner-addr t01001 --num-sectors 1
14+
echo Initializing genesis ...
15+
lotus-seed --sector-dir $GENESIS_PATH genesis new $LOTUS_PATH/localnet.json
16+
echo Initializing address ...
17+
lotus-seed --sector-dir $GENESIS_PATH genesis add-miner $LOTUS_PATH/localnet.json $GENESIS_PATH/pre-seal-t01000.json
18+
lotus-seed --sector-dir $GENESIS_PATH genesis add-miner $LOTUS_PATH/localnet.json $GENESIS_PATH/pre-seal-t01001.json
19+
touch $LOTUS_PATH/.init.genesis
20+
echo Done
21+
fi
22+
23+
echo Starting lotus deamon ...
24+
exec lotus daemon --lotus-make-genesis=$LOTUS_PATH/devgen.car --genesis-template=$LOTUS_PATH/localnet.json --bootstrap=false

0 commit comments

Comments
 (0)