-
Notifications
You must be signed in to change notification settings - Fork 254
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
Does wait_for_finalized hang indefinitely if the tx dropped or usurped #889
Comments
This documentation is a bit tricky to understand I reckon but if you take a look at https://github.com/paritytech/substrate/blob/master/client/transaction-pool/api/src/lib.rs#L59-#L104,
It will wait up to 512 blocks until the |
Thank you for your help. However, based on the documentation, I understand that the FinalityTimeout only applies to transactions that are included in a block. If a transaction is usurped or dropped and not included in any block, would the method still trigger a FinalityTimeout? subxt/subxt/src/tx/tx_progress.rs Lines 244 to 246 in 42bcdde
|
The extrinsic can be kicked out from the pool (dropped, invalid etc) and then later be re-entered in the pool again (Retracted) but I'm not sure whether that can happen for /cc @jsdw do you know? :) |
When I wrote this logic, I had these comments in mind: /// The stream is considered finished only when either `Finalized` or `FinalityTimeout`
/// event is triggered. You are however free to unsubscribe from notifications at any point.
And /// Note that there are conditions that may cause transactions to reappear in the pool.
It seemed like one can't guarantee that a transaction won't go from eg I decided to ask this question on the stackexchange to see if I can get any further clarification, because it is a good one! I'd suggest following up on this line of questioning there rather than here, so that people more familiar with Substrate internals can chime in: |
I'll close this now, and if we learn something interesting from the StackExchange answer that leads to tweaking Subxt then I'll open a new issue for that. Otherwise, You currently have the option to handle transaction status updates however you'd like if the built-in |
I have made an investigation, and find something interesting. The Stream trait implemented for TxProgress will end only when the event FinalityTimeout or Finalized received. But I found the RPC server of substrate will remove subscribers when the usurped, invalid, dropped, finalized or finality_timeout received. So I'm curious whether TxProgress would drop the connection and stop waiting for new events? Please find below some relevant code snippets: subxt/subxt/src/tx/tx_progress.rs Lines 137 to 181 in a2b8dde
This is Listener, the server side corresponding to the client of subscribition. It will fire a event when the transaction status changed, and it will close the connection if
And
And you could find relevent codes here, the Sender will change |
I assume that you are referring to the substrate RPC server implementation, it will just drop the subscription and no more message will be sent on the subscription. Then, no the connection will not be dropped in that scenario. To conclude, subxt will wait "forever/until the connection closed" on |
Ah very intersting; thanks @furoxr for your digging! Based on that code then we should probably tweak Subxt to do the same; if the subscription is dropped after those messages then we should also be ending it. I'll re-open this as reminder to do so |
Just to elaborate on the plan here; Subxt should end the
(We currently only end when Make sure to return an appropriate error when While we're here, I wonder whether we can unit test the
|
subxt/subxt/src/tx/tx_progress.rs
Lines 102 to 116 in 42bcdde
I have a question regarding a scenario where I send a transaction and invoke this method to wait for its finalization. Is there a risk that the program may hang indefinitely? This is because the status of the transaction may be usurped or dropped, causing the method to continue waiting without returning an error in such cases.
The text was updated successfully, but these errors were encountered: