Skip to content

Commit 76eaa3a

Browse files
authored
fix(fortuna): configurable backlog processing (#2459)
1 parent 1d97777 commit 76eaa3a

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

apps/fortuna/Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/fortuna/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fortuna"
3-
version = "7.4.6"
3+
version = "7.4.7"
44
edition = "2021"
55

66
[lib]

apps/fortuna/src/config.rs

+8
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ pub struct EthereumConfig {
128128
#[serde(default)]
129129
pub confirmed_block_status: BlockStatus,
130130

131+
/// The number of blocks to look back for events that might be missed when starting the keeper
132+
#[serde(default = "default_backlog_range")]
133+
pub backlog_range: u64,
134+
131135
/// Use the legacy transaction format (for networks without EIP 1559)
132136
#[serde(default)]
133137
pub legacy_tx: bool,
@@ -194,6 +198,10 @@ fn default_priority_fee_multiplier_pct() -> u64 {
194198
100
195199
}
196200

201+
fn default_backlog_range() -> u64 {
202+
1000
203+
}
204+
197205
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
198206
pub struct EscalationPolicyConfig {
199207
// The keeper will perform the callback as long as the tx is within this percentage of the configured gas limit.

apps/fortuna/src/keeper.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ pub(crate) mod keeper_metrics;
3333
pub(crate) mod process_event;
3434
pub(crate) mod track;
3535

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

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

83-
// Spawn a thread to handle the events from last BACKLOG_RANGE blocks.
81+
// Spawn a thread to handle the events from last backlog_range blocks.
8482
let gas_limit: U256 = chain_eth_config.gas_limit.into();
8583
spawn(
8684
process_backlog(
8785
BlockRange {
88-
from: latest_safe_block.saturating_sub(BACKLOG_RANGE),
86+
from: latest_safe_block.saturating_sub(chain_eth_config.backlog_range),
8987
to: latest_safe_block,
9088
},
9189
contract.clone(),

0 commit comments

Comments
 (0)