From b5136b1a5d59c8f64cf4e5364ef12ac74950c34d Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 23 Jun 2026 22:31:28 +0200 Subject: [PATCH 1/2] common: remove unused data_cache.h Dead since 40eb82873 (2025-10) moved verRct caching into the mempool; only a stale #include remained in blockchain.cpp. --- src/common/data_cache.h | 65 ------------------------------ src/cryptonote_core/blockchain.cpp | 1 - 2 files changed, 66 deletions(-) delete mode 100644 src/common/data_cache.h diff --git a/src/common/data_cache.h b/src/common/data_cache.h deleted file mode 100644 index 8b0f26ea8..000000000 --- a/src/common/data_cache.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2014-2024, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers - -#pragma once - -#include -#include - -namespace tools -{ - template - class data_cache - { - public: - void add(const T& value) - { - std::lock_guard lock(m); - if (data.insert(value).second) - { - T& old_value = buf[counter++ % MAX_SIZE]; - data.erase(old_value); - old_value = value; - } - } - - bool has(const T& value) const - { - std::lock_guard lock(m); - return (data.find(value) != data.end()); - } - - private: - mutable std::mutex m; - std::unordered_set data; - T buf[MAX_SIZE] = {}; - size_t counter = 0; - }; -} diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index f2e8e230a..8d1308e03 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -57,7 +57,6 @@ #include "common/notify.h" #include "common/varint.h" #include "common/pruning.h" -#include "common/data_cache.h" #include "time_helper.h" #undef MONERO_DEFAULT_LOG_CATEGORY From 8a744a6388a13055a4dd852221d8ef02c6fe0f70 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 23 Jun 2026 22:32:17 +0200 Subject: [PATCH 2/2] tests: remove dead transactions_generation_from_blockchain Functional test commented out since 2014 (296ae46ed); never #included or called (main.cpp only runs transactions_flow_test). --- tests/functional_tests/CMakeLists.txt | 6 +- ...ransactions_generation_from_blockchain.cpp | 154 ------------------ .../transactions_generation_from_blockchain.h | 31 ---- 3 files changed, 2 insertions(+), 189 deletions(-) delete mode 100644 tests/functional_tests/transactions_generation_from_blockchain.cpp delete mode 100644 tests/functional_tests/transactions_generation_from_blockchain.h diff --git a/tests/functional_tests/CMakeLists.txt b/tests/functional_tests/CMakeLists.txt index f42b59140..c21ce1a33 100644 --- a/tests/functional_tests/CMakeLists.txt +++ b/tests/functional_tests/CMakeLists.txt @@ -28,12 +28,10 @@ set(functional_tests_sources main.cpp - transactions_flow_test.cpp - transactions_generation_from_blockchain.cpp) + transactions_flow_test.cpp) set(functional_tests_headers - transactions_flow_test.h - transactions_generation_from_blockchain.h) + transactions_flow_test.h) monero_add_minimal_executable(functional_tests ${functional_tests_sources} diff --git a/tests/functional_tests/transactions_generation_from_blockchain.cpp b/tests/functional_tests/transactions_generation_from_blockchain.cpp deleted file mode 100644 index 3abb13909..000000000 --- a/tests/functional_tests/transactions_generation_from_blockchain.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (c) 2014-2024, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers - -#include "include_base_utils.h" -using namespace epee; -#include "wallet/wallet2.h" - -using namespace cryptonote; - -/* -bool transactions_generation_from_blockchain(std::string& blockchain_folder_path) -{ - string_tools::parse_hexstr_to_binbuff() - tx_memory_pool pool; - blockchain_storage bchs(pool); - bool r = bchs.init(blockchain_folder_path); - CHECK_AND_ASSERT_MES(r, false, "failed to load blockchain"); - - //amount = 3000000000000 - //key_offsets = 1,2,3,4,5,10,12,27,31,33,34 - // -} - -tx_source_entry::output_entry make_outptu_entr_for_gindex(size_t i, std::map& txs, std::vector >& v) -{ - tx_source_entry::output_entry oe; - oe = i; - oe.second = txs[v[i].first].boost::get(vout[v[i].second].target).key; - return oe; -} - -bool make_tx(blockchain_storage& bch) -{ - std::map txs; - std::vector > v; - bch.get_outs_for_amounts(3000000000000, v); - - std::vector sources(11); - sources[0].amount = 3000000000000; - sources[0].outputs.push_back(make_outptu_entr_for_gindex(1, txs, v)); - sources[0].outputs.push_back(make_outptu_entr_for_gindex(2, txs, v)); - sources[0].outputs.push_back(make_outptu_entr_for_gindex(3, txs, v)); - sources[0].outputs.push_back(make_outptu_entr_for_gindex(4, txs, v)); - sources[0].outputs.push_back(make_outptu_entr_for_gindex(5, txs, v)); - sources[0].outputs.push_back(make_outptu_entr_for_gindex(10, txs, v)); - sources[0].outputs.push_back(make_outptu_entr_for_gindex(12, txs, v)); - sources[0].outputs.push_back(make_outptu_entr_for_gindex(27, txs, v)); - sources[0].outputs.push_back(make_outptu_entr_for_gindex(31, txs, v)); - sources[0].outputs.push_back(make_outptu_entr_for_gindex(33, txs, v)); - sources[0].outputs.push_back(make_outptu_entr_for_gindex(34, txs, v)); - sources[0].real_out_tx_key = - - BOOST_FOREACH(transfer_container::iterator it, selected_transfers) - { - sources.resize(sources.size()+1); - cryptonote::tx_source_entry& src = sources.back(); - transfer_details& td = *it; - src.amount = td.m_tx.vout[td.m_internal_output_index].amount; - //paste mixin transaction - if(daemon_resp.outs.size()) - { - daemon_resp.outs[i].outs.sort([](const out_entry& a, const out_entry& b){return a.global_amount_index < b.global_amount_index;}); - BOOST_FOREACH(out_entry& daemon_oe, daemon_resp.outs[i].outs) - { - if(td.m_global_output_index == daemon_oe.global_amount_index) - continue; - tx_output_entry oe; - oe.first = daemon_oe.global_amount_index; - oe.second = daemon_oe.out_key; - src.outputs.push_back(oe); - if(src.outputs.size() >= fake_outputs_count) - break; - } - } - - //paste real transaction to the random index - auto it_to_insert = std::find_if(src.outputs.begin(), src.outputs.end(), [&](const tx_output_entry& a) - { - return a.first >= td.m_global_output_index; - }); - //size_t real_index = src.outputs.size() ? (rand() % src.outputs.size() ):0; - tx_output_entry real_oe; - real_oe.first = td.m_global_output_index; - real_oe.second = boost::get(td.m_tx.vout[td.m_internal_output_index].target).key; - auto interted_it = src.outputs.insert(it_to_insert, real_oe); - src.real_out_tx_key = td.m_tx.tx_pub_key; - src.real_output = interted_it - src.outputs.begin(); - src.real_output_in_tx_index = td.m_internal_output_index; - src.rct = false; - ++i; - } - - - if(found_money != needed_money) - { - //lets make last output to odd money - dsts.resize(dsts.size()+1); - cryptonote::tx_destination_entry& destination = dsts.back(); - CHECK_AND_ASSERT_MES(found_money > needed_money, false, "internal error found_money=" << found_money << " !> needed_money=" << needed_money); - destination.amount = found_money - needed_money; - } - - - transaction tx; - bool r = cryptonote::construct_tx(m_account.get_keys(), sources, dsts, tx, unlock_time); - if(!r) - { - std::cout << "transaction construction failed" << std::endl; - } - - COMMAND_RPC_SEND_RAW_TX::request req; - req.tx_as_hex = epee::string_tools::buff_to_hex_nodelimer(tx_to_blob(tx)); - COMMAND_RPC_SEND_RAW_TX::response daemon_send_resp; - r = net_utils::http::invoke_http_json_remote_command(m_daemon_address + "/sendrawtransaction", req, daemon_send_resp, m_http_client); - CHECK_AND_ASSERT_MES(r, false, "failed to send transaction"); - if(daemon_send_resp.status != CORE_RPC_STATUS_OK) - { - std::cout << "daemon failed to accept generated transaction" << ENDL; - return false; - } - - std::cout << "transaction generated ok and sent to daemon" << std::endl; - BOOST_FOREACH(transfer_container::iterator it, selected_transfers) - it->m_spent = true; - - return true; -}*/ diff --git a/tests/functional_tests/transactions_generation_from_blockchain.h b/tests/functional_tests/transactions_generation_from_blockchain.h deleted file mode 100644 index 12e78579d..000000000 --- a/tests/functional_tests/transactions_generation_from_blockchain.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2014-2024, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list -// of conditions and the following disclaimer in the documentation and/or other -// materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers - -bool transactions_generation_from_blockchain(std::string& blockchain_path);