mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 07:08:05 -05:00
doc/testnet/node: simplyfied outputs visualization
This commit is contained in:
@@ -6,6 +6,11 @@ understand all the steps required and how each component operates.
|
||||
Unless instructed otherwise, each daemon runs on its own shell, so don't
|
||||
stop a running one to start another.
|
||||
|
||||
Each command to execute will be inside a codeblock, on its first line,
|
||||
marked by the user `$` symbol, followed by the expected output. For
|
||||
longer command outputs, some lines will be emmited to keep the guide
|
||||
simple.
|
||||
|
||||
We also strongly suggest to first execute next guide steps on a
|
||||
[local environment](#local-deployment) to become familiar with
|
||||
each command, before broadcasting transactions to the actual network.
|
||||
@@ -33,7 +38,7 @@ each marked `[network_config]`. The sections look like this:
|
||||
At the top of the `darkfid` and `drk` config file, we can modify the
|
||||
network being used by changing the following line:
|
||||
|
||||
```
|
||||
```toml
|
||||
# Blockchain network to use
|
||||
network = "testnet"
|
||||
```
|
||||
@@ -50,17 +55,44 @@ the software system-wide. Instead, we'll be running all the commands
|
||||
from the git repository, so we're able to easily pull any necessary
|
||||
updates.
|
||||
|
||||
Refer to the main [DarkFi](../index.html) page for instructions on how
|
||||
to install Rust and necessary deps.
|
||||
Refer to the main [DarkFi](../index.html#build) page for instructions
|
||||
on how to install Rust and necessary deps. Skip last step of the build
|
||||
process, as you don't need to compile all binaries of the project.
|
||||
|
||||
Once you have the repository in place, and everything is installed, we
|
||||
can compile the `darkfid` node and the `drk` wallet CLI:
|
||||
|
||||
```
|
||||
```shell
|
||||
$ make darkfid drk
|
||||
```
|
||||
|
||||

|
||||
...
|
||||
make -C bin/darkfid \
|
||||
PREFIX="/home/anon/.cargo" \
|
||||
CARGO="cargo" \
|
||||
RUST_TARGET="x86_64-unknown-linux-gnu" \
|
||||
RUSTFLAGS=""
|
||||
make[1]: Entering directory '/home/anon/darkfi/bin/darkfid'
|
||||
RUSTFLAGS="" cargo build --target=x86_64-unknown-linux-gnu --release --package darkfid
|
||||
...
|
||||
Compiling darkfid v0.5.0 (/home/anon/darkfi/bin/darkfid)
|
||||
Finished `release` profile [optimized] target(s) in 4m 19s
|
||||
cp -f ../../target/x86_64-unknown-linux-gnu/release/darkfid darkfid
|
||||
cp -f ../../target/x86_64-unknown-linux-gnu/release/darkfid ../../darkfid
|
||||
make[1]: Leaving directory '/home/anon/darkfi/bin/darkfid'
|
||||
make -C bin/drk \
|
||||
PREFIX="/home/anon/.cargo" \
|
||||
CARGO="cargo" \
|
||||
RUST_TARGET="x86_64-unknown-linux-gnu" \
|
||||
RUSTFLAGS=""
|
||||
make[1]: Entering directory '/home/anon/darkfi/bin/drk'
|
||||
RUSTFLAGS="" cargo build --target=x86_64-unknown-linux-gnu --release --package drk
|
||||
...
|
||||
Compiling drk v0.5.0 (/home/anon/darkfi/bin/drk)
|
||||
Finished `release` profile [optimized] target(s) in 2m 16s
|
||||
cp -f ../../target/x86_64-unknown-linux-gnu/release/drk drk
|
||||
cp -f ../../target/x86_64-unknown-linux-gnu/release/drk ../../drk
|
||||
make[1]: Leaving directory '/home/anon/darkfi/bin/drk'
|
||||
```
|
||||
|
||||
This process will now compile the node and the wallet CLI tool.
|
||||
When finished, we can begin using the network. Run `darkfid` and `drk`
|
||||
@@ -69,20 +101,18 @@ will be used to `darkfid` and `drk`.
|
||||
|
||||
Please note that the exact paths may differ depending on your local setup.
|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./darkfid
|
||||
|
||||
Config file created in "~/.config/darkfi/darkfid_config.toml". Please review it and try again.
|
||||
```
|
||||
|
||||

|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./drk wallet --address
|
||||
|
||||
Config file created in "~/.config/darkfi/drk_config.toml". Please review it and try again.
|
||||
```
|
||||
|
||||

|
||||
|
||||
## Running
|
||||
|
||||
### Using Tor
|
||||
@@ -109,42 +139,47 @@ your config file in a text editor (the default path is
|
||||
`~/.config/darkfi/drk_config.toml`). Look for the section marked
|
||||
`[network_config."testnet"]` and change this line:
|
||||
|
||||
```
|
||||
```toml
|
||||
# Password for the wallet database
|
||||
wallet_pass = "changeme"
|
||||
```
|
||||
|
||||
Once you've changed the default password for your testnet wallet, we can
|
||||
proceed with the wallet initialization. We simply have to initialize a
|
||||
wallet, and create a keypair.
|
||||
Once you've changed the default password for your testnet wallet, we
|
||||
can proceed with the wallet initialization. We simply have to
|
||||
initialize a wallet, and create a keypair. The wallet address shown in
|
||||
the outputs is examplatory and will different from the one you get.
|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./drk wallet --initialize
|
||||
|
||||
Initializing Money Merkle tree
|
||||
Successfully initialized Merkle tree for the Money contract
|
||||
Generating alias DRK for Token: 241vANigf1Cy3ytjM1KHXiVECxgxdK4yApddL8KcLssb
|
||||
Initializing DAO Merkle trees
|
||||
Successfully initialized Merkle trees for the DAO contract
|
||||
```
|
||||
|
||||

|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./drk wallet --keygen
|
||||
|
||||
Generating a new keypair
|
||||
New address:
|
||||
CbaqFqGTgn86Zh9AjUeMw3DJyVCshaPSPFtmj6Cyd5yU
|
||||
```
|
||||
|
||||

|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./drk wallet --default-address 1
|
||||
```
|
||||
|
||||

|
||||
|
||||
The second command will print out your new DarkFi address where you
|
||||
can receive payments. Take note of it. Alternatively, you can always
|
||||
retrieve your default address using:
|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./drk wallet --address
|
||||
```
|
||||
|
||||

|
||||
CbaqFqGTgn86Zh9AjUeMw3DJyVCshaPSPFtmj6Cyd5yU
|
||||
```
|
||||
|
||||
### Miner
|
||||
|
||||
@@ -160,11 +195,24 @@ will be minted to.
|
||||
|
||||
First, compile it:
|
||||
|
||||
```
|
||||
```shell
|
||||
$ make minerd
|
||||
```
|
||||
|
||||

|
||||
...
|
||||
make -C bin/minerd \
|
||||
PREFIX="/home/anon/.cargo" \
|
||||
CARGO="cargo" \
|
||||
RUST_TARGET="x86_64-unknown-linux-gnu" \
|
||||
RUSTFLAGS=""
|
||||
make[1]: Entering directory '/home/anon/darkfi/bin/minerd'
|
||||
RUSTFLAGS="" cargo build --target=x86_64-unknown-linux-gnu --release --package minerd
|
||||
...
|
||||
Compiling minerd v0.5.0 (/home/anon/darkfi/bin/minerd)
|
||||
Finished `release` profile [optimized] target(s) in 1m 25s
|
||||
cp -f ../../target/x86_64-unknown-linux-gnu/release/minerd minerd
|
||||
cp -f ../../target/x86_64-unknown-linux-gnu/release/minerd ../../minerd
|
||||
make[1]: Leaving directory '/home/anon/darkfi/bin/minerd'
|
||||
```
|
||||
|
||||
This process will now compile the mining daemon. When finished, run
|
||||
`minerd` once so that it spawns its config file on your system. This
|
||||
@@ -172,21 +220,24 @@ config file is used to configure `minerd`. You can define how many
|
||||
threads will be used for mining. RandomX can use up to 2080 MiB per
|
||||
thread so configure it to not consume all your system available memory.
|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./minerd
|
||||
|
||||
Config file created in "~/.config/darkfi/minerd_config.toml". Please review it and try again.
|
||||
```
|
||||
|
||||

|
||||
|
||||
Once that's in place, you can run it again and `minerd` will start,
|
||||
waiting for requests to mine blocks.
|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./minerd
|
||||
```
|
||||
|
||||

|
||||
14:20:06 [INFO] Starting DarkFi Mining Daemon...
|
||||
14:20:06 [INFO] Initializing a new mining daemon...
|
||||
14:20:06 [INFO] Mining daemon initialized successfully!
|
||||
14:20:06 [INFO] Starting mining daemon...
|
||||
14:20:06 [INFO] Mining daemon started successfully!
|
||||
```
|
||||
|
||||
You now have to expose `minerd` RPC to `darkfid`, and configure it
|
||||
to use your wallet address as the rewards recipient, when submitting
|
||||
@@ -198,7 +249,7 @@ is `~/.config/darkfi/darkfid_config.toml`). Find the `recipient` and
|
||||
uncomment them by removing the `#` character at the start of line,
|
||||
like this:
|
||||
|
||||
```
|
||||
```toml
|
||||
# Put your `minerd` endpoint here (default for testnet is in this example)
|
||||
minerd_endpoint = "tcp://127.0.0.1:28467"
|
||||
# Put the address from `drk wallet --address` here
|
||||
@@ -211,11 +262,11 @@ is `~/.config/darkfi/minerd_config.toml`). Finally, replace the
|
||||
`YOUR_WALLET_ADDRESS_HERE` string with your `drk` wallet address that
|
||||
you can retrieve as follows:
|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./drk wallet --address
|
||||
```
|
||||
|
||||

|
||||
CbaqFqGTgn86Zh9AjUeMw3DJyVCshaPSPFtmj6Cyd5yU
|
||||
```
|
||||
|
||||
Note: when modifying the `darkfid` config file to use with the
|
||||
testnet, be sure to change the values under the section marked
|
||||
@@ -227,16 +278,27 @@ Now that `darkfid` configuration is in place, you can run it again and
|
||||
`darkfid` will start, create the necessary keys for validation of blocks
|
||||
and transactions, and begin syncing the blockchain.
|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./darkfid
|
||||
```
|
||||
|
||||

|
||||
14:23:23 [INFO] Initializing DarkFi node...
|
||||
14:23:23 [INFO] Node is configured to run with fixed PoW difficulty: 1
|
||||
14:23:23 [INFO] Initializing a Darkfi daemon...
|
||||
14:23:23 [INFO] Initializing Validator
|
||||
14:23:23 [INFO] Initializing Blockchain
|
||||
14:23:23 [INFO] Deploying native WASM contracts
|
||||
14:23:23 [INFO] Deploying Money Contract with ContractID BZHKGQ26bzmBithTQYTJtjo2QdCqpkR9tjSBopT4yf4o
|
||||
14:23:29 [INFO] Successfully deployed Money Contract
|
||||
14:23:29 [INFO] Deploying DAO Contract with ContractID Fd8kfCuqU8BoFFp6GcXv5pC8XXRkBK7gUPQX5XDz7iXj
|
||||
...
|
||||
```
|
||||
|
||||
As its syncing, you'll see periodic messages like this:
|
||||
|
||||
```
|
||||
```shell
|
||||
...
|
||||
[INFO] Blocks received: 4020/4763
|
||||
...
|
||||
```
|
||||
|
||||
This will give you an indication of the current progress. Keep it running,
|
||||
@@ -245,22 +307,34 @@ and you should see a `Blockchain synced!` message after some time.
|
||||
If you're running `minerd`, you should see a notification from the
|
||||
`minerd` terminal like this:
|
||||
|
||||
```
|
||||
```shell
|
||||
...
|
||||
[INFO] [RPC] Server accepted conn from tcp://127.0.0.1:44974/
|
||||
...
|
||||
```
|
||||
|
||||

