-
Notifications
You must be signed in to change notification settings - Fork 5k
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
getTransaction should return pending transactions #6704
Comments
I’m also more specifically interested that it returns pending transactions from an account managed by the user’s MetaMask, since it could be stored locally and the getTransaction can check this cache before hitting INFURA at all. I understand that in general responding to getTransaction for a given pending hash by an arbitrary addresses may be infeasible. Thanks Dan! :) |
Yeah, that's what I imagined, but thanks for making it explicit for anyone who jumps on this issue. I actually thought we never returned a tx until it was mined before. Are you sure this isn't a new feature request? I'm pretty sure some dapps use this Could this be a candidate for a new method, something like |
I’m not certain, but I “feel” like I used to get transaction data before it was mined. It could have also been an artifact of how the fallback provider works in ethers. If MM is one back end, and returns null, maybe when it fell back onto the next provider, like Etherscan, it was able to get the pending transaction. It should still be safe to return a transaction, since the blockNumber and blockHas will be null, so that can be used to determine mined-ness, but I could imagine if people were relying on getTransaction returning null until it is mined. I usually recommend using receipts for that though... I may have an old computer with an antique MetaMask on it that I can try... |
We have releases going back quite a way over here. My primary concern is that if dapp devs are relying on a returned So it seems like a kind of "softly" breaking API: The code keeps working, but the expectations change. I agree that getting the receipt or checking the blockHash is fine for someone who knows about this, but for "already live" code, this could introduce insecurity. |
Oh, completely agree on that. We need to see if old versions returned pending transactions first. If they didn’t, this becomes a whole new bit of functionality with the possible failures you described. If they did return pending transactions, it’s a bit more “softly”... Since any developer that built their dapp since this changed, may fall in the same boat of that expectation... I could also have the JsonRpcSigner create its own connection directly to INFURA to look for pending transactions... Since I do have the transaction hash, there is no way for a backend to lie about the contents of the transaction, since I can verify the raw transaction hash matches. |
Sounds good. Removing |
Hey everyone! We have the same problem at 1inch.exchange! Metamask was giving one or two weeks before the tx hash after sending it and now metamask gives the tx if its really mined. |
Could you clarify this? I'm not sure what you mean here. As far as I can tell, we have always only returned a transaction once it was mined. |
Actually, I have just confirmed myself, that at least in my version (6.6.1), the call to So, I am not seeing either the bug people are having (on a fairly recent version), nor am I experiencing what @danfinlay says has always been the behaviour. :p @deacix What version of MetaMask are you using? Is there maybe some legacy configuration setting I may have enabled? |
Oh I'm sorry, it seems I mistook this with I don't understand what problem @deacix is having. |
Oh! Haha. Yes, that makes sense. The getTransactionReceipt should not return until it is mined (or null if not mined). The problem, which I have not been able to reproduce myself, but have had many people come to me about, is that when they send a transaction (using eth_sendTransaction), which returns the transaction hash, when they then immediately perform an eth_getTransactionByHash, using that hash, they get null back, until the transaction is mined. Internally, this is how ethers deals with the fact that the JSON-RPC API only returns the transaction hash, where as in ethers the response to sendTransaction is a complete transaction; for example, if gas price was omitted, and MM populated it, or updated it through the user’s interaction with the UI, the gasPrice used is returned, along with nonce and anything else the signing entity (like MM) populated. All other signers implicitly provide this data, so I’m trying to rally support to fix this in the eth2.0 JSON-RPC API (the correct thing for them to have done would be to return the signed transaction, but the calls we aimed to mimic the bitcoind API). This also enables additional levels of security and reliability a library can perform. :) |
I made this codesandbox that you can reproduce the issue with (works on mainnet or rinkeby, all that is needed is a small ETH balance to test) I'm using metamask version The bug happens with all Contract interactions, but in the above test, the user tries to approve the null address to transfer 5 wei of WETH. Expected behavior: Observed behavior: |
So I went and sequentially installed all the versions between 6.6.2 and 6.0.0 and none of them fixed the issue. I also tried using older versions of ethers.js. I then thought what the other variable in the system was and I decided to try switching out the default geth node and voila! That fixed it! Instead of the default rinkeby provider in metamask I used the custom RPC https://geth-rinkeby.airswap-api.com which is our rinkeby geth node at AirSwap (running geth version 1.8.27). That fixes the issue. So diffing the responses between those two nodes should help you narrow down on what the issue is. |
Hi everyone! I have 6.6.2 and ethers.js 4.0.30. |
Our application is https://1inch.exchange |
@deacix Which network are you using? |
Mainnet of course :) |
Feel free test it on 1inch. Do a token swap and see that the loading spinner is showing until the transaction is mined. |
Here is my code: const tx = await this.aggregatedTokenSwapService.tokenSwap(
Here is the return of the service call: return this.contract.aggregate( |
@ricmoo @deacix it seems to me to be an issue with metamask's geth provider, which I believe is Infura. To verify this I tried pasting in a mainnet infura url ( If you use a non-infura mainnet node as a custom RPC in metamask it fixes the issue. I tried I'm guessing the issue is that Infura is doing something in their JSON RPC response that other mainnet nodes aren't, and there is logic in ethers.js that depends on something in the data structure and so a promise isn't getting called, etc. The issue doesn't occur in Web3 as far as I can tell, just ethers. |
I was able to narrow down the issue, I don't think it is metamask related at all, it just involves Infura and ethers.js. This issue can probably be closed out. Write up is here: ethers-io/ethers.js#544 (comment) |
@deacix Can you try out ethers |
In Summary
|
I'd like @frankiebee's opinion since I know she's doing some work on the tx-controller and how it connects to the network provider. |
I believe we already have in are middleware stack for getTransactionCount but not by has. This would not be difficult to do |
This would be pretty easy to do I can pick up this issue |
From @ricmoo:
This could also lead into a bigger discussion of how to provide general tx data to dapp developers, but there is an initial bug that is much smaller in scope here.
The text was updated successfully, but these errors were encountered: