Skip to content

Commit 7ab47e7

Browse files
committed
chore(consensus): use tracing in narwhal
1 parent f2c618d commit 7ab47e7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

core/consensus/src/narwhal.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use narwhal_node::NodeStorage;
1313
use sui_protocol_config::{Chain, ProtocolConfig, ProtocolVersion};
1414
use tokio::sync::Mutex;
1515
use tokio::time::Instant;
16+
use tracing::{debug, error, trace, warn};
1617

1718
use crate::validator::Validator;
1819

@@ -114,23 +115,23 @@ impl NarwhalService {
114115
{
115116
let mut status = self.status.lock().await;
116117
if *status == Status::Running {
117-
println!("NarwhalService is already running.");
118+
error!("NarwhalService is already running.");
118119
return;
119120
}
120121

121122
let name = self.arguments.primary_keypair.public().clone();
122123
let execution_state = Arc::new(state);
123124

124125
let epoch = self.committee.epoch();
125-
println!("Starting NarwhalService for epoch {epoch}");
126+
debug!("Starting NarwhalService for epoch {epoch}");
126127

127128
// create the network client the primary and worker use to communicate
128129
let network_client =
129130
NetworkClient::new_from_keypair(&self.arguments.primary_network_keypair);
130131

131132
let mut running = false;
132133
for i in 0..MAX_RETRIES {
133-
println!("Trying to start the Narwhal Primary...");
134+
debug!("Trying to start the Narwhal Primary...");
134135
if i > 0 {
135136
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
136137
}
@@ -149,7 +150,7 @@ impl NarwhalService {
149150
)
150151
.await
151152
{
152-
println!("Unable to start Narwhal Primary: {e:?}");
153+
warn!("Unable to start Narwhal Primary: {e:?}");
153154
} else {
154155
running = true;
155156
break;
@@ -161,7 +162,7 @@ impl NarwhalService {
161162

162163
let mut running = false;
163164
for i in 0..MAX_RETRIES {
164-
println!("Trying to start the Narwhal Worker...");
165+
debug!("Trying to start the Narwhal Worker...");
165166
if i > 0 {
166167
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
167168
}
@@ -180,7 +181,7 @@ impl NarwhalService {
180181
)
181182
.await
182183
{
183-
println!("Unable to start Narwhal Worker: {e:?}");
184+
warn!("Unable to start Narwhal Worker: {e:?}");
184185
} else {
185186
running = true;
186187
break;
@@ -198,18 +199,18 @@ impl NarwhalService {
198199
pub async fn shutdown(&self) {
199200
let mut status = self.status.lock().await;
200201
if *status == Status::Stopped {
201-
println!("Narwhal shutdown was called but node is not running.");
202+
error!("Narwhal shutdown was called but node is not running.");
202203
return;
203204
}
204205

205206
let now = Instant::now();
206207
let epoch = self.committee.epoch();
207-
println!("Shutting down Narwhal epoch {epoch:?}");
208+
trace!("Shutting down Narwhal epoch {epoch:?}");
208209

209210
self.worker_node.shutdown().await;
210211
self.primary.shutdown().await;
211212

212-
println!(
213+
debug!(
213214
"Narwhal shutdown for epoch {:?} is complete - took {} seconds",
214215
epoch,
215216
now.elapsed().as_secs_f64()

0 commit comments

Comments
 (0)