Skip to content

fix(fortuna): Configurable backlog processing #2459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/fortuna/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/fortuna/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fortuna"
version = "7.4.6"
version = "7.4.7"
edition = "2021"

[lib]
Expand Down
8 changes: 8 additions & 0 deletions apps/fortuna/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ pub struct EthereumConfig {
#[serde(default)]
pub confirmed_block_status: BlockStatus,

/// The number of blocks to look back for events that might be missed when starting the keeper
#[serde(default = "default_backlog_range")]
pub backlog_range: u64,

/// Use the legacy transaction format (for networks without EIP 1559)
#[serde(default)]
pub legacy_tx: bool,
Expand Down Expand Up @@ -194,6 +198,10 @@ fn default_priority_fee_multiplier_pct() -> u64 {
100
}

fn default_backlog_range() -> u64 {
1000
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct EscalationPolicyConfig {
// The keeper will perform the callback as long as the tx is within this percentage of the configured gas limit.
Expand Down
6 changes: 2 additions & 4 deletions apps/fortuna/src/keeper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ pub(crate) mod keeper_metrics;
pub(crate) mod process_event;
pub(crate) mod track;

/// How many blocks to look back for events that might be missed when starting the keeper
const BACKLOG_RANGE: u64 = 1000;
/// Track metrics in this interval
const TRACK_INTERVAL: Duration = Duration::from_secs(10);
/// Check whether we need to conduct a withdrawal at this interval.
Expand Down Expand Up @@ -80,12 +78,12 @@ pub async fn run_keeper_threads(

let fulfilled_requests_cache = Arc::new(RwLock::new(HashSet::<u64>::new()));

// Spawn a thread to handle the events from last BACKLOG_RANGE blocks.
// Spawn a thread to handle the events from last backlog_range blocks.
let gas_limit: U256 = chain_eth_config.gas_limit.into();
spawn(
process_backlog(
BlockRange {
from: latest_safe_block.saturating_sub(BACKLOG_RANGE),
from: latest_safe_block.saturating_sub(chain_eth_config.backlog_range),
to: latest_safe_block,
},
contract.clone(),
Expand Down
Loading