-
Notifications
You must be signed in to change notification settings - Fork 122
sweepbatcher: presign transactions in parallel #1022
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
Conversation
If a SignTx call is slow, the whole presign() function could timeout if all the calls are done sequentially. In this commit each call is done in a separate goroutine to reduce total latency.
Loop was pinned to commit c44e078c33e0 (tapchannel: support stxo on aux sweeper) which was merged into "main" branch of taproot-assets as e6ae082c0b4b.
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.
LGTM. We might be able to stop all signing requests if an error happens in one of them.
minRelayFeeRate, fr, loadOnly, | ||
) | ||
if err != nil { | ||
return fmt.Errorf("failed to presign unsigned "+ |
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.
before we return, should we cancel grCtx
so the other signing requests are stopped?
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.
+1, if you're signing with sighash_all then I believe you should terminate early. If signatures in an otherwise "failed" batch can be re-used (i.e sighash_single?) then you should still sign them. Although I believe the former is the case.
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.
grCtx is canceled automatically if an error is returned.
https://pkg.go.dev/golang.org/x/sync/errgroup#WithContext
The derived Context is canceled the first time a function passed to Go returns a non-nil error or the first time Wait returns, whichever occurs first.
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.
@GeorgeTsagk Each goroutine signs a separate transaction (they are the same except that they have different fee rates). We need all of them to proceed. If some of them fail to sign, we cancel the whole process.
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.
LGTM
github.com/lightninglabs/loop/swapserverrpc v1.0.14 | ||
github.com/lightninglabs/taproot-assets v0.7.0-rc1.0.20250925100956-c44e078c33e0 | ||
github.com/lightninglabs/taproot-assets/taprpc v1.0.10-0.20250925100956-c44e078c33e0 | ||
github.com/lightninglabs/taproot-assets v0.7.0-rc1.0.20251014172227-e6ae082c0b4b |
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.
👍
We'll soon tag our rc2 so eventually you might want to bump again to a tagged version, if preferred.
minRelayFeeRate, fr, loadOnly, | ||
) | ||
if err != nil { | ||
return fmt.Errorf("failed to presign unsigned "+ |
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.
+1, if you're signing with sighash_all then I believe you should terminate early. If signatures in an otherwise "failed" batch can be re-used (i.e sighash_single?) then you should still sign them. Although I believe the former is the case.
If a
SignTx
call is slow, the wholepresign()
function could timeout if all the calls are done sequentially. In this commit each call is done in a separate goroutine to reduce total latency.CC @GeorgeTsagk for taproot-assets commit fix (second commit of this PR).
Pull Request Checklist
release_notes.md
if your PR contains major features, breaking changes or bugfixes