From 758e7f15cd20ffcbab14eb472c3e61b45fe20c8f Mon Sep 17 00:00:00 2001 From: Haider-Ali-DS Date: Mon, 14 Oct 2024 16:49:16 +0500 Subject: [PATCH] fix testnet gas limit according to new gateway --- analog-gmp | 2 +- prices.csv | 3 +++ primitives/src/gmp.rs | 12 ++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 prices.csv diff --git a/analog-gmp b/analog-gmp index 190c6de35..e1cf6b405 160000 --- a/analog-gmp +++ b/analog-gmp @@ -1 +1 @@ -Subproject commit 190c6de352d6a98b78d544f7e03c1347ad35fcd8 +Subproject commit e1cf6b4053b1b719fe07c6f5b304a7ddd6db2d88 diff --git a/prices.csv b/prices.csv new file mode 100644 index 000000000..8db244341 --- /dev/null +++ b/prices.csv @@ -0,0 +1,3 @@ +network_id,symbol,usd_price +0,ARB,0.5318413166906073 +1,ASTR,0.05837589379134875 diff --git a/primitives/src/gmp.rs b/primitives/src/gmp.rs index 97fd129f1..db4fbe825 100644 --- a/primitives/src/gmp.rs +++ b/primitives/src/gmp.rs @@ -166,8 +166,16 @@ impl Message { e: U256::from_be_slice(&signature[0..32]), s: U256::from_be_slice(&signature[32..64]), }; - let gas_limit = if let Self::Gmp(GmpMessage { gasLimit, .. }) = &self { - let gas_limit = u64::try_from(*gasLimit).unwrap_or(u64::MAX).saturating_add(100_000); + let gas_limit = if let Self::Gmp(GmpMessage { gasLimit, data, .. }) = &self { + // 50 gas per payload bytes + let data_gas: u64 = (data.len() as u64).saturating_mul(50); + // Base Cost for executing a gateway message + let gateway_execute_cost = 100_000; + let gas_limit = u64::try_from(*gasLimit) + .unwrap_or(u64::MAX) + .saturating_add(100_000) + .saturating_add(gateway_execute_cost) + .saturating_add(data_gas); Some(gas_limit.min(29_900_000)) } else { None