Skip to content

[Performance Issue]: PollingBlockTracker is instantiated with too high pollingInterval #13302

Open
@alexdupre

Description

@alexdupre

Describe the bug

MetaMask keeps a cache of request/response in order to minimize the calls to the RPC endpoint, but its refresh interval is set too high even for the Ethereum blockchain, let alone other EVM-compatible blockchains with sub-second block creation time.

The PollingBlockTracker cache is instantiated with the default pollingInterval value that is set to 20 seconds:

const blockTracker = new PollingBlockTracker({

https://github.com/MetaMask/eth-block-tracker/blob/c83a963aac367e9820126d7d5a544044741e0b10/src/PollingBlockTracker.ts#L45

The result is that block creations are detected much later than they actually happened, with the consequence that transaction confirmations and event logs are delayed, ruining the user experience.

For the transaction confirmation there is a workaround, it's possible to manually poll the eth_getTransactionReceipt function that bypass the cache and also allow MetaMask to detect a block change faster, as soon as the receipt with a more recent block number is returned. But for the event logs I haven't found a workaround yet.

It'd be very useful if the default polling interval was set to a more sane value (5 seconds?), and perhaps overridable from the MetaMask network configuration (and the related API to add a network to MM).

Steps to reproduce

  1. Connect to a network with sub-second block finality
  2. Call the eth_blockNumber (or submit a transaction, or listen to events)

Error messages or log output

No response

Version

10.8.2

Build type

No response

Browser

Chrome, Firefox

Operating system

Windows, MacOS, Linux

Hardware wallet

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions