Skip to content

Commit eff20e0

Browse files
committed
fix(gw-listener): prevent drift detection errors from killing the listener
All drift detection code paths now log-and-continue instead of propagating errors to run_get_logs. A transient DB or RPC failure during drift checking should not interrupt processing of VerifyProofRequest, ActivateKey, or ActivateCrs events.
1 parent d3c779a commit eff20e0

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

coprocessor/fhevm-engine/gw-listener/src/gw_listener.rs

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,16 @@ impl<P: Provider<Ethereum> + Clone + 'static, A: AwsS3Interface + Clone + 'stati
156156
.map(|block| block.saturating_sub(1))
157157
.or(last_processed_block_num);
158158
let expected_senders = if let Some(gw_config_addr) = self.conf.gateway_config_address {
159-
self.fetch_expected_senders(gw_config_addr, sender_seed_block)
160-
.await?
159+
match self
160+
.fetch_expected_senders(gw_config_addr, sender_seed_block)
161+
.await
162+
{
163+
Ok(senders) => senders,
164+
Err(e) => {
165+
error!(error = %e, "Failed to fetch expected tx-senders; drift detection disabled until GatewayConfig event arrives");
166+
Vec::new()
167+
}
168+
}
161169
} else {
162170
Vec::new()
163171
};
@@ -168,13 +176,17 @@ impl<P: Provider<Ethereum> + Clone + 'static, A: AwsS3Interface + Clone + 'stati
168176
self.conf.drift_post_consensus_grace_blocks,
169177
);
170178
if replay_from_block.is_none() {
171-
self.rebuild_drift_detector(
172-
db_pool,
173-
&mut drift_detector,
174-
progress.earliest_open_ct_commits_block,
175-
last_processed_block_num,
176-
)
177-
.await?;
179+
if let Err(e) = self
180+
.rebuild_drift_detector(
181+
db_pool,
182+
&mut drift_detector,
183+
progress.earliest_open_ct_commits_block,
184+
last_processed_block_num,
185+
)
186+
.await
187+
{
188+
error!(error = %e, "Failed to rebuild drift detector; continuing with partial state");
189+
}
178190
}
179191

180192
let filter_addresses = {
@@ -310,23 +322,29 @@ impl<P: Provider<Ethereum> + Clone + 'static, A: AwsS3Interface + Clone + 'stati
310322
}
311323
}
312324
a if Some(a) == self.conf.ciphertext_commits_address => {
313-
self.process_ciphertext_commits_log(
325+
if let Err(e) = self.process_ciphertext_commits_log(
314326
&mut drift_detector,
315327
log,
316328
to_block,
317329
db_pool,
318330
)
319-
.await?;
331+
.await {
332+
error!(error = %e, "Failed to process CiphertextCommits log");
333+
}
320334
}
321335
a if Some(a) == self.conf.gateway_config_address => {
322-
self.process_gateway_config_log(&mut drift_detector, log)?;
336+
if let Err(e) = self.process_gateway_config_log(&mut drift_detector, log) {
337+
error!(error = %e, "Failed to process GatewayConfig log");
338+
}
323339
}
324340
_ => {
325341
error!(log = ?log, "Unexpected log address");
326342
}
327343
}
328344
}
329-
drift_detector.end_of_batch(to_block, db_pool).await?;
345+
if let Err(e) = drift_detector.end_of_batch(to_block, db_pool).await {
346+
error!(error = %e, "Drift detector end_of_batch failed");
347+
}
330348
last_processed_block_num = Some(to_block);
331349
if replay_from_block.is_some() {
332350
if to_block == current_block {

0 commit comments

Comments
 (0)