|
||||
|
||||
This means that `darkfid` and `minerd` are connected over RPC and `minerd`
|
||||
can start mining.
|
||||
|
||||

|
||||
|
||||
When `darkfid` and `minerd` are correctly connected and you get an error
|
||||
like this:
|
||||
This means that `darkfid` and `minerd` are connected over RPC and
|
||||
`minerd` can start mining. You will see log messages like these:
|
||||
|
||||
```shell
|
||||
...
|
||||
14:23:56 [INFO] Mining block 4abc760a1f1c7198837e91c24d8e045e9fc9cb9fdf3a5fd45e184c25b03b0b51 for target:
|
||||
115792089237316195423570985008687907853269984665640564039457584007913129639935
|
||||
14:24:04 [INFO] Mined block 4abc760a1f1c7198837e91c24d8e045e9fc9cb9fdf3a5fd45e184c25b03b0b51 with nonce: 2
|
||||
14:24:06 [INFO] Received request to mine block 17e7428ecb3d911477f8452170d0822c831c6912027abb120e4b4c4cf01d6020 for target:
|
||||
115792089237316195423570985008687907853269984665640564039457584007913129639935
|
||||
14:24:06 [INFO] Checking if a pending request is being processed...
|
||||
...
|
||||
```
|
||||
[ERROR] minerd::rpc: Failed mining block f6b4a0f0c8f90905da271ec0add2e856939ef3b0d6cd5b28964d9c2b6d0a0fa9 with error: Miner task stopped
|
||||
|
||||
When `darkfid` and `minerd` are correctly connected and you get an
|
||||
error like this:
|
||||
|
||||
```shell
|
||||
...
|
||||
[ERROR] minerd::rpc: Failed mining block f6b4a0f0c8f90905da271ec0add2e856939ef3b0d6cd5b28964d9c2b6d0a0fa9 with error:
|
||||
Miner task stopped
|
||||
...
|
||||
```
|
||||
|
||||
That's expected behavior. It means your setup is correct and you are
|
||||
@@ -271,8 +345,10 @@ start mining the next height one.
|
||||
|
||||
Otherwise, you'll see a notification like this:
|
||||
|
||||
```
|
||||
```shell
|
||||
...
|
||||
[INFO] Mined block b6c7bd3545daa81d0e2e56ee780363beef6eb5b54579f54dca0cdd2a59989b76 with nonce: 266292
|
||||
...
|
||||
```
|
||||
|
||||
Which means the current height block has been mined succesfully by
|
||||
@@ -288,17 +364,44 @@ and to find coins that are intended for you. In another terminal,
|
||||
you can run the following commands to first scan the blockchain,
|
||||
and then to subscribe to new blocks:
|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./drk scan
|
||||
|
||||
...
|
||||
Requested to scan from block number: 0
|
||||
Last confirmed block reported by darkfid: 1 - da4455f461df6833a68b659d1770f58e44b6bc4abdd934cb22d084c24333255f
|
||||
Requesting block 0...
|
||||
Block 0 received! Scanning block...
|
||||
=======================================
|
||||
Header {
|
||||
Hash: b967812a860e8bf43deb03dd4f7cf69258f7719ddb7f2183d4e4fa3559b9f39d
|
||||
Version: 1
|
||||
Previous: 86bbac430a4b3a182f125b37a486e9c486bbfa34d84ef4a66b4a23e5f0c625b1
|
||||
Height: 0
|
||||
Timestamp: 2025-05-12T13:00:24
|
||||
Nonce: 0
|
||||
Transactions Root: 0x081361c364feba0d28a418e2e20c216ce442d5127036e3491ceaf1996fdb3c3b
|
||||
State Root: afc1694dd6b290d8b92c33d3fc746707da9bed857eb9e90f11683d2e243b8047
|
||||
Proof of Work data: Darkfi
|
||||
}
|
||||
=======================================
|
||||
[scan_block] Iterating over 1 transactions
|
||||
[scan_block] Processing transaction: 91525ff00a3755a8df93c626b59f6e36cf021d85ebccecdedc38f3f1890a15fc
|
||||
Requesting block 1...
|
||||
Block 1 received! Scanning block...
|
||||
...
|
||||
Requested to scan from block number: 2
|
||||
Last confirmed block reported by darkfid: 1 - da4455f461df6833a68b659d1770f58e44b6bc4abdd934cb22d084c24333255f
|
||||
Finished scanning blockchain
|
||||
```
|
||||
|
||||

