Skip to content
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

feat(wallet): send a cancel message to a receiver when it responds to a canceled transaction #3976

Merged
merged 5 commits into from
Apr 4, 2022

Conversation

SWvheerden
Copy link
Collaborator

@SWvheerden SWvheerden commented Mar 30, 2022

Description

This will send a cancel message to a receiving node when it responds to an already canceled transaction.

Motivation and Context

This catches an edge case where the sender can cancel a stale transaction when the receiver is offline, but when it comes online it tries to continue the transaction.

How Has This Been Tested?

Included new cucumber test.

@SWvheerden SWvheerden changed the title [wip] cancel stale transactions feat: cancel stale transactions Mar 31, 2022
@stringhandler stringhandler changed the title feat: cancel stale transactions feat(wallet): send a cancel message to a receiver when it responds to a canceled transaction Mar 31, 2022
@@ -1682,6 +1687,21 @@ where
Some(s) => s,
}
},
Err(TransactionStorageError::ValueNotFound(_)) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? Feels like it might send a false positive

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking at this code, and added this extra.
My reasoning was, we don't know about this tx for whatever reason.
For example, our storage crashed or something. Now someone is asking about the tx and we don't know about, so rather send them a cancel than just ignore the request and they don't have to continue looking at the tx.

Copy link
Contributor

@hansieodendaal hansieodendaal Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe Err(_) => return Err(TransactionServiceError::TransactionDoesNotExistError) (or Err(TransactionStorageError::ValueNotFound(key))) when receiving a finalized transaction should result in a recovery attempt for those outputs.

Reasoning: The sender has already broadcast this transaction, so the receiver can attempt to recover the funds.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any error there could result in lost funds. We need to do some recovery here to get those funds. At this point, the sender cannot cancel the tx, so we should try and do a recovery to recover that tx as we should have created the keys from our master.

@@ -313,3 +313,21 @@ Feature: Wallet Transactions
And I wait 5 seconds
Then I restart wallet WALLET_RECV
Then I wait for wallet WALLET_RECV to have at least 1000000 uT

@critical
Scenario: Wallet should cancel stale transactions
Copy link
Contributor

@hansieodendaal hansieodendaal Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Scenario: Wallet should cancel stale transactions
Scenario: Wallet should cancel stale cancelled transactions

Copy link
Contributor

@hansieodendaal hansieodendaal Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The focus must be to do this automatically only for cancelled transactions; this is not clear reading the name of the test

@aviator-app aviator-app bot merged commit 96d24c6 into tari-project:development Apr 4, 2022
@SWvheerden SWvheerden deleted the sw_cancels_stale branch April 22, 2022 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants