contrib/localnet/darkfid-singe-node: updated to work with latest darkfid

This commit is contained in:
skoupidi
2024-02-14 14:32:22 +02:00
parent 44103f0359
commit f345f7a338
12 changed files with 120 additions and 164 deletions

View File

@@ -1,2 +1,2 @@
faucetd/blockchain
darkfid0
darkfid
drk

View File

@@ -1,4 +1,27 @@
darkfid localnet
================
This will start one darkfid node in single-node mode and a faucet node.
This will start one darkfid node in localnet mode,
along with a minerd daemon to mine blocks.
If we want to test wallet stuff, we must generate
a testing wallet and pass its address to the darkfid
config, so the wallet gets the block rewards the node
produces. First we start darkfid and wait until its
initialized:
```
% ./tmux_sessions.sh
```
In another terminal, we generate a wallet, set it as
the default and grab its address:
```
% ../../../drk -c drk.toml wallet --initialize
% ../../../drk -c drk.toml wallet --keygen
% ../../../drk -c drk.toml wallet --default-address 1
% ../../../drk -c drk.toml wallet --address
```
Then we replace the `recipient` field in `darkfid.toml`
config with the output of the last command, and restart
the daemon. After some blocks have been generated we
will see some `DRK` in our test wallet.

View File

@@ -1,3 +1,2 @@
#!/bin/sh
rm -rf darkfid0 faucetd/blockchain
git checkout faucetd/wallet.db
rm -rf darkfid drk

View File

@@ -0,0 +1,57 @@
## darkfid configuration file
##
## Please make sure you go through all the settings so you can configure
## your daemon properly.
##
## The default values are left commented. They can be overridden either by
## uncommenting, or by using the command-line.
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:48340"
# Blockchain network to use
network = "localnet"
# Localnet blockchain network configuration
[network_config."localnet"]
# Path to the blockchain database directory
database = "darkfid"
# Finalization threshold, denominated by number of blocks
threshold = 3
# minerd JSON-RPC endpoint
minerd_endpoint = "tcp://127.0.0.1:48467"
# PoW block production target, in seconds
pow_target = 10
# Optional fixed PoW difficulty, used for testing
pow_fixed_difficulty = 1
# Participate in block production
miner = true
# Wallet address to receive mining rewards.
# This is a dummy one so the miner can start,
# replace with your own one.
recipient = "9vw6WznKk7xEFQwwXhJWMMdjUPi3cXL8NrFKQpKifG1U"
# Skip syncing process and start node right away
skip_sync = true
## Localnet sync P2P network settings
[network_config."localnet".sync_net]
# P2P accept addresses the instance listens on for inbound connections
inbound = ["tcp+tls://0.0.0.0:48242"]
# Allow localnet hosts
localnet = true
## Localnet miners P2P network settings
[network_config."localnet".miners_net]
# P2P accept addresses the instance listens on for inbound connections
inbound = ["tcp+tls://0.0.0.0:48241"]
# Allow localnet hosts
localnet = true

View File

@@ -1,77 +0,0 @@
## darkfid configuration file
##
## Please make sure you go through all the settings so you can configure
## your daemon properly.
##
## The default values are left commented. They can be overridden either by
## uncommenting, or by using the command-line.
# Chain to use (testnet, mainnet)
chain = "testnet"
# Path to the wallet database
wallet_path = "darkfid0/wallet.db"
# Password for the wallet database
wallet_pass = "changeme"
# Path to the blockchain database directory
database = "darkfid0/blockchain"
# JSON-RPC listen url
rpc_listen = "tcp://127.0.0.1:8340"
# Participate in the consensus protocol
consensus = true
# Enable single-node mode for local testing
single_node = true
# P2P accept addresses for the consensus protocol
consensus_p2p_accept = ["tcp://127.0.0.1:8341"]
# P2P external addresses for the consensus protocol
consensus_p2p_external = ["tcp://127.0.0.1:8341"]
# Connection slots for the consensus protocol
#consensus_slots = 8
# Connection slots for the consensus protocol
#consensus_p2p_seed = []
# Peers to connect to for the consensus protocol
#consensus_p2p_peer = []
# Prefered transports of outbound connections for the consensus protocol
consensus_p2p_transports = ["tls", "tcp"]
# P2P accept addresses for the syncing protocol
sync_p2p_accept = ["tcp://127.0.0.1:8342"]
# P2P external addresses for the syncing protocol
sync_p2p_external = ["tcp://127.0.0.1:8342"]
# Connection slots for the syncing protocol
#sync_slots = 8
# Seed nodes to connect to for the syncing protocol
#sync_p2p_seed = []
# Peers to connect to for the syncing protocol
#sync_p2p_peer = []
# Prefered transports of outbound connections for the syncing protocol
sync_p2p_transports = ["tls", "tcp"]
# Enable localnet hosts
localnet = true
# Enable channel log
channel_log = true
# Whitelisted faucet public key
faucet_pub = ["DqaZzCTipXeJw4kcc6ro1SJuzo3diaNjFiaAnKTGQEK1"]
# Verify system clock is correct
#clock_sync = true