|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./drk subscribe
|
||||
```
|
||||
|
||||

|
||||
Subscribing to receive notifications of incoming blocks
|
||||
Detached subscription to background
|
||||
All is good. Waiting for block notifications...
|
||||
```
|
||||
|
||||
Now you can leave the subscriber running. In case you stop it, just
|
||||
run `drk scan` again until the chain is fully scanned, and then you
|
||||
@@ -308,44 +411,42 @@ should be able to subscribe again.
|
||||
|
||||
For local (non-testnet) development we recommend running master, and
|
||||
use the existing `contrib/localnet/darkfid-single-node` folder, which
|
||||
provides the corresponding configurations to operate.
|
||||
provides the corresponding configurations to operate. Some outputs are
|
||||
emitted since they are identical to previous steps.
|
||||
|
||||
First, compile `darkfid` node, `minerd` mining daemon and the `drk`
|
||||
wallet CLI:
|
||||
|
||||
```
|
||||
```shell
|
||||
$ make darkfid minerd drk
|
||||
```
|
||||
|
||||

|
||||
|
||||
Enter the localnet folder, and initialize a wallet:
|
||||
|
||||
```
|
||||
```shell
|
||||
$ cd contrib/localnet/darkfid-single-node/
|
||||
$ ./init-wallet.sh
|
||||
```
|
||||
|
||||

