regtest: add source-built Loop server - #1222
Open
sputn1ck wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a source-built, regtest-only Loop server (built from this repo) plus a refreshed Docker-based regtest topology, scripts, and tests to exercise real protocol flows (Loop Out, standard Loop In, static-address deposit Loop In) through loopd/loop.
Changes:
- Introduces a new
regtest/serverimplementation of the swap + static-address server RPCs, including update/notification hubs and protocol-driven tests. - Adds a new
cmd/loopserver-regtestbinary and a Docker build for it, wiring it behind an L402-authenticated Aperture proxy in the regtest Compose stack. - Updates the regtest operator experience (scripts, e2e acceptance runner, runbook) and adds release notes for the new environment.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| regtest/server/updates.go | In-memory state update hub + notification hub used by swap/static-address flows. |
| regtest/server/updates_test.go | Unit tests for update/notification replay and cancellation behavior. |
| regtest/server/staticaddr_test.go | Static-address protocol tests (MuSig2 signing, admission policy, idempotence, etc.). |
| regtest/server/server.go | Core regtest server wiring/config validation and lifecycle management. |
| regtest/server/server_test.go | Validation tests for server config bounds (Loop In CLTV delta). |
| regtest/server/rpc.go | Implements small RPC surface including L402 fetch and notification streaming. |
| regtest/server/loopout.go | Protocol-11 Loop Out server implementation with HTLC publication, confirmation, and preimage recovery. |
| regtest/server/loopout_test.go | Loop Out protocol tests (happy path, ambiguous broadcast reconciliation, preimage recovery, cancellation). |
| regtest/server/loopin.go | Standard Loop In server implementation with probe payment handshake and on-chain claim. |
| regtest/server/loopin_test.go | Loop In protocol tests including duplicate/idempotence handling and sweep publishing. |
| regtest/server/helpers.go | Shared helpers for keys, amount validation, invoice decoding/validation, chain height, etc. |
| regtest/regtest.sh | Reworked regtest orchestration script (compose selection, readiness waits, clean start, L402 bootstrap). |
| regtest/README.md | New runbook describing the source-built regtest server topology, safety boundary, and workflows. |
| regtest/e2e.sh | Automated acceptance script to run all three flows via real CLI/API, mining required confirmations. |
| regtest/Dockerfile | Multi-stage build for the loopserver-regtest binary used in the Compose topology. |
| regtest/docker-compose.yml | Updates Compose stack to build/run the in-repo server, pin Aperture build, and refresh supporting services. |
| regtest/aperture.yaml | Aperture config for L402 + routing to the loopserver backend in regtest. |
| docs/release-notes/release-notes-next.md | Release note entry for the new source-built regtest server environment. |
| cmd/loopserver-regtest/main.go | New entrypoint binary: connects to lnd/bitcoind, enforces regtest-only policy, serves gRPC (+ optional TLS). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
56
to
58
| - "--debuglevel=debug" | ||
| - "--externalip=lndserver" | ||
| - "--tlsextradomain=lndserver" |
Comment on lines
+189
to
+193
| func (s *Server) goSwap(run func(context.Context)) { | ||
| s.wg.Go(func() { | ||
| run(s.ctx) | ||
| }) | ||
| } |
Comment on lines
+83
to
+90
| minLndVersion := &verrpc.Version{ | ||
| AppMajor: 0, | ||
| AppMinor: 18, | ||
| AppPatch: 4, | ||
| BuildTags: []string{ | ||
| "signrpc", "walletrpc", "chainrpc", "invoicesrpc", | ||
| }, | ||
| } |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Safety boundary
The server refuses non-regtest lnd nodes and intentionally keeps swap state in memory. It is a protocol fixture, not a production service, and the runbook warns against exposing it to untrusted networks or valuable funds.
Testing
make lintgo test -race ./regtest/server -count=1go test ./... -run '^$'go test ./regtest/server -run '^TestLoopOutRecoversPreimageFromSuccessSpend$' -count=20./regtest/regtest.sh start./regtest/e2e.shThe live acceptance run completed Loop Out and standard Loop In in
SUCCESS, static-address Loop In inSUCCEEDED, and its deposit inLOOPED_IN, with an empty mempool after scripted confirmation mining.