MetaMask / MetaMask/eth-json-rpc-filters
`eth_newPendingTransactionFilter` doesn't seem to work
- Dominant language
- JavaScript
- Stars
- 29
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
According to the [Ethereum docs](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newpendingtransactionfilter), this method will create a filter that tracks pending transactions. The results of this filter (and thus the transaction hashes) are available by calling `eth_getFilterChanges` with the filter id.
However, the RPC method as implemented by this middleware doesn't seem to put anything in the filter changes. I believe this is happening because in TxFilter, [`fromBlock` is always set to one block later than `toBlock`](https://github.com/MetaMask/eth-json-rpc-filters/blob/5cbea3037b0655aa2c188d85b8ffe559a263dc0d/tx-filter.js#L14-L15). This is opposition to BlockFilter, where [`fromBlock` is merely set to one later than `oldBlock` but `toBlock` remains as the same as `newBlock`](https://github.com/MetaMask/eth-json-rpc-filters/blob/5cbea3037b0655aa2c188d85b8ffe559a263dc0d/block-filter.js#L14-L15).
Not only this, but the implementation also seems to be wrong. The docs seem to indicate that only pending transactions should show up in the filter changes. However, I am not seeing where the set of transactions is being filtered to just the pending ones. It seems that any time a new block arrives, then the hashes of the transactions in that block will show up in the pending transactions filter changes. As there is no unit test for this implementation, I cannot confirm this behavior, but that's what it looks like to me.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by comparing TxFilter and BlockFilter, especially the fromBlock and toBlock handling referenced in tx-filter.js and block-filter.js. Trace eth_newPendingTransactionFilter through eth_getFilterChanges and add unit coverage for pending-only results and filter range updates. Done means the filter returns pending transaction hashes without incorrectly including transactions from newly mined blocks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100