bodhi.js
bodhi.js copied to clipboard
Implement `insufficient funds for gas`
We should have some pre-calculations of gas cost & not allow the transaction to go through.
But if it does, an explicit error should be returned. This will help metamask users and other tooling to behave properly as a result of the failure.
ValueError: {'code': -32000, 'message': 'insufficient funds for gas * price + value'}
Automated test should be added to test for this case.
@gluneau do you still remember how to reproduce this issue? or is it still an issue?
Example tx: 0x6362791044de67e6368890632f2b179e1bdbc5188fd1278f9b2b38de51f59d0f error: The contract code couldn't be stored, please check your gas limit.
This is a known issue, it’s because his account has insufficient ACA to deploy contract.
@shunjizhan says:
I think we should throw an error from api.rpc.evm.call() if any of the events failed, and mark extrinsic as failed. From here we can see that even this TX has a failed event evm (CreatedFailed), it is still marked as “Success”. If mandala throws a timely error, he will get something like execution failed: ReserveStorageFailed, instead of getting this confusing error.
I'm looking for this explicit error to be returned when there is not enough funds for gas, just like it happened here.
https://github.com/AcalaNetwork/Acala/blob/4bfb317465125add17bc7f9dcb10a7283a48521f/modules/evm/rpc/src/lib.rs#L186 https://github.com/AcalaNetwork/Acala/blob/4bfb317465125add17bc7f9dcb10a7283a48521f/runtime/mandala/src/lib.rs#L2154 make estimate to false
if from
is specified, check it's balance in estimateGas
https://docs.alchemy.com/reference/eth-estimategas