Skip to content

Commit 6f6b2bb

Browse files
committed
Merge bitcoin#35808: fuzz: reset connman state in p2p targets
d29b22d fuzz: reset connman state in p2p targets (Hao Xu) Pull request description: Resets `ConnmanTestMsg` at the start of each input in `cmpctblock` and `p2p_handshake`, matching the other reused-connman fuzz targets and preventing sticky `CConnman` state from leaking between corpus inputs. Before this, deterministic-fuzz-coverage showed single inputs were stable, but all-input directory runs were not: ```diff cmpctblock, src/net.cpp:4172 - Branch (4172:9): [True: 1.21k, False: 33.0k] + Branch (4172:9): [True: 613, False: 33.6k] - Branch (4172:72): [True: 901, False: 311] + Branch (4172:72): [True: 497, False: 116] ``` ```diff p2p_handshake, src/net.cpp:4172 - Branch (4172:9): [True: 98, False: 1.67k] + Branch (4172:9): [True: 743, False: 1.03k] - Branch (4172:72): [True: 90, False: 8] + Branch (4172:72): [True: 612, False: 131] ``` With the resets, `deterministic-fuzz-coverage` passed for both `cmpctblock` and `p2p_handshake`. ACKs for top commit: nervana21: re-tACK d29b22d maflcko: lgtm ACK d29b22d Tree-SHA512: bd445ae33ab7f9850046e3de4e318bee9ae7b38ee77ee282d0f5c3a88a4b67610dd00faef2af913a4d7d42bfc42b957855b2d85f1849f77823149baa089afce2
2 parents dc0395c + d29b22d commit 6f6b2bb

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/test/fuzz/cmpctblock.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,15 @@ FUZZ_TARGET(cmpctblock, .init = initialize_cmpctblock)
126126
FakeSteadyClock steady_clock;
127127

128128
auto setup = g_setup;
129+
auto& connman = *static_cast<ConnmanTestMsg*>(setup->m_node.connman.get());
130+
connman.Reset();
129131
auto& mempool = *setup->m_node.mempool;
130132
auto& chainman = static_cast<TestChainstateManager&>(*setup->m_node.chainman);
131133
chainman.ResetIbd();
132134
chainman.DisableNextWrite();
133135
const size_t initial_index_size{WITH_LOCK(chainman.GetMutex(), return chainman.BlockIndex().size())};
134136

135137
AddrMan addrman{*setup->m_node.netgroupman, /*deterministic=*/true, /*consistency_check_ratio=*/0};
136-
auto& connman = *static_cast<ConnmanTestMsg*>(setup->m_node.connman.get());
137138
auto peerman = PeerManager::make(connman, addrman,
138139
/*banman=*/nullptr, chainman,
139140
mempool, *setup->m_node.warnings,

src/test/fuzz/p2p_handshake.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ FUZZ_TARGET(p2p_handshake, .init = ::initialize)
4040

4141
auto& node{g_setup->m_node};
4242
auto& connman{static_cast<ConnmanTestMsg&>(*node.connman)};
43+
connman.Reset();
4344
auto& chainman{static_cast<TestChainstateManager&>(*node.chainman)};
4445
FakeNodeClock clock{1610000000s}; // 2021-01-07, arbitrary
4546
FakeSteadyClock steady_clock;

0 commit comments

Comments
 (0)