Skip to content

Commit

Permalink
fix testnet gas limit according to new gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
haider-rs committed Oct 14, 2024
1 parent 9010639 commit 758e7f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions prices.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
network_id,symbol,usd_price
0,ARB,0.5318413166906073
1,ASTR,0.05837589379134875
12 changes: 10 additions & 2 deletions primitives/src/gmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 758e7f1

Please sign in to comment.