Skip to content

Commit 10572b2

Browse files
committed
use max_block_gas for tx max_gas unless configured
1 parent bee2448 commit 10572b2

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

crates/relayer/src/chain/cosmos/types/gas.rs

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ pub fn max_gas_from_config(config: &CosmosSdkConfig) -> u64 {
4949
config.max_gas.unwrap_or(DEFAULT_MAX_GAS)
5050
}
5151

52+
/// The maximum amount of gas the relayer is willing to pay for a transaction
53+
pub fn max_gas_from_config_opt(config: &CosmosSdkConfig) -> Option<u64> {
54+
config.max_gas
55+
}
56+
5257
/// The gas multiplier
5358
pub fn gas_multiplier_from_config(config: &CosmosSdkConfig) -> f64 {
5459
config.gas_multiplier.unwrap_or_default().to_f64()

crates/relayer/src/chain/namada/tx.rs

+9-16
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use tendermint_rpc::endpoint::broadcast::tx_sync::Response;
1717
use tracing::{debug, debug_span, trace, warn};
1818

1919
use crate::chain::cosmos::gas::{adjust_estimated_gas, AdjustGas};
20-
use crate::chain::cosmos::types::gas::max_gas_from_config;
20+
use crate::chain::cosmos::types::gas::max_gas_from_config_opt;
2121
use crate::chain::cosmos::types::tx::{TxStatus, TxSyncResult};
2222
use crate::chain::cosmos::wait::all_tx_results_found;
2323
use crate::chain::endpoint::ChainEndpoint;
@@ -165,24 +165,17 @@ impl NamadaChain {
165165
let fee_token_str = self.config.gas_price.denom.clone();
166166
let fee_token = Address::from_str(&fee_token_str)
167167
.map_err(|_| NamadaError::address_decode(fee_token_str.clone()))?;
168-
let max_gas = max_gas_from_config(&self.config);
169168
let gas_price = self.config.gas_price.price;
170169

171170
let max_block_gas_key = namada_sdk::parameters::storage::get_max_block_gas_key();
172-
let max_block_gas: u64 = match self.rt.block_on(rpc::query_storage_value(
173-
self.ctx.client(),
174-
&max_block_gas_key,
175-
)) {
176-
Ok(max_block_gas) => max_block_gas,
177-
Err(e) => {
178-
warn!(
179-
id = %chain_id,
180-
"estimate_fee: error while querying max block gas, defaulting to config default. Error: {}",
181-
e
182-
);
183-
max_gas
184-
}
185-
};
171+
let max_block_gas: u64 = self
172+
.rt
173+
.block_on(rpc::query_storage_value(
174+
self.ctx.client(),
175+
&max_block_gas_key,
176+
))
177+
.map_err(NamadaError::namada)?;
178+
let max_gas = max_gas_from_config_opt(&self.config).unwrap_or(max_block_gas);
186179

187180
let args = args.clone().dry_run_wrapper(true);
188181
// Set the max gas to the gas limit for the simulation

0 commit comments

Comments
 (0)