[v0.20.x-branch] Backport #11106: invoices: migrate legacy AMP invoice HTLCs - #11107
Conversation
AMP invoices created before reusable invoices store their HTLCs inline and have no AMPState metadata. Reconstruct the sub-invoice state from each HTLC set ID before inserting it into SQL. This preserves the AMP associations during read-back verification. Add regression coverage for settled and canceled legacy sets, AMP metadata, and custom records. (cherry picked from commit 96a0a26)
|
Please cherry-pick the changes locally and resolve any conflicts. git fetch origin backport-11106-to-v0.20.x-branch
git worktree add --checkout .worktree/backport-11106-to-v0.20.x-branch backport-11106-to-v0.20.x-branch
cd .worktree/backport-11106-to-v0.20.x-branch
git reset --hard HEAD^
git cherry-pick -x cb9c86195251422dc217c35b915e54a55d8f8580 b7a2f153962c34b3920533da0ae70f05e01d7a4f
git push --force-with-lease |
(cherry picked from commit b7a2f15)
da8c765 to
8fc74ae
Compare
🟠 PR Severity: HIGH
🟠 High (1 file)
🟢 Low (2 files)
AnalysisThis is a backport of #11106 fixing a bug in the KV-to-SQL migration for legacy AMP invoices: without reconstructed To override, add a |
Backport of #11106
Change Description
Legacy AMP invoices created before reusable AMP invoices store their HTLCs
inline and don't contain
AMPStatemetadata.The KV-to-SQL migration inserted the generic HTLC rows for these invoices, but
without
AMPStateit did not create AMP sub-invoices or associate the HTLCswith them. SQL read-back therefore returned an empty HTLC map, and strict
migration verification aborted startup.
Reconstruct the modern AMP sub-invoice state from each inline HTLC's set ID
before insertion. This preserves the HTLC associations, AMP metadata, custom
records, amounts, and settlement metadata while keeping the compatibility
handling isolated to the migration.
The migration fails closed if the legacy data is structurally inconsistent.
Release notes are included for v0.21.3 and v0.20.4.
Steps to Test
The regression test migrates a settled legacy AMP invoice with a canceled
competing set, AMP metadata, a large child index, and custom records, then
verifies complete SQL read-back equality.