Skip to content

Commit 26ae907

Browse files
authored
fix(fortuna): Propagate submission errors correctly (#2458)
1 parent 2fdddfb commit 26ae907

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
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.5"
3+
version = "7.4.6"
44
edition = "2021"
55

66
[lib]

apps/fortuna/src/eth_utils/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct SubmitTxResult {
2020
pub gas_multiplier: u64,
2121
pub fee_multiplier: u64,
2222
pub duration: Duration,
23-
pub receipt: Result<TransactionReceipt, anyhow::Error>,
23+
pub receipt: TransactionReceipt,
2424
}
2525

2626
#[derive(Clone, Debug)]
@@ -193,7 +193,7 @@ pub async fn submit_tx_with_backoff<T: Middleware + NonceManaged + 'static>(
193193
num_retries.store(retry_number + 1, std::sync::atomic::Ordering::Relaxed);
194194
},
195195
)
196-
.await;
196+
.await?;
197197

198198
let duration = start_time.elapsed();
199199
let num_retries = num_retries.load(std::sync::atomic::Ordering::Relaxed);

apps/fortuna/src/keeper/process_event.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ pub async fn process_event_with_backoff(
6262
.inc();
6363

6464
match success {
65-
Ok(res) => {
66-
tracing::info!("Processed event successfully in {:?}", res.duration);
65+
Ok(result) => {
66+
tracing::info!("Processed event successfully in {:?}", result.duration);
6767

6868
metrics
6969
.requests_processed_success
@@ -73,39 +73,37 @@ pub async fn process_event_with_backoff(
7373
metrics
7474
.request_duration_ms
7575
.get_or_create(&account_label)
76-
.observe(res.duration.as_millis() as f64);
76+
.observe(result.duration.as_millis() as f64);
7777

7878
// Track retry count, gas multiplier, and fee multiplier for successful transactions
7979
metrics
8080
.retry_count
8181
.get_or_create(&account_label)
82-
.observe(res.num_retries as f64);
82+
.observe(result.num_retries as f64);
8383

8484
metrics
8585
.final_gas_multiplier
8686
.get_or_create(&account_label)
87-
.observe(res.gas_multiplier as f64);
87+
.observe(result.gas_multiplier as f64);
8888

8989
metrics
9090
.final_fee_multiplier
9191
.get_or_create(&account_label)
92-
.observe(res.fee_multiplier as f64);
92+
.observe(result.fee_multiplier as f64);
9393

94-
if let Ok(receipt) = res.receipt {
95-
if let Some(gas_used) = receipt.gas_used {
96-
let gas_used_float = gas_used.as_u128() as f64 / 1e18;
94+
if let Some(gas_used) = result.receipt.gas_used {
95+
let gas_used_float = gas_used.as_u128() as f64 / 1e18;
96+
metrics
97+
.total_gas_spent
98+
.get_or_create(&account_label)
99+
.inc_by(gas_used_float);
100+
101+
if let Some(gas_price) = result.receipt.effective_gas_price {
102+
let gas_fee = (gas_used * gas_price).as_u128() as f64 / 1e18;
97103
metrics
98-
.total_gas_spent
104+
.total_gas_fee_spent
99105
.get_or_create(&account_label)
100-
.inc_by(gas_used_float);
101-
102-
if let Some(gas_price) = receipt.effective_gas_price {
103-
let gas_fee = (gas_used * gas_price).as_u128() as f64 / 1e18;
104-
metrics
105-
.total_gas_fee_spent
106-
.get_or_create(&account_label)
107-
.inc_by(gas_fee);
108-
}
106+
.inc_by(gas_fee);
109107
}
110108
}
111109
metrics.reveals.get_or_create(&account_label).inc();

0 commit comments

Comments
 (0)