Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ build-asan/
test_runner/
doc/release-notes/*.backup
src/domain/CMakeLists.txt
bchn/
/bitcoin-core/
*.mdb
*.log
banlist.dat
Expand Down
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ option(WITH_CONSOLE_NODE_CINT "" OFF)
option(WITH_EXAMPLES "Compile with examples." OFF)
option(ENABLE_SHARED "" OFF)
option(ENABLE_SHARED_NODE_CINT "" ON)
option(KTH_ASIO_STANDALONE "Use standalone Asio instead of Boost.Asio" OFF)

# set(ENABLE_POSITION_INDEPENDENT_CODE ON)
# set(WITH_CONSOLE OFF)
Expand All @@ -54,6 +55,20 @@ if (WITH_LOCAL_MINING)
add_definitions(-DWITH_LOCAL_MINING)
endif()

# Asio standalone mode - define both our macro and Asio's expected macro
if (KTH_ASIO_STANDALONE)
add_definitions(-DKTH_ASIO_STANDALONE)
add_definitions(-DASIO_STANDALONE)
endif()

# jemalloc support
option(KTH_WITH_JEMALLOC "Use jemalloc for memory allocation" OFF)
if (KTH_WITH_JEMALLOC)
find_package(jemalloc REQUIRED)
add_definitions(-DKTH_WITH_JEMALLOC)
message(STATUS "Knuth: jemalloc enabled")
endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/ci_utils/cmake)
include(KnuthTools)

Expand Down
1 change: 1 addition & 0 deletions banlist.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Knuth banlist - format: IP create_time ban_until reason
9 changes: 6 additions & 3 deletions conan.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@
"libiconv/1.17#1e65319e945f2d31941a9d28cc13c058%1751603408.655",
"libbacktrace/cci.20210118#a7691bfccd8caaf66309df196790a5a1%1725632951.012",
"gmp/6.3.0#187de23af494e24e69bf9dfc1966a60d%1762775034.77",
"ftxui/6.1.9#053f78ab577d2d787fce0cd2e72bfa69%1748517521.121",
"fmt/12.0.0#dc7de7f3968e5d6b377f27b7d0f33916%1758262922.745",
"ctre/3.10.0#3f970a74e5cc3ba1a8ccb8e7f513062f%1755247138.192",
"catch2/3.11.0#17ac0eaea50698d4bd1704871e90cda7%1767110221.402",
"catch2/3.11.0#a560b55882ff2deb1f4bafad832a1b98%1762775012.454",
"bzip2/1.0.8#c470882369c2d95c5c77e970c0c7e321%1763677986.008",
"boost/1.90.0#d5e8defe7355494953be18524a7f135b%1765955095.179"
"boost/1.89.0#010f59feedfd171b15f467b42f723d13%1763743419.408",
"asio/1.36.0#75a50dae6e50af10cfb2150286b7df39%1756280309.023"
],
"build_requires": [
"secp256k1-precompute/1.0.0#53841449a185e25ee2337aa5e4f3583f%1751564430.278",
"m4/1.4.19#b38ced39a01e31fef5435bc634461fd2%1700758725.451",
"cmake/4.2.1#951586eff155256a7b5298631d6b1416%1765387599.255",
"b2/5.4.2#ffd6084a119587e70f11cd45d1a386e2%1766594659.866"
"cmake/3.31.10#313d16a1aa16bbdb2ca0792467214b76%1763665505.054",
"b2/5.3.3#107c15377719889654eb9a162a673975%1750340310.079"
],
"python_requires": [],
"config_requires": []
Expand Down
37 changes: 32 additions & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class KthRecipe(KnuthConanFileV2):
"with_icu": [True, False],
"with_png": [True, False],
"with_qrencode": [True, False],
"with_jemalloc": [True, False],
"asio_standalone": [True, False],

# secp256k1 options
"secp256k1_enable_coverage": [True, False],
Expand Down Expand Up @@ -110,7 +112,16 @@ class KthRecipe(KnuthConanFileV2):
"with_icu": False,
"with_png": False,
"with_qrencode": False,

# WARNING: jemalloc causes crashes with LMDB (mdb_env_close/mdb_dbi_close segfaults).
# LMDB uses mmap extensively which conflicts with jemalloc's memory management.
# Potential solutions if jemalloc is needed:
# 1. Run with MALLOC_CONF="retain:true" (less aggressive munmap)
# 2. Use MDB_WRITEMAP flag in LMDB (writes directly to mmap, bypasses malloc)
# 3. Compile LMDB separately without jemalloc linkage
# For now, keep disabled until a proper solution is implemented.
"with_jemalloc": False,
"asio_standalone": True,

# secp256k1 options
"secp256k1_enable_coverage": False,
"secp256k1_enable_branch_coverage": False,
Expand Down Expand Up @@ -161,6 +172,8 @@ def requirements(self):
self.requires("ctre/3.10.0", transitive_headers=True, transitive_libs=True)
self.requires("tiny-aes-c/1.0.0", transitive_headers=True, transitive_libs=True)

self.requires("ftxui/6.1.9", transitive_headers=True, transitive_libs=True)

# simdutf for SIMD-optimized base64 encoding (not available for WebAssembly)
if self.settings.os != "Emscripten":
self.requires("simdutf/7.1.0", transitive_headers=True, transitive_libs=True)
Expand All @@ -171,8 +184,12 @@ def requirements(self):
if self.options.with_qrencode:
self.requires("libqrencode/4.1.1", transitive_headers=True, transitive_libs=True)

# if self.options.asio_standalone:
# self.requires("asio/1.24.0", transitive_headers=True, transitive_libs=True)
if self.options.with_jemalloc:
# https://jasone.github.io/2025/06/12/jemalloc-postmortem/
self.requires("jemalloc/5.3.0", transitive_headers=True, transitive_libs=True)

if self.options.asio_standalone:
self.requires("asio/1.36.0", transitive_headers=True, transitive_libs=True)


def build_requirements(self):
Expand Down Expand Up @@ -248,6 +265,8 @@ def generate(self):
tc.variables["WITH_ICU"] = option_on_off(self.options.with_icu)
tc.variables["KTH_WITH_PNG"] = option_on_off(self.options.with_png)
tc.variables["KTH_WITH_QRENCODE"] = option_on_off(self.options.with_qrencode)
tc.variables["KTH_WITH_JEMALLOC"] = option_on_off(self.options.with_jemalloc)
tc.variables["KTH_ASIO_STANDALONE"] = option_on_off(self.options.asio_standalone)

# Secp256k1 --------------------------------------------
tc.variables["SECP256K1_ENABLE_COVERAGE"] = option_on_off(self.options.secp256k1_enable_coverage)
Expand Down Expand Up @@ -356,6 +375,8 @@ def package_info(self):
infrastructure_defines.append("KTH_WITH_PNG")
if self.options.with_qrencode:
infrastructure_defines.append("KTH_WITH_QRENCODE")
if self.options.with_jemalloc:
infrastructure_defines.append("KTH_WITH_JEMALLOC")
self.cpp_info.components["infrastructure"].defines = infrastructure_defines
# Infrastructure core dependencies: secp256k1, boost, fmt, ctre, spdlog, simdutf (non-wasm)
self.cpp_info.components["infrastructure"].requires = [
Expand All @@ -373,8 +394,14 @@ def package_info(self):
self.cpp_info.components["infrastructure"].requires.append("libpng::libpng")
if self.options.with_qrencode:
self.cpp_info.components["infrastructure"].requires.append("libqrencode::libqrencode")


# Add asio when using standalone mode
if self.options.asio_standalone:
self.cpp_info.components["infrastructure"].requires.append("asio::asio")
# Add jemalloc when enabled
if self.options.with_jemalloc:
self.cpp_info.components["infrastructure"].requires.append("jemalloc::jemalloc")


# Domain models and business logic
self.cpp_info.components["domain"].libs = ["domain"]
self.cpp_info.components["domain"].names["cmake_find_package"] = "domain"
Expand Down
Loading
Loading