Add read-only waiting proof inspection command - #247
Draft
ellemouton wants to merge 3 commits into
Draft
Conversation
Member
Author
|
Temporary user instructions for the Additional note: |
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.
What changed
Adds a temporary, read-only
inspectwaitingproofscommand for diagnosing lnd startup failures caused by records in thewaitingproofsbucket.The command:
channel.dbcopy with bboltReadOnly: true;metadata/dbpkey;invalid public key: unsupported format: 3d;This is intentionally opened as a draft because it is primarily a temporary debugging helper for an active investigation.
Background
An lnd v0.21.1 node is crash-looping immediately after unlock with:
The leading byte of a legacy remote waiting proof is
isRemote=0x01. The v0.21 typed decoder can interpret that same byte as the V2 proof type, then interpret shifted channel ID bytes as a MuSig2 nonce. If the resulting nonce starts with0x3d,btcec.ParsePubKeyreturns the reported error.The affected operator's inspection output showed:
The missing raw DB version key is important. lnd's
FetchMetareturns the latest DB version when themetadatabucket exists butmetadata/dbpis absent. That means startup logs can report the latest version even though the raw version key is missing, causing mandatory migrations such as migration 35 to be skipped. Locally, a fresh channeldb created through lnd's init path hasmetadatapresent anddbpabsent, which reproduces this metadata condition.With the latest version of this command, that first line is explicit:
For this failure mode, both 9-byte records are clean legacy V1 waiting proofs. The remote record reproduces the exact
0x3dcrash through the V2 misdecode path; the local record enters the V1 path and fails with shifted EOF.How to use
Stop lnd first and make an offline copy of
channel.db:Inspect the copy:
For machine-readable output:
Key verdicts:
exact_reported_crash_reproduced: the store contains a record that produces the reported3derror.waiting_proof_store_ruled_out: the bucket is absent or empty; inspect another startup pubkey path such aswtclient.db.other_startup_fatal_records_found: the store has fatal records, but they do not match the reported error.needs_full_v2_decode: a V2-looking record passed nonce parsing and requires the full v0.21 decoder.reported_crash_not_found: no record in this bucket explains the reported error.For an exact match,
legacy=clean_legacy_v1with a 9-byte key means the value and key satisfy migration 35's legacy layout checks. A typed key/value type disagreement instead points toward a damaged or externally modified typed record.Validation
0x3dreproduction.metadata/dbpplus both local and remote legacy waiting proofs.go test ./cmd/chantools -run 'TestInspectWaitingProofs' -count=1has_metadata_bucket=true has_db_version_key=falseon a fresh channeldb.The full command-package suite has an unrelated pointer-address normalization failure in
TestCompactDBAndDumpChannelson Darwin/arm64; the same failure reproduced before this update.