Skip to content

Commit

Permalink
add/remove some info
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzhhuang committed Dec 27, 2024
1 parent ee7e8ba commit 80043d7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
6 changes: 0 additions & 6 deletions block-relayer/src/block_relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,6 @@ impl EventHandler<Self, PeerCompactBlockMessage> for BlockRelayer {
if let Some(metrics) = self.metrics.as_ref() {
metrics.block_relay_time.observe(time_sec);
}
sl_info!(
"{action} {hash} {time_sec}",
time_sec = time_sec,
hash = compact_block_msg.message.compact_block.header.id().to_hex(),
action = "block_relay_time",
);
//TODO should filter too old block?

if let Err(e) = self.handle_block_event(compact_block_msg, ctx) {
Expand Down
12 changes: 6 additions & 6 deletions network-p2p/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1308,12 +1308,12 @@ impl<T: BusinessLayerHandle + Send> Future for NetworkWorker<T> {
})) => {
if let Some(metrics) = this.metrics.as_ref() {
for (protocol, message) in &messages {
info!(
"[network-p2p] receive notification from {} {} {}",
remote,
protocol,
message.len()
);
// info!(
// "[network-p2p] receive notification from {} {} {}",
// remote,
// protocol,
// message.len()
// );
metrics
.notifications_sizes
.with_label_values(&["in", protocol])
Expand Down
20 changes: 10 additions & 10 deletions network/api/src/peer_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,18 @@ impl PeerSelector {
peers
});
if best_peers.is_empty() || best_peers[0].total_difficulty() <= min_difficulty {
info!(
"best peer difficulty {:?} is smaller than min difficulty {:?}, return None",
best_peers[0].total_difficulty(),
min_difficulty
);
// info!(
// "best peer difficulty {:?} is smaller than min difficulty {:?}, return None",
// best_peers[0].total_difficulty(),
// min_difficulty
// );
None
} else {
info!(
"best peer difficulty {:?}, info: {:?} picked",
best_peers[0].total_difficulty(),
best_peers
);
// info!(
// "best peer difficulty {:?}, info: {:?} picked",
// best_peers[0].total_difficulty(),
// best_peers
// );
Some(best_peers)
}
}
Expand Down
22 changes: 20 additions & 2 deletions sync/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use starcoin_network::PeerEvent;
use starcoin_service_registry::{
ActorService, EventHandler, ServiceContext, ServiceFactory, ServiceHandler,
};
use starcoin_storage::block::DagSyncBlock;
use starcoin_storage::block_info::BlockInfoStore;
use starcoin_storage::{BlockStore, Storage};
use starcoin_sync_api::{
Expand Down Expand Up @@ -666,6 +667,8 @@ impl ServiceHandler<Self, SyncSpecificTagretRequest> for SyncService {
None => {
if let Some(block) = storage.get_block(msg.block_id)? {
block
} else if let Some(sync_dag_block) = storage.get_dag_sync_block(msg.block_id)? {
sync_dag_block.block
} else {
let block_from_remote = verified_rpc_client
.get_block_diligently(vec![msg.block_id])
Expand All @@ -676,7 +679,7 @@ impl ServiceHandler<Self, SyncSpecificTagretRequest> for SyncService {
msg.block_id
));
}
block_from_remote
let block = block_from_remote
.first()
.as_ref()
.expect("it should not be none, because the len = 1")
Expand All @@ -685,7 +688,12 @@ impl ServiceHandler<Self, SyncSpecificTagretRequest> for SyncService {
format_err!("Get block by id failed, block id: {:?}", msg.block_id)
})?
.0
.clone()
.clone();
storage.save_dag_sync_block(DagSyncBlock {
block: block.clone(),
children: vec![],
})?;
block
}
}
};
Expand All @@ -695,6 +703,10 @@ impl ServiceHandler<Self, SyncSpecificTagretRequest> for SyncService {
let mut blocks_to_be_executed = vec![];

// ensure the previous blocks are ready to be executed or were executed already
info!(
"[sync specific] Start to sync specific block: {:?}",
specific_block.id()
);
while !current_round.is_empty() {
for block_id in current_round {
// already executed
Expand Down Expand Up @@ -737,6 +749,10 @@ impl ServiceHandler<Self, SyncSpecificTagretRequest> for SyncService {
.collect::<Vec<_>>();
blocks_to_be_executed.extend(next_round);
next_round = vec![];
info!(
"[sync specific] Fetch parents blocks, current_round: {:?}",
current_round
);
}
let mut waiting_for_execution_heap = blocks_to_be_executed
.into_iter()
Expand All @@ -746,6 +762,7 @@ impl ServiceHandler<Self, SyncSpecificTagretRequest> for SyncService {
.collect::<BinaryHeap<_>>();

let mut failed_blocks: Vec<Block> = vec![];
info!("[sync specific] Start to execute blocks");
loop {
let block = match waiting_for_execution_heap.pop() {
Some(sync_block) => sync_block.block,
Expand Down Expand Up @@ -775,6 +792,7 @@ impl ServiceHandler<Self, SyncSpecificTagretRequest> for SyncService {
}
}
}
info!("[sync specific] Sync specific block done");
Ok(())
};

Expand Down

0 comments on commit 80043d7

Please sign in to comment.