What changed, and why it matters
This commit fixes a test-only data comparison mismatch during a database migration. When moving channel policy data to SQLite, empty signature fields were stored differently (nil vs empty slice), causing validation comparisons to fail. The fix normalizes empty signatures to nil before comparison, and adds a test case covering this scenario. It does not appear to affect live node behavior or introduce a security vulnerability.
No security action required. Treat as a normal bug fix for migration validation. Reviewers may verify that the normalization covers all comparable byte-slice fields in the policy record.
Security signals we found
No cryptographic or signature validation changes
No network-facing or authentication changes
Change is confined to migration test/validation comparison
Normalization pattern already existed for ExtraOpaqueData
Evidence from the diff
The change is in graph/db/migration1/sql_migration.go and its test. During graph migration validation, the KV decoder returns a non-nil empty byte slice for empty SigBytes, while SQLite returns nil for an empty BLOB. The existing code already normalized ExtraOpaqueData; this commit extends normalization to SigBytes. The test adds a channel policy with an explicitly empty SigBytes and updates expected policy counts. This is a correctness fix for migration validation logic, not a runtime protocol or cryptographic change.
Changed components
graph/db/migration1/sql_migration.gograph/db/migration1/sql_migration_test.goInspect captured patch +27 / −3
### graph/db/migration1/sql_migration.go
@@ -856,12 +856,20 @@ func validateMigratedChannelWithBatchData(cfg *SQLStoreConfig,
default:
}
+ // The KV decoder uses a non-nil empty slice, while SQLite
+ // uses nil for an empty BLOB. Normalize both before comparison.
if len(expPolicy.ExtraOpaqueData) == 0 {
expPolicy.ExtraOpaqueData = nil
}
if len(migPolicy.ExtraOpaqueData) == 0 {
migPolicy.ExtraOpaqueData = nil
}
+ if len(expPolicy.SigBytes) == 0 {
+ expPolicy.SigBytes = nil
+ }
+ if len(migPolicy.SigBytes) == 0 {
+ migPolicy.SigBytes = nil
+ }
return sqldb.CompareRecords(
*expPolicy, *migPolicy, "channel policy",
### graph/db/migration1/sql_migration_test.go
@@ -408,11 +408,21 @@ func TestMigrateGraphToSQL(t *testing.T) {
},
),
- // Now, insert a single update for the
- // first channel.
+ // Insert two updates for the first channel,
+ // preserving the non-empty signature case.
// - channel policy count += 1
makeTestPolicy(chanID1, node1, false),
+ // SQLite returns nil when this empty signature is
+ // read back, exercising the representation mismatch.
+ // - channel policy count += 1
+ makeTestPolicy(
+ chanID1, node2, true,
+ func(p *models.ChannelEdgePolicy) {
+ p.SigBytes = []byte{}
+ },
+ ),
+
// Insert two updates for the second
// channel, one for each direction.
// - channel policy count += 1
@@ -429,7 +439,7 @@ func TestMigrateGraphToSQL(t *testing.T) {
expGraphStats: graphStats{
numNodes: 4,
numChannels: 3,
- numPolicies: 3,
+ numPolicies: 4,
},
},
{
@@ -678,9 +688,15 @@ func fetchAllChannelsAndPolicies(t *testing.T, store V1Store) chanSet {
if p1 != nil && len(p1.ExtraOpaqueData) == 0 {
p1.ExtraOpaqueData = nil
}
+ if p1 != nil && len(p1.SigBytes) == 0 {
+ p1.SigBytes = nil
+ }
if p2 != nil && len(p2.ExtraOpaqueData) == 0 {
p2.ExtraOpaqueData = nil
}
+ if p2 != nil && len(p2.SigBytes) == 0 {
+ p2.SigBytes = nil
+ }
channels = append(channels, chanInfo{
edgeInfo: info,Why this scored 24/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.