View File

@@ -0,0 +1,16 @@
## drk configuration file
##
## Please make sure you go through all the settings so you can configure
## your daemon properly.
##
## The default values are left commented. They can be overridden either by
## uncommenting, or by using the command-line.
# Path to wallet database
wallet_path = "drk/wallet.db"
# Password for the wallet database
wallet_pass = "testing"
# darkfid JSON-RPC endpoint
endpoint = "tcp://127.0.0.1:48340"

View File

@@ -1,55 +0,0 @@
## faucetd configuration file
##
## Please make sure you go through all the settings so you can configure
## your daemon properly.
##
## The default values are left commented. They can be overridden either by
## uncommenting, or by using the command-line.
# Chain to use (testnet, mainnet)
chain = "testnet"
# Path to the wallet database
wallet_path = "faucetd/wallet.db"
# Password for the wallet database
wallet_pass = "changeme"
# Path to the blockchain database directory
database = "faucetd/blockchain"
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:8440"
# P2P accept addresses for the syncing protocol
sync_p2p_accept = ["tcp://127.0.0.1:8442"]
# P2P external addresses for the syncing protocol
sync_p2p_external = ["tcp://127.0.0.1:8442"]
# Connection slots for the syncing protocol
#sync_slots = 8
# Seed nodes to connect to for the syncing protocol
#sync_p2p_seed = []
# Peers to connect to for the syncing protocol
sync_p2p_peer = ["tcp://127.0.0.1:8342"]
# Prefered transports of outbound connections for the syncing protocol
sync_p2p_transports = ["tls", "tcp"]
# Enable localnet hosts
localnet = true
# Enable channel log
channel_log = true
# Airdrop timeout limit in seconds
airdrop_timeout = 120
# Airdrop amount limit
airdrop_limit = "1000000"
# Whitelisted faucet addresses
faucet_pub = ["DqaZzCTipXeJw4kcc6ro1SJuzo3diaNjFiaAnKTGQEK1"]

View File

@@ -0,0 +1,10 @@
## minerd configuration file
##
## Please make sure you go through all the settings so you can configure
## your daemon properly.
##
## The default values are left commented. They can be overridden either by
## uncommenting, or by using the command-line.
# JSON-RPC listen URL
rpc_listen = "tcp://127.0.0.1:48467"

View File

@@ -3,14 +3,12 @@ set -e
set -x
# Path to `drk` binary
DRK="../../../drk"
DRK="../../../drk -c drk.toml"
# First run the consensus node and the faucet:
#
# ./tmux_sessions.sh now && cd ../../../ && make darkfid faucetd && cd -
# ./clean.sh
# ./tmux_sessions.sh -v
# ./sync-wallet.sh
# ./tmux_sessions.sh -vv
#
# In another term run the wallet syncing:
#

View File

@@ -3,7 +3,7 @@ set -e
set -x
# Path to `drk` binary
DRK="../../../drk"
DRK="../../../drk -vv -c drk.toml"
while true; do
if $DRK ping 2> /dev/null; then
@@ -12,7 +12,5 @@ while true; do
sleep 1
done
$DRK wallet --initialize
$DRK scan
$DRK subscribe blocks
$DRK subscribe

View File

@@ -1,31 +1,18 @@
#!/bin/sh
set -e
# Start a tmux session with a consensus nodes and a faucet that's able to mint tokens.
# Start a tmux session with a minerd daemon and a darkfid node
if [ "$1" = "-v" ]; then
verbose="-v"
if [ "$1" = "-vv" ]; then
verbose="-vv"
shift
else
verbose=""
fi
if [ "$1" = "now" ]; then
now="$(date +%s)"
sed \
-e 's/pub const SLOT_TIME: .*/pub const SLOT_TIME: u64 = 20;/' \
-e 's/pub const FINAL_SYNC_DUR: .*/pub const FINAL_SYNC_DUR: u64 = 15;/' \
-e "s/pub static ref TESTNET_GENESIS_TIMESTAMP: .*/pub static ref TESTNET_GENESIS_TIMESTAMP: Timestamp = Timestamp($now);/" \
-e "s/pub static ref TESTNET_BOOTSTRAP_TIMESTAMP: .*/pub static ref TESTNET_BOOTSTRAP_TIMESTAMP: Timestamp = Timestamp($now);/" \
-i ../../../src/consensus/constants.rs
exit
fi
tmux new-session -d
tmux send-keys "LOG_TARGETS='!sled,!net' ../../../darkfid ${verbose} -c darkfid0.toml" Enter
sleep 10
tmux send-keys "../../../minerd ${verbose} -c minerd.toml" Enter
sleep 1
tmux split-window -v
tmux send-keys "LOG_TARGETS='!sled,!net' ../../../faucetd ${verbose} -c faucetd.toml" Enter
tmux send-keys "LOG_TARGETS='!sled,!net' ../../../darkfid ${verbose} -c darkfid.toml" Enter
tmux attach