From 00d21ee75e1c4b8fbbad5eaf58da1bc0db163b39 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 30 Jun 2026 15:59:47 +0200 Subject: [PATCH 1/3] epee: remove dead code Each symbol below has no references anywhere in the tree (src/, contrib/, tests/); the full build still links cleanly. Per-symbol history is given so the "why is this unused" is auditable (hashes are ancestors of HEAD). net/connection_basic (all four lost their last caller in the 2022 connection rewrite, 3be1dbd09 "connection: fix implementation"): - to_string(t_connection_type): unused free function. Added 9bfa593ee (2015) to print a connection's type in a debug log; 3be1dbd09 (2022) switched that log line to std::to_string on the enum, orphaning this overload. - do_send_handler_write / do_send_handler_write_from_queue: trace-only stubs added eabb51960 (2015) on the TCP send path; their calls in do_send_chunk / the write-completion handler were deleted by 3be1dbd09 (2022). The real send path is connection::start_write(). - sleep_before_packet: outbound rate-limit sleep added eabb51960 (2015); callers were thinned over time (cf5f62361, 2017) and the last removed by 3be1dbd09 (2022). Rate-limiting now lives in connection::start_write() via the global out-throttle. net/levin_base: - struct bucket_head: legacy levin packet header from the 2014 epee import, superseded by bucket_head2 (the wire header, `using header = bucket_head2`). Its last use went away with the old levin_protocol_handler in 0c545f614 (2024, "epee/test: remove levin_protocol_handler and core_proxy tests"). - LEVIN_PROTOCOL_VER_0: dead on arrival - present since the 2014 import, never referenced (the code uses LEVIN_PROTOCOL_VER_1). net/net_utils_base (connection-context logging macros): - LOG_PRINT_CC_L4: levin trace macro (2014 import); all call sites removed in 5833d66f6 (2017, "Change logging to easylogging++"). - LOG_PRINT_CCONTEXT_L3: had a single "REMOTE PEERLIST" call site, removed in the same 5833d66f6 (2017). - LOG_PRINT_CC_L3: only ever referenced inside LOG_PRINT_CCONTEXT_L3's body, never invoked directly - transitively dead once the above was removed. - LOG_CC: dead on arrival - added in 5833d66f6 (2017) but never invoked. (The plain LOG_PRINT_L3 macro that LOG_PRINT_CC_L3/CCONTEXT_L3 wrap is still used elsewhere and is left untouched; only these unused CC wrappers go.) net/network_throttle: - typedef network_MB: added eabb51960 (2015); its only consumers (set_target_kill / m_target_MB) were stripped the same day in 5ce4256e3 (2015), leaving an unused typedef. profile_tools: - START_WAY_POINTS / WAY_POINT / WAY_POINT2: dead on arrival - upstream-epee profiling macros present since the 2014 import, never once invoked (they only ever appear as definitions in profile_tools.h across all history). - TIME_MEASURE_PAUSE / TIME_MEASURE_RESTART and their _NS_ variants: dead on arrival - added bda8c5983 (2017, "epee: add nanosecond timer and pause/restart profiling macros") but never wired to any call site. Of this family only TIME_MEASURE_START / TIME_MEASURE_FINISH are actually used. storages: - typedef binarybuffer (portable_storage_base): used by the binary store/load API since the 2014 import; its last consumer (store_to_binary) was removed in 7414e2bac (2020, "Change epee binary output from std::stringstream to byte_stream"). - the templated min_bytes() member declaration (portable_storage_from_bin): declared but never defined or called. Added 7f407c027 (2020-12-26, "portable_storage: add some sanity checks on data size") alongside the ps_min_bytes<> trait struct, but the size checks were implemented via that trait (ps_min_bytes<>::strict), so this member was never defined or wired up - dead on arrival. The ps_min_bytes<> trait remains in use and is left intact. --- contrib/epee/include/net/connection_basic.hpp | 4 -- contrib/epee/include/net/levin_base.h | 15 ----- contrib/epee/include/net/net_utils_base.h | 4 -- contrib/epee/include/net/network_throttle.hpp | 1 - contrib/epee/include/profile_tools.h | 7 --- .../include/storages/portable_storage_base.h | 1 - .../storages/portable_storage_from_bin.h | 2 - contrib/epee/src/connection_basic.cpp | 55 ------------------- 8 files changed, 89 deletions(-) diff --git a/contrib/epee/include/net/connection_basic.hpp b/contrib/epee/include/net/connection_basic.hpp index 3a30e7443..fc0365034 100644 --- a/contrib/epee/include/net/connection_basic.hpp +++ b/contrib/epee/include/net/connection_basic.hpp @@ -96,7 +96,6 @@ class connection_basic_pimpl; // PIMPL for this class e_connection_type_P2P = 2 // to other p2p node (probably limited) }; - std::string to_string(t_connection_type type); class connection_basic { // not-templated base class for rapid development of some code parts // beware of removing const, net_utils::connection is sketchily doing a cast to prevent storing ptr twice @@ -165,8 +164,6 @@ class connection_basic { // not-templated base class for rapid development of so } // various handlers to be called from connection class: - void do_send_handler_write(const void * ptr , size_t cb); - void do_send_handler_write_from_queue(const boost::system::error_code& e, size_t cb , int q_len); // from handle_write, sending next part void logger_handle_net_write(size_t size); // network data written void logger_handle_net_read(size_t size); // network data read @@ -183,7 +180,6 @@ class connection_basic { // not-templated base class for rapid development of so static int get_tos_flag(); // handlers and sleep - void sleep_before_packet(size_t packet_size, int phase, int q_len); // execute a sleep ; phase is not really used now(?) static double get_sleep_time(size_t cb); }; diff --git a/contrib/epee/include/net/levin_base.h b/contrib/epee/include/net/levin_base.h index 404c06538..8b33b1672 100644 --- a/contrib/epee/include/net/levin_base.h +++ b/contrib/epee/include/net/levin_base.h @@ -43,20 +43,6 @@ namespace epee class byte_slice; namespace levin { -#pragma pack(push) -#pragma pack(1) - struct bucket_head - { - uint64_t m_signature; - uint64_t m_cb; - uint8_t m_have_to_return_data; - uint32_t m_command; - int32_t m_return_code; - uint32_t m_reservedA; //probably some flags in future - uint32_t m_reservedB; //probably some check sum in future - }; -#pragma pack(pop) - #pragma pack(push) #pragma pack(1) @@ -83,7 +69,6 @@ constexpr const std::chrono::milliseconds LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED{0} #define LEVIN_PACKET_END 0x00000008 -#define LEVIN_PROTOCOL_VER_0 0 #define LEVIN_PROTOCOL_VER_1 1 diff --git a/contrib/epee/include/net/net_utils_base.h b/contrib/epee/include/net/net_utils_base.h index c52791344..595ad9056 100644 --- a/contrib/epee/include/net/net_utils_base.h +++ b/contrib/epee/include/net/net_utils_base.h @@ -471,18 +471,14 @@ inline MAKE_LOGGABLE(connection_context_base, ct, os) #define LOG_INFO_CC(ct, message) MINFO(ct << message) #define LOG_DEBUG_CC(ct, message) MDEBUG(ct << message) #define LOG_TRACE_CC(ct, message) MTRACE(ct << message) -#define LOG_CC(level, ct, message) MLOG(level, ct << message) #define LOG_PRINT_CC_L0(ct, message) LOG_PRINT_L0(ct << message) #define LOG_PRINT_CC_L1(ct, message) LOG_PRINT_L1(ct << message) #define LOG_PRINT_CC_L2(ct, message) LOG_PRINT_L2(ct << message) -#define LOG_PRINT_CC_L3(ct, message) LOG_PRINT_L3(ct << message) -#define LOG_PRINT_CC_L4(ct, message) LOG_PRINT_L4(ct << message) #define LOG_PRINT_CCONTEXT_L0(message) LOG_PRINT_CC_L0(context, message) #define LOG_PRINT_CCONTEXT_L1(message) LOG_PRINT_CC_L1(context, message) #define LOG_PRINT_CCONTEXT_L2(message) LOG_PRINT_CC_L2(context, message) -#define LOG_PRINT_CCONTEXT_L3(message) LOG_PRINT_CC_L3(context, message) #define LOG_ERROR_CCONTEXT(message) LOG_ERROR_CC(context, message) #define CHECK_AND_ASSERT_MES_CC(condition, return_val, err_message) CHECK_AND_ASSERT_MES(condition, return_val, "[" << epee::net_utils::print_connection_context_short(context) << "]" << err_message) diff --git a/contrib/epee/include/net/network_throttle.hpp b/contrib/epee/include/net/network_throttle.hpp index 444a72f36..b3784dac6 100644 --- a/contrib/epee/include/net/network_throttle.hpp +++ b/contrib/epee/include/net/network_throttle.hpp @@ -75,7 +75,6 @@ namespace net_utils typedef double network_speed_kbps; // externally, for parameters and return values, all defined in kilobytes per second typedef double network_speed_bps; // throttle-internally, bytes per second typedef double network_time_seconds; -typedef double network_MB; class i_network_throttle; diff --git a/contrib/epee/include/profile_tools.h b/contrib/epee/include/profile_tools.h index 76f794a36..2872a429d 100644 --- a/contrib/epee/include/profile_tools.h +++ b/contrib/epee/include/profile_tools.h @@ -53,19 +53,12 @@ namespace epee #define PROFILE_FUNC_THIRD(immortal_ptr_str) #endif -#define START_WAY_POINTS() uint64_t _____way_point_time = epee::misc_utils::get_tick_count(); -#define WAY_POINT(name) {uint64_t delta = epee::misc_utils::get_tick_count()-_____way_point_time; MDEBUG("Way point " << name << ": " << delta);_____way_point_time = misc_utils::get_tick_count();} -#define WAY_POINT2(name, avrg_obj) {uint64_t delta = epee::misc_utils::get_tick_count()-_____way_point_time; avrg_obj.push(delta); MDEBUG("Way point " << name << ": " << delta);_____way_point_time = misc_utils::get_tick_count();} #define TIME_MEASURE_START(var_name) uint64_t var_name = epee::misc_utils::get_tick_count(); -#define TIME_MEASURE_PAUSE(var_name) var_name = epee::misc_utils::get_tick_count() - var_name; -#define TIME_MEASURE_RESTART(var_name) var_name = epee::misc_utils::get_tick_count() - var_name; #define TIME_MEASURE_FINISH(var_name) var_name = epee::misc_utils::get_tick_count() - var_name; #define TIME_MEASURE_NS_START(var_name) uint64_t var_name = epee::misc_utils::get_ns_count(); -#define TIME_MEASURE_NS_PAUSE(var_name) var_name = epee::misc_utils::get_ns_count() - var_name; -#define TIME_MEASURE_NS_RESTART(var_name) var_name = epee::misc_utils::get_ns_count() - var_name; #define TIME_MEASURE_NS_FINISH(var_name) var_name = epee::misc_utils::get_ns_count() - var_name; namespace profile_tools diff --git a/contrib/epee/include/storages/portable_storage_base.h b/contrib/epee/include/storages/portable_storage_base.h index c15c9b826..8d13172c8 100644 --- a/contrib/epee/include/storages/portable_storage_base.h +++ b/contrib/epee/include/storages/portable_storage_base.h @@ -160,7 +160,6 @@ namespace epee typedef boost::variant storage_entry; - typedef std::string binarybuffer;//it's ok /************************************************************************/ /* */ diff --git a/contrib/epee/include/storages/portable_storage_from_bin.h b/contrib/epee/include/storages/portable_storage_from_bin.h index fb1ab6888..1dd3c3949 100644 --- a/contrib/epee/include/storages/portable_storage_from_bin.h +++ b/contrib/epee/include/storages/portable_storage_from_bin.h @@ -83,8 +83,6 @@ namespace epee void read(section& sec); void read(std::string& str); void read(array_entry &ae); - template - size_t min_bytes() const; void set_limits(size_t objects, size_t fields, size_t strings); private: struct recursuion_limitation_guard diff --git a/contrib/epee/src/connection_basic.cpp b/contrib/epee/src/connection_basic.cpp index c1f9f8cf9..16004d510 100644 --- a/contrib/epee/src/connection_basic.cpp +++ b/contrib/epee/src/connection_basic.cpp @@ -67,21 +67,6 @@ namespace } } - std::string to_string(t_connection_type type) - { - if (type == e_connection_type_NET) - return std::string("NET"); - else if (type == e_connection_type_RPC) - return std::string("RPC"); - else if (type == e_connection_type_P2P) - return std::string("P2P"); - - return std::string("UNKNOWN"); - } - - -/* ============================================================================ */ - class connection_basic_pimpl { public: connection_basic_pimpl(const std::string &name); @@ -222,46 +207,6 @@ int connection_basic::get_tos_flag() { return connection_basic_pimpl::m_default_tos; } -void connection_basic::sleep_before_packet(size_t packet_size, int phase, int q_len) { - double delay=0; // will be calculated - do - { // rate limiting - if (m_was_shutdown) { - _dbg2("m_was_shutdown - so abort sleep"); - return; - } - - { - CRITICAL_REGION_LOCAL( network_throttle_manager::m_lock_get_global_throttle_out ); - delay = network_throttle_manager::get_global_throttle_out().get_sleep_time_after_tick( packet_size ); - } - - delay *= 0.50; - if (delay > 0) { - long int ms = (long int)(delay * 1000); - MTRACE("Sleeping in " << __FUNCTION__ << " for " << ms << " ms before packet_size="< 0); - -// XXX LATER XXX - { - CRITICAL_REGION_LOCAL( network_throttle_manager::m_lock_get_global_throttle_out ); - network_throttle_manager::get_global_throttle_out().handle_trafic_exact( packet_size ); // increase counter - global - } - -} - -void connection_basic::do_send_handler_write(const void* ptr , size_t cb ) { - // No sleeping here; sleeping is done once and for all in connection::handle_write - MTRACE("handler_write (direct) - before ASIO write, for packet="<::handle_write - MTRACE("handler_write (after write, from queue="< Date: Tue, 30 Jun 2026 15:59:47 +0200 Subject: [PATCH 2/3] blockchain_db: remove unused MDB_val_copy specializations The MDB_val_copy and MDB_val_copy specializations have no references anywhere in the tree (src/, contrib/, tests/); the full build still links cleanly. They were real helpers that copied block/tx blobs and the "version" key into LMDB from 2015 (3fcb8daf6 / f7e99047e). All instantiations were removed in 99fbe1008 (2018, "db_lmdb: save some string copies for readonly db keys/ values"), which writes blobs directly and points readonly MDB_vals at string literals (zero-copy). Every remaining MDB_val_copy<> call site uses the uint64_t/uint32_t/uint8_t primary template; these two specializations have sat unused since. --- src/blockchain_db/lmdb/db_lmdb.cpp | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index ffc027031..ecd9e551b 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -106,36 +106,6 @@ private: T t_copy; }; -template<> -struct MDB_val_copy: public MDB_val -{ - MDB_val_copy(const cryptonote::blobdata &bd) : - data(new char[bd.size()]) - { - memcpy(data.get(), bd.data(), bd.size()); - mv_size = bd.size(); - mv_data = data.get(); - } -private: - std::unique_ptr data; -}; - -template<> -struct MDB_val_copy: public MDB_val -{ - MDB_val_copy(const char *s): - size(strlen(s)+1), // include the NUL, makes it easier for compares - data(new char[size]) - { - mv_size = size; - mv_data = data.get(); - memcpy(mv_data, s, size); - } -private: - size_t size; - std::unique_ptr data; -}; - } namespace cryptonote From fa91ae464491eed18af726d9fcaee2fb3afe81f3 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 30 Jun 2026 21:11:20 +0200 Subject: [PATCH 3/3] common: remove dead code Each symbol below has no references anywhere in the tree (src/, contrib/, tests/), and none on the in-flight FCMP++ (fcmp++-stage-new) or CARROT (carrot_impl) integration branches; the full build still links cleanly. Per-symbol history is given so the "why is this unused" is auditable (hashes are ancestors of HEAD). command_line: - parse_command_line template: boost wrapper used by the connectivity tool and wallet from the 2014 import; the last caller was removed in b8a08f199 (2017, "wallet: fix --log-file not working"). Not boost's own boost::program_options::parse_command_line, a different function still in use. download: - download_finished / download_error: dead on arrival - added 63f0e074e (2017, "download: async API") but never wired to any caller. perf_timer: - set_performance_timer_log_level: dead on arrival - added 74dfdb0b3 (2016), never called. It was the only writer of performance_timer_log_level, which is therefore never reassigned and stays at its default (el::Level::Info). Note: the unused PERF_TIMER_L / PERF_TIMER_UNIT_L macros are deliberately left in place - the FCMP++ wallet-scanning work (fcmp++-stage-new, wallet2.cpp) uses PERF_TIMER_L, so removing them would break that branch on rebase. --- src/common/command_line.h | 13 ------------- src/common/download.cpp | 14 -------------- src/common/download.h | 2 -- src/common/perf_timer.cpp | 11 ----------- src/common/perf_timer.h | 2 -- 5 files changed, 42 deletions(-) diff --git a/src/common/command_line.h b/src/common/command_line.h index 681eb903b..9c304fbda 100644 --- a/src/common/command_line.h +++ b/src/common/command_line.h @@ -219,19 +219,6 @@ namespace command_line description.add_options()(arg.name, boost::program_options::bool_switch(), arg.description); } - template - boost::program_options::basic_parsed_options parse_command_line(int argc, const charT* const argv[], - const boost::program_options::options_description& desc, bool allow_unregistered = false) - { - auto parser = boost::program_options::command_line_parser(argc, argv); - parser.options(desc); - if (allow_unregistered) - { - parser.allow_unregistered(); - } - return parser.run(); - } - template bool handle_error_helper(const boost::program_options::options_description& desc, F parser) { diff --git a/src/common/download.cpp b/src/common/download.cpp index 859c80219..fd8e11478 100644 --- a/src/common/download.cpp +++ b/src/common/download.cpp @@ -274,20 +274,6 @@ namespace tools return control; } - bool download_finished(const download_async_handle &control) - { - CHECK_AND_ASSERT_MES(control != 0, false, "NULL async download handle"); - boost::lock_guard lock(control->mutex); - return control->stopped; - } - - bool download_error(const download_async_handle &control) - { - CHECK_AND_ASSERT_MES(control != 0, false, "NULL async download handle"); - boost::lock_guard lock(control->mutex); - return !control->success; - } - bool download_wait(const download_async_handle &control) { CHECK_AND_ASSERT_MES(control != 0, false, "NULL async download handle"); diff --git a/src/common/download.h b/src/common/download.h index 8efd29a33..97d0a3f56 100644 --- a/src/common/download.h +++ b/src/common/download.h @@ -46,8 +46,6 @@ namespace tools bool download(const std::string &path, const std::string &url, std::function progress = NULL); download_async_handle download_async(const std::string &path, const std::string &url, std::function result, std::function progress = NULL); - bool download_error(const download_async_handle &h); - bool download_finished(const download_async_handle &h); bool download_wait(const download_async_handle &h); bool download_cancel(const download_async_handle &h); } diff --git a/src/common/perf_timer.cpp b/src/common/perf_timer.cpp index fae0d7478..30d0b557d 100644 --- a/src/common/perf_timer.cpp +++ b/src/common/perf_timer.cpp @@ -97,17 +97,6 @@ el::Level performance_timer_log_level = el::Level::Info; static thread_local std::vector *performance_timers = NULL; #endif -void set_performance_timer_log_level(el::Level level) -{ - if (level != el::Level::Debug && level != el::Level::Trace && level != el::Level::Info - && level != el::Level::Warning && level != el::Level::Error && level != el::Level::Fatal) - { - MERROR("Wrong log level: " << el::LevelHelper::convertToString(level) << ", using Info"); - level = el::Level::Info; - } - performance_timer_log_level = level; -} - PerformanceTimer::PerformanceTimer(bool paused): started(true), paused(paused) { if (paused) diff --git a/src/common/perf_timer.h b/src/common/perf_timer.h index 3e53adcb8..8e9e10055 100644 --- a/src/common/perf_timer.h +++ b/src/common/perf_timer.h @@ -75,8 +75,6 @@ private: el::Level level; }; -void set_performance_timer_log_level(el::Level level); - #define PERF_TIMER_NAME(name) pt_##name #define PERF_TIMER_UNIT(name, unit) tools::LoggingPerformanceTimer PERF_TIMER_NAME(name)(#name, "perf." MONERO_DEFAULT_LOG_CATEGORY, unit, tools::performance_timer_log_level) #define PERF_TIMER_UNIT_L(name, unit, l) tools::LoggingPerformanceTimer PERF_TIMER_NAME(name)t_##name(#name, "perf." MONERO_DEFAULT_LOG_CATEGORY, unit, l)