mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 07:08:05 -05:00
consensu: seeds to be ignored during syncing, localnet: lilith node added
This commit is contained in:
@@ -34,7 +34,7 @@ consensus_p2p_external = "tls://127.0.0.1:8341"
|
||||
#consensus_slots = 8
|
||||
|
||||
# Connection slots for the consensus protocol
|
||||
#consensus_p2p_seed = []
|
||||
consensus_p2p_seed = ["tls://127.0.0.1:33033"]
|
||||
|
||||
# Peers to connect to for the consensus protocol
|
||||
#consensus_p2p_peer = []
|
||||
@@ -49,7 +49,7 @@ sync_p2p_external = "tls://127.0.0.1:8342"
|
||||
#sync_slots = 8
|
||||
|
||||
# Seed nodes to connect to for the syncing protocol
|
||||
#sync_p2p_seed = []
|
||||
sync_p2p_seed = ["tls://127.0.0.1:33032"]
|
||||
|
||||
# Peers to connect to for the syncing protocol
|
||||
#sync_p2p_peer = []
|
||||
|
||||
@@ -34,7 +34,7 @@ consensus_p2p_external = "tls://127.0.0.1:8441"
|
||||
#consensus_slots = 8
|
||||
|
||||
# Connection slots for the consensus protocol
|
||||
consensus_p2p_seed = ["tls://127.0.0.1:8341"]
|
||||
consensus_p2p_seed = ["tls://127.0.0.1:33033"]
|
||||
|
||||
# Seed nodes JSON-RPC listen URL for clock synchronization
|
||||
consensus_seed_rpc = ["tcp://127.0.0.1:8340"]
|
||||
@@ -55,7 +55,7 @@ sync_p2p_external = "tls://127.0.0.1:8442"
|
||||
#sync_slots = 8
|
||||
|
||||
# Seed nodes to connect to for the syncing protocol
|
||||
sync_p2p_seed = ["tls://127.0.0.1:8342"]
|
||||
sync_p2p_seed = ["tls://127.0.0.1:33032"]
|
||||
|
||||
# Peers to connect to for the syncing protocol
|
||||
#sync_p2p_peer = []
|
||||
|
||||
@@ -34,7 +34,7 @@ consensus = false
|
||||
#consensus_slots = 8
|
||||
|
||||
# Connection slots for the consensus protocol
|
||||
#consensus_p2p_seed = ["tls://127.0.0.1:8341"]
|
||||
#consensus_p2p_seed = ["tls://127.0.0.1:33033"]
|
||||
|
||||
# Peers to connect to for the consensus protocol
|
||||
#consensus_p2p_peer = []
|
||||
@@ -49,7 +49,7 @@ sync_p2p_external = "tls://127.0.0.1:8542"
|
||||
#sync_slots = 8
|
||||
|
||||
# Seed nodes to connect to for the syncing protocol
|
||||
sync_p2p_seed = ["tls://127.0.0.1:8342"]
|
||||
sync_p2p_seed = ["tls://127.0.0.1:33032"]
|
||||
|
||||
# Peers to connect to for the syncing protocol
|
||||
#sync_p2p_peer = []
|
||||
|
||||
@@ -31,7 +31,7 @@ sync_p2p_external = "tls://127.0.0.1:8642"
|
||||
#sync_slots = 8
|
||||
|
||||
# Seed nodes to connect to for the syncing protocol
|
||||
sync_p2p_seed = ["tls://127.0.0.1:8342"]
|
||||
sync_p2p_seed = ["tls://127.0.0.1:33032"]
|
||||
|
||||
# Peers to connect to for the syncing protocol
|
||||
#sync_p2p_peer = []
|
||||
|
||||
31
contrib/localnet/lilith_config.toml
Normal file
31
contrib/localnet/lilith_config.toml
Normal file
@@ -0,0 +1,31 @@
|
||||
## lilith 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.
|
||||
|
||||
# Daemon published url, common for all enabled networks
|
||||
url = "tls://127.0.0.1"
|
||||
|
||||
## Per-network settings
|
||||
[network."darkfid_sync"]
|
||||
port = 33032
|
||||
#seeds = []
|
||||
#peers = []
|
||||
|
||||
[network."darkfid_consensus"]
|
||||
port = 33033
|
||||
#seeds = []
|
||||
#peers = []
|
||||
|
||||
#[network."ircd"]
|
||||
#port = 25551
|
||||
#seeds = []
|
||||
#peers = []
|
||||
|
||||
#[network."taud"]
|
||||
#port = 23331
|
||||
#seeds = []
|
||||
#peers = []
|
||||
@@ -1,19 +1,24 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Start a tmux session with two consensus nodes and a non-consensus node, and
|
||||
# Start a tmux session with a lilith node, two consensus nodes, a non-consensus node, and
|
||||
# a faucet that's able to mint tokens.
|
||||
|
||||
tmux new-session -d
|
||||
tmux send-keys "LOG_TARGETS='!sled' ../../darkfid -v -c darkfid0.toml" Enter
|
||||
tmux send-keys "../../lilith -c lilith_config.toml" Enter
|
||||
sleep 2
|
||||
tmux split-window -v
|
||||
tmux send-keys "LOG_TARGETS='!sled' ../../darkfid -v -c darkfid1.toml" Enter
|
||||
sleep 2
|
||||
tmux split-window -h
|
||||
tmux send-keys "LOG_TARGETS='!sled' ../../darkfid -v -c darkfid2.toml" Enter
|
||||
tmux send-keys "LOG_TARGETS='!sled' ../../darkfid -c darkfid0.toml" Enter
|
||||
sleep 2
|
||||
tmux select-pane -t 0
|
||||
tmux split-window -h
|
||||
tmux send-keys "LOG_TARGETS='!sled,!net' ../../faucetd -v -c faucetd.toml" Enter
|
||||
tmux send-keys "LOG_TARGETS='!sled' ../../darkfid -c darkfid1.toml" Enter
|
||||
sleep 2
|
||||
tmux select-pane -t 1
|
||||
tmux split-window -h
|
||||
tmux send-keys "LOG_TARGETS='!sled' ../../darkfid -c darkfid2.toml" Enter
|
||||
sleep 2
|
||||
tmux select-pane -t 3
|
||||
tmux split-window -h
|
||||
tmux send-keys "LOG_TARGETS='!sled,!net' ../../faucetd -c faucetd.toml" Enter
|
||||
tmux attach
|
||||
|
||||
@@ -10,46 +10,57 @@ use log::{debug, info, warn};
|
||||
/// async task used for block syncing.
|
||||
pub async fn block_sync_task(p2p: net::P2pPtr, state: ValidatorStatePtr) -> Result<()> {
|
||||
info!("Starting blockchain sync...");
|
||||
|
||||
// we retrieve p2p network connected channels, so we can use it to
|
||||
// We retrieve p2p network connected channels, so we can use it to
|
||||
// parallelize downloads.
|
||||
let seeds = p2p.settings().seeds.clone();
|
||||
let channels_map = p2p.channels().lock().await;
|
||||
let values = channels_map.values();
|
||||
// Using len here because is_empty() uses unstable library feature
|
||||
// called 'exact_size_is_empty'.
|
||||
if p2p.channels().lock().await.values().len() != 0 {
|
||||
// Currently we will just use the last channel
|
||||
let channel = p2p.channels().lock().await.values().last().unwrap().clone();
|
||||
|
||||
// Communication setup
|
||||
let msg_subsystem = channel.get_message_subsystem();
|
||||
msg_subsystem.add_dispatch::<BlockResponse>().await;
|
||||
let response_sub = channel.subscribe_msg::<BlockResponse>().await?;
|
||||
|
||||
// Node sends the last known block hash of the canonical blockchain
|
||||
// and loops until the response is the same block (used to utilize
|
||||
// batch requests).
|
||||
let mut last = state.read().await.blockchain.last()?;
|
||||
info!("Last known block: {:?} - {:?}", last.0, last.1);
|
||||
|
||||
loop {
|
||||
// Node creates a `BlockOrder` and sends it
|
||||
let order = BlockOrder { slot: last.0, block: last.1 };
|
||||
channel.send(order).await?;
|
||||
|
||||
// Node stores response data.
|
||||
let resp = response_sub.receive().await?;
|
||||
|
||||
// Verify and store retrieved blocks
|
||||
debug!("block_sync_task(): Processing received blocks");
|
||||
state.write().await.receive_sync_blocks(&resp.blocks).await?;
|
||||
|
||||
let last_received = state.read().await.blockchain.last()?;
|
||||
info!("Last received block: {:?} - {:?}", last_received.0, last_received.1);
|
||||
|
||||
if last == last_received {
|
||||
break
|
||||
if values.len() != 0 {
|
||||
// Node iterates the channel peers to ask for their consensus state
|
||||
for channel in values {
|
||||
// Filtering seed channel, as they don't have registered protocols
|
||||
if seeds.contains(&channel.address()) {
|
||||
debug!("Seed channel, continuing..");
|
||||
continue
|
||||
}
|
||||
|
||||
last = last_received;
|
||||
// Communication setup
|
||||
let msg_subsystem = channel.get_message_subsystem();
|
||||
msg_subsystem.add_dispatch::<BlockResponse>().await;
|
||||
let response_sub = channel.subscribe_msg::<BlockResponse>().await?;
|
||||
|
||||
// Node sends the last known block hash of the canonical blockchain
|
||||
// and loops until the response is the same block (used to utilize
|
||||
// batch requests).
|
||||
let mut last = state.read().await.blockchain.last()?;
|
||||
info!("Last known block: {:?} - {:?}", last.0, last.1);
|
||||
|
||||
loop {
|
||||
// Node creates a `BlockOrder` and sends it
|
||||
let order = BlockOrder { slot: last.0, block: last.1 };
|
||||
channel.send(order).await?;
|
||||
|
||||
// Node stores response data.
|
||||
let resp = response_sub.receive().await?;
|
||||
|
||||
// Verify and store retrieved blocks
|
||||
debug!("block_sync_task(): Processing received blocks");
|
||||
state.write().await.receive_sync_blocks(&resp.blocks).await?;
|
||||
|
||||
let last_received = state.read().await.blockchain.last()?;
|
||||
info!("Last received block: {:?} - {:?}", last_received.0, last_received.1);
|
||||
|
||||
if last == last_received {
|
||||
break
|
||||
}
|
||||
|
||||
last = last_received;
|
||||
}
|
||||
|
||||
// Currently we use the first channel we connect to
|
||||
break
|
||||
}
|
||||
} else {
|
||||
warn!("Node is not connected to other nodes");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use log::{info, warn};
|
||||
use log::{debug, info, warn};
|
||||
|
||||
use crate::{
|
||||
consensus::{
|
||||
@@ -12,6 +12,7 @@ use crate::{
|
||||
/// async task used for consensus state syncing.
|
||||
pub async fn consensus_sync_task(p2p: P2pPtr, state: ValidatorStatePtr) -> Result<()> {
|
||||
info!("Starting consensus state sync...");
|
||||
let seeds = p2p.settings().seeds.clone();
|
||||
let channels_map = p2p.channels().lock().await;
|
||||
let values = channels_map.values();
|
||||
// Using len here because is_empty() uses unstable library feature
|
||||
@@ -19,6 +20,12 @@ pub async fn consensus_sync_task(p2p: P2pPtr, state: ValidatorStatePtr) -> Resul
|
||||
if values.len() != 0 {
|
||||
// Node iterates the channel peers to ask for their consensus state
|
||||
for channel in values {
|
||||
// Filtering seed channel, as they don't have registered protocols
|
||||
if seeds.contains(&channel.address()) {
|
||||
debug!("Seed channel, continuing..");
|
||||
continue
|
||||
}
|
||||
|
||||
// Communication setup
|
||||
let msg_subsystem = channel.get_message_subsystem();
|
||||
msg_subsystem.add_dispatch::<ConsensusResponse>().await;
|
||||
|
||||
Reference in New Issue
Block a user