MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
11.66k stars 4.78k forks source link

[Bug]: Token balances displayed as zero #24918

Open sleepytanya opened 1 month ago

sleepytanya commented 1 month ago

Describe the bug

Token balances might randomly appear as zero, and transactions can't be submitted.

Probably the same bug:

https://github.com/MetaMask/metamask-extension/issues/24921 https://github.com/MetaMask/metamask-extension/issues/24925 https://github.com/MetaMask/metamask-extension/issues/24918

Also related https://github.com/MetaMask/metamask-extension/issues/24921

Expected behavior

Token balances are accurately reflected.

Screenshots/Recordings

https://jam.dev/c/50618d6c-1bb1-41ef-855f-54f18273509a

Steps to reproduce

  1. Start send+swap transaction
  2. Choose any token other that ETH
  3. Notice that token balances on the token picker are all 0 and transaction can't be submitted

Error messages or log output

No response

Version

dev build

Build type

None

Browser

Chrome, Firefox

Operating system

MacOS

Hardware wallet

No response

Additional context

dev build 4c64f44

Severity

No response

sleepytanya commented 1 month ago

This issue happens on develop:

https://github.com/MetaMask/metamask-extension/assets/104780023/81066f0b-920b-471a-9f3f-1f8d9fd8f684

If user selects a different destination token then the subsequent transaction with this token as a primary currency will show it's actual balance:

https://github.com/MetaMask/metamask-extension/assets/104780023/5012e9e6-57d0-466f-9917-6d0db49c2f1f

sleepytanya commented 1 month ago

Token details tab display inconsistent info (develop):

Screenshot 2024-06-03 at 15 23 32

https://github.com/MetaMask/metamask-extension/assets/104780023/ce1ac68d-5bac-485e-b17d-537df768bd1d

sleepytanya commented 4 weeks ago
  1. Balances on the home screen randomly switch between 0 and actual numbers
  2. Token balances on the send+swap flow randomly switch between 0 and actual numbers too (I don't think I caught it on video, most of the time you will see 0 balances on the asset picker)
  3. Balance on the token details screen should display the actual balance, token name and fiat value - it doesn't happen in the video
  4. When send+swap initiated from the token details screen user have to click 'Send' two or three times to start the flow
  5. If user switches back to the original destination token, 'no quotes available' warning is displayed (which shouldn't be displayed), and 'Confirm' button is unavailable (user can't submit send).

1-4 look like the same bug in different forms, 5 is probably related to a different issue (ticket for the 'no quotes' https://github.com/MetaMask/metamask-extension/issues/24922

Current develop (sorry for the long videos - bug happens randomly): https://jam.dev/c/1d7b2875-8a0e-4728-8bcb-b1595fb4dff4

sleepytanya commented 4 weeks ago

Latest build from here https://consensys.slack.com/archives/C068SFX90PN/p1717713259996549

Issue is still present:

https://jam.dev/c/8c8c12d3-fef6-44e9-9248-b43a291b2c29

https://jam.dev/c/4cd15286-728e-4a9c-a9a7-a1034098a021

BZahory commented 3 weeks ago

Added functionality to allow transactions to be submitted when the balance isn't known. As for the disparities between home and the asset picker modal, this is related to rate-limiting (i.e. out of swap+send scope), but let's leave this issue open as this is something I'd like to better mitigate

bergeron commented 3 weeks ago

There's lots of 429 rate limiting happening in those RPC requests, which is one reason this kind of thing can happen. Are you using a free infura plan? Those hit limits quite easy, and you can DM me for a higher limit one like we would use in production.

davibroc commented 2 weeks ago

I am also seeing a similar problem with the Swap flow see the video. Only way for the token list to show the balance is to click on the token details.

https://github.com/MetaMask/metamask-extension/assets/6082863/3fe42ac7-fd3c-4add-9ead-523aa781e0d3

sahar-fehri commented 2 weeks ago

I have tried reproducing the steps in this video https://jam.dev/c/8c8c12d3-fef6-44e9-9248-b43a291b2c29 And i did not have any issues:

https://github.com/MetaMask/metamask-extension/assets/10994169/fb39ccac-5582-4d25-a41d-631f17b16c67

davibroc commented 2 weeks ago

Still happening

https://github.com/MetaMask/metamask-extension/assets/6082863/d996cfeb-398f-4b0d-aa9f-3787f4af280c

bergeron commented 1 week ago

@davibroc I'd like to see the chrome network tab while this happens, to see whether you're hitting 429 rate limits like the original post.

davibroc commented 1 week ago

@bergeron here it is

https://github.com/MetaMask/metamask-extension/assets/6082863/ae43fdde-112e-4488-ba2a-6c93b161334e

bergeron commented 1 week ago

Infura rate limiting seems to be the cause.

I'd like to know what infura key reporters are using. When I use a free tier key, I also get these issues. Where 429 errors on the RPC calls to fetch balances cause failed to load balance for token... from the eth-token-tracker. Among other UI issues.

Screenshot 2024-06-21 at 11 58 20 AM

But that's happened to me for a while, not specifically on this release. I had to start using the production infura key locally, like what users would have, which doesn't reproduce these errors.

Comparing to older 11.x releases, I also haven't detected an increase in the # of RPC requests in this v12 release.

sleepytanya commented 1 week ago

I do not reproduce the issue on the latest v12.0.0 build [https://github.com/MetaMask/metamask-extension/commit/eebc4d5b2284024eaeb190cddfa89990f593ca34]

https://github.com/MetaMask/metamask-extension/assets/104780023/af9d21e1-7af8-4e76-bf3f-ab84130b67a4