From e81b36b55340505481bba510f09031dd99b32727 Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Wed, 26 Jun 2024 10:28:41 +0200 Subject: [PATCH] fix: Check gas limit before padding --- 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 deb38df46d..f0cf831988 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 a823c06e86..89f922167a 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 6a5724eb4e..3f6da04cf2 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,