Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Invalid number" (no gas limit is set by default) instead of insufficient balance error at attempt to register ENS name #8691

Closed
churik opened this issue Aug 2, 2019 · 33 comments

Comments

@churik
Copy link
Member

churik commented Aug 2, 2019

Description

Type: Bug
Summary: if you don't have enough SNT to register new name - instead of appropriate error application couldn't set Network fee (Gas Limit is always empty)
If you set it Gas Limit manually, you can proceed and sign transaction - "Intrisic gas too low" error.
Theoretically, it can be reproduced in any DApp if token balance is not validated on DApp side (tried in AirSwap and UniSwap, balance is validated.)

Expected behavior

"Insufficient balance" error or button Register is disabled when you don't have enough SNT (so you can't open transaction screen)

Actual behavior

IMG_3C3D24D4FE85-1

Reproduction

  • Open Status
  • Create new account
  • Try to register new ENS name

Additional Information

  • Status version: nightly 01.08.2019
  • Operating System: Android, iOS
@asemiankevich
Copy link
Contributor

@rachelhamlin

@flexsurfer flexsurfer self-assigned this Aug 22, 2019
@flexsurfer
Copy link
Member

flexsurfer commented Aug 22, 2019

@rachelhamlin @hesterbruikman @andmironov @errorists in the current case there is an error in the contract because there is not enough SNT, and contract can't be run, and gas can't be estimated, so we need to show a proper message when gas can't be estimated and there is an error in the contract and we know transaction will be failed even if user provide gas manually

@hesterbruikman
Copy link
Contributor

@flexsurfer thanks for tagging!

What can the user do in this situation?

It sounds like:
The issue might resolved if the user somehow buys more ETH
Does this solve the issue or might the contract error also occur when there is enough ETH for gas available?

@flexsurfer
Copy link
Member

@hesterbruikman this current case not related to ETH it's about a contract execution, contract can't be executed, and we don't know the exact reason, yeah for this current case we could guess that there is not enought SNT and if user buys more SNT it will work, but we need more general message for all cases, something like "gas cannot be estimated because of an error during contract execution"

@hesterbruikman
Copy link
Contributor

Thanks for clarifying. Sounds like we're looking for a bandaid:/ In this case the user also can't change the amount as it's specified by the contract.

What causes the contract error?

For a message I suggest:
"Something's wrong with the contract. Make sure you have enough assets and try again"

@flexsurfer
Copy link
Member

What causes the contract error?

it may be some condition in the contract, for example, permissions, or balance check, or smth else, wrong parameters passed to contract from dapp for example etc

@hesterbruikman
Copy link
Contributor

hesterbruikman commented Aug 22, 2019

If you think the above error message works, I suggest we go with that for now. Next to that I'll make a note in our design backlog on Wrike. I think eventually we want a different pattern/screen in case of a full blown contract error. Like an error state version of the Send transaction overview screen. Now it seems the error is gas estimate, but that's a symptom, the problem is the contract itself not performing required steps to produce an accurate/useful overview screen.

@rachelhamlin
Copy link
Contributor

Is it possible that the user can try again and succeed, or is the contract going to fail repeatedly if this error is hit @flexsurfer? It sounds like a really variable underlying cause; ditto Hester.

Also, is @3esmit maybe able to look into why this is happening?

@flexsurfer
Copy link
Member

@rachelhamlin the contract going to fail repeatedly if this error is hit, and we know why, it's normal behaviour, we just need to show a proper error message to a user instead of "invalid number"

@hesterbruikman
Copy link
Contributor

@andmironov
Copy link

andmironov commented Sep 2, 2019

Hey! What about informing about a "special" transaction like this?

On the left – not enough ETH to pay the network fee error. On the right – a special transaction with enough ETH to pay the network fee.

Also, I'm not sure I've understood the problem 100% :-)

Screen Shot 2019-09-02 at 13 51 08

@andmironov
Copy link

UPD

  1. Not enough ETH to pay for the network fee;
  2. Same as 1 but user taps on the (!) icon;
  3. A special transaction

Screen Shot 2019-09-03 at 18 41 37

@andmironov
Copy link

andmironov commented Sep 3, 2019

Ok, had a chat with @flexsurfer and he explained it to me. So the error while calculating the transaction fee is an indicator of a possible error in the contract (we can't know what exactly is the error) and means that the user most likely should not send this transaction. But they still can. So this is what I suggest:

Screen Shot 2019-09-03 at 19 33 34

wdyt?

@flexsurfer
Copy link
Member

@andmironov looks good, but to sign anyway gas should be set first manually

@andmironov
Copy link

ok got it! Also, made a few changes and have a question:
since it takes time to check if the network fee is possible to calculate, should there be a loading state? Take a loot, from left to right.

Screen Shot 2019-09-04 at 10 54 53

@flexsurfer
Copy link
Member

looks good, but complex :)

@andmironov
Copy link

just as life is...

@andmironov
Copy link

andmironov commented Sep 4, 2019

UPD

Screen Shot 2019-09-04 at 12 34 30

I just realized after talking to Simon and discussing the transaction overview from another perspective, that a transaction interaction should be a special type of transaction, with not too many fields. This makes it look cleaner also

@rachelhamlin
Copy link
Contributor

rachelhamlin commented Sep 4, 2019

Love the gate keeping with Set custom fee requiring action @andmironov. And I understand the problem much more clearly now too. :) Edit: Also prefer the pared back fields for this special Tx.

