canvas-ui icon indicating copy to clipboard operation
canvas-ui copied to clipboard

Gas estimation value on `ContractTrapped` prevents call execution

Open cmichi opened this issue 4 years ago • 0 comments

If a contract contains an assertion which fails by default ‒ i.e. the contract traps for the RPC which does the gas estimation ‒ then the gas estimation goes crazy and the call cannot be executed with default settings. This does not happen in the polkadot-js UI.

Assertions in contracts are typically used to make sure that the contract execution is reverted. I've uploaded a minimal contract, which you can use for reproduction here: assertfalse.contract.zip.

It just contains a constructor and this method:

#[ink(message)]
pub fn assert_false(&self) {
    assert!(false);
}

When you open the "Execute assertfalse (instance)" page the gas estimation will be set to a red

127.001s execution time
6350.067% of block time

screenshot-paritytech github io-2021 05 10-11_43_33

It's not possible to execute the method with these settings, the "Call" button is disabled. If the "Max Gas Allowed" is set manually it works.

In the polkadot-js UI it works fine: screenshot-polkadot js org-2021 05 10-13_37_13

My hunch is that there is maybe some default value which is used on ContractTrapped returned by the RPC and this one is way too large?

cmichi avatar May 10 '21 11:05 cmichi