From fa9a3de09b4c6eef40f1073f09c9a0bd1858adf2 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 27 Jun 2025 17:22:17 +0200 Subject: [PATCH] fuzz: DisableNextWrite This is required in the process_message(s) fuzz targets to avoid leaking the next write time from one run to the next. Also, disable it completely because it is not needed and due to leveldb-internal non-determinism. --- src/test/fuzz/process_message.cpp | 1 + src/test/fuzz/process_messages.cpp | 1 + src/test/util/validation.cpp | 9 +++++++++ src/test/util/validation.h | 2 ++ src/validation.h | 2 +- 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/test/fuzz/process_message.cpp b/src/test/fuzz/process_message.cpp index d415f216c09..202e3e4bfa9 100644 --- a/src/test/fuzz/process_message.cpp +++ b/src/test/fuzz/process_message.cpp @@ -65,6 +65,7 @@ FUZZ_TARGET(process_message, .init = initialize_process_message) auto& chainman = static_cast(*g_setup->m_node.chainman); SetMockTime(1610000000); // any time to successfully reset ibd chainman.ResetIbd(); + chainman.DisableNextWrite(); node::Warnings warnings{}; NetGroupManager netgroupman{{}}; diff --git a/src/test/fuzz/process_messages.cpp b/src/test/fuzz/process_messages.cpp index 941c9b159eb..6df261cb595 100644 --- a/src/test/fuzz/process_messages.cpp +++ b/src/test/fuzz/process_messages.cpp @@ -55,6 +55,7 @@ FUZZ_TARGET(process_messages, .init = initialize_process_messages) auto& chainman = static_cast(*g_setup->m_node.chainman); SetMockTime(1610000000); // any time to successfully reset ibd chainman.ResetIbd(); + chainman.DisableNextWrite(); node::Warnings warnings{}; NetGroupManager netgroupman{{}}; diff --git a/src/test/util/validation.cpp b/src/test/util/validation.cpp index bcd6a7a7dc3..ce558078a6d 100644 --- a/src/test/util/validation.cpp +++ b/src/test/util/validation.cpp @@ -9,6 +9,15 @@ #include #include +void TestChainstateManager::DisableNextWrite() +{ + struct TestChainstate : public Chainstate { + void ResetNextWrite() { m_next_write = NodeClock::time_point::max() - 1s; } + }; + for (auto* cs : GetAll()) { + static_cast(cs)->ResetNextWrite(); + } +} void TestChainstateManager::ResetIbd() { m_cached_finished_ibd = false; diff --git a/src/test/util/validation.h b/src/test/util/validation.h index 45ef773409a..f9c6a8ac02a 100644 --- a/src/test/util/validation.h +++ b/src/test/util/validation.h @@ -10,6 +10,8 @@ class CValidationInterface; struct TestChainstateManager : public ChainstateManager { + /** Disable the next write of all chainstates */ + void DisableNextWrite(); /** Reset the ibd cache to its initial state */ void ResetIbd(); /** Toggle IsInitialBlockDownload from true to false */ diff --git a/src/validation.h b/src/validation.h index 624a2ee8d6b..c25dd2de2d9 100644 --- a/src/validation.h +++ b/src/validation.h @@ -785,7 +785,7 @@ public: return m_mempool ? &m_mempool->cs : nullptr; } -private: +protected: bool ActivateBestChainStep(BlockValidationState& state, CBlockIndex* pindexMostWork, const std::shared_ptr& pblock, bool& fInvalidFound, ConnectTrace& connectTrace) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool->cs); bool ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew, const std::shared_ptr& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions& disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool->cs);