-
Notifications
You must be signed in to change notification settings - Fork 5
Remove txn from pool when contract formation or renewal fails #444
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
Open
ChrisSchinnerl
wants to merge
6
commits into
master
Choose a base branch
from
chris/remove-txn
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e6a04ea
add RemoveV2PoolTransactions
ChrisSchinnerl cab67ff
add TestRemoveV2PoolTransactions
ChrisSchinnerl 9fcfc9e
add regression test
ChrisSchinnerl edc0d7a
changeset
ChrisSchinnerl f3fe179
fix typo
ChrisSchinnerl 43034aa
address comments
ChrisSchinnerl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...orphaned_transaction_hat_wasnt_broadcast_during_failed_formationrenewrefresh.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| default: patch | ||
| --- | ||
|
|
||
| # Clean up orphaned transaction that wasn't broadcast during failed formation/renew/refresh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is quite dangerous.. Not sure I like it. There’s no way to tell if the transaction has been broadcast so it’d be easy to create harder to debug issues
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.
What if we add an optional arg to
BroadcastV2TransactionSetto prevent persistence of the transaction iff the broadcast failed and aErrBroadcastFailedthat we can check for.To make sure that 1. we didn't broadcast and 2. we won't retry.
Because right now we have a similar issue on
master.BroadcastV2TransactionSetmight fail, we release the inputs but then we might retry later and double spend.Uh oh!
There was an error while loading. Please reload this page.
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 we'd need to go a lot further to get the correct fix instead of a somewhat dangerous patch. Needs a lot of thought on potential edge cases since we don't have anything like replace by fee in place.
We started persisting broadcasted txns to prevent double spend attempts during restarts in addition to retrying if the txn doesn't make it into the next block.
We effectively need to check if the txn is valid for our tpool and attempt a broadcast before actually adding it to our local pool and persisting it preferably under lock, but that comes with its own edge cases. If broadcast fails, we realistically don't want it in our local tpool locking resources either but that's also the safest option and it's temporary.
The smallest change would be to reverse the order, but it doesn't fully solve the issue.
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.
Yeah I considered changing the order but I wasn't sure if we wanted to change the behavior of "if it's in the pool we definitely rebroadcast".
But I just realized. Doesn't
hostdsupport reverting a renewal now when a renewed contract never makes it on chain? Thanks to the CoW like behavior you added for faster renewals? Because that makes me wonder if the following approach is now possible:In
handleRPCRenewContractinstead of callings.chain.AddV2PoolTransactionwe call a news.chain.ValidateV2PoolTransactionoptimistically. Then we calls.contractor.RenewV2Contractfollowed bys.wallet.BroadcastV2TransactionSet.There is a gap between validating the txn set before the renewal and actually adding it in the broadcasting call but maybe that is alright now? If validation fails while broadcasting, we end up with a contract in our database that has definitely not been broadcasted or added to the pool. So it should expire. The error the client gets is then "contract is already renewed" for a few hours before it then succeeds on the next try hopefully.