Browse Source

docs: adding docker steps to other tutorials

feat/stacks-js-updates
Alexander Graebe 4 years ago
parent
commit
28048deee9
  1. 1
      src/common/navigation.yaml
  2. 91
      src/pages/mining.md
  3. 197
      src/pages/stacks-blockchain/running-in-docker.md
  4. 26
      src/pages/stacks-blockchain/running-testnet-node.md

1
src/common/navigation.yaml

@ -60,7 +60,6 @@ sections:
- path: /managing-accounts
- path: /sending-tokens
- path: /running-testnet-node
- path: /running-in-docker
- path: /integrate-stacking
- title: Stacks 1.0
pages:

91
src/pages/mining.md

@ -111,10 +111,99 @@ cd ../..
./target/release/stacks-node start --config=./testnet/conf/krypton-follower-conf.toml
```
## Enable debug logging
### Enable debug logging
In case you are running into issues or would like to see verbose logging, you can run your node with debug logging enabled. In the command line, run:
```bash
BLOCKSTACK_DEBUG=1 stacks-node krypton
```
## Optional: Running with Docker
Alternatively, you can run the testnet node with Docker.
-> Ensure you have [Docker](https://docs.docker.com/get-docker/) installed on your machine.
### Create a config file directory
You need a dedicated directory to keep the config file(s):
```bash
mkdir -p $HOME/stacks
```
### Generate keychain and get testnet tokens
Generate a keychain:
```bash
docker run -i node:alpine npx blockstack-cli@1.1.0-beta.1 make_keychain -t
```
Run the faucet:
```bash
# replace <btc_address> with `btcAddress` property from your keychain
curl -XPOST "https://stacks-node-api.blockstack.org/extended/v1/faucets/btc?address=<btc_address>" | json_pp
```
### Create configuration file
Inside the new `$HOME/stacks` folder, you should create a new miner config `Config.toml`:
```toml
[node]
working_dir = "/root/stacks-node/current"
rpc_bind = "0.0.0.0:20443"
p2p_bind = "0.0.0.0:20444"
# Enter your private key here!
seed = "replace-with-your-privateKey-from-above"
miner = true
[burnchain]
chain = "bitcoin"
mode = "krypton"
peer_host = "bitcoind.krypton.blockstack.org"
#process_exit_at_block_height = 5340
#burnchain_op_tx_fee = 5500
#commit_anchor_block_within = 10000
rpc_port = 18443
peer_port = 18444
[[mstx_balance]]
address = "STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6"
amount = 10000000000000000
[[mstx_balance]]
address = "ST11NJTTKGVT6D1HY4NJRVQWMQM7TVAR091EJ8P2Y"
amount = 10000000000000000
[[mstx_balance]]
address = "ST1HB1T8WRNBYB0Y3T7WXZS38NKKPTBR3EG9EPJKR"
amount = 10000000000000000
[[mstx_balance]]
address = "STRYYQQ9M8KAF4NS7WNZQYY59X93XEKR31JP64CP"
amount = 10000000000000000
```
-> Notice that this configuration differs from the one used to run the miner locally
### Run the miner
```bash
docker run -d \
--name stacks_miner \
--rm \ # remove this to persist data across restarts
-e RUST_BACKTRACE="full" \ # remove to disable debug logs
-e BLOCKSTACK_DEBUG="1" \ # remove to disable debug logs
-v "$HOME/stacks/Config.toml:/src/stacks-node/Config.toml" \
-p 20443:20443 \
-p 20444:20444 \
blockstack/stacks-blockchain:v23.0.0.6-krypton \
/bin/stacks-node start --config /src/stacks-node/Config.toml
```
You can review the node logs with this command:
```bash
docker logs -f stacks_miner
```

197
src/pages/stacks-blockchain/running-in-docker.md

@ -1,197 +0,0 @@
---
title: Running a testnet node with Docker
description: Set up and run a miner on the Stacks 2.0 testnet with Docker
icon: TestnetIcon
duration: 10 minutes
experience: beginners
tags:
- tutorial
images:
large: /images/pages/testnet.svg
sm: /images/pages/testnet-sm.svg
---
## Introduction:
This tutorial will walk you through the following steps:
- Run the node with Docker
- Mine Stacks token with Docker
## Requirements:
- a computer
- [Docker](https://docs.docker.com/get-docker/)
- a keyboard and monitor
- `jq` binary (if not installed, run the commands **without** `| jq`)
- dedicated directory to keep the config file(s)
- i.e. for \*Nix, `$HOME/stacks`: `mkdir -p $HOME/stacks`
### Create Seed
_Note: following command can take a few minutes to install dependencies and output data_
Generate keychain:
```bash
docker run -i node:alpine npx blockstack-cli@1.1.0-beta.1 make_keychain -t | jq
```
Example Output (_`EACCES` error can be ignored_):
```json
{
"mnemonic": "exhaust spin topic distance hole december impulse gate century absent breeze ostrich armed clerk oak peace want scrap auction sniff cradle siren blur blur",
"keyInfo": {
"privateKey": "2033269b55026ff2eddaf06d2e56938f7fd8e9d697af8fe0f857bb5962894d5801",
"address": "STTX57EGWW058FZ6WG3WS2YRBQ8HDFGBKEFBNXTF",
"btcAddress": "mkRYR7KkPB1wjxNjVz3HByqAvVz8c4B6ND",
"index": 0
}
}
```
### Request BTC from the faucet
_replace 'btc_address' with `btcAddress` property from your keychain_
Request BTC:
```bash
curl -XPOST "https://stacks-node-api.blockstack.org/extended/v1/faucets/btc?address=<btc_address>" | jq
```
Example Output:
```json
{
"txid": "1970274d25f7ecb7f4ac1f992059d52fd9c393fdc1610b58ba1d279b7f6f8a0e",
"raw_tx": "0200000001fa6e50dff221a46e3b98fb78658929731773047009974f275f41a8142339b0a3010000006a47304402202f11a4cd0f86cf5f4889a8dabe7f447062e3d59a52dd93ba702e5a9518959973022063bc4bb0c5e5423c457743bd6e34a1484d6a836c7f61a8205757a9cffc8f98150121037328e8299133b6dbaec1e9993a7377bf79c66bc3379abe3c4ba4c3663270beb8ffffffff0280f0fa02000000001976a91421e280644637dc09bcd6009ce1d976b638f36ee188acc0d80f24010000001976a914c096562c63bf3a2d4b6c0939a697e4ac89ab0a9d88ac00000000",
"success": true
}
```
## Miner
### Config
https://docs.blockstack.org/mining#running-a-miner
To use the following config, you'll need to make a new `seed`, which you should have already generated from the above section.
**Config.toml**:
```toml
[node]
working_dir = "/root/stacks-node/current"
rpc_bind = "0.0.0.0:20443"
p2p_bind = "0.0.0.0:20444"
# Enter your private key here!
seed = "replace-with-your-privateKey-from-above"
miner = true
[burnchain]
chain = "bitcoin"
mode = "krypton"
peer_host = "bitcoind.krypton.blockstack.org"
#process_exit_at_block_height = 5340
#burnchain_op_tx_fee = 5500
#commit_anchor_block_within = 10000
rpc_port = 18443
peer_port = 18444
[[mstx_balance]]
address = "STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6"
amount = 10000000000000000
[[mstx_balance]]
address = "ST11NJTTKGVT6D1HY4NJRVQWMQM7TVAR091EJ8P2Y"
amount = 10000000000000000
[[mstx_balance]]
address = "ST1HB1T8WRNBYB0Y3T7WXZS38NKKPTBR3EG9EPJKR"
amount = 10000000000000000
[[mstx_balance]]
address = "STRYYQQ9M8KAF4NS7WNZQYY59X93XEKR31JP64CP"
amount = 10000000000000000
```
Copy/Paste the above (with your specific `seed`) as `$HOME/stacks/Config.toml`
You should now have a miner config located at `$HOME/stacks/Config.toml`
### Commands
_Note_: When these containers are stopped, all data is deleted. To persist the data across restarts, either use a docker bind-mount, or remove the `--rm` from the below commands.
**Without** DEBUG output:
```bash
docker run -d \
--name stacks_miner \
--rm \
-v "$HOME/stacks/Config.toml:/src/stacks-node/Config.toml" \
-p 20443:20443 \
-p 20444:20444 \
blockstack/stacks-blockchain:v23.0.0.6-krypton \
/bin/stacks-node start --config /src/stacks-node/Config.toml
```
**With** DEBUG output:
```bash
docker run -d \
--name stacks_miner \
--rm \
-e RUST_BACKTRACE="full" \
-e BLOCKSTACK_DEBUG="1" \
-v "$HOME/stacks/Config.toml:/src/stacks-node/Config.toml" \
-p 20443:20443 \
-p 20444:20444 \
blockstack/stacks-blockchain:v23.0.0.6-krypton \
/bin/stacks-node start --config /src/stacks-node/Config.toml
```
**Logs**:
```bash
docker logs -f stacks_miner
```
## Follower
https://docs.blockstack.org/stacks-blockchain/running-testnet-node
### Commands
_Note_: When these containers are stopped, all data is deleted. To persist the data across restarts, either use a docker bind-mount, or remove the `--rm` from the below commands.
**Without** DEBUG output:
```bash
docker run -d \
--name stacks_follower \
--rm \
-p 20443:20443 \
-p 20444:20444 \
blockstack/stacks-blockchain:v23.0.0.6-krypton \
/bin/stacks-node krypton
```
**With** DEBUG output:
```bash
docker run -d \
--name stacks_follower \
--rm \
-e RUST_BACKTRACE="full" \
-e BLOCKSTACK_DEBUG="1" \
-p 20443:20443 \
-p 20444:20444 \
blockstack/stacks-blockchain:v23.0.0.6-krypton \
/bin/stacks-node krypton
```
**Logs**:
```bash
docker logs -f stacks_follower
```

26
src/pages/stacks-blockchain/running-testnet-node.md

@ -1,6 +1,6 @@
---
title: Running a testnet node
description: Learn how to set up and run a testnet node.
description: Learn how to set up and run a testnet node
icon: TestnetIcon
duration: 15 minutes
experience: beginners
@ -82,6 +82,30 @@ INFO [1588108047.585] [src/chainstate/stacks/index/marf.rs:732] First-ever block
Your node will receive new blocks when they are produced, and you can use the [Stacks Node RPC API](/references/stacks-blockchain-api#stacks-node-rpc-api) to send transactions, fetch information for contracts and accounts, and more.
## Optional: Running with Docker
Alternatively, you can run the testnet node with Docker.
-> Ensure you have [Docker](https://docs.docker.com/get-docker/) installed on your machine.
```bash
docker run -d \
--name stacks_follower \
--rm \ # remove this to persist data across restarts
-e RUST_BACKTRACE="full" \ # remove to disable debug logs
-e BLOCKSTACK_DEBUG="1" \ # remove to disable debug logs
-p 20443:20443 \
-p 20444:20444 \
blockstack/stacks-blockchain:v23.0.0.6-krypton \
/bin/stacks-node krypton
```
You can review the node logs with this command:
```bash
docker logs -f stacks_follower
```
## Optional: Mining Stacks token
Now that you have a running testnet node, you can easily set up a miner.

Loading…
Cancel
Save