Might want to suggest a copy tweak, but first...

@flexsurfer can you help me to better understand the risk involved in signing? Assuming the possible range of errors is mostly buggy things like balance check not working, wrong parameters passed, etc...is the risk simply that the user wastes gas on a Tx that is likely to fail? Or more seriously, perhaps the contract has holes in it that could lead to bigger losses?

@andmironov
Copy link

Also, the network will be shown only if it's not Mainnet, which means one less field.
And another thing: when it's a transaction interaction, it might better be "Reject" instead of "Cancel"

Screen Shot 2019-09-04 at 12 41 48

@3esmit
Copy link
Member

3esmit commented Sep 6, 2019

Seems like the issue is no ETH in user selected/active account?

@3esmit
Copy link
Member

3esmit commented Sep 11, 2019

I tested this and I get the error com.facebook.react.bridge.NoSuchKeyException:backgroundColor when I tap the "invalid number" error.

@3esmit
Copy link
Member

3esmit commented Sep 11, 2019

The "invalid number" might be a side effect of trying to make an invalid transaction, this can have multiple causes:

  • no ether in balance
  • infinite gas (failing) transaction

In the case of ENS Usernams seems like we have a problem as the dapp is trying a transaction against 0xDB5ac1a559b02E12F29fC0eC0e37Be8E046DEF49 (UsernameRegistrar) instead of 0x744d70FDBE2Ba4CF95131626614a1763DF805B9E (SNT)

This is the correct usage of UsernameRegistrar:
SNT.approveAndCall(UsernameRegistrar,10*10^18,UsernameRegistrar.methods.register(...params).encodeABI())
See:
https://github.com/status-im/ens-usernames/blob/77d9394d21a5b6213902473b7a16d62a41d9cd09/test/usernameregistrar.spec.js#L342-L444

Some checks must be done before allowing the button to be pressed:

  • user have 10 SNT in account
  • user have allowed/entered public key (why register username with no pubkey? perhaps only warn but allow?)

Note: input filed for address (payment address?) dont need to be showed, because its optional (not used?), perhaps show only in an advanced form?

@3esmit
Copy link
Member

3esmit commented Sep 11, 2019

Sorry, my mistake, its actually using the correct call. I sucessfully registered an username: https://etherscan.io/tx/0x7dade245d085889da1f1b62f72472e09e089c25181838168a4cc275691a4e402

So to get rid off the "Invalid Number" error I needed to have 10 SNT on my account.

So perhaps we need only to threat errors on the case user dont have SNT or sufficient ETH/GAS before allowing the button to be pressed.

@andmironov for the signing UI suggested I also agree, it should show appropriate error. "could not calculate fee" means that something is really bad about that transaction. so I think that the appropriate error message should be what it actually means: "transaction always fails or exceeds gas limit". Advanced users should be able to force sign/submit a transaction that wasn't able to calculate the gas limit, by manually specifying the transaction gas limit - as you suggested.

@rachelhamlin
Copy link
Contributor

@3esmit what about these potential failures mentioned by Andrey?

it may be some condition in the contract, for example, permissions, or balance check, or smth else, wrong parameters passed to contract from dapp for example etc

There are more options than just insufficient ETH/SNT, no?

@3esmit
Copy link
Member

3esmit commented Sep 11, 2019

@rachelhamlin Yes, but all them render the same result: not possible o calculate gas, transaction fails if included in a block.

All these errors (some condition in the contract) will be shown as "unable to calculate gas fee".

In case ETH transfer, a transaction with no enough balance will be ignored by nodes (and if included in a block would render an invalid block), but in case of ERC20, a transaction with no enough erc20 will not able to calculate gas, and in case included in a block, will render a valid block but will fail the individual transaction with "invalid jump" or "no enough gas".

@rachelhamlin
Copy link
Contributor

Okay, got it. So this solution looks pretty good.

Perhaps a more accurate + succinct error message flow would be:

The contract can't calculate the network fee. Set a custom network fee to sign at your own risk. --> Set custom fee --> This contract has an error in it. Sign at your own risk using custom network fee.

@3esmit it's accurate to say "the contract has an error in it" right?

@andmironov wdyt?

@andmironov
Copy link

andmironov commented Sep 12, 2019

looks good to me! @rachelhamlin will update the screens with new copy

@andmironov
Copy link

Screen Shot 2019-09-12 at 12 58 48

Note: the tooltip next to the (!) icon is displayed when the icon is tapped. It disappears when the icon is tapped again. Here's how the animation could look https://www.dropbox.com/s/o21lf4uppizzr7e/err.mov?dl=0

@andmironov
Copy link

@3esmit
Copy link
Member

3esmit commented Sep 12, 2019

it's accurate to say "the contract has an error in it" right?

In some cases yes, but for all would be accurate to say "transaction probably will fail", or if you want to say that it has an error, would be always on the transaction, because we cannot test/check if the error is because of a badly programmed contract logic or because of badly set parameters in the transaction.

This message could also appear if someone sets the gas limit of transaction to a value lower then the gas estimated (if it was able to estimate in first place).

@rachelhamlin
Copy link
Contributor

Got it! I think "transaction will probably fail" is a much better message for the second error screen then. Left a comment to that effect in Figma, @andmironov - let me know if you disagree.

@rachelhamlin
Copy link
Contributor

Closing this issue in favor of #9037, which combines this and #8485 into one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants