Skip to content

Commit c70c7f8

Browse files
devin-ai-integration[bot]Jayant Krishnamurthy
andauthored
feat(fortuna): retry processing backlog using configured block_delays (#2436)
* feat(fortuna): retry processing backlog using configured block_delays Co-Authored-By: Jayant Krishnamurthy <[email protected]> * chore(fortuna): update Cargo.lock for version bump Co-Authored-By: Jayant Krishnamurthy <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Jayant Krishnamurthy <[email protected]>
1 parent d85b045 commit c70c7f8

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

apps/fortuna/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/fortuna/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fortuna"
3-
version = "7.4.2"
3+
version = "7.4.3"
44
edition = "2021"
55

66
[lib]

apps/fortuna/src/keeper.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ pub async fn run_keeper_threads(
9393
chain_state.clone(),
9494
metrics.clone(),
9595
fulfilled_requests_cache.clone(),
96+
chain_eth_config.block_delays.clone(),
9697
)
9798
.in_current_span(),
9899
);

apps/fortuna/src/keeper/block.rs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ pub async fn process_new_blocks(
334334
}
335335

336336
/// Processes the backlog_range for a chain.
337+
/// It processes the backlog range for each configured block delay.
338+
#[allow(clippy::too_many_arguments)]
337339
#[tracing::instrument(skip_all)]
338340
pub async fn process_backlog(
339341
backlog_range: BlockRange,
@@ -343,18 +345,39 @@ pub async fn process_backlog(
343345
chain_state: BlockchainState,
344346
metrics: Arc<KeeperMetrics>,
345347
fulfilled_requests_cache: Arc<RwLock<HashSet<u64>>>,
348+
block_delays: Vec<u64>,
346349
) {
347350
tracing::info!("Processing backlog");
351+
// Process blocks immediately first
348352
process_block_range(
349-
backlog_range,
350-
contract,
353+
backlog_range.clone(),
354+
Arc::clone(&contract),
351355
gas_limit,
352-
escalation_policy,
353-
chain_state,
354-
metrics,
355-
fulfilled_requests_cache,
356+
escalation_policy.clone(),
357+
chain_state.clone(),
358+
metrics.clone(),
359+
fulfilled_requests_cache.clone(),
356360
)
357361
.in_current_span()
358362
.await;
363+
364+
// Then process with each configured delay
365+
for delay in &block_delays {
366+
let adjusted_range = BlockRange {
367+
from: backlog_range.from.saturating_sub(*delay),
368+
to: backlog_range.to.saturating_sub(*delay),
369+
};
370+
process_block_range(
371+
adjusted_range,
372+
Arc::clone(&contract),
373+
gas_limit,
374+
escalation_policy.clone(),
375+
chain_state.clone(),
376+
metrics.clone(),
377+
fulfilled_requests_cache.clone(),
378+
)
379+
.in_current_span()
380+
.await;
381+
}
359382
tracing::info!("Backlog processed");
360383
}

0 commit comments

Comments
 (0)