Skip to content

Conversation

starius
Copy link
Collaborator

@starius starius commented Oct 15, 2025

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.

CC @GeorgeTsagk for taproot-assets commit fix (second commit of this PR).

Pull Request Checklist

  • Update release_notes.md if your PR contains major features, breaking changes or bugfixes

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.
@starius starius requested a review from hieblmi October 15, 2025 01:43
Loop was pinned to commit c44e078c33e0 (tapchannel: support stxo on aux sweeper)
which was merged into "main" branch of taproot-assets as e6ae082c0b4b.
@starius starius requested a review from GeorgeTsagk October 15, 2025 02:18
@starius starius marked this pull request as ready for review October 15, 2025 02:18
Copy link
Collaborator

@hieblmi hieblmi left a 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 "+
Copy link
Collaborator

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?

Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

Copy link
Member

@GeorgeTsagk GeorgeTsagk left a 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
Copy link
Member

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 "+
Copy link
Member

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.

@starius starius merged commit db907aa into lightninglabs:master Oct 15, 2025
15 of 18 checks passed
@starius starius deleted the parallel-presign branch October 15, 2025 14:46
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