Skip to content

Commit a6f53ed

Browse files
committed
Fix some logic issues in the snapshot restore target and update README
1 parent 2e873db commit a6f53ed

2 files changed

Lines changed: 49 additions & 40 deletions

File tree

Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,17 @@ PAUSE_HEIGHT ?= 999999999999
2828
CORES ?= $(shell cat /proc/cpuinfo | grep processor | wc -l)
2929
TIMEOUT ?= 120
3030

31+
# Create the chainstate dir and extract an archive to it when the "up" target is used
3132
$(CHAINSTATE_DIR): /usr/bin/tar /usr/bin/zstd
32-
@mkdir -p $@
33-
if [ -f "$(CHAINSTATE_ARCHIVE)" -a "$(MAKECMDGOALS)" = "up" ]; then
34-
sudo tar --same-owner -xf $(CHAINSTATE_ARCHIVE) -C $(CHAINSTATE_DIR) || false
33+
@mkdir -p $(CHAINSTATE_DIR)
34+
@if [ "$(TARGET)" = "up" ]; then
35+
if [ -f "$(CHAINSTATE_ARCHIVE)" ]; then
36+
sudo tar --same-owner -xf $(CHAINSTATE_ARCHIVE) -C $(CHAINSTATE_DIR) || exit 1
37+
else
38+
@echo "Chainstate archive ($(CHAINSTATE_ARCHIVE)) not found. Exiting"
39+
rm -rf $(CHAINSTATE_DIR)
40+
exit 1
41+
fi
3542
fi
3643

3744
# Boot the network from the local chainstate archive
@@ -119,6 +126,8 @@ snapshot: current-chainstate-dir down
119126
@if [ -d "$(ACTIVE_CHAINSTATE_DIR)/logs" ]; then \
120127
rm -rf $(ACTIVE_CHAINSTATE_DIR)/logs; \
121128
fi
129+
@echo "Creating snapshot: $(CHAINSTATE_ARCHIVE)"
130+
@echo "cd $(ACTIVE_CHAINSTATE_DIR); sudo tar --zstd -cf $(CHAINSTATE_ARCHIVE) *; cd $(PWD)"
122131
cd $(ACTIVE_CHAINSTATE_DIR); sudo tar --zstd -cf $(CHAINSTATE_ARCHIVE) *; cd $(PWD)
123132

124133
# pause all services in the network (netork is down, but recoverably with target 'unpause')

README.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@
22
Modified from: https://github.com/stacks-sbtc/sbtc/tree/v1.0.2/docker, changes:
33

44
- Deleted services related to sBTC, mempool and grafana
5-
- Added 5 stacks miners, by default there are 3 miners competing for mining
5+
- Configured for 3 stacks miners and signers
66
- bind-mounts a local filesystem for data persistence
7+
- Uses a chainstate archive to boot the network quickly
8+
- Configurable signing weight across the 3 signers
79

810
## Quickstart
911

10-
### Start network in Epoch 3.2
12+
### Start network using a chainstate archive
13+
*Note*: default chainstate archive at `./docker/chainstate.tar.zstd` will be used unless overridden by `CHAINSTATE_ARCHIVE` env var.
14+
1115
Creates a dynamic chainstate folder at `./docker/chainstate/$(date +%s)` from a chainstate archive
1216
```sh
1317
make up
1418
```
19+
To override the archive used to restore the network:
20+
```sh
21+
CHAINSTATE_ARCHIVE=./docker/chainsate_new.tar.zstd make up
22+
```
1523

