mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-09-08 20:50:48 +02:00
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.
This commit is contained in:
@@ -65,6 +65,7 @@ FUZZ_TARGET(process_message, .init = initialize_process_message)
|
|||||||
auto& chainman = static_cast<TestChainstateManager&>(*g_setup->m_node.chainman);
|
auto& chainman = static_cast<TestChainstateManager&>(*g_setup->m_node.chainman);
|
||||||
SetMockTime(1610000000); // any time to successfully reset ibd
|
SetMockTime(1610000000); // any time to successfully reset ibd
|
||||||
chainman.ResetIbd();
|
chainman.ResetIbd();
|
||||||
|
chainman.DisableNextWrite();
|
||||||
|
|
||||||
node::Warnings warnings{};
|
node::Warnings warnings{};
|
||||||
NetGroupManager netgroupman{{}};
|
NetGroupManager netgroupman{{}};
|
||||||
|
@@ -55,6 +55,7 @@ FUZZ_TARGET(process_messages, .init = initialize_process_messages)
|
|||||||
auto& chainman = static_cast<TestChainstateManager&>(*g_setup->m_node.chainman);
|
auto& chainman = static_cast<TestChainstateManager&>(*g_setup->m_node.chainman);
|
||||||
SetMockTime(1610000000); // any time to successfully reset ibd
|
SetMockTime(1610000000); // any time to successfully reset ibd
|
||||||
chainman.ResetIbd();
|
chainman.ResetIbd();
|
||||||
|
chainman.DisableNextWrite();
|
||||||
|
|
||||||
node::Warnings warnings{};
|
node::Warnings warnings{};
|
||||||
NetGroupManager netgroupman{{}};
|
NetGroupManager netgroupman{{}};
|
||||||
|
@@ -9,6 +9,15 @@
|
|||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
|
|
||||||
|
void TestChainstateManager::DisableNextWrite()
|
||||||
|
{
|
||||||
|
struct TestChainstate : public Chainstate {
|
||||||
|
void ResetNextWrite() { m_next_write = NodeClock::time_point::max() - 1s; }
|
||||||
|
};
|
||||||
|
for (auto* cs : GetAll()) {
|
||||||
|
static_cast<TestChainstate*>(cs)->ResetNextWrite();
|
||||||
|
}
|
||||||
|
}
|
||||||
void TestChainstateManager::ResetIbd()
|
void TestChainstateManager::ResetIbd()
|
||||||
{
|
{
|
||||||
m_cached_finished_ibd = false;
|
m_cached_finished_ibd = false;
|
||||||
|
@@ -10,6 +10,8 @@
|
|||||||
class CValidationInterface;
|
class CValidationInterface;
|
||||||
|
|
||||||
struct TestChainstateManager : public ChainstateManager {
|
struct TestChainstateManager : public ChainstateManager {
|
||||||
|
/** Disable the next write of all chainstates */
|
||||||
|
void DisableNextWrite();
|
||||||
/** Reset the ibd cache to its initial state */
|
/** Reset the ibd cache to its initial state */
|
||||||
void ResetIbd();
|
void ResetIbd();
|
||||||
/** Toggle IsInitialBlockDownload from true to false */
|
/** Toggle IsInitialBlockDownload from true to false */
|
||||||
|
@@ -785,7 +785,7 @@ public:
|
|||||||
return m_mempool ? &m_mempool->cs : nullptr;
|
return m_mempool ? &m_mempool->cs : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
bool ActivateBestChainStep(BlockValidationState& state, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool->cs);
|
bool ActivateBestChainStep(BlockValidationState& state, CBlockIndex* pindexMostWork, const std::shared_ptr<const CBlock>& pblock, bool& fInvalidFound, ConnectTrace& connectTrace) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool->cs);
|
||||||
bool ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions& disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool->cs);
|
bool ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew, const std::shared_ptr<const CBlock>& pblock, ConnectTrace& connectTrace, DisconnectedBlockTransactions& disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_mempool->cs);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user