|
||||
|
||||
Then start `darkfid` and wait until its initialized:
|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./tmux_sessions.sh
|
||||
```
|
||||
|
||||

|
||||
|
||||
After some blocks have been generated we
|
||||
will see some `DRK` in our test wallet.
|
||||
On a different shell(or tmux pane in the session),
|
||||
navigate to `contrib/localnet/darkfid-single-node`
|
||||
folder again and check wallet balance
|
||||
|
||||
```
|
||||
```shell
|
||||
$ ./wallet-balance.sh
|
||||
|
||||
Token ID | Aliases | Balance
|
||||
----------------------------------------------+---------+---------
|
||||
241vANigf1Cy3ytjM1KHXiVECxgxdK4yApddL8KcLssb | DRK | 20
|
||||
```
|
||||

|
||||
|
||||
Don't forget that when using this local node, all operations
|
||||
should be executed inside the `contrib/localnet/darkfid-single-node`
|
||||
@@ -355,7 +456,7 @@ folder, and `./drk` command to be replaced by `../../../drk -c drk.toml`
|
||||
|
||||
To run a node in full debug mode:
|
||||
|
||||
```
|
||||
```shell
|
||||
$ LOG_TARGETS='!sled,!rustls,!net' ./darkfid -vv | tee /tmp/darkfid.log
|
||||
```
|
||||
|
||||
@@ -364,7 +465,7 @@ we disable those.
|
||||
|
||||
We can now view the log, and grep through it.
|
||||
|
||||
```
|
||||
```shell
|
||||
$ tail -n +0 -f /tmp/darkfid.log | grep -a --line-buffered -v DEBUG
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user