1624
### Start network from genesis
1725
Creates a static chainstate folder at `./docker/chainstate/genesis`
@@ -92,6 +100,7 @@ CORES=10 TIMEOUT=60 make stress
92100
#### Create a chainstate snapshot
93101
- Setting the env var `PAUSE_HEIGHT` is optional to pause the chain at a specific height, else a default of Bitcoin block `999999999999` is used.
94102
- Setting the env var `MINE_INTERVAL_EPOCH3` is recommended to reach the `PAUSE_HEIGHT` more quickly to create the snapshot
103+
- Optionally, the `CHAINSTATE_ARCHIVE` env var may be set to store the archive in a non-default location/name
95104
**This operation will work with either the `up` or `genesis` targets**
96105
```sh
97106
make genesis
@@ -105,7 +114,30 @@ Once the Bitcoin miner has reached the specified height:
105114
```sh
106115
make snapshot
107116
```
108-
This will first bring down the network, then replace the existing `./docker/chainstate.tar.zstd` archive file used with the `up` Makefile targer
117+
This will first bring down the network, then replace the existing `./docker/chainstate.tar.zstd` archive file used with the `up` Makefile target.
118+
119+
To create the chainstate archive in a non-default location/name *File path must be absolute*:
120+
```sh
121+
CHAINSTATE_ARCHIVE=$(pwd)/docker/chainstate_new.tar.zstd make snapshot
122+
```
123+
124+
**Note**: `CHAINSTATE_ARCHIVE` must be defined to use with `make up` to use a non-default snapshot.
125+
ex:
126+
```sh
127+
CHAINSTATE_ARCHIVE=./docker/chainstate_new.tar.zstd make up
128+
```
129+
130+
#### Force stop the devnet network
131+
If the network is in a "stuck" state where the Makefile targets are not stopping the services (i.e. the `.current-chainstate-dir` file was removed while network was running), `down-force` may be used to force stop the network.
132+
133+
```sh
134+
make down-force
135+
```
136+
137+
Additionally, `clean` target will call `down-force` *and also* delete any chainstates on disk in `./docker/chainstate/*`
138+
```sh
139+
make clean
140+
```
109141

110142

111143
## Containers
@@ -118,6 +150,8 @@ This will first bring down the network, then replace the existing `./docker/chai
118150
- **stacks-signer-1**: event observer for stacks-miner-1
119151
- **stacks-signer-2**: event observer for stacks-miner-2
120152
- **stacks-signer-3**: event observer for stacks-miner-3
153+
- **stacks-api**: API instance receiving events from stacks-miner-1
154+
- **postgres**: postgres DB used by stacks-api
121155
- **stacker**: stack for `stacks-signer-1`, `stacks-signer-2` and `stacks-signer-3`
122156
- **tx-broadcaster**: submits token transfer txs to ensure stacks block production during a sortition
123157
- **monitor**: monitors block details and tracks stacking calls
@@ -175,40 +209,6 @@ This will first bring down the network, then replace the existing `./docker/chai
175209
176210
```
177211

178-
### Miner 4
179-
180-
```text
181-
‣ Mnemonic: report weasel jealous pizza long order section oak dignity radar combine project broom glass bridge pulp glory magic dutch toe undo patient photo core
182-
‣ Private Key: 2eafe91d1bf9a37a650717f208d16e7f3d4fda8563945ddd68894355eb237e3a01
183-
‣ Public Key: 03a667f9005f357702d8341dfa4718fb73aae590f96fb3e35c2943ec684f30d224
184-
‣ Stacks address: ST1FFP2RB883Y5NWM4KN86B1827JHGQ1AJ0H06EFV
185-
‣ BTC Address: mpBAYsNW5Cii7cVrEJKU3NPTJKw59AtEqf
186-
‣ WIF: cP9TN5ztLSQvii5ExoRB3FgNXqfknF36M5mA1GxkHe7yW9PjdChg
187-
‣ Miner Rewards
188-
‣ Stacks address: ST1235HCHDHFRSVX3EM4DFRTGJ0MK8FBYXNYXRE96
189-
‣ Private Key: 452b2a668a05ba3330c4d31ed8a8839302bf03fb869e4ca13a0f5e84875cfc1201
190-
‣ Mnemonic: call police remember square people duck shadow glue cook major long sustain sphere spare cup chase humble recipe sell orbit sudden labor apple organ
191-
‣ WIF: cPuA2MPKBXpKCfSq8wWABShe1LsYwQtSwrzRDsEMToYkzUuRGmN8
192-
193-
```
194-
195-
### Miner 5
196-
197-
```text
198-
‣ Mnemonic: position sport mango recycle thumb gasp lens zoo stand have mass prison icon stairs average silly grid swing famous trend hover ramp bunker raw
199-
‣ Private Key: 57e3f3bae2100348e300c48789da97e704fcdaed2e9a6327f2d2ca43039c5eb501
200-
‣ Public Key: 021f834b1abe414bda1024b30ba936091a0f1dc8cb677f67e266797ce11956520e
201-
‣ Stacks address: ST17P55SW82SJ1HF0AJ6AHFV70K5S0S0YH6C8RW9T
202-
‣ BTC Address: mnkhnR27DddFMU6FhFvGmEQBXQ1EaWqgce
203-
‣ WIF: cQXYoecjY477cZ98JLn5uwaPAYWkppk57HgW3TjEMZpyo8pqmFdC
204-
‣ Miner Rewards
205-
‣ Stacks address: ST2RT3Z1ETNWMTV7CSCC3WAT6QM560N9E8V87ANJQ
206-
‣ Private Key: 9ffcae72c15c361f05f7ccd09e03d212bef00bf57706ee90f209cf8b51b429df01
207-
‣ Mnemonic: spider cinnamon short adapt bird cherry crane burger liar order giant jungle purity dignity call diesel anxiety wife fiscal enhance tool amused immense gaze
208-
‣ WIF: cSwhJ2fb8wVednntbodDydckisuQ3tMFSVx2hZcoUeYiJ3Q2g71k
209-
210-
```
211-
212212
## Signer Accounts
213213

214214
### Signer 1

0 commit comments

Comments
 (0)