mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 07:08:05 -05:00
faucetd: added missing decoding crate
localnet/tmux_sessions.sh modified to keep pane open if code crashes on init consensus/protos: some extra logging
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -1678,6 +1678,7 @@ dependencies = [
|
||||
"async-std",
|
||||
"async-trait",
|
||||
"blake3",
|
||||
"bs58",
|
||||
"chrono",
|
||||
"ctrlc-async",
|
||||
"darkfi",
|
||||
|
||||
@@ -14,6 +14,7 @@ async-executor = "1.4.1"
|
||||
async-std = "1.11.0"
|
||||
async-trait = "0.1.53"
|
||||
blake3 = "1.3.1"
|
||||
bs58 = "0.4.0"
|
||||
chrono = "0.4.19"
|
||||
ctrlc-async = {version = "3.2.2", default-features = false, features = ["async-std", "termination"]}
|
||||
darkfi = {path = "../../", features = ["blockchain", "wallet", "rpc", "net", "node"]}
|
||||
@@ -22,7 +23,7 @@ futures-lite = "1.12.0"
|
||||
hex = "0.4.3"
|
||||
lazy-init = "0.5.0"
|
||||
log = "0.4.17"
|
||||
num-bigint = "0.4.3"
|
||||
num-bigint = {version = "0.4.3", features = ["serde"]}
|
||||
rand = "0.8.5"
|
||||
serde_json = "1.0.81"
|
||||
simplelog = "0.12.0"
|
||||
|
||||
@@ -4,12 +4,16 @@ set -e
|
||||
# Start a tmux session with two consensus nodes and a non-consensus node, and
|
||||
# a faucet that's able to mint tokens.
|
||||
|
||||
tmux new-session -d "LOG_TARGETS='!sled' ../../darkfid -v -c darkfid0.toml"
|
||||
tmux new-session -d
|
||||
tmux send-keys "LOG_TARGETS='!sled' ../../darkfid -v -c darkfid0.toml" Enter
|
||||
sleep 2
|
||||
tmux split-window -v "LOG_TARGETS='!sled' ../../darkfid -v -c darkfid1.toml"
|
||||
tmux split-window -v
|
||||
tmux send-keys "LOG_TARGETS='!sled' ../../darkfid -v -c darkfid1.toml" Enter
|
||||
sleep 2
|
||||
tmux split-window -h "LOG_TARGETS='!sled' ../../darkfid -v -c darkfid2.toml"
|
||||
tmux split-window -h
|
||||
tmux send-keys "LOG_TARGETS='!sled' ../../darkfid -v -c darkfid2.toml" Enter
|
||||
sleep 2
|
||||
tmux select-pane -t 0
|
||||
tmux split-window -h "LOG_TARGETS='!sled' ../../faucetd -v -c faucetd.toml"
|
||||
tmux split-window -h
|
||||
tmux send-keys "LOG_TARGETS='!sled,!net' ../../faucetd -v -c faucetd.toml" Enter
|
||||
tmux attach
|
||||
|
||||
@@ -2,7 +2,7 @@ use async_std::sync::Arc;
|
||||
|
||||
use async_executor::Executor;
|
||||
use async_trait::async_trait;
|
||||
use log::{debug, error, warn};
|
||||
use log::{debug, error, info, warn};
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
@@ -59,18 +59,25 @@ impl ProtocolProposal {
|
||||
}
|
||||
};
|
||||
|
||||
debug!("ProtocolProposal::handle_receive_proposal() recv: {:?}", proposal);
|
||||
info!("ProtocolProposal::handle_receive_proposal() recv: {:?}", proposal);
|
||||
|
||||
let proposal_copy = (*proposal).clone();
|
||||
|
||||
debug!("handle_receive_proposal(): Starting state transition validation");
|
||||
debug!(
|
||||
"ProtocolProposal::handle_receive_proposal(): Starting state transition validation"
|
||||
);
|
||||
let canon_state_clone = self.state.read().await.state_machine.lock().await.clone();
|
||||
let mem_state = MemoryState::new(canon_state_clone);
|
||||
|
||||
match ValidatorState::validate_state_transitions(mem_state, &proposal_copy.block.txs) {
|
||||
Ok(_) => debug!("handle_receive_proposal(): State transition valid"),
|
||||
Ok(_) => {
|
||||
debug!("ProtocolProposal::handle_receive_proposal(): State transition valid")
|
||||
}
|
||||
Err(e) => {
|
||||
warn!("handle_receive_proposal(): State transition fail: {}", e);
|
||||
warn!(
|
||||
"ProtocolProposal::handle_receive_proposal(): State transition fail: {}",
|
||||
e
|
||||
);
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -78,7 +85,7 @@ impl ProtocolProposal {
|
||||
let vote = match self.state.write().await.receive_proposal(&proposal_copy) {
|
||||
Ok(v) => {
|
||||
if v.is_none() {
|
||||
debug!("handle_receive_proposal(): Node didn't vote for proposed block.");
|
||||
debug!("ProtocolProposal::handle_receive_proposal(): Node didn't vote for proposed block.");
|
||||
continue
|
||||
}
|
||||
v.unwrap()
|
||||
@@ -90,18 +97,21 @@ impl ProtocolProposal {
|
||||
};
|
||||
|
||||
if let Err(e) = self.state.write().await.receive_vote(&vote).await {
|
||||
error!("handle_receive_proposal(): receive_vote error: {}", e);
|
||||
error!("ProtocolProposal::handle_receive_proposal(): receive_vote error: {}", e);
|
||||
continue
|
||||
}
|
||||
|
||||
// Broadcast block to rest of nodes
|
||||
if let Err(e) = self.p2p.broadcast_with_exclude(proposal_copy, &exclude_list).await {
|
||||
error!("handle_receive_proposal(): proposal broadcast fail: {}", e);
|
||||
error!(
|
||||
"ProtocolProposal::handle_receive_proposal(): proposal broadcast fail: {}",
|
||||
e
|
||||
);
|
||||
};
|
||||
|
||||
// Broadcast vote
|
||||
if let Err(e) = self.p2p.broadcast(vote).await {
|
||||
error!("handle_receive_proposal(): vote broadcast fail: {}", e);
|
||||
error!("ProtocolProposal::handle_receive_proposal(): vote broadcast fail: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use async_executor::Executor;
|
||||
use async_std::sync::{Arc, Mutex};
|
||||
use async_trait::async_trait;
|
||||
use log::{debug, error, warn};
|
||||
use log::{debug, error, info, warn};
|
||||
|
||||
use crate::{
|
||||
consensus::{
|
||||
@@ -57,7 +57,7 @@ impl ProtocolSync {
|
||||
}
|
||||
|
||||
async fn handle_receive_request(self: Arc<Self>) -> Result<()> {
|
||||
debug!("handle_receive_request() [START]");
|
||||
debug!("ProtocolSync::handle_receive_request() [START]");
|
||||
loop {
|
||||
let order = match self.request_sub.receive().await {
|
||||
Ok(v) => v,
|
||||
@@ -67,7 +67,7 @@ impl ProtocolSync {
|
||||
}
|
||||
};
|
||||
|
||||
debug!("handle_receive_request() received {:?}", order);
|
||||
debug!("ProtocolSync::handle_receive_request() received {:?}", order);
|
||||
|
||||
// Extra validations can be added here
|
||||
let key = order.sl;
|
||||
@@ -78,7 +78,7 @@ impl ProtocolSync {
|
||||
continue
|
||||
}
|
||||
};
|
||||
debug!("handle_receive_request(): Found {} blocks", blocks.len());
|
||||
debug!("ProtocolSync::handle_receive_request(): Found {} blocks", blocks.len());
|
||||
|
||||
let response = BlockResponse { blocks };
|
||||
if let Err(e) = self.channel.send(response).await {
|
||||
@@ -91,11 +91,13 @@ impl ProtocolSync {
|
||||
// Consensus-mode enabled nodes have already performed these steps,
|
||||
// during proposal finalization.
|
||||
if self.consensus_mode {
|
||||
debug!("handle_receive_block(): node runs in consensus mode, skipping...");
|
||||
debug!(
|
||||
"ProtocolSync::handle_receive_block(): node runs in consensus mode, skipping..."
|
||||
);
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
debug!("handle_receive_block() [START]");
|
||||
debug!("ProtocolSync::handle_receive_block() [START]");
|
||||
let exclude_list = vec![self.channel.address()];
|
||||
loop {
|
||||
let info = match self.block_sub.receive().await {
|
||||
@@ -106,13 +108,13 @@ impl ProtocolSync {
|
||||
}
|
||||
};
|
||||
|
||||
debug!("handle_receive_block() received block");
|
||||
info!("ProtocolSync::handle_receive_block() Received block {}", info.blockhash());
|
||||
|
||||
// We block here if there's a pending validation, otherwise we might
|
||||
// apply the same block twice.
|
||||
debug!("handle_receive_block(): Waiting for pending block to apply");
|
||||
debug!("ProtocolSync::handle_receive_block(): Waiting for pending block to apply");
|
||||
while *self.pending.lock().await {}
|
||||
debug!("handle_receive_block(): Pending lock released");
|
||||
debug!("ProtocolSync::handle_receive_block(): Pending lock released");
|
||||
|
||||
// Node stores finalized block, if it doesn't exist (checking by slot),
|
||||
// and removes its transactions from the unconfirmed_txs vector.
|
||||
@@ -123,51 +125,62 @@ impl ProtocolSync {
|
||||
let has_block = match self.state.read().await.blockchain.has_block(&info_copy) {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
error!("handle_receive_block(): failed checking for has_block(): {}", e);
|
||||
error!(
|
||||
"ProtocolSync::handle_receive_block(): failed checking for has_block(): {}",
|
||||
e
|
||||
);
|
||||
*self.pending.lock().await = false;
|
||||
continue
|
||||
}
|
||||
};
|
||||
|
||||
if !has_block {
|
||||
debug!("handle_receive_block(): Starting state transition validation");
|
||||
debug!(
|
||||
"ProtocolSync::handle_receive_block(): Starting state transition validation"
|
||||
);
|
||||
let canon_state_clone = self.state.read().await.state_machine.lock().await.clone();
|
||||
let mem_state = MemoryState::new(canon_state_clone);
|
||||
let state_updates =
|
||||
match ValidatorState::validate_state_transitions(mem_state, &info.txs) {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
warn!("handle_receive_block(): State transition fail: {}", e);
|
||||
warn!(
|
||||
"ProtocolSync::handle_receive_block(): State transition fail: {}",
|
||||
e
|
||||
);
|
||||
*self.pending.lock().await = false;
|
||||
continue
|
||||
}
|
||||
};
|
||||
debug!("handle_receive_block(): All state transitions passed");
|
||||
debug!("ProtocolSync::handle_receive_block(): All state transitions passed");
|
||||
|
||||
debug!("handle_receive_block(): Updating canon state machine");
|
||||
debug!("ProtocolSync::handle_receive_block(): Updating canon state machine");
|
||||
if let Err(e) =
|
||||
self.state.write().await.update_canon_state(state_updates, None).await
|
||||
{
|
||||
error!("handle_receive_block(): Canon statemachine update fail: {}", e);
|
||||
error!(
|
||||
"ProtocolSync::handle_receive_block(): Canon statemachine update fail: {}",
|
||||
e
|
||||
);
|
||||
*self.pending.lock().await = false;
|
||||
continue
|
||||
};
|
||||
|
||||
debug!("handle_receive_block(): Appending block to ledger");
|
||||
debug!("ProtocolSync::handle_receive_block(): Appending block to ledger");
|
||||
if let Err(e) = self.state.write().await.blockchain.add(&[info_copy.clone()]) {
|
||||
error!("handle_receive_block(): blockchain.add() fail: {}", e);
|
||||
error!("ProtocolSync::handle_receive_block(): blockchain.add() fail: {}", e);
|
||||
*self.pending.lock().await = false;
|
||||
continue
|
||||
};
|
||||
|
||||
if let Err(e) = self.state.write().await.remove_txs(info_copy.txs.clone()) {
|
||||
error!("handle_receive_block(): remove_txs() fail: {}", e);
|
||||
error!("ProtocolSync::handle_receive_block(): remove_txs() fail: {}", e);
|
||||
*self.pending.lock().await = false;
|
||||
continue
|
||||
};
|
||||
|
||||
if let Err(e) = self.p2p.broadcast_with_exclude(info_copy, &exclude_list).await {
|
||||
error!("handle_receive_block(): p2p broadcast fail: {}", e);
|
||||
error!("ProtocolSync::handle_receive_block(): p2p broadcast fail: {}", e);
|
||||
*self.pending.lock().await = false;
|
||||
continue
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user