Compare commits

...

3 Commits

Author SHA1 Message Date
0g-peterzhb
ce7393180b
Merge f456773b72 into 22ed8f5f91 2024-08-16 10:34:52 +08:00
Bo QIU
22ed8f5f91
opt router debug logs (#160)
Some checks failed
abi-consistent-check / build-and-compare (push) Has been cancelled
code-coverage / unittest-cov (push) Has been cancelled
rust / check (push) Has been cancelled
rust / test (push) Has been cancelled
rust / lints (push) Has been cancelled
functional-test / test (push) Has been cancelled
2024-08-16 10:34:28 +08:00
Peter Zhang
f456773b72 remove update_config.sh, users can pass in cli params to the program 2024-07-17 17:43:19 +08:00
4 changed files with 20 additions and 46 deletions

View File

@ -26,10 +26,10 @@ use crate::peer_manager::PeerManager;
use crate::Config;
lazy_static::lazy_static! {
pub static ref FIND_FILE_TIMEOUT: chrono::Duration = chrono::Duration::minutes(2);
pub static ref ANNOUNCE_FILE_TIMEOUT: chrono::Duration = chrono::Duration::minutes(2);
pub static ref ANNOUNCE_SHARD_CONFIG_TIMEOUT: chrono::Duration = chrono::Duration::minutes(2);
pub static ref TOLERABLE_DRIFT: chrono::Duration = chrono::Duration::seconds(5);
pub static ref FIND_FILE_TIMEOUT: chrono::Duration = chrono::Duration::minutes(5);
pub static ref ANNOUNCE_FILE_TIMEOUT: chrono::Duration = chrono::Duration::minutes(5);
pub static ref ANNOUNCE_SHARD_CONFIG_TIMEOUT: chrono::Duration = chrono::Duration::minutes(5);
pub static ref TOLERABLE_DRIFT: chrono::Duration = chrono::Duration::seconds(10);
}
#[allow(deprecated)]
@ -403,7 +403,7 @@ impl Libp2pEventHandler {
// verify timestamp
let d = duration_since(timestamp);
if d < TOLERABLE_DRIFT.neg() || d > *FIND_FILE_TIMEOUT {
debug!(%timestamp, "Invalid timestamp, ignoring FindFile message");
debug!(%timestamp, ?d, "Invalid timestamp, ignoring FindFile message");
return MessageAcceptance::Ignore;
}
@ -481,7 +481,7 @@ impl Libp2pEventHandler {
// verify timestamp
let d = duration_since(msg.timestamp);
if d < TOLERABLE_DRIFT.neg() || d > *FIND_FILE_TIMEOUT {
debug!(%msg.timestamp, "Invalid timestamp, ignoring FindFile message");
debug!(%msg.timestamp, ?d, "Invalid timestamp, ignoring FindFile message");
return MessageAcceptance::Ignore;
}
@ -550,7 +550,8 @@ impl Libp2pEventHandler {
let seen_ips: Vec<IpAddr> = match self.network_globals.peers.read().peer_info(peer_id) {
Some(v) => v.seen_ip_addresses().collect(),
None => {
debug!(%announced_ip, "Failed to verify announced IP address, no peer info found");
// ignore file announcement from un-seen peers
trace!(%announced_ip, "Failed to verify announced IP address, no peer info found");
return false;
}
};
@ -558,7 +559,8 @@ impl Libp2pEventHandler {
if seen_ips.iter().any(|x| *x == announced_ip) {
true
} else {
debug!(%announced_ip, ?seen_ips, "Failed to verify announced IP address, mismatch with seen ips");
// ignore file announcement if announced IP and seen IP mismatch
trace!(%announced_ip, ?seen_ips, "Failed to verify announced IP address, mismatch with seen ips");
false
}
}
@ -587,7 +589,7 @@ impl Libp2pEventHandler {
// propagate gossip to peers
let d = duration_since(msg.resend_timestamp);
if d < TOLERABLE_DRIFT.neg() || d > *ANNOUNCE_FILE_TIMEOUT {
debug!(%msg.resend_timestamp, "Invalid resend timestamp, ignoring AnnounceFile message");
debug!(%msg.resend_timestamp, ?d, "Invalid resend timestamp, ignoring AnnounceFile message");
return MessageAcceptance::Ignore;
}
@ -628,7 +630,7 @@ impl Libp2pEventHandler {
// propagate gossip to peers
let d = duration_since(msg.resend_timestamp);
if d < TOLERABLE_DRIFT.neg() || d > *ANNOUNCE_SHARD_CONFIG_TIMEOUT {
debug!(%msg.resend_timestamp, "Invalid resend timestamp, ignoring AnnounceShardConfig message");
debug!(%msg.resend_timestamp, ?d, "Invalid resend timestamp, ignoring AnnounceShardConfig message");
return MessageAcceptance::Ignore;
}
@ -674,7 +676,7 @@ impl Libp2pEventHandler {
// propagate gossip to peers
let d = duration_since(msg.resend_timestamp);
if d < TOLERABLE_DRIFT.neg() || d > *ANNOUNCE_FILE_TIMEOUT {
debug!(%msg.resend_timestamp, "Invalid resend timestamp, ignoring AnnounceChunks message");
debug!(%msg.resend_timestamp, ?d, "Invalid resend timestamp, ignoring AnnounceChunks message");
return MessageAcceptance::Ignore;
}

View File

@ -749,7 +749,7 @@ impl SyncService {
to_terminate.push(*tx_seq);
}
}
} else {
} else if self.controllers.contains_key(&min_tx_seq) {
to_terminate.push(min_tx_seq);
}
@ -757,9 +757,12 @@ impl SyncService {
self.controllers.remove(tx_seq);
}
debug!(?to_terminate, "File sync terminated");
let num_terminated = to_terminate.len();
if num_terminated > 0 {
debug!(?to_terminate, "File sync terminated");
}
to_terminate.len()
num_terminated
}
fn on_heartbeat(&mut self) {

View File

@ -1 +1 @@
debug,hyper=info,h2=info,rpc=info,discv5=info,router=info,jsonrpsee_http_server=info
debug,hyper=info,h2=info,rpc=info,discv5=info,jsonrpsee_http_server=info

View File

@ -1,31 +0,0 @@
#!/bin/bash
MINER_KEY=""
MINE_CONTRACT=""
BLOCKCHAIN_RPC=""
FLOW_CONTRACT=""
BLOCK_NUMBER=0
PUBLIC_IP=$(curl -s https://ipinfo.io/ip)
FILE=run/config.toml
# enable sync
sed -in-place='' 's/# \[sync\]/\[sync\]/g' $FILE
# enable auto_sync
sed -in-place='' 's/# auto_sync_enabled = false/auto_sync_enabled = true/g' $FILE
# reduce timeout for finding peers
sed -in-place='' 's/# find_peer_timeout = .*/find_peer_timeout = "10s"/g' $FILE
# set public ip
sed -in-place='' "s/# network_enr_address = .*/network_enr_address = \"$PUBLIC_IP\"/g" $FILE
# set miner key
sed -in-place='' "s/miner_key = \"\"/miner_key = \"$MINER_KEY\"/g" $FILE
# set miner contract address
sed -in-place='' "s/mine_contract_address = .*/mine_contract_address = \"$MINE_CONTRACT\"/g" $FILE
# set blockchain rpc endpoint
sed -in-place='' "s|blockchain_rpc_endpoint = .*|blockchain_rpc_endpoint = \"$BLOCKCHAIN_RPC\"|g" $FILE
# set flow contract address
sed -in-place='' "s/log_contract_address = .*/log_contract_address = \"$FLOW_CONTRACT\"/g" $FILE
# set contract deployed block number
sed -in-place='' "s/log_sync_start_block_number = .*/log_sync_start_block_number = $BLOCK_NUMBER/g" $FILE
# update the boot node ids
sed -in-place='' 's|network_boot_nodes = .*|network_boot_nodes = ["/ip4/54.219.26.22/udp/1234/p2p/16Uiu2HAmTVDGNhkHD98zDnJxQWu3i1FL1aFYeh9wiQTNu4pDCgps","/ip4/52.52.127.117/udp/1234/p2p/16Uiu2HAkzRjxK2gorngB1Xq84qDrT4hSVznYDHj6BkbaE4SGx9oS","/ip4/18.167.69.68/udp/1234/p2p/16Uiu2HAm2k6ua2mGgvZ8rTMV8GhpW71aVzkQWy7D37TTDuLCpgmX"]|g' $FILE