How to deploy and run a Stacks Testnet Node for blockstack 如何运行一个stacks 测试网络节点

Run a Stacks Testnet Node
运行一个stacks 测试网络节点

“Neon” is phase 1 of the Stacks 2.0 testnet. In Neon, you can run a node and connect it to a public network. This guide will walk you through downloading and running your own node in the Neon network.
“Neon” 是Stacks 2.0测试网络的第一个版本,通过“Neon”, 您可以通过运行一个服务器节点并把它连接到一个公共网络。这篇教程将会指导您在“Neon”网络中,如何下载并运行您自己的服务器节点。

* Prerequisites  前期准备
* Download and install the stacks-blockchain repository 下载并安装stacks区块链库
* Run your node  运行节点
* Running a miner  运行挖矿程序
* Creating an optimized binary   生成一个优化过的二进制
* Enable debug logging  打开调试日志

Step 1: Prerequisites 前期准备
Note: If you use Linux, you may need to manually install libssl-dev and other packages. In your command line, run the following to get all packages:
请注意:如果您使用linux,您也许需要人工安装 libssl-dev 和其他的程序安装包。在您的命令行终端中运行下面的命令,获得所有的安装包。
sudo apt-get install build-essential cmake libssl-dev pkg-config


Download and install the stacks-blockchain repository
下载并安装 stacks区块链库

The first step is to ensure that you have Rust installed. If you are using macOS, Linux, or another Unix-like OS, run the following. If you are on a different OS, follow the official Rust installation guide.
第一步是为了确保您已经安装了Rust,如果您现在正在使用macos,linux,或者其他的Unix系统。您可以运行下面的命令,如果您使用其他的操作系统,请参考这篇 官方Rust安装指南.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh


If Rust is already installed, you might see this prompt. Select ‘Proceed with Installation’ to make sure you have the latest version installed.
如果Rust已经安装,您应该会看到下面的提示,选择‘Proceed with Installation’ 来确保您已经安装了最新的版本。

In case you just installed Rust, you will be prompted to run the following command to make the cargo command available:
为了确保您已经安装了Rust, 您会收到一个提示让您运行下面的命令,从而使cargo 命令有效。
source $HOME/.cargo/env


Next, clone this repository:
下一步,克隆这个库:
git clone https://github.com/blockstack/ ... n.git cd stacks-blockchain


Install the Stacks node by running:
执行下面的命令,来安装Stacks 节点:
cargo install --path ./testnet/stacks-node


Step 2: Run your node
运行您的服务器节点


You’re all set to run a node that connects to the Neon network.
Back in the command line, run:
您已经准备好了运行一个节点来连接到Neon 网络,返回到命令行,运行下面的命令:
stacks-node neon


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:
当你第一次运行这个命令,您将会看到一些日志表明这个Rust节点正在被编译。一旦编译完成,您会看到类似下面的一些日志:
INFO [1588108047.585] [src/chainstate/stacks/index/marf.rs:732] First-ever block 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206


Awesome! Your node is now connected to the Neon network. Your node will receive new blocks when they are produced, and you can use your node’s RPC API to send transactions, fetch information for contracts and accounts, and more.
很好!您的节点已经链接到这个Neon网络了,当出块时,您的电脑会接收到新的区块,并且您可以使用node’s RPC API 来发送交易, 为智能合同程序和账户取回信息,等等。

Step 3: Running a miner
运行一个挖矿程序


Once you’ve followed the above steps to run a node, it’s only a few more steps to run a Proof-of-burn miner on the Neon testnet.
如果您已经完成了上面所有的步骤,您可以通过下面的方法来运行一个Proof-of-burn的挖矿程序,部署在Neon测试网络上。

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.
首先,我们需要生存一个keychain,通过keychain,我们可以从一个“水龙头”得到一些测试网络的比特币,并用这些比特币来开始挖矿。

To get a keychain, the simplest way is to use the blockstack-cli. We’ll use the make_keychain command, and pass -t to indicate that we want a testnet keychain.
为了得到一个keychain,最简单的方法就是使用blockstack-cli,我们要用到make_keychain命令 和 pass -t 来表明我们希望得到一个测试网络的keychain。
 
npx [email protected] make_keychain -t


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 } }



We need to get some testnet BTC to that address. Grab the btcAddress field, and head over to the Stacks testnet website. In the BTC faucet section, past in your btcAddress, and submit. 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.
我们需要一些测试网络的比特币转移到那个地址,请备份好btcAddress 字段,然后跳转到 stacks测试网络官网.  在比特币“水龙头”部分 , 粘贴您的btcAddress 然后提交。您需要发送0.5测试网络的比特币到这个地址。不要弄丢这些信息-因为我们还要继续使用这个私钥字段。

Now, we need to configure out node to use this Bitcoin keychain. In the stacks-blockchain folder, create a new file called testnet/stacks-node/conf/neon-miner-conf.toml.
Paste in the following configuration:
现在, 我们需要配置节点来使用比特币 keychain, 在stacks-blockchain文件夹里面,新建一个文件并命名为testnet/stacks-node/conf/neon-miner-conf.toml. 把下面的命令粘贴进去。
[node] rpc_bind = "0.0.0.0:20443" p2p_bind = "0.0.0.0:20444" bootstrap_node = "048dd4f26101715853533dee005f0915375854fd5be73405f679c1917a5d4d16aaaf3c4c0d7a9c132a36b8c5fe1287f07dad8c910174d789eb24bdfb5ae26f5f27@neon.blockstack.org:20444" # Enter your private key here! # 在这里输入您的私钥! seed = "replace-with-your-private-key" miner = true [burnchain] chain = "bitcoin" mode = "neon" peer_host = "neon.blockstack.org" 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 make_keychain command. Replace the seed field with your private key. Save and close this configuration file.
现在,拿好您之前得到的私钥,当你运行make_keychain 命令时, 用您的私钥来填写seed字段, 并保存并关闭这个配置文件。

To run your miner, run this in the command line:
为了运行您的挖矿程序,请运行下面的命令:
stacks-node start --config=./testnet/stacks-node/conf/neon-miner-conf.toml



Your node should start. It will take some time to sync, and then your miner will be running!
您的节点现在可以开始工作了,它需要花费一些时间来同步,然后您的挖矿程序就可以工作了!

Step 4: Creating an optimized binary 
生成一个优化过的二进制


The steps above are great for trying to run a node temporarily. If you want to host a node on a server somewhere, you might want to generate an optimized binary. To do so, use the same configuration as above, but run:
以上的步骤是用来运行一个临时的节点,如果您希望配置一个节点在一台服务器上,您可能希望生成一个优化过的二进制。为了实现这一点,请同样执行上面的步骤,然后运行:
cd testnet/stacks-node cargo build --release --bin stacks-node


The above code will compile an optimized binary. To use it, run:
上面的代码将会编译一个优化过的二进制,为了用它,请运行下面的命令:
cd ../.. ./target/release/stacks-node start --config=./testnet/conf/neon-follower-conf.toml


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:
运行过程中, 为了防止您碰到问题或者看到冗长的日志,您可以在您的节点上开启调试日志功能,请直接运行下面的命令:
BLOCKSTACK_DEBUG=1 stacks-node neon

 
0
Pay Tips 03-06-20

0 comments

If you wanna get more accurate answers, Please Login or Register