bodhi.js icon indicating copy to clipboard operation
bodhi.js copied to clipboard

Implement `insufficient funds for gas`

Open gluneau opened this issue 3 years ago • 4 comments

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 avatar Feb 02 '22 23:02 gluneau

@gluneau do you still remember how to reproduce this issue? or is it still an issue?

lrcnz avatar Mar 02 '22 03:03 lrcnz

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.

image

@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.

gluneau avatar Mar 09 '22 16:03 gluneau

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

zjb0807 avatar Mar 30 '22 23:03 zjb0807

if from is specified, check it's balance in estimateGas https://docs.alchemy.com/reference/eth-estimategas

shunjizhan avatar Oct 05 '23 03:10 shunjizhan