I'm building an application that needs to send hundreds of transactions every minute (consistently for hours & even days) to the Polygon blockchain.
To achieve this I'm
- setting unique (and +1 increasing) nonce values to each transaction
- setting a very high gas price for the transaction (15% higher than the top gas prices in the latest block)
- attempting to send transactions in order of their nonces (though this isn't 100% accurate all the time)
- making as few calls to the RPC as possible, and populating most parameter values from within my own system (gasPrice, gasLimit, nonce)
- using Alchemy as my RPC provider, a single nodeJS (w/ ethers) instance as my backend
I'm only sending one type of transaction and there's very little variation between each request. On average, I'm noticing that most of my transactions are getting mined within 4-5seconds. However, I've sometimes noticed that when I have too many TXs in the mempool, or when I'm sending requests too fast, some transactions remain in the Mempool (in Alchemy's mempool watcher; these often don't even appear in Polygonscan) forever and this essentially chokes my system and prevents future transactions from going through as well.
I'm not sure why some of these transactions are getting stuck even when they respect nonces and have high gas price values. Can anyone please guide me towards what could be the issue?
And for a service that needs to scale to rates like this (~10Tx/s from a single wallet), do you have any suggestions for alternative methods/approaches?
– Shanzid Shaiham Apr 01 '22 at 19:39