From 35ee573a155d4124a4906451adb4d4f913929e60 Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Wed, 26 Jun 2024 19:18:13 +0200 Subject: [PATCH] fix: Check gas limit before padding (#1734) --- apps/fortuna/Cargo.lock | 2 +- apps/fortuna/Cargo.toml | 2 +- apps/fortuna/src/keeper.rs | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/fortuna/Cargo.lock b/apps/fortuna/Cargo.lock index deb38df46..f0cf83198 100644 --- a/apps/fortuna/Cargo.lock +++ b/apps/fortuna/Cargo.lock @@ -1502,7 +1502,7 @@ dependencies = [ [[package]] name = "fortuna" -version = "6.4.0" +version = "6.4.1" dependencies = [ "anyhow", "axum", diff --git a/apps/fortuna/Cargo.toml b/apps/fortuna/Cargo.toml index a823c06e8..89f922167 100644 --- a/apps/fortuna/Cargo.toml +++ b/apps/fortuna/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fortuna" -version = "6.4.0" +version = "6.4.1" edition = "2021" [dependencies] diff --git a/apps/fortuna/src/keeper.rs b/apps/fortuna/src/keeper.rs index 6a5724eb4..3f6da04cf 100644 --- a/apps/fortuna/src/keeper.rs +++ b/apps/fortuna/src/keeper.rs @@ -452,8 +452,6 @@ pub async fn process_event( backoff::Error::transient(anyhow!("Error estimating gas for reveal: {:?}", e)) })?; - // Pad the gas estimate by 33% - let gas_estimate = gas_estimate.saturating_mul(4.into()) / 3; if gas_estimate > gas_limit { return Err(backoff::Error::permanent(anyhow!( @@ -463,6 +461,9 @@ pub async fn process_event( ))); } + // Pad the gas estimate by 25% after checking it against the gas limit + let gas_estimate = gas_estimate.saturating_mul(5.into()) / 4; + let contract_call = contract .reveal_with_callback( event.provider_address,