cosmos / cosmjs

The Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers.
https://cosmos.github.io/cosmjs/
Apache License 2.0
635 stars 328 forks source link

Out of gas #1529

Open shan-c opened 7 months ago

shan-c commented 7 months ago

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], '');

webmaster128 commented 7 months ago

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.

shan-c commented 7 months ago

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

ValarDragon commented 7 months ago

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.

shan-c commented 7 months ago

Can you suggest any updated rpc node ?