AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 54 Bitcoin

channeldb: preserve db version during init

Public commit record

What the developer wrote

Authored by Elle Mouton

76/100 · Adequate
channeldb: preserve db version during init

Keep the top-level bucket creation introduced by PR #9653, since initialized
DBs can still be missing newer buckets such as the historical channel bucket.

Do not let the metadata bucket created during init make a fresh DB look
initialized. Use strict metadata reads so a missing metadata/dbp key is distinct
from a present DB version, then write metadata/dbp for genuinely fresh DBs.

Existing DBs with a metadata bucket but missing metadata/dbp are left for the
migration recovery path instead of being treated as latest.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a database initialization bug in LND's channel database. Previously, creating an empty metadata bucket during setup could trick the code into thinking an old or partially-created database was already fully up-to-date, potentially skipping needed upgrades. The change distinguishes between a truly new database, a database missing its version key, and an already-initialized database, so migrations run when they should.

Recommended action

Review migration recovery paths to ensure they correctly handle databases with a metadata bucket but missing dbVersionKey. Verify that existing deployments cannot reach the problematic state in production, and consider backporting to affected release branches.

Security signals we found

01

Database version detection logic flaw

02

Potential migration skip due to incorrect initialized-state detection

03

New explicit error for missing DB version key

04

Added unit tests covering missing version key and missing top-level buckets

Risk score

Why this scored 54/100

Our methodology →
Potential impact 18/30
Exploitability 8/25
Stealth signal 7/15
Affected reach 10/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.