-
Notifications
You must be signed in to change notification settings - Fork 102
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
processAudit runs txn search async, redo match res. locking #819
Conversation
client/core/trade.go
Outdated
if t.MatchIsRevoked(match) { | ||
errChan <- ExpirationErr(fmt.Sprintf("match revoked while waiting to find counterparty contract coin %v (%s). "+ | ||
"Check your internet and wallet connections!", contractID, contractSymb)) | ||
return wait.DontTryAgain | ||
} | ||
if tries > 2 { | ||
t.dc.log.Infof("Still searching for contract coin %v (%s) for match %v. "+ |
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.
Still considering if it should still try at least a couple times even if it is revoked, or is being revoked a good indicator that the audit is now irrelevant...
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.
Audit is only useful for the normal swap negotiation path, so I've concluded no, the audit is not needed for a revoked match, which will go to refund. However, I believe there is an opportunity for an improvement that would require more work: #829
Working as intended, although I'm uncertain about the audit timeout during resolution. |
bfcd652
to
a67bef5
Compare
// With updated swap data, attempt match status resolution. | ||
if needsResolution { |
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.
Now making sure match status and proof data updates happen before firing off the resolution goroutine.
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.
Tests well.
I do feel like there is some new added complexity around lock handling in status.go
that could have been avoided. For example, the new (exported?) getter methods in trackedTrade
are only needed because we're not locking for all of resolveConflictWithServerData
anymore. But there were only two paths (I think) that had the potential for long delays from mutex locking, and you've already stated that the correct solution is to run auditContract
in a goroutine
and unlock. New pattern seems racier.
I discovered a very similar issue to the one addressed by this PR, which is the client's |
return wait.TryAgain | ||
} | ||
errChan <- err | ||
if err == nil { |
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.
@buck54321 The hack I was using to simulate slow wallet AuditContract discovery of the coin is the following right after AuditContract
:
if tries < 14 {
err = asset.CoinNotFoundError
}
With that rebase, I added one commit (703767f) that adapts the recheck interval to the recently raised default broadcast timeout so that periodic ticks are every 90 seconds (12 minutes / 8 divisions) instead of every 4 minutes (12 minutes / 3 divisions). The commit also tweaks the |
This prevents contract auditing from blocking all incoming messages (and pretty much any other activities for the trade in question).
Instead of expiring the coin waiter after broadcast timeout, it just goes until it finds the contract or the match is revoked.
The trackedTrade locking is also changed a great deal in match status resolution, no longer locking a trackedTrade unless and until needed.