build: Generate ip_asn.dat.h during build process
What changed, and why it matters
This commit is a routine build-system change. It makes Bitcoin Core automatically include a small network-mapping data file (ASMap) into the compiled binary by default, while adding an option to turn that embedding off. There is no indication this fixes or introduces a security vulnerability.
No security action required; review as normal build-system maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change adds a CMake option WITH_EMBEDDED_ASMAP (default ON, disabled for fuzzing builds) that controls whether src/node/data/ip_asn.dat is converted into a C++ header and compiled into bitcoin_node via target_raw_data_sources. It also exposes the flag to the Python test framework so functional tests can detect whether embedded ASMap data is present. A minor formatting fix removes a stray closing brace/newline in the header-generation script.
Changed components
CMake build systemsrc/node ASMap data embeddingtest framework configurationInspect captured patch +18 / −2
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 005b1074..37c727b9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -127,6 +127,8 @@ if(WITH_ZMQ)
find_package(ZeroMQ 4.0.0 MODULE REQUIRED)
endif()
+option(WITH_EMBEDDED_ASMAP "Embed default ASMap data." ON)
+
option(WITH_USDT "Enable tracepoints for Userspace, Statically Defined Tracing." OFF)
if(WITH_USDT)
find_package(USDT MODULE REQUIRED)
@@ -216,6 +218,7 @@ if(BUILD_FOR_FUZZING)
set(BUILD_GUI OFF)
set(ENABLE_EXTERNAL_SIGNER OFF)
set(WITH_ZMQ OFF)
+ set(WITH_EMBEDDED_ASMAP OFF)
set(BUILD_TESTS OFF)
set(BUILD_GUI_TESTS OFF)
set(BUILD_BENCH OFF)
@@ -667,6 +670,7 @@ else()
set(ipc_status OFF)
endif()
message(" IPC ................................. ${ipc_status}")
+message(" Embedded ASMap ...................... ${WITH_EMBEDDED_ASMAP}")
message(" USDT tracing ........................ ${WITH_USDT}")
message(" QR code (GUI) ....................... ${WITH_QRENCODE}")
message(" DBus (GUI) .......................... ${WITH_DBUS}")
diff --git a/cmake/script/GenerateHeaderFromRaw.cmake b/cmake/script/GenerateHeaderFromRaw.cmake
index d373d1c4..2c40e419 100644
--- a/cmake/script/GenerateHeaderFromRaw.cmake
+++ b/cmake/script/GenerateHeaderFromRaw.cmake
@@ -18,6 +18,5 @@ ${formatted_bytes}
};
inline constexpr std::span ${raw_source_basename}{detail_${raw_source_basename}_raw};
-}
-")
+}")
file(WRITE ${HEADER_PATH} "${header_content}")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index cf1f26c9..2d64ee88 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -286,6 +286,13 @@ target_link_libraries(bitcoin_node
$<TARGET_NAME_IF_EXISTS:libevent::pthreads>
$<TARGET_NAME_IF_EXISTS:USDT::headers>
)
+if(WITH_EMBEDDED_ASMAP)
+ target_compile_definitions(bitcoin_node PRIVATE ENABLE_EMBEDDED_ASMAP=1)
+ include(TargetDataSources)
+ target_raw_data_sources(bitcoin_node NAMESPACE node::data
+ node/data/ip_asn.dat
+ )
+endif()
# Bitcoin wrapper executable that can call other executables.
if(BUILD_BITCOIN_BIN)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 1603ac82..78fe0a92 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -25,6 +25,7 @@ function(create_test_config)
set_configure_variable(BUILD_DAEMON BUILD_BITCOIND)
set_configure_variable(BUILD_FUZZ_BINARY ENABLE_FUZZ_BINARY)
set_configure_variable(WITH_ZMQ ENABLE_ZMQ)
+ set_configure_variable(WITH_EMBEDDED_ASMAP ENABLE_EMBEDDED_ASMAP)
set_configure_variable(ENABLE_EXTERNAL_SIGNER ENABLE_EXTERNAL_SIGNER)
set_configure_variable(WITH_USDT ENABLE_USDT_TRACEPOINTS)
set_configure_variable(ENABLE_IPC ENABLE_IPC)
diff --git a/test/config.ini.in b/test/config.ini.in
index 40b9395b..20fa36b9 100644
--- a/test/config.ini.in
+++ b/test/config.ini.in
@@ -25,6 +25,7 @@ RPCAUTH=@abs_top_srcdir@/share/rpcauth/rpcauth.py
@BUILD_BITCOIND_TRUE@ENABLE_BITCOIND=true
@ENABLE_FUZZ_BINARY_TRUE@ENABLE_FUZZ_BINARY=true
@ENABLE_ZMQ_TRUE@ENABLE_ZMQ=true
+@ENABLE_EMBEDDED_ASMAP_TRUE@ENABLE_EMBEDDED_ASMAP=true
@ENABLE_EXTERNAL_SIGNER_TRUE@ENABLE_EXTERNAL_SIGNER=true
@ENABLE_USDT_TRACEPOINTS_TRUE@ENABLE_USDT_TRACEPOINTS=true
@ENABLE_IPC_TRUE@ENABLE_IPC=true
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index 1f957564..3251bd9f 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -1017,6 +1017,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
"""Checks whether the zmq module was compiled."""
return self.config["components"].getboolean("ENABLE_ZMQ")
+ def is_embedded_asmap_compiled(self):
+ """Checks whether ASMap data was embedded during compilation."""
+ return self.config["components"].getboolean("ENABLE_EMBEDDED_ASMAP")
+
def is_usdt_compiled(self):
"""Checks whether the USDT tracepoints were compiled."""
return self.config["components"].getboolean("ENABLE_USDT_TRACEPOINTS")
Why this scored 15/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.