If you’re using Truffle’s HDWalletProvider and seeing big numbers of requests made by eth_getBlockByNumber or/and eth_BlockNumber most likely this is coming from HDWalletProvider which does constant block polling.
Some suggestions below:
- truffle-hdwallet-provider is deprecated, try to use the current one which might be better at block polling.
In most cases it should be enough to replace:
const HDWalletProvider = require('truffle-hdwallet-provider');
const HDWalletProvider = require("@truffle/hdwallet-provider");
If that doesn’t help, see pollingInterval param that you can use to control it:
- Use HDWalletProvider only where needed, eg. deploying or calling contract methods. For anything else (like sending tx) you can use either a Websocket or HTTP provider, example for HTTP:
const web3 = new Web3(new Web3.providers.HttpProvider(`https://rinkeby.infura.io/v3/<INFURA_PROJECT_ID>`));
- Similar posts regarding the same issue: