fix(spv): anchor headers up to a checkpoint above them

With proof of work skipped, chaining headers from a checkpoint up to a
transaction's block proves nothing: a server can fabricate a header and
fake headers after a real checkpoint. The header must now hash-chain up to
the nearest checkpoint at or above its height, whose hash is hardcoded.
This also anchors heights below the first checkpoint. The cached anchor
state is renamed AnchoredDownTo and caches without it are re-verified
once. Blocks above the newest checkpoint remain a documented limit.
See ADR 0040.
This commit is contained in:
davide committed 2026-11-03 14:52:29 +01:00
1 parent c8ba2294f2
commit 4e3d93e167
12 files changed
+277 -87

No files matched your search

@@ -25,7 +25,7 @@ public class StorageEdgeCaseTests
RawTxHex = new() { ["aa"] = "0102" },
VerifiedAt = new() { ["aa"] = 10 },
BlockHeaders = new() { [10] = "00" },
AnchoredUpTo = new() { [100] = 150 },
AnchoredDownTo = new() { [100] = 150 },
},
};
var path = Path.Combine(Path.GetTempPath(), $"plm-cache-{Guid.NewGuid()}.json");
@@ -43,7 +43,7 @@ public class StorageEdgeCaseTests
Assert.Equal("0102", c.RawTxHex!["aa"]);
Assert.Equal(10, c.VerifiedAt!["aa"]);
Assert.Equal("00", c.BlockHeaders![10]);
Assert.Equal(150, c.AnchoredUpTo![100]);
Assert.Equal(150, c.AnchoredDownTo![100]);
}
finally { File.Delete(path); }
}