-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Enable EIP- 2831 Signer transaction.wait() style rejections. #1477
Comments
This is now available in 5.2.0. Please check out this article for more details. :) |
Thanks you @ricmoo, exciting feature out here and very much need ! Any plan to support it for external providers (through Web3Provider)? Indeed, current implementation of JsonRpcSigner#sendTransaction doesn't pass return this.provider._wrapTransaction(tx, hash); which results in if (confirms !== 0 && startBlock != null) {
replacement = { which ultimately results into opting out of tx replacement watching in BaseProvider#_waitForTransaction if (replaceable) {
let lastBlockNumber = replaceable.startBlock; I can think of multiple of solutions (calling Would love to hear from you back. |
@mwamedacen Thanks! Yes, it was completely an oversight. I will add that to the next release. :) |
Thanks again @ricmoo, do you think it would be possible to opt-in for transaction replacement detection through |
@mwamedacen What do you mean? You want to not throw on replacement and receive no notice and stall indefinitely? You can just use |
Sorry I wasn't clear, I meant: if we deal with transaction hash, waiting for transaction never throws on replacement (might be wrong though). |
If you wait on a transaction hash it will eventually resolve to the receipt or throw an exception which includes the receipt of the replacement transaction. Prior to this feature, Does that make sense? |
Sorry I'm a bit confused, my case is when I don't have access to the transactionResponse object but only the hash. So I'm waiting on the transaction via the provider, say await web3Provider.waitForTransaction(transactionHash) In this case, replaceable param is always passed down to _waitFortransaction() as null async waitForTransaction(transactionHash: string, confirmations?: number, timeout?: number): Promise<TransactionReceipt> {
return this._waitForTransaction(transactionHash, (confirmations == null) ? 1: confirmations, timeout || 0, null);
} |
Hey Ricmoo, @ricmoo thanks for an amazing support for the speeded-up transaction. I am right now testing the functionality on Polygon. Maybe I am doing sth wrong but I have followed your explanation here: Updated the version of ethers.js to I have the following pattern: I have a handleDepositCallback function that calls the contract. That function returns
Then using MetaMask, I submit a transaction:
In such case, should we get to the catch() block? |
Yes, you should get the catch block. Are you not? |
No, it never gets to the
and returns the transaction details with receipt. It could be that I am doing sth wrong, therefore I prefer to check with you. I have only tested it on Polygon. I will try also on BSC. |
There are definitely problems with both Polygon and BSC when it comes to receipts, that are still being tracked down; they seem to emit data before they complete indexing (and therefore responding to requests). So, the |
When submitting a low-priced transaction on Polygon I often encounter that resulting In that case replacement tx won't be detected. @devdomsos may this be your issue? |
Yes,
That is a mined transaction. The not-mined transaction object looks like this:
As you can see both @Velenir, I have null for the 'from' key on Polygon. I have tried 2 RPC urls, both were public. Which nodes would you recommend I use? |
Yes, all in all it's working. Not working only in the case of:
|
@Velenir thank you for the info. How would you recommend I test then the transaction replacement on Polygon? I would then have to wait for the network to be congested to test this? On BSC I am not even able to in time upspeed the transaction. It goes through right away. |
If you use a private node, then you should be able to send an intentionally underpriced transaction and it would be detected alright. |
For POLYGON For BSC Could you share with us the way you call the smart contract and how you await for the wait() promise? Only if you are ok with sharing this of course. Maybe I am doing something wrong on my end. |
Can we standardize this as EIP-2831? |
Hey @devdomsos, thanks for the sample code. I'm using typescript and struggling to handle the error from
What the "CertainErrorType " should be? |
@aysuio, not sure if you found an answer to it, but generally I was using template code from this update:
Let me know if you managed to test this feature on your end. :) I still cannot get it to work because I cannot test it. |
tried TRANSACTION_REPLACED, it generated error params as stated in ethers.js enum ErrorCode There are bunch of other codes like UNPREDICTABLE_GAS_LIMIT, which are well defined in the ErrorCode. |
@aysuio, how did you manage to re-produce the replaced transaction? Which blockchain were you testing it on? Thanks! |
When you get TRANSACTION_REPLACED, how can you get the new transaction hash that of the replacement? |
The |
@ricmoo Is ethers just polling the node under the hood to grab all the information? |
@GregTheGreek Depending on the backend, it uses the block listener to then get the nonce; if the nonce has changed, then it searches the block for the tx matching the nonce and from, to derive the replacement reason (replaced, cancelled or repriced). |
@ricmoo Question: I dont have a Thanks |
When a Signer sends a transaction, the TransactionResponse object has a
.wait()
method. Currently that method rejects aCALL_EXCEPTION
if the transaction reverts, otherwise it resolves with the TransactionReceipt, once the transaction is mined, based on its hash.This feature will enable an additional rejection case, along with a new error in the Logger,, TRANSACTION_REPLACED. This will occur if the transaction is replaced (i.e. the
from
andnonce
match the transaction but the hash is different), with a field indicating the reason for the replacement:repriced
; the data and to match, but the gas price has changedcancelled
; the data has been changed to0x
and theto
changed to thefrom
replaced
; any other changeThis must occur in a minor version bump.
In v6 we may change
repriced
to also resolve (instead of reject), but this requires more thought and would not be backwards compatible within v5.The text was updated successfully, but these errors were encountered: