Skip to content

Commit 2b632b3

Browse files
committed
add signer and update versions
Added signer docker compose file as extra service, which can be started with an optional flag on all available networks. Updated node and API versions to the latest ones.
1 parent 749aae7 commit 2b632b3

File tree

9 files changed

+191
-39
lines changed

9 files changed

+191
-39
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ Session.vim
2828
node_modules/
2929
stacks-node-follower/Config.toml
3030
configurations/*/Config.toml
31+
configurations/*/Signer.toml
3132
configurations/private-testnet/*.toml
3233

3334
conf/*/Config.toml
35+
conf/*/Signer.toml
3436
conf/*/Config-with-bitcoin-flag.toml
3537
conf/*/bitcoin.conf
3638
conf/private-testnet/*.toml

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ cp sample.env .env
2525
### Seed chainstate from Hiro Archiver
2626

2727
Using data from the [Hiro Archiver](https://docs.hiro.so/hiro-archive) service, this script will download the latest files, extract them and restore the postgres data. \
28-
_**Note**: it can take a long time to process the data, and you'll need at a minimum roughly 150GB of free space_
28+
_**Note**: it can take a long time to process the data, and you'll need at a minimum roughly 350GB of free space_
2929

3030
```bash
3131
sudo ./scripts/seed-chainstate.sh

conf/mainnet/Config.toml.sample

+14-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ working_dir = "/root/stacks-blockchain/data"
33
rpc_bind = "0.0.0.0:20443"
44
p2p_bind = "0.0.0.0:20444"
55
bootstrap_node = "02196f005965cebe6ddc3901b7b1cc1aa7a88f305bb8c5893456b8f9a605923893@seed.mainnet.hiro.so:20444"
6-
7-
[[events_observer]]
8-
endpoint = "stacks-blockchain-api:3700"
9-
retry_count = 255
10-
events_keys = ["*"]
6+
stacker = true
117

128
[burnchain]
139
chain = "bitcoin"
@@ -17,3 +13,16 @@ username = "stacks"
1713
password = "foundation"
1814
rpc_port = 8332
1915
peer_port = 8333
16+
17+
[connection_options]
18+
auth_token = "1234"
19+
private_neighbors = false
20+
21+
[[events_observer]]
22+
events_keys = ["stackerdb", "block_proposal", "burn_blocks"]
23+
endpoint = "stacks-signer:30000"
24+
25+
[[events_observer]]
26+
endpoint = "stacks-blockchain-api:3700"
27+
events_keys = ["*"]
28+
timeout_ms = 300_000

conf/mocknet/Config.toml.sample

+12-5
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@ rpc_bind = "0.0.0.0:20443"
33
p2p_bind = "0.0.0.0:20444"
44
wait_time_for_microblocks = 10000
55
use_test_genesis_chainstate = true
6-
7-
[[events_observer]]
8-
endpoint = "stacks-blockchain-api:3700"
9-
retry_count = 255
10-
events_keys = ["*"]
6+
stacker = true
117

128
[burnchain]
139
chain = "bitcoin"
1410
mode = "mocknet"
1511
commit_anchor_block_within = 5000
1612

13+
[[events_observer]]
14+
events_keys = ["stackerdb", "block_proposal", "burn_blocks"]
15+
endpoint = "stacks-signer:30000"
16+
17+
[[events_observer]]
18+
endpoint = "stacks-blockchain-api:3700"
19+
events_keys = ["*"]
20+
timeout_ms = 60_000
21+
1722
[[ustx_balance]]
1823
# "mnemonic": "point approve language letter cargo rough similar wrap focus edge polar task olympic tobacco cinnamon drop lawn boring sort trade senior screen tiger climb",
1924
# "keyInfo": {
@@ -59,6 +64,8 @@ address = "STSTW15D618BSZQB85R058DS46THH86YQQY6XCB7"
5964
amount = 100000000000000
6065

6166
[connection_options]
67+
auth_token = "1234"
68+
private_neighbors = false
6269
read_only_call_limit_write_length = 0
6370
read_only_call_limit_read_length = 100000
6471
read_only_call_limit_write_count = 0

conf/testnet/Config.toml.sample

+55-10
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,31 @@
22
working_dir = "/root/stacks-blockchain/data"
33
rpc_bind = "0.0.0.0:20443"
44
p2p_bind = "0.0.0.0:20444"
5-
bootstrap_node="029266faff4c8e0ca4f934f34996a96af481df94a89b0c9bd515f3536a95682ddc@seed.testnet.hiro.so:30444"
6-
always_use_affirmation_maps = false
5+
bootstrap_node = "029266faff4c8e0ca4f934f34996a96af481df94a89b0c9bd515f3536a95682ddc@seed.testnet.hiro.so:30444"
6+
always_use_affirmation_maps = true
7+
require_affirmed_anchor_blocks = true
8+
pox_sync_sample_secs = 30
9+
stacker = true
710

811
[burnchain]
9-
chain = "bitcoin"
10-
mode = "xenon"
11-
peer_host = "bitcoin.testnet.stacks.org"
12-
username = "stacks"
13-
password = "foundation"
14-
rpc_port = 18332
15-
peer_port = 18333
12+
mode = "krypton"
13+
peer_host = "bitcoin.regtest.hiro.so"
14+
peer_port = 18444
15+
pox_prepare_length = 100
16+
pox_reward_length = 900
17+
18+
[connection_options]
19+
auth_token = "1234"
20+
private_neighbors = false
21+
22+
[[events_observer]]
23+
events_keys = ["stackerdb", "block_proposal", "burn_blocks"]
24+
endpoint = "stacks-signer:30000"
1625

1726
[[events_observer]]
1827
endpoint = "stacks-blockchain-api:3700"
19-
retry_count = 255
2028
events_keys = ["*"]
29+
timeout_ms = 60_000
2130

2231
[[ustx_balance]]
2332
address = "ST2QKZ4FKHAH1NQKYKYAYZPY440FEPK7GZ1R5HBP2"
@@ -34,3 +43,39 @@ amount = 10000000000000000
3443
[[ustx_balance]]
3544
address = "ST2TFVBMRPS5SSNP98DQKQ5JNB2B6NZM91C4K3P7B"
3645
amount = 10000000000000000
46+
47+
[[burnchain.epochs]]
48+
epoch_name = "1.0"
49+
start_height = 0
50+
51+
[[burnchain.epochs]]
52+
epoch_name = "2.0"
53+
start_height = 0
54+
55+
[[burnchain.epochs]]
56+
epoch_name = "2.05"
57+
start_height = 1
58+
59+
[[burnchain.epochs]]
60+
epoch_name = "2.1"
61+
start_height = 2
62+
63+
[[burnchain.epochs]]
64+
epoch_name = "2.2"
65+
start_height = 3
66+
67+
[[burnchain.epochs]]
68+
epoch_name = "2.3"
69+
start_height = 4
70+
71+
[[burnchain.epochs]]
72+
epoch_name = "2.4"
73+
start_height = 5
74+
75+
[[burnchain.epochs]]
76+
epoch_name = "2.5"
77+
start_height = 6
78+
79+
[[burnchain.epochs]]
80+
epoch_name = "3.0"
81+
start_height = 56_457

docs/config.md

+17-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ _Note: Burnchchain environment variables defined in `./env` will overwrite value
55

66
- `.env`
77
- `./conf/mainnet/Config.toml`
8+
- `./conf/mainnet/Signer.toml`
89
- `./conf/testnet/Config.toml`
10+
- `./conf/testnet/Signer.toml`
911

1012
## Environment Variables
1113

@@ -19,10 +21,22 @@ Most variables in `.env` shouldn't be modified, but there are a few you may wish
1921
| `DOCKER_NETWORK` | Name of docker network used to launch services | `stacks` |
2022
| `EXPOSE_POSTGRES` | Expose postgres service to the host OS | `false` |
2123
| `STACKS_BLOCKCHAIN_VERSION` | Stacks Blockchain Docker image version | `latest released version` |
24+
| `STACKS_SIGNER_VERSION` | Stacks Signer Docker image version | `latest released version` |
2225
| `STACKS_BLOCKCHAIN_API_VERSION` | Stacks Blockchain API Docker image version | `latest released version` |
2326
| `POSTGRES_VERSION` | Postgres Docker image version | `14` |
2427
| `NGINX_PROXY_PORT` | HTTP port for the nginx proxy | `80` |
2528

29+
### Stacks Signer Settings
30+
31+
#### You must set values for the _SIGNER_PRIVATE_KEY_ on the specific network if you're running a signer, otherwise they can be left empty.
32+
33+
| Name | Description | Default Value |
34+
| ---------------------------- | ------------------------------------------------------------------------------------------------ | ------------- |
35+
| `AUTH_TOKEN` | Authorization token for HTTP requests made from the signer to your Stacks node | `1234` |
36+
| `SIGNER_PRIVATE_KEY` | The private key of the signer, on mainnet. | |
37+
| `TESTNET_SIGNER_PRIVATE_KEY` | The private key of the signer, on testnet. | |
38+
| `STACKS_SIGNER_PORT` | The port where the signer will expose an RPC endpoint for receiving events from your Stacks node | `30000` |
39+
2640
### API Settings
2741

2842
#### Recommened to leave these settings _as is_
@@ -81,8 +95,6 @@ Most variables in `.env` shouldn't be modified, but there are a few you may wish
8195

8296
| Name | Description | Default Value |
8397
| --------------- | ------------------------------------- | ---------------------------- |
84-
| `TBTC_HOST` | FQDN of bitcoin mainnnet host | `bitcoin.testnet.stacks.org` |
85-
| `TBTC_RPC_USER` | RPC username for bitcoin mainnet host | `stacks` |
86-
| `TBTC_RPC_PASS` | RPC password for bitcoin mainnet host | `foundation` |
87-
| `TBTC_RPC_PORT` | RPC port for bitcoin mainnet host | `18332` |
88-
| `TBTC_P2P_PORT` | P2P port for bitcoin mainnet host | `18333` |
98+
| `TBTC_HOST` | FQDN of bitcoin testnet host | `bitcoin.regtest.hiro.so` |
99+
| `TBTC_RPC_PORT` | RPC port for bitcoin testnet host | `18332` |
100+
| `TBTC_P2P_PORT` | P2P port for bitcoin testnet host | `18333` |

docs/usage.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ Usage:
88
-n|--network: [ mainnet | testnet | mocknet ]
99
-a|--action: [ start | stop | logs | reset | upgrade | import | export | bns ]
1010
optional args:
11-
-f|--flags: [ proxy ]
11+
-f|--flags: [ signer,proxy ]
1212
export: combined with 'logs' action, exports logs to a text file
1313
ex: ./manage.sh -n mainnet -a start -f proxy
14+
ex: ./manage.sh -n mainnet -a start -f signer,proxy
1415
ex: ./manage.sh --network mainnet --action start --flags proxy
1516
ex: ./manage.sh -n mainnet -a logs export
1617
```
@@ -25,6 +26,16 @@ Usage:
2526
./manage.sh -n <network> -a restart
2627
```
2728

29+
#### With optional signer
30+
31+
```bash
32+
./manage.sh -n <network> -a start -f signer
33+
```
34+
35+
```bash
36+
./manage.sh -n <network> -a restart -f signer
37+
```
38+
2839
#### With optional proxy
2940

3041
```bash

manage.sh

100755100644
+64-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ shopt -s expand_aliases
88
export NETWORK="mainnet"
99
export ACTION=""
1010
export PROFILE="stacks-blockchain"
11+
SIGNER=false
1112
STACKS_CHAIN_ID="2147483648"
1213
STACKS_SHUTDOWN_TIMEOUT=1200 # default to 20 minutes, during sync it can take a long time to stop the runloop
1314
LOG_TAIL="100"
@@ -154,9 +155,10 @@ usage() {
154155
log " -n|--network: [ mainnet | testnet | mocknet ]"
155156
log " -a|--action: [ start | stop | logs | reset | upgrade | import | export | bns ]"
156157
log " optional args:"
157-
log " -f|--flags: [ proxy ]"
158+
log " -f|--flags: [ signer,proxy ]"
158159
log " export: combined with 'logs' action, exports logs to a text file"
159160
log " ex: ${COLCYAN}${0} -n mainnet -a start -f proxy${COLRESET}"
161+
log " ex: ${COLCYAN}${0} -n mainnet -a start -f signer,proxy${COLRESET}"
160162
log " ex: ${COLCYAN}${0} --network mainnet --action start --flags proxy${COLRESET}"
161163
log " ex: ${COLCYAN}${0} -n mainnet -a logs export${COLRESET}"
162164
echo
@@ -434,14 +436,62 @@ events_file_env(){
434436

435437
# Function that updates Config.toml
436438
update_configs(){
437-
if [ "${NETWORK}" == "testnet" ]; then
439+
if [ "${NETWORK}" == "testnet" ]; then
438440
BTC_HOST=${TBTC_HOST}
439441
BTC_RPC_USER=${TBTC_RPC_USER}
440442
BTC_RPC_PASS=${TBTC_RPC_PASS}
441443
BTC_RPC_PORT=${TBTC_RPC_PORT}
442444
BTC_P2P_PORT=${TBTC_P2P_PORT}
443-
fi
445+
SIGNER_PRIVATE_KEY=${TESTNET_SIGNER_PRIVATE_KEY}
446+
fi
444447
CONFIG_TOML="${SCRIPTPATH}/conf/${NETWORK}/Config.toml"
448+
SIGNER_TOML="${SCRIPTPATH}/conf/${NETWORK}/Signer.toml"
449+
450+
## update Config.toml with signer options
451+
if [ "${SIGNER}" != "true" ]; then
452+
${VERBOSE} && log "${COLYELLOW}Disabling signer options in ${CONFIG_TOML}${COLRESET}"
453+
sed -i.tmp "
454+
/^\[\[events_observer\]\]/{
455+
:a
456+
N
457+
/endpoint.*stacks-signer/!ba
458+
s/^/#/mg
459+
}
460+
/^stacker = true/ s/^/#/
461+
" "${CONFIG_TOML}" || {
462+
log_exit "Unable to update values in Config.toml file: ${COLCYAN}${CONFIG_TOML}${COLRESET}"
463+
}
464+
else
465+
[ ! ${SIGNER_PRIVATE_KEY} ] && log_exit "Signer private key not set!"
466+
${VERBOSE} && log "${COLYELLOW}Enabling signer options in ${CONFIG_TOML}${COLRESET}"
467+
sed -i.tmp "
468+
/^#\[\[events_observer\]\]/{
469+
:a
470+
N
471+
/endpoint.*stacks-signer/!ba
472+
s/^#//mg
473+
}
474+
/^#stacker = true/ s/^#//
475+
" "${CONFIG_TOML}" || {
476+
log_exit "Unable to update values in Config.toml file: ${COLCYAN}${CONFIG_TOML}${COLRESET}"
477+
}
478+
479+
## update Signer.toml with env vars
480+
[[ ! -f "${SIGNER_TOML}" ]] && cp "${SIGNER_TOML}.sample" "${SIGNER_TOML}"
481+
${VERBOSE} && log "${COLYELLOW}Updating values in ${SIGNER_TOML} from .env${COLRESET}"
482+
$(sed -i.tmp "
483+
/^node_host/s/.*/node_host = \"${STACKS_CORE_RPC_HOST}:${STACKS_CORE_RPC_PORT}\"/;
484+
/^endpoint/s/.*/endpoint = \"0.0.0.0:${STACKS_SIGNER_PORT}\"/;
485+
/^auth_password/s/.*/auth_password = \"${AUTH_TOKEN}\"/;
486+
/^stacks_private_key/s/.*/stacks_private_key = \"${SIGNER_PRIVATE_KEY}\"/;
487+
" "${SIGNER_TOML}" 2>&1) || {
488+
log_exit "Unable to update values in Signer.toml file: ${COLCYAN}${SIGNER_TOML}${COLRESET}"
489+
}
490+
${VERBOSE} && log "${COLYELLOW}Deleting temp Signer.toml file: ${SIGNER_TOML}.tmp${COLRESET}"
491+
$(rm "${SIGNER_TOML}.tmp" 2>&1) || {
492+
log_exit "Unable to delete tmp Signer.toml file: ${COLCYAN}${SIGNER_TOML}.tmp${COLRESET}"
493+
}
494+
fi
445495

446496
## update Config.toml with btc vars
447497
[[ ! -f "${CONFIG_TOML}" ]] && cp "${CONFIG_TOML}.sample" "${CONFIG_TOML}"
@@ -452,6 +502,8 @@ update_configs(){
452502
/^password/s/.*/password = \"${BTC_RPC_PASS}\"/;
453503
/^rpc_port/s/.*/rpc_port = ${BTC_RPC_PORT}/;
454504
/^peer_port/s/.*/peer_port = ${BTC_P2P_PORT}/;
505+
/^auth_token/s/.*/auth_token = \"${AUTH_TOKEN}\"/;
506+
/^endpoint = \"stacks-signer/s/.*/endpoint = \"stacks-signer:${STACKS_SIGNER_PORT}\"/;
455507
" "${CONFIG_TOML}" 2>&1) || {
456508
log_exit "Unable to update values in Config.toml file: ${COLCYAN}${CONFIG_TOML}${COLRESET}"
457509
}
@@ -547,6 +599,12 @@ docker_up() {
547599
if ! check_event_replay; then
548600
log_exit "Event-replay in progress. Refusing to start services"
549601
fi
602+
603+
# Set signer env based on flag
604+
if [[ "${FLAGS_ARRAY[*]}" == *"signer"* ]]; then
605+
SIGNER=true
606+
fi
607+
550608
# Sanity checks before starting services
551609
local param="-d"
552610
if [ "${PROFILE}" == "bns" ]; then
@@ -567,9 +625,10 @@ docker_up() {
567625
${VERBOSE} && log "created (recursive) persistent-data dir ${SCRIPTPATH}/persistent-data/${NETWORK}/event-replay"
568626
fi
569627
${VERBOSE} && log "Using existing data dir: ${SCRIPTPATH}/persistent-data/${NETWORK}"
570-
update_configs
571628
fi
572-
629+
630+
update_configs
631+
573632
# # See if we can detect a Hiro API major version change requiring an event-replay import
574633
# if check_api; then
575634
# log_warn " Required to perform a stacks-blockchain-api event-replay:"

0 commit comments

Comments
 (0)