Skip to content

staticaddr/loopin: prevent sweepless signing timeouts - #1228

Open
starius wants to merge 3 commits into
lightninglabs:masterfrom
starius:parallel-sweepless-sign
Open

staticaddr/loopin: prevent sweepless signing timeouts#1228
starius wants to merge 3 commits into
lightninglabs:masterfrom
starius:parallel-sweepless-sign

Conversation

@starius

@starius starius commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

For a sweepless Static Address loop-in, the server can ask the client to presign many fee variants of the sweep transaction. The client previously handled those notifications one at a time, and Aperture's L402 interceptor also held its token-payment mutex across each authenticated unary RPC. On a high-latency connection this made every signature response wait for another full round trip, so later variants could miss the server's signing deadline even though the client was otherwise able to sign them.

This change processes sweep requests through a bounded 128-worker pool and lets unary RPCs that already have a paid L402 token run concurrently. Token acquisition, payment resumption, and payment-required challenges still use Aperture's serialized path, preventing concurrent calls from initiating duplicate payments, while streaming RPC authentication remains unchanged. Shutdown cancels and drains the workers before manager-owned resources are released, and the fixed pool prevents a burst of server notifications from creating unbounded signing work.

  • TODO: change the Aperture client itself not to serialize the requests

Since this path signs server-provided transactions, the change also tightens the validation boundary before creating any MuSig2 session. The client verifies that the PSBT contains an unsigned transaction, that the server supplied an exact and unique prevout for every input, and that every deposit it is asked to sign is locally owned with the expected value and script. Malformed or inconsistent requests are rejected before signing instead of producing a signature over an incorrect digest or reaching a nil prevout.

Pull Request Checklist

  • Add an entry to docs/release-notes/release-notes-next.md, or apply the
    no-changelog label (required by CI)

The server can issue many presigning requests at once, but the client
handled notifications serially. Slow transports could leave later
responses past the server signing deadline.

Dispatch each request independently and drain active handlers during
shutdown so notification intake and cleanup remain safe.
Authenticated RPCs were serialized behind Aperture's token-payment
mutex. Slow sweep responses could therefore exceed the server timeout.

Use a paid token without the acquisition lock while keeping a
serialized fallback for payment challenges.
Unbounded notification handlers could exhaust client and signer
resources. Incomplete server prevout mappings could also crash or
misstate a signing hash.

Bound request processing with a fixed worker pool and verify prevouts
and locally owned deposit data before signing.
@starius
starius force-pushed the parallel-sweepless-sign branch from efe9b4a to 04a4e3a Compare September 9, 2026 16:36
@starius
starius marked this pull request as ready for review September 9, 2026 20:18
@starius
starius requested a review from hieblmi September 9, 2026 20:18
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.

1 participant