Skip to content

Commit fa9a3de

Browse files
author
MarcoFalke
committed
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.
1 parent aeeeeec commit fa9a3de

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

src/test/fuzz/process_message.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ FUZZ_TARGET(process_message, .init = initialize_process_message)
6565
auto& chainman = static_cast<TestChainstateManager&>(*g_setup->m_node.chainman);
6666
SetMockTime(1610000000); // any time to successfully reset ibd
6767
chainman.ResetIbd();
68+
chainman.DisableNextWrite();
6869

6970
node::Warnings warnings{};
7071
NetGroupManager netgroupman{{}};

src/test/fuzz/process_messages.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ FUZZ_TARGET(process_messages, .init = initialize_process_messages)
5555
auto& chainman = static_cast<TestChainstateManager&>(*g_setup->m_node.chainman);
5656
SetMockTime(1610000000); // any time to successfully reset ibd
5757
chainman.ResetIbd();
58+
chainman.DisableNextWrite();
5859

5960
node::Warnings warnings{};
6061
NetGroupManager netgroupman{{}};

src/test/util/validation.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
#include <validation.h>
1010
#include <validationinterface.h>
1111

12+
void TestChainstateManager::DisableNextWrite()
13+
{
14+
struct TestChainstate : public Chainstate {
15+
void ResetNextWrite() { m_next_write = NodeClock::time_point::max() - 1s; }
16+
};
17+
for (auto* cs : GetAll()) {
18+
static_cast<TestChainstate*>(cs)->ResetNextWrite();
19+
}
20+
}
1221
void TestChainstateManager::ResetIbd()
1322
{
1423
m_cached_finished_ibd = false;

src/test/util/validation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
class CValidationInterface;
1111

1212
struct TestChainstateManager : public ChainstateManager {
13+
/** Disable the next write of all chainstates */
14+
void DisableNextWrite();
1315
/** Reset the ibd cache to its initial state */
1416
void ResetIbd();
1517
/** Toggle IsInitialBlockDownload from true to false */

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ class Chainstate
785785
return m_mempool ? &m_mempool->cs : nullptr;
786786
}
787787

788-
private:
788+
protected:
789789
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);
790790
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);
791791

0 commit comments

Comments
 (0)