From 7ee94bf4b02376af8b2cfc78ea954ca340fab8c5 Mon Sep 17 00:00:00 2001 From: Hodlinator <172445034+hodlinator@users.noreply.github.com> Date: Thu, 10 Sep 2026 11:31:04 +0200 Subject: [PATCH] asmap: Make outputted ASMap version match externally computed hashes * Change version from double to single SHA256 This invalidates serialized AddrMan data which forces re-bucketing. * Avoid reversing byte order for ASMap version in log Makes it easier to match it with externally computed hashes of the encoded file. --- src/init.cpp | 2 +- src/util/asmap.cpp | 2 +- test/functional/feature_asmap.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 3930e31316f..20fcf9e8afd 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1701,7 +1701,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) return false; #endif } - LogInfo("Using asmap version %s for IP bucketing", asmap_version.ToString()); + LogInfo("Using asmap version %s for IP bucketing", HexStr(asmap_version)); } else { node.netgroupman = std::make_unique(NetGroupManager::NoAsmap()); LogInfo("Using /16 prefix for IP bucketing"); diff --git a/src/util/asmap.cpp b/src/util/asmap.cpp index 04e47c24c05..ce96613d3b3 100644 --- a/src/util/asmap.cpp +++ b/src/util/asmap.cpp @@ -349,5 +349,5 @@ uint256 AsmapVersion(const std::span data) HashWriter asmap_hasher; asmap_hasher << data; - return asmap_hasher.GetHash(); + return asmap_hasher.GetSHA256(); } diff --git a/test/functional/feature_asmap.py b/test/functional/feature_asmap.py index 5debdfbe408..653f0caab7d 100755 --- a/test/functional/feature_asmap.py +++ b/test/functional/feature_asmap.py @@ -22,7 +22,7 @@ from test_framework.util import ( ) ASMAP = 'src/test/data/asmap.raw' # path to unit test skeleton asmap -VERSION = 'bafc9da308f45179443bd1d22325400ac9104f741522d003e3fac86700f68895' +VERSION = '55dcec00c72b8a33a271dad20271e14cfbe5526aa1dc12e2559f30c376d85a35' def expected_messages(filename): return [f'Opened asmap file "{filename}" (59 bytes) from disk',