-
Notifications
You must be signed in to change notification settings - Fork 7
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
340 add handling for non recoverable stellar submission errors #391
340 add handling for non recoverable stellar submission errors #391
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far. We'd still need to add some very descriptive logging of course but the core logic seems on track
629f78a
to
38f5f5e
Compare
ec36c10
to
e025bdc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some minor comments but I really like the new structure overall and I think it should do the trick. Good job @b-yap 👍
clients/wallet/src/resubmissions.rs
Outdated
// pause process for 20 minutes | ||
#[cfg(not(test))] | ||
pause_process_in_secs(1200).await; | ||
|
||
// for testing purpose, set to 5 seconds | ||
#[cfg(test)] | ||
pause_process_in_secs(5).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to pause it? We are already pausing in the loop
of the outer function, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
clients/wallet/src/resubmissions.rs
Outdated
|
||
// Remove original transaction. | ||
// The same envelope will be saved again using a different sequence number | ||
self.remove_tx_envelope_from_cache(tx.seq_num); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to keep remove this here and keep it in line 270. In the (very rare/unlikely) case that our vault client shuts down when executing the logic between line 260 and 264, the actual resubmission might not have been happened (because the client dies) but the sequence number and envelope got removed from cache, so upon restart the vault client would not try that one again, which is bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh actually, I'm wrong. I missed that we might return from this function in line 264 already. Let's move this line into the if statement of lines 263 to 265.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
clients/wallet/src/resubmissions.rs
Outdated
// Check if we already submitted this transaction | ||
if !self.is_transaction_already_submitted(&tx).await { | ||
return self.bump_sequence_number_and_submit(tx).await | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Check if we already submitted this transaction | |
if !self.is_transaction_already_submitted(&tx).await { | |
return self.bump_sequence_number_and_submit(tx).await | |
} | |
// Check if we already submitted this transaction | |
if !self.is_transaction_already_submitted(&tx).await { | |
self.bump_sequence_number_and_submit(tx).await | |
self.remove_tx_envelope_from_cache(tx.seq_num); | |
return; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i called remove_tx_envelope_from_cache()
first, before the bump_sequence_number_and_submit()
0193a90
to
0732930
Compare
…ob/18298175427#step:10:39
…actions/runs/6743040605/job/18330206794?pr=391#step:9:152
…ob/18387709725#step:11:12
c0933ca
to
b6f4695
Compare
…ob/18392787715?pr=391#step:12:665
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good overall, I just added some minor suggestions
clients/wallet/src/resubmissions.rs
Outdated
|
||
#[cfg_attr(test, mockable)] | ||
impl StellarWallet { | ||
pub async fn resubmit_transactions_from_cache(&self) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rename this function to indicate that this will actually start scheduling a periodic resubmission? Maybe we should also pass in the resubmission interval into this function call instead. Something like: start_periodic_resubmission_of_transactions_from_cache(&self, interval_in_seconds: u64)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed, and added the interval param
…ob/18553402505?pr=391#step:10:56
…ob/18613198292?pr=391#step:10:41
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good to go now. At least I don't see any other immediate problems with this implementation and the error handling seems to be the way we need it. Good job @b-yap and ready for merge (once the CI errors are gone).
The aim of this PR is to add error handling logic for failed submissions.
Closes #340
General overview of the changes:
resubmissions.rs
, dedicated for resubmission and handling of errors. Bulk of the code is heremock.rs
, contains the function helpers for the tests casesAlso updated theresubmit_transactions_from_cache()
, with a parameter that helps handle failed tasksHow to begin the review:
typeFailedTasks
= essential for removing transaction envelopes in cache for failed resubmissionsremove_tx_envelope_from_cache()
if the error is not viable for resubmissionresubmit_transactions_from_cache()
= the only public method. Every 30 minutes it will read from cache and resubmit existing ones_resubmit_transactions_from_cache()
if auto check is set to true, checkfn auto_check_running_tasks()
handle_errors()
handle_error()
= resubmits transactions with the ff errors:tx_bad_seq
tx_internal_error
CacheErrorKind::SequenceNumberAlreadyUsed
handle_tx_internal_error()
= resubmits a transaction with the errortx_internal_error
handle_tx_bad_seq_error_with_xdr()
= resubmits a transaction with the errortx_bad_seq
bump_sequence_number_and_submit()
= bump the sequence number of a transaction and resubmits itis_transaction_already_submitted()
= a costly checking if a transaction already exists. This is currently limited to just 10 pagesfnauto_check_running_tasks()
= auto checks for failed resubmissions and forcefully remove transactions from the cache