Skip to content

Commit b1a0344

Browse files
authored
Merge pull request #76 from NillionNetwork/chore/keeper-logging
chore: add more logging to keeper
2 parents 42ae3f9 + 9308d67 commit b1a0344

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

keeper/src/l2/supervisor.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use alloy::{eips::BlockId, providers::Provider};
1212
use anyhow::Context;
1313
use std::sync::Arc;
1414
use tokio::{sync::Mutex, time::interval};
15-
use tracing::{debug, error, info};
15+
use tracing::{error, info};
1616

1717
pub struct L2Supervisor {
1818
client: Arc<L2KeeperClient>,
@@ -121,25 +121,28 @@ impl L2Supervisor {
121121
loop {
122122
ticker.tick().await;
123123

124-
let block_timestamp = match self.client.provider().get_block(BlockId::latest()).await {
125-
Ok(Some(block)) => {
126-
metrics::get().l2.escalations.set_block(block.header.number);
127-
block.header.timestamp
128-
}
129-
Ok(None) => {
130-
error!("No latest block found (is the chain working?)");
131-
continue;
132-
}
133-
Err(e) => {
134-
error!("Failed to fetch latest block: {e}");
135-
continue;
136-
}
137-
};
124+
let (block, block_timestamp) =
125+
match self.client.provider().get_block(BlockId::latest()).await {
126+
Ok(Some(block)) => {
127+
metrics::get().l2.escalations.set_block(block.header.number);
128+
(block.header.number, block.header.timestamp)
129+
}
130+
Ok(None) => {
131+
error!("No latest block found (is the chain working?)");
132+
continue;
133+
}
134+
Err(e) => {
135+
error!("Failed to fetch latest block: {e}");
136+
continue;
137+
}
138+
};
139+
info!("Processing block {block}");
138140

139141
if let Err(e) = self.rewards_distributor.sync_state().await {
140142
error!("Error syncing state: {e}");
141143
}
142144

145+
info!("Processing escalations for block {block}");
143146
if let Err(e) = self
144147
.round_escalator
145148
.process_escalations(block_timestamp)
@@ -148,10 +151,11 @@ impl L2Supervisor {
148151
error!("Failed to process escalations: {e}");
149152
}
150153

154+
info!("Processing rounds for block {block}");
151155
self.process_rounds(block_timestamp).await;
152156

153157
if let Some(ref responder) = erc8004_responder {
154-
debug!("Tick: processing ERC-8004 validation responses");
158+
info!("Processing ERC-8004 validation responses for block {block}");
155159
if let Err(e) = responder.process_responses().await {
156160
error!("Failed to process ERC-8004 validation responses: {e}");
157161
}
@@ -176,6 +180,7 @@ impl L2Supervisor {
176180

177181
{
178182
let state = self.state.lock().await;
183+
info!("Keeping track of {} rounds", state.rounds.len());
179184
for (key, round) in state.rounds.iter() {
180185
if let Some(outcome) = round.outcome {
181186
if !round.rewards_done && !round.members.is_empty() {
@@ -188,10 +193,12 @@ impl L2Supervisor {
188193
}
189194
}
190195

196+
info!("Have {} reward jobs to process", reward_jobs.len());
191197
for (key, outcome, members) in reward_jobs {
192198
if outcome == 0 {
193199
continue;
194200
}
201+
info!("Distributing rewards for key {key:?}");
195202
if let Err(e) = self
196203
.rewards_distributor
197204
.distribute_rewards(block_timestamp, key, outcome, members)
@@ -201,6 +208,7 @@ impl L2Supervisor {
201208
}
202209
}
203210

211+
info!("Have {} jail jobs to process", jail_jobs.len());
204212
for (key, members) in jail_jobs {
205213
if let Err(e) = self.jailer.enforce(key, members).await {
206214
error!(

0 commit comments

Comments
 (0)