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

Reduce Ethereum JSON RPC API calls for token list #13777

Closed
bbondy opened this issue Jan 26, 2021 · 1 comment · Fixed by brave/ethereum-remote-client#217
Closed

Reduce Ethereum JSON RPC API calls for token list #13777

bbondy opened this issue Jan 26, 2021 · 1 comment · Fixed by brave/ethereum-remote-client#217

Comments

@bbondy
Copy link
Member

bbondy commented Jan 26, 2021

This issue is for our Crypto Wallets (MetaMask fork) at https://github.com/brave/ethereum-remote-client

Our Infura usage is too high.

Infura shows us this breakdown by method calls:
Screen Shot 2021-01-26 at 3 33 41 PM

When you load brave://wallet and login you will see that having that tab open does a lot of Infura calls.

If you add some logging here:
ethereum-remote-client/node_modules/eth-json-rpc-infura/src/index.js

For fetchUrl you will see that when a token is added, we’re doing several calls to the contract address every few seconds.
You can see this in about://extensions in the background page dev tools.

In particular we auto-add BAT, so you can see the calls are made for BAT even when that tab is not active.
You can see via looking at the parameters for the calls has the BAT contract address.

I assume maybe these calls are to get the token balance?

Please make the following changes:

  1. Find out why these calls are made.
  2. Lower the frequency of these calls to reduce Infura usage.
  3. Only make these calls when the tab is active or the browser pane is open.
@ryanml
Copy link
Contributor

ryanml commented Feb 12, 2021

Verification passed on

OS | MacOS
Component | 1.0.26 Dev

  • Verified that no token calls are made when the browser is not in focus, and that they start again appropriately when refocused. Accurate balances and prices are still maintained
    image

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