Skip to content

Commit

Permalink
cosmos-sdk reject zero gas limit
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Jul 14, 2022
1 parent 874ce92 commit 589525b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions orchestrator/cosmos_gravity/src/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,19 @@ pub async fn send_messages(
gas_adjustment: f64,
) -> Result<TxResponse, GravityError> {
let cosmos_address = cosmos_key.to_address(&contact.get_prefix()).unwrap();
let min_gas_limit = 500000 * messages.len() as u64;

// compute the fee as fee=ceil(gas_limit * gas_price)
let fee_amount: f64 = min_gas_limit as f64 * gas_price.0;
let fee_amount: u64 = fee_amount.abs().ceil() as u64;
let fee_amount = Coin {
denom: gas_price.1.clone(),
amount: 0u32.into(),
amount: fee_amount.into(),
};

let fee = Fee {
amount: vec![fee_amount],
gas_limit: 0,
gas_limit: min_gas_limit,
granter: cosmos_granter,
payer: None,
};
Expand All @@ -150,7 +154,7 @@ pub async fn send_messages(

// multiply the estimated gas by the configured gas adjustment
let gas_limit: f64 = (gas.gas_used as f64) * gas_adjustment;
args.fee.gas_limit = cmp::max(gas_limit as u64, 500000 * messages.len() as u64);
args.fee.gas_limit = cmp::max(gas_limit as u64, min_gas_limit);

// compute the fee as fee=ceil(gas_limit * gas_price)
let fee_amount: f64 = args.fee.gas_limit as f64 * gas_price.0;
Expand Down

0 comments on commit 589525b

Please sign in to comment.