Skip to content

Commit 6c27d8d

Browse files
committed
Revert "feat(fortuna): extract RETRY_PREVIOUS_BLOCKS into EthereumConfig (#2713)"
This reverts commit 0b1a59f.
1 parent 2f1becd commit 6c27d8d

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

apps/fortuna/src/config.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ pub struct EthereumConfig {
189189
/// at each specified delay. For example: [5, 10, 20].
190190
#[serde(default = "default_block_delays")]
191191
pub block_delays: Vec<u64>,
192-
193-
#[serde(default = "default_retry_previous_blocks")]
194-
pub retry_previous_blocks: u64,
195192
}
196193

197194
fn default_sync_fee_only_on_register() -> bool {
@@ -202,10 +199,6 @@ fn default_block_delays() -> Vec<u64> {
202199
vec![5]
203200
}
204201

205-
fn default_retry_previous_blocks() -> u64 {
206-
100
207-
}
208-
209202
fn default_priority_fee_multiplier_pct() -> u64 {
210203
100
211204
}

apps/fortuna/src/keeper.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,7 @@ pub async fn run_keeper_threads(
105105

106106
let (tx, rx) = mpsc::channel::<BlockRange>(1000);
107107
// Spawn a thread to watch for new blocks and send the range of blocks for which events has not been handled to the `tx` channel.
108-
spawn(
109-
watch_blocks_wrapper(
110-
chain_state.clone(),
111-
latest_safe_block,
112-
tx,
113-
chain_eth_config.retry_previous_blocks,
114-
)
115-
.in_current_span(),
116-
);
108+
spawn(watch_blocks_wrapper(chain_state.clone(), latest_safe_block, tx).in_current_span());
117109

118110
// Spawn a thread for block processing with configured delays
119111
spawn(

apps/fortuna/src/keeper/block.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const RETRY_INTERVAL: Duration = Duration::from_secs(5);
3030
const BLOCK_BATCH_SIZE: u64 = 100;
3131
/// How much to wait before polling the next latest block
3232
const POLL_INTERVAL: Duration = Duration::from_secs(2);
33+
/// Retry last N blocks
34+
const RETRY_PREVIOUS_BLOCKS: u64 = 100;
3335

3436
#[derive(Debug, Clone)]
3537
pub struct BlockRange {
@@ -194,15 +196,13 @@ pub async fn watch_blocks_wrapper(
194196
chain_state: BlockchainState,
195197
latest_safe_block: BlockNumber,
196198
tx: mpsc::Sender<BlockRange>,
197-
retry_previous_blocks: u64,
198199
) {
199200
let mut last_safe_block_processed = latest_safe_block;
200201
loop {
201202
if let Err(e) = watch_blocks(
202203
chain_state.clone(),
203204
&mut last_safe_block_processed,
204205
tx.clone(),
205-
retry_previous_blocks,
206206
)
207207
.in_current_span()
208208
.await
@@ -221,7 +221,6 @@ pub async fn watch_blocks(
221221
chain_state: BlockchainState,
222222
last_safe_block_processed: &mut BlockNumber,
223223
tx: mpsc::Sender<BlockRange>,
224-
retry_previous_blocks: u64,
225224
) -> Result<()> {
226225
tracing::info!("Watching blocks to handle new events");
227226

@@ -230,7 +229,7 @@ pub async fn watch_blocks(
230229

231230
let latest_safe_block = get_latest_safe_block(&chain_state).in_current_span().await;
232231
if latest_safe_block > *last_safe_block_processed {
233-
let mut from = latest_safe_block.saturating_sub(retry_previous_blocks);
232+
let mut from = latest_safe_block.saturating_sub(RETRY_PREVIOUS_BLOCKS);
234233

235234
// In normal situation, the difference between latest and last safe block should not be more than 2-3 (for arbitrum it can be 10)
236235
// TODO: add a metric for this in separate PR. We need alerts

0 commit comments

Comments
 (0)