From 5e946a9a0d0f98c5e1fe55914f941f0f9a305358 Mon Sep 17 00:00:00 2001 From: HariniRajan397 Date: Sun, 8 Nov 2020 04:32:00 +0000 Subject: [PATCH] Feat : Added instructions for running testnet node(both follower and miner node) on Windows using Binary. Fixes blockstack/docs#661 --- src/pages/mining.md | 108 +++++++++++++++++- .../stacks-blockchain/running-testnet-node.md | 45 ++++++++ 2 files changed, 150 insertions(+), 3 deletions(-) diff --git a/src/pages/mining.md b/src/pages/mining.md index 1953c2a0..ccdd923b 100644 --- a/src/pages/mining.md +++ b/src/pages/mining.md @@ -126,6 +126,108 @@ In case you are running into issues or would like to see verbose logging, you ca BLOCKSTACK_DEBUG=1 stacks-node krypton ``` +## Running a miner in Windows + +### Generate keychain and get testnet tokens in Windows + +To setup the miner, first, we need to generate a keychain. With this keychain, we'll get some testnet BTC from a faucet, and then use that BTC to start mining. + +To get a keychain, the simplest way is to use the `stacks-cli`.We'll use the `stx make-keychain` command,and pass -t to indicate that we want a testnet keychain. + +Generate a keychain: + +```bash +npm install --global @stacks/cli +stx make_keychain -t > cli_keychain.json +type cli_keychain.json +``` + +After this runs, you'll probably see some installation logs, and at the end you should see some JSON that looks like this: + +```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 faucet: + +We need to get some testnet BTC to that address. Grab the btcAddress field, and call the BTC faucet: + +```bash +# replace with `btcAddress` property from your keychain +curl -XPOST "https://stacks-node-api.blockstack.org/extended/v1/faucets/btc?address=" +``` + +You'll be sent 0.5 testnet BTC to that address. Don't lose this information - we'll need to use the `privateKey` field later on. + +### Create configuration file + +Now, we need to configure our node to use this Bitcoin keychain. In the `folder where your binary is extracted`, create a new file called `testnet-miner-conf.toml`. + +Paste in the following configuration: + +```toml +[node] +rpc_bind = "0.0.0.0:20443" +p2p_bind = "0.0.0.0:20444" +bootstrap_node = "048dd4f26101715853533dee005f0915375854fd5be73405f679c1917a5d4d16aaaf3c4c0d7a9c132a36b8c5fe1287f07dad8c910174d789eb24bdfb5ae26f5f27@testnet-miner.blockstack.org:20444" +# Enter your private key here! +seed = "replace-with-your-private-key" +miner = true + +[burnchain] +chain = "bitcoin" +mode = "krypton" +peer_host = "bitcoind.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 +``` + +Now, grab your `privateKey` from earlier, when you ran the `stx make_keychain` command. Replace the seed field with your private key. Save and close this configuration file. + +### Run the miner + +To run your miner, run this in the command line: + +```bash +stacks-node start --config=testnet-miner-conf.toml +``` + +Your node should start. It will take some time to sync, and then your miner will be running! + +### Enable debug logging in Windows + +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 +set RUST_BACKTRACE=full; +set BLOCKSTACK_DEBUG=1; +stacks-node start --config=testnet-miner-conf.toml +``` + ## Optional: Running with Docker Alternatively, you can run the testnet node with Docker. @@ -155,7 +257,7 @@ You need a dedicated directory to keep the config file(s): mkdir -p $HOME/stacks ``` -### Create configuration file +### Create config file Inside the new `$HOME/stacks` folder, you should create a new miner config `Config.toml`: @@ -194,7 +296,7 @@ amount = 10000000000000000 -> Notice that this configuration differs from the one used to run the miner locally -### Run the miner +### Start the miner -> The ENV VARS `RUST_BACKTRACE` and `BLOCKSTACK_DEBUG` are optional. If removed, debug logs will be disabled @@ -228,7 +330,7 @@ Ensure you have the following prerequisites installed on your machine: - [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) - [helm](https://helm.sh/docs/intro/install/) -### Generate keychain and get testnet tokens +### Generate keychain and get some testnet tokens Generate a keychain: diff --git a/src/pages/stacks-blockchain/running-testnet-node.md b/src/pages/stacks-blockchain/running-testnet-node.md index 50e5c8fc..36a68926 100644 --- a/src/pages/stacks-blockchain/running-testnet-node.md +++ b/src/pages/stacks-blockchain/running-testnet-node.md @@ -91,6 +91,51 @@ 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. +## Running the testnet node on Windows + +### Prerequisites + +Before you begin, check that you have the below necessary softwares installed on your PC + +- [MicrosoftC++BuildTools](https://visualstudio.microsoft.com/visual-cpp-build-tools/). +- [NodeJs](https://nodejs.org/en/download/). +- [Git](https://git-scm.com/downloads). + +#### Optional Dependencies + +- [Python](https://www.python.org/downloads/). +- [Rust](https://www.rust-lang.org/tools/install). + +### Download the Binary and run the follower node + +First, download the binary using the below link: + + + +Extract the binary .Open the command prompt from the folder where binary is extracted and execute the below command: + +```bash +stacks-node krypton +# This command will start the testnet follower node. +``` + +To execute Stacks node with extra debugging enabled, run: + +```bash +set RUST_BACKTRACE=full +set BLOCKSTACK_DEBUG=1 +stacks-node krypton +# This command will execute the binary and start the follower node with debug enabled. +``` + +The first time you run this, you'll see some logs indicating that the Rust code is being compiled. Once that's done, you should see some logs that look something like the this: + +```bash +INFO [1588108047.585] [src/chainstate/stacks/index/marf.rs:732] First-ever block 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206 +``` + +**Awesome! Your node is now connected to the testnet network.** + ## Optional: Running with Docker Alternatively, you can run the testnet node with Docker.