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:
1 parent
c8ba2294f2
commit
4e3d93e167
12 files changed
+277
-87
No files matched your search
+3
-3
@@ -168,10 +168,10 @@ static async Task<int> Sync(string[] o)
|
||||
doc.Cache?.NextReceiveIndex ?? 0,
|
||||
doc.Cache?.NextChangeIndex ?? 0,
|
||||
net,
|
||||
doc.Cache?.AnchoredUpTo);
|
||||
doc.Cache?.AnchoredDownTo);
|
||||
var result = await sync.SyncOnceAsync();
|
||||
|
||||
var (rawHex, verifiedAt, blockHeaders, anchoredUpTo) = sync.ExportCaches(net);
|
||||
var (rawHex, verifiedAt, blockHeaders, anchoredDownTo) = sync.ExportCaches(net);
|
||||
doc.Cache = new SyncCache
|
||||
{
|
||||
TipHeight = result.TipHeight,
|
||||
@@ -188,7 +188,7 @@ static async Task<int> Sync(string[] o)
|
||||
RawTxHex = rawHex,
|
||||
VerifiedAt = verifiedAt,
|
||||
BlockHeaders = blockHeaders,
|
||||
AnchoredUpTo = anchoredUpTo,
|
||||
AnchoredDownTo = anchoredDownTo,
|
||||
};
|
||||
WalletStore.Save(doc, path, CliPassword.Current);
|
||||
|
||||
|
||||
Reference in new issue
Block a user