Skip to content

multi: keep lndclient out of the core package mocks - #2388

Merged
jtobin merged 6 commits into
darioAnongba/embedded-engine-groundworkfrom
darioAnongba/embedded-engine-test-deps
Nov 13, 2026
Merged

jtobin merged 6 commits into
darioAnongba/embedded-engine-groundworkfrom
darioAnongba/embedded-engine-test-deps

Conversation

@darioAnongba

@darioAnongba darioAnongba commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #2387.

asset, commitment, tapscript, vm, proof, tappsbt, tapsend and address carry mock files in their regular build. Those files import internal/test, which imports lndclient, lnwallet and gRPC, so a program that imports any of the eight packages links lnd's RPC clients. With this change go list -deps reports no lndclient for them.

  • internal/test keeps MockSigner and RandCommitmentKeyRing in internal/test/lndmock and the gRPC server helpers in internal/test/grpcmock. The package itself imports none of the three.
  • MockProofCourier is declared in proof/courier.go, since URLDispatch returns it for the mockcourier address scheme.
  • The pre-verification pass of a backup import answers chain queries with a type local to backup, so the import path does not depend on the test helpers of proof.
  • WithSkipTimeLockValidationForAllProofs reaches the proof files of additional inputs. The pre-verification pass has no chain backend, and it accepts an asset with a time locked input in its history.
  • RandTapCommitVersion is declared in commitment/mock.go with the other random generators.
  • The property test generators of asset live in asset/assetmock, so a regular build of asset does not run their package-level initializers.

The mock files still link internal/test itself into the eight packages, and pgregory.net/rapid with it.

@darioAnongba darioAnongba self-assigned this Nov 12, 2026
@darioAnongba darioAnongba moved this from 🆕 New to 🏗 In progress in Taproot-Assets Project Board Nov 12, 2026
@darioAnongba
darioAnongba marked this pull request as ready for review November 12, 2026 13:42

@jtobin jtobin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opus flags a corner case problem here, and extant on main, around backups w/timelocks, in that a check should extend to additional inputs, but doesn't at present. Seems worth fixing.

Example fix, which just propagates the flag via the context:

Details
diff --git a/proof/verifier.go b/proof/verifier.go
index 2efc4d51a..1ca36861e 100644
--- a/proof/verifier.go
+++ b/proof/verifier.go
@@ -73,6 +73,10 @@ type VerifierCtx struct {
 	// into its nested input files.
 	trustedRoot bool
 
+	// skipTimeLockValidation propagates the skip requested by
+	// WithSkipTimeLockValidationForAllProofs into nested input files.
+	skipTimeLockValidation bool
+
 	// ActivationHeight is the block height from which transition proofs
 	// must satisfy the activation rules. A confirmed proof anchored below
 	// it is exempt only if chain verification binds a non-zero claimed
@@ -107,8 +111,9 @@ type verifyOptions struct {
 	skipTimeLockValidationForFinalProof bool
 
 	// skipTimeLockValidation skips locktime checks for all proofs in a
-	// file. This is used when verifying proofs without access to the
-	// chain backend (e.g. during backup pre-verification).
+	// file and in the files of their additional inputs. This is used when
+	// verifying proofs without access to the chain backend (e.g. during
+	// backup pre-verification).
 	skipTimeLockValidation bool
 
 	// trustedRoot permits a proof file to start at a proof other than a
@@ -139,8 +144,8 @@ func WithSkipTimeLockValidationForFinalProof() VerifyOption {
 }
 
 // WithSkipTimeLockValidationForAllProofs skips locktime checks for
-// every proof in the file. Use this when verifying proofs without
-// access to the chain backend.
+// every proof in the file, and in the files of their additional inputs.
+// Use this when verifying proofs without access to the chain backend.
 func WithSkipTimeLockValidationForAllProofs() VerifyOption {
 	return func(o *verifyOptions) {
 		o.skipTimeLockValidation = true
@@ -1923,6 +1928,13 @@ func (f *File) Verify(ctx context.Context,
 	trustedRoot := verifyOpts.trustedRoot || vCtx.trustedRoot
 	vCtx.trustedRoot = trustedRoot
 
+	// The files of additional inputs are verified with vCtx, which carries
+	// the skip for all proofs into them. The final proof options apply to
+	// the tip of this file only, so they stay here.
+	skipTimeLocks := verifyOpts.skipTimeLockValidation ||
+		vCtx.skipTimeLockValidation
+	vCtx.skipTimeLockValidation = skipTimeLocks
+
 	// A proof file must contain at least one proof to establish an asset
 	// state.
 	if err := f.IsValid(); err != nil {
@@ -2011,9 +2023,7 @@ func (f *File) Verify(ctx context.Context,
 		var proofOpts []ProofVerificationOption
 
 		// Skip timelocks for all proofs if requested.
-		if verifyOpts.skipTimeLockValidation &&
-			assetUsesTimeLock(&decodedProof.Asset) {
-
+		if skipTimeLocks && assetUsesTimeLock(&decodedProof.Asset) {
 			proofOpts = append(
 				proofOpts, WithSkipTimeLockValidation(),
 			)

Otherwise looks solid.

@github-project-automation github-project-automation Bot moved this from 🏗 In progress to 👀 In review in Taproot-Assets Project Board Nov 13, 2026
@darioAnongba
darioAnongba force-pushed the darioAnongba/embedded-engine-groundwork branch from e89246a to 1451fab Compare November 13, 2026 12:56
@darioAnongba
darioAnongba force-pushed the darioAnongba/embedded-engine-test-deps branch from 160576e to 2650d42 Compare November 13, 2026 13:03
MockSigner and RandCommitmentKeyRing live in internal/test/lndmock and
the gRPC server helpers in internal/test/grpcmock. Package test itself
imports neither lndclient, lnwallet nor grpc, so the packages whose
mock files import it do not link lnd's RPC clients. The unused
ParseRPCKeyDescriptor helper is dropped.
URLDispatch returns a MockProofCourier for the mockcourier address
scheme, so the type is part of the courier code rather than of the
test helpers in mock.go.
WithSkipTimeLockValidationForAllProofs applies to every proof of a
file and to the files of the additional inputs those proofs carry. The
backup pre-verification pass has no chain backend and relies on it for
an asset with a time locked input in its history.
The pre-verification pass of an import skips time lock validation and
must not reach the chain backend. Its chain lookup is a type local to
the package that answers every query with a zero value, so the import
path does not depend on the test helpers of package proof.
RandTapCommitVersion is a test helper, so it lives with the other
random generators. The minting code in mint.go does not import
internal/test.
The property test generators of package asset live in
asset/assetmock. Their package-level initializers instantiate much of
the rapid library, so a production build of asset stays free of that
code. The alt leaf encoding test runs as an external test of asset.

@jtobin jtobin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍 👍

@jtobin
jtobin merged commit f1d7c22 into darioAnongba/embedded-engine-groundwork Nov 13, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Taproot-Assets Project Board Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants