pendulum-chain / api-solang

This is the code for the npm package @pendulum-chain/api-solang
0 stars 0 forks source link

Allow tolerance parameter for estimated gas fees #1

Closed TorstenStueber closed 8 months ago

TorstenStueber commented 9 months ago

I observed that the estimated gas fee for a contract call can sometimes not be sufficient. More precisely, when the required gas for a contract call is estimated using the RPC call and then the contract call is executed with the estimated gas as a specified limit, then in some circumstances the call is not successful and returns an OutOfGas error.

An example of such a call happened in Foucoco block 1,145,719.

This is unexpected and I suppose that either 1) this is a gas estimation bug in pallet-contracts (see, e.g., the over estimation fixes [1], [2], [3], [4]) or 2) it is just generally naive to assume that the required gas between estimation and actually executing the call would be exactly the same in all circumstances.

Therefore, this library should add some tolerance to the specified gas limits. The tolerance should be in percent and should be specifiable by the caller. The default should be 10% tolerance.