Skip to content

Commit

Permalink
Merge pull request #128 from degen-lab/feat/add-signer-and-update-ver…
Browse files Browse the repository at this point in the history
…sions

Add signer and update versions
  • Loading branch information
wileyj authored Oct 28, 2024
2 parents 1b60fa7 + 420794a commit 9098ef2
Show file tree
Hide file tree
Showing 14 changed files with 260 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ Session.vim
node_modules/
stacks-node-follower/Config.toml
configurations/*/Config.toml
configurations/*/Signer.toml
configurations/private-testnet/*.toml

conf/*/Config.toml
conf/*/Signer.toml
conf/*/Config-with-bitcoin-flag.toml
conf/*/bitcoin.conf
conf/private-testnet/*.toml
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@ git clone https://github.com/stacks-network/stacks-blockchain-docker && cd stack
cp sample.env .env
```

### Sync from genesis
### Sync from genesis (no signer)

```bash
./manage.sh -n mainnet -a start
```

### Sync from genesis (with signer)

```bash
./manage.sh -n mainnet -a start -f signer
```

### Seed chainstate from Hiro Archiver

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. \
_**Note**: it can take a long time to process the data, and you'll need at a minimum roughly 150GB of free space_
_**Note**: it can take a long time to process the data, and you'll need at a minimum roughly 350GB of free space_

```bash
sudo ./scripts/seed-chainstate.sh
Expand Down
1 change: 1 addition & 0 deletions compose-files/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ services:
ports:
- ${STACKS_CORE_RPC_PORT:-20443}:${STACKS_CORE_RPC_PORT:-20443}
- ${STACKS_CORE_P2P_PORT:-20444}:${STACKS_CORE_P2P_PORT:-20444}
- ${NODE_METRICS_PORT:-9153}:${NODE_METRICS_PORT:-9153}
env_file:
- ${SCRIPTPATH}/.env
networks:
Expand Down
29 changes: 29 additions & 0 deletions compose-files/extra-services/signer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: "3.5"
services:
stacks-signer:
image: blockstack/stacks-signer:${STACKS_SIGNER_VERSION:-latest}
container_name: stacks-signer
restart: on-failure
volumes:
- ${SCRIPTPATH}/conf/${NETWORK}:/src/stacks-signer
- ${SCRIPTPATH}/persistent-data/${NETWORK}/stacks-signer:/root/stacks-signer/data
ports:
- ${SIGNER_METRICS_PORT:-9154}:${SIGNER_METRICS_PORT:-9154}
env_file:
- ${SCRIPTPATH}/.env
networks:
- default
profiles:
- stacks-blockchain
command:
[
"/bin/stacks-signer",
"run",
"--config",
"/src/stacks-signer/Signer.toml",
]
networks:
default:
name: ${DOCKER_NETWORK}
ipam:
driver: default
19 changes: 15 additions & 4 deletions conf/mainnet/Config.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ working_dir = "/root/stacks-blockchain/data"
rpc_bind = "0.0.0.0:20443"
p2p_bind = "0.0.0.0:20444"
bootstrap_node = "02196f005965cebe6ddc3901b7b1cc1aa7a88f305bb8c5893456b8f9a605923893@seed.mainnet.hiro.so:20444"

[[events_observer]]
endpoint = "stacks-blockchain-api:3700"
events_keys = ["*"]
prometheus_bind = "0.0.0.0:9153"
stacker = true

[burnchain]
chain = "bitcoin"
Expand All @@ -16,3 +14,16 @@ username = "stacks"
password = "foundation"
rpc_port = 8332
peer_port = 8333

[connection_options]
auth_token = "1234"
private_neighbors = false

[[events_observer]]
events_keys = ["stackerdb", "block_proposal", "burn_blocks"]
endpoint = "stacks-signer:30000"

[[events_observer]]
endpoint = "stacks-blockchain-api:3700"
events_keys = ["*"]
timeout_ms = 300_000
8 changes: 8 additions & 0 deletions conf/mainnet/Signer.toml.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_host = "stacks-blockchain:20443"
endpoint = "0.0.0.0:30000"
metrics_endpoint = "0.0.0.0:9154"
network = "mainnet"
db_path = "/root/stacks-signer/data/signer.sqlite"
auth_password = ""
stacks_private_key = ""
block_proposal_timeout_ms = 180000
17 changes: 13 additions & 4 deletions conf/mocknet/Config.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ rpc_bind = "0.0.0.0:20443"
p2p_bind = "0.0.0.0:20444"
wait_time_for_microblocks = 10000
use_test_genesis_chainstate = true

[[events_observer]]
endpoint = "stacks-blockchain-api:3700"
events_keys = ["*"]
prometheus_bind = "0.0.0.0:9153"
stacker = true

[burnchain]
chain = "bitcoin"
mode = "mocknet"
commit_anchor_block_within = 5000

[[events_observer]]
events_keys = ["stackerdb", "block_proposal", "burn_blocks"]
endpoint = "stacks-signer:30000"

[[events_observer]]
endpoint = "stacks-blockchain-api:3700"
events_keys = ["*"]
timeout_ms = 60_000

[[ustx_balance]]
# "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",
# "keyInfo": {
Expand Down Expand Up @@ -58,6 +65,8 @@ address = "STSTW15D618BSZQB85R058DS46THH86YQQY6XCB7"
amount = 100000000000000

[connection_options]
auth_token = "1234"
private_neighbors = false
read_only_call_limit_write_length = 0
read_only_call_limit_read_length = 100000
read_only_call_limit_write_count = 0
Expand Down
8 changes: 8 additions & 0 deletions conf/mocknet/Signer.toml.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_host = "stacks-blockchain:20443"
endpoint = "0.0.0.0:30000"
metrics_endpoint = "0.0.0.0:9154"
network = "testnet"
db_path = "/root/stacks-signer/data/signer.sqlite"
auth_password = ""
stacks_private_key = ""
block_proposal_timeout_ms = 180000
65 changes: 56 additions & 9 deletions conf/testnet/Config.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,32 @@
working_dir = "/root/stacks-blockchain/data"
rpc_bind = "0.0.0.0:20443"
p2p_bind = "0.0.0.0:20444"
bootstrap_node="029266faff4c8e0ca4f934f34996a96af481df94a89b0c9bd515f3536a95682ddc@seed.testnet.hiro.so:30444"
always_use_affirmation_maps = false
bootstrap_node = "029266faff4c8e0ca4f934f34996a96af481df94a89b0c9bd515f3536a95682ddc@seed.testnet.hiro.so:30444"
always_use_affirmation_maps = true
require_affirmed_anchor_blocks = true
pox_sync_sample_secs = 30
prometheus_bind = "0.0.0.0:9153"
stacker = true

[burnchain]
chain = "bitcoin"
mode = "xenon"
peer_host = "bitcoin.testnet.stacks.org"
username = "stacks"
password = "foundation"
rpc_port = 18332
peer_port = 18333
mode = "krypton"
peer_host = "bitcoin.regtest.hiro.so"
peer_port = 18444
pox_prepare_length = 100
pox_reward_length = 900

[connection_options]
auth_token = "1234"
private_neighbors = false

[[events_observer]]
events_keys = ["stackerdb", "block_proposal", "burn_blocks"]
endpoint = "stacks-signer:30000"

[[events_observer]]
endpoint = "stacks-blockchain-api:3700"
events_keys = ["*"]
timeout_ms = 60_000

[[ustx_balance]]
address = "ST2QKZ4FKHAH1NQKYKYAYZPY440FEPK7GZ1R5HBP2"
Expand All @@ -33,3 +44,39 @@ amount = 10000000000000000
[[ustx_balance]]
address = "ST2TFVBMRPS5SSNP98DQKQ5JNB2B6NZM91C4K3P7B"
amount = 10000000000000000

[[burnchain.epochs]]
epoch_name = "1.0"
start_height = 0

[[burnchain.epochs]]
epoch_name = "2.0"
start_height = 0

[[burnchain.epochs]]
epoch_name = "2.05"
start_height = 1

[[burnchain.epochs]]
epoch_name = "2.1"
start_height = 2

[[burnchain.epochs]]
epoch_name = "2.2"
start_height = 3

[[burnchain.epochs]]
epoch_name = "2.3"
start_height = 4

[[burnchain.epochs]]
epoch_name = "2.4"
start_height = 5

[[burnchain.epochs]]
epoch_name = "2.5"
start_height = 6

[[burnchain.epochs]]
epoch_name = "3.0"
start_height = 56_457
8 changes: 8 additions & 0 deletions conf/testnet/Signer.toml.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_host = "stacks-blockchain:20443"
endpoint = "0.0.0.0:30000"
metrics_endpoint = "0.0.0.0:9154"
network = "testnet"
db_path = "/root/stacks-signer/data/signer.sqlite"
auth_password = ""
stacks_private_key = ""
block_proposal_timeout_ms = 180000
24 changes: 19 additions & 5 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ _Note: Burnchchain environment variables defined in `./env` will overwrite value

- `.env`
- `./conf/mainnet/Config.toml`
- `./conf/mainnet/Signer.toml`
- `./conf/testnet/Config.toml`
- `./conf/testnet/Signer.toml`

## Environment Variables

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

### Stacks Signer Settings

#### 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.

| Name | Description | Default Value |
| ---------------------------- | ------------------------------------------------------------------------------------------------ | ------------- |
| `AUTH_TOKEN` | Authorization token for HTTP requests made from the signer to your Stacks node | `1234` |
| `SIGNER_PRIVATE_KEY` | The private key of the signer, on mainnet. | |
| `TESTNET_SIGNER_PRIVATE_KEY` | The private key of the signer, on testnet. | |
| `STACKS_SIGNER_PORT` | The port where the signer will expose an RPC endpoint for receiving events from your Stacks node | `30000` |
| `SIGNER_METRICS_PORT` | The port where the signer will expose an endpoint for reading metrics | `9154` |

### API Settings

#### Recommened to leave these settings _as is_
Expand Down Expand Up @@ -64,6 +79,7 @@ Most variables in `.env` shouldn't be modified, but there are a few you may wish
| `STACKS_LOG_DEBUG` | Verbose output logs | `0` |
| `STACKS_LOG_JSON` | Output logs in json format | `0` |
| `STACKS_SHUTDOWN_TIMEOUT` | Time to wait for Stacks Blockchain to shutdown properly.<br>_recommended to leave this at the default_ | `1200` |
| `NODE_METRICS_PORT` | The port where the node will expose an endpoint for reading metrics | `9153` |

### Burnchain Settings

Expand All @@ -81,8 +97,6 @@ Most variables in `.env` shouldn't be modified, but there are a few you may wish

| Name | Description | Default Value |
| --------------- | ------------------------------------- | ---------------------------- |
| `TBTC_HOST` | FQDN of bitcoin mainnnet host | `bitcoin.testnet.stacks.org` |
| `TBTC_RPC_USER` | RPC username for bitcoin mainnet host | `stacks` |
| `TBTC_RPC_PASS` | RPC password for bitcoin mainnet host | `foundation` |
| `TBTC_RPC_PORT` | RPC port for bitcoin mainnet host | `18332` |
| `TBTC_P2P_PORT` | P2P port for bitcoin mainnet host | `18333` |
| `TBTC_HOST` | FQDN of bitcoin testnet host | `bitcoin.regtest.hiro.so` |
| `TBTC_RPC_PORT` | RPC port for bitcoin testnet host | `18332` |
| `TBTC_P2P_PORT` | P2P port for bitcoin testnet host | `18333` |
13 changes: 12 additions & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ Usage:
-n|--network: [ mainnet | testnet | mocknet ]
-a|--action: [ start | stop | logs | reset | upgrade | import | export | bns ]
optional args:
-f|--flags: [ proxy ]
-f|--flags: [ signer,proxy ]
export: combined with 'logs' action, exports logs to a text file
ex: ./manage.sh -n mainnet -a start -f proxy
ex: ./manage.sh -n mainnet -a start -f signer,proxy
ex: ./manage.sh --network mainnet --action start --flags proxy
ex: ./manage.sh -n mainnet -a logs export
```
Expand All @@ -25,6 +26,16 @@ Usage:
./manage.sh -n <network> -a restart
```

#### With optional signer

```bash
./manage.sh -n <network> -a start -f signer
```

```bash
./manage.sh -n <network> -a restart -f signer
```

#### With optional proxy

```bash
Expand Down
Loading

0 comments on commit 9098ef2

Please sign in to comment.