diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index c316b3a45a..81c5b1f6af 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -315,7 +315,52 @@ jobs: format: 'golang' parallel: true - # Integration tests on Postgres backend. + ######################## + # run integration tests with lnd remote-signer + ######################## + integration-test-lnd-remote-signer: + name: run itests with lnd remote-signer + runs-on: ubuntu-latest + steps: + - name: cleanup space + run: rm -rf /opt/hostedtoolcache + + - name: git checkout + uses: actions/checkout@v4 + + - name: Setup go ${{ env.GO_VERSION }} + uses: actions/setup-go@v5 + with: + go-version: '${{ env.GO_VERSION }}' + + - name: run itest + run: make itest-parallel remote-signing=1 + + - name: Zip log files on failure + if: ${{ failure() }} + run: 7z a logs-itest-lnd-remotesigner.zip itest/**/*.log + + - name: Upload log files on failure + uses: actions/upload-artifact@v4 + if: ${{ failure() }} + with: + name: logs-itest-lnd-remotesigner + path: logs-itest-lnd-remotesigner.zip + retention-days: 5 + + - name: Send coverage + uses: coverallsapp/github-action@v2 + if: ${{ success() }} + continue-on-error: true + with: + file: itest/coverage.txt + flag-name: 'itest' + format: 'golang' + parallel: true + + ######################## + # run integration tests with Postgres backend + ######################## integration-test-postgres: name: run itests postgres runs-on: ubuntu-latest diff --git a/docs/release-notes/release-notes-0.8.0.md b/docs/release-notes/release-notes-0.8.0.md index 7cac80f512..fa824c67b4 100644 --- a/docs/release-notes/release-notes-0.8.0.md +++ b/docs/release-notes/release-notes-0.8.0.md @@ -36,7 +36,7 @@ - [Garbage collection of orphaned UTXOs](https://github.com/lightninglabs/taproot-assets/pull/1832) by sweeping tombstones and burn outputs when executing onchain transactions. Garbage collection will be executed on every burn, transfer or call to - `AnchorVirtualPsbts`. A new configuration is available to control the sweeping + `AnchorVirtualPsbts`. A new configuration is available to control the sweeping via the flag `wallet.sweep-orphan-utxos`. ## RPC Updates @@ -57,7 +57,7 @@ ## Config Changes - [PR#1870](https://github.com/lightninglabs/taproot-assets/pull/1870) - The `proofs-per-universe` configuration option is removed. New option + The `proofs-per-universe` configuration option is removed. New option `max-proof-cache-size` sets the proof cache limit in bytes and accepts human-readable values such as `64MB`. @@ -66,6 +66,12 @@ - [PR#1897](https://github.com/lightninglabs/taproot-assets/pull/1897) Fix witness writeback issue when a split commitment is present. +- A [bug in `btcwallet` and `lnd` was fixed that prevented `tapd` from running + properly when connected to an `lnd` node that is running in remote-signing + mode](https://github.com/lightninglabs/taproot-assets/pull/1694). A new + integration test suite now asserts that `tapd` fully supports remote-signing + `lnd` backends. + ## Breaking Changes ## Performance Improvements diff --git a/itest/mint_fund_seal_test.go b/itest/mint_fund_seal_test.go index c850a5cff0..54414d9e2a 100644 --- a/itest/mint_fund_seal_test.go +++ b/itest/mint_fund_seal_test.go @@ -597,7 +597,7 @@ func deriveRandomKey(t *testing.T, ctxt context.Context, keyRing *lndservices.LndRpcKeyRing) keychain.KeyDescriptor { var ( - randFam = test.RandInt31n(math.MaxInt32) + randFam = test.RandInt31n(math.MaxInt8) randInd = test.RandInt31n(255) desc keychain.KeyDescriptor err error @@ -605,7 +605,7 @@ func deriveRandomKey(t *testing.T, ctxt context.Context, // Ensure that we use a different key family from tapd. for randFam == asset.TaprootAssetsKeyFamily { - randFam = test.RandInt31n(math.MaxInt32) + randFam = test.RandInt31n(math.MaxInt8) } desc, err = keyRing.DeriveNextKey( diff --git a/itest/multisig.go b/itest/multisig.go index db1428cf11..80980f4ef6 100644 --- a/itest/multisig.go +++ b/itest/multisig.go @@ -489,6 +489,15 @@ func FinalizePacket(t *testing.T, lnd *rpc.HarnessRPC, return signedPacket } +// FinalizeFullySigned is a helper function that finalizes a PSBT packet +// that is already fully signed. It will return the finalized packet. +func FinalizeFullySigned(t *testing.T, pkt *psbt.Packet) *psbt.Packet { + err := psbt.MaybeFinalizeAll(pkt) + require.NoError(t, err) + + return pkt +} + // PublishAndLogTransferOption defines a functional option for // PublishAndLogTransfer. type PublishAndLogTransferOption func(*publishAndLogTransferOptions) diff --git a/itest/psbt_test.go b/itest/psbt_test.go index 27fe90b8b4..6cbfa8e9b3 100644 --- a/itest/psbt_test.go +++ b/itest/psbt_test.go @@ -1272,7 +1272,7 @@ func testPsbtInteractiveAltLeafAnchoring(t *harnessTest) { require.NoError(t.t, err) commitPacket = signPacket(t.t, senderLnd, commitPacket) - commitPacket = FinalizePacket(t.t, senderLnd.RPC, commitPacket) + commitPacket = FinalizeFullySigned(t.t, commitPacket) publishResp := PublishAndLogTransfer( t.t, sender, commitPacket, []*tappsbt.VPacket{activePacket}, []*tappsbt.VPacket{passivePacket}, commitResp, @@ -2918,7 +2918,7 @@ func testPsbtExternalCommit(t *harnessTest) { t.Logf("Committed transaction: %v", toJSON(t.t, commitResp)) btcPacket = signPacket(t.t, aliceLnd, btcPacket) - btcPacket = FinalizePacket(t.t, aliceLnd.RPC, btcPacket) + btcPacket = FinalizeFullySigned(t.t, btcPacket) transferLabel := "itest-psbt-external-commit" diff --git a/itest/test_harness.go b/itest/test_harness.go index d008e0bf06..81d189e28d 100644 --- a/itest/test_harness.go +++ b/itest/test_harness.go @@ -18,6 +18,8 @@ import ( "github.com/lightninglabs/taproot-assets/taprpc" unirpc "github.com/lightninglabs/taproot-assets/taprpc/universerpc" "github.com/lightningnetwork/lnd/build" + "github.com/lightningnetwork/lnd/lnrpc" + "github.com/lightningnetwork/lnd/lnrpc/walletrpc" "github.com/lightningnetwork/lnd/lntest" "github.com/lightningnetwork/lnd/lntest/node" "github.com/lightningnetwork/lnd/lntest/port" @@ -40,13 +42,24 @@ var ( // noDelete is a command line flag for disabling deleting the tapd // data directories. - noDelete = flag.Bool("nodelete", false, "Set to true to keep all "+ - "tapd data directories after completing the tests") + noDelete = flag.Bool( + "nodelete", false, "Set to true to keep all tapd data "+ + "directories after completing the tests", + ) // logLevel is a command line flag for setting the log level of the // integration test output. - logLevel = flag.String("loglevel", "info", "Set the log level of the "+ - "integration test output") + logLevel = flag.String( + "loglevel", "info", "Set the log level of the integration "+ + "test output", + ) + + // lndRemoteSigner is a command line flag that indicates whether the + // lnd instances should be set up to use a remote signer. + lndRemoteSigner = flag.Bool( + "lndremotesigner", false, "if true, the lnd instances will "+ + "be set up to use a remote signer", + ) ) const ( @@ -303,7 +316,45 @@ func setupHarnesses(t *testing.T, ht *harnessTest, proofCourier = universeServer } - alice := lndHarness.NewNodeWithCoins("Alice", nil) + var alice *node.HarnessNode + if *lndRemoteSigner { + signer := lndHarness.NewNode("Signer", nil) + + rpcAccts := signer.RPC.ListAccounts( + &walletrpc.ListAccountsRequest{}, + ) + + watchOnlyAccounts, err := walletrpc.AccountsToWatchOnly( + rpcAccts.Accounts, + ) + require.NoError(t, err) + alice = lndHarness.NewNodeRemoteSigner( + "WatchOnly", []string{ + "--remotesigner.enable", + fmt.Sprintf( + "--remotesigner.rpchost=localhost:%d", + signer.Cfg.RPCPort, + ), + fmt.Sprintf( + "--remotesigner.tlscertpath=%s", + signer.Cfg.TLSCertPath, + ), + fmt.Sprintf( + "--remotesigner.macaroonpath=%s", + signer.Cfg.AdminMacPath, + ), + }, + []byte("itestpassword"), &lnrpc.WatchOnly{ + MasterKeyBirthdayTimestamp: 0, + MasterKeyFingerprint: nil, + Accounts: watchOnlyAccounts, + }, + ) + + lndHarness.FundNumCoins(alice, 5) + } else { + alice = lndHarness.NewNodeWithCoins("Alice", nil) + } // Create a tapd that uses Alice and connect it to the universe server. tapdHarness := setupTapdHarness( diff --git a/make/testing_flags.mk b/make/testing_flags.mk index 546f63e97b..6d6e76a270 100644 --- a/make/testing_flags.mk +++ b/make/testing_flags.mk @@ -62,6 +62,11 @@ ifneq ($(nodelete),) ITEST_FLAGS += -nodelete endif +# Run the lnd node in remote signing mode. +ifneq ($(remote-signing),) +ITEST_FLAGS += -lndremotesigner +endif + # Run the optional tests. ifneq ($(optional),) ITEST_FLAGS += -optional -postgrestimeout=240m