cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

Out of gas

Open shan-c opened this issue 1 year ago • 4 comments

I've been using stargateSigningClient.simulate method for gas estimation. This estimated gas from this method is never sufficient. Especially for osmosis, there is huge gap in estimation.

const sendMsg: MsgSendEncodeObject = { typeUrl: '/cosmos.bank.v1beta1.MsgSend', value: { fromAddress: senderAddress, toAddress: address, amount: [ { denom, amount, }, ], }, }; const simulation = await signingClient.simulate(senderAddress, [sendMsg], '');

shan-c avatar Dec 20 '23 16:12 shan-c

This is expected. You need to add a multiplier to the result of simulate. 1.3 (i.e. +30%) used to be a good choice for a long time. Due to some changes in the SDK it is often not enough anymore and we now used 1.4 by default.

webmaster128 avatar Dec 20 '23 17:12 webmaster128

But for osmosis chain, the gap is huge, its like 10x

shan-c avatar Dec 21 '23 05:12 shan-c

For osmosis this has now been fixed if the ful node your interacting with is v21.1.0 or higher in version. (v21.1.2 recommended)

The problem was, there has always been a buggy code path in the SDK + Osmosis for gas simulation, and that buggy code path had more gas in it. This fix correctly makes that code path get gas tracked.

ValarDragon avatar Dec 22 '23 13:12 ValarDragon

Can you suggest any updated rpc node ?

shan-c avatar Dec 23 '23 13:12 shan-c