@@ -29,21 +29,24 @@ class TestConditionChecker : public AbstractThresholdConditionChecker
29
29
const int64_t m_end;
30
30
const int m_period;
31
31
const int m_threshold;
32
+ const int m_min_activation_height;
32
33
const int m_bit;
33
34
34
- TestConditionChecker (int64_t begin, int64_t end, int period, int threshold, int bit)
35
- : m_begin{begin}, m_end{end}, m_period{period}, m_threshold{threshold}, m_bit{bit}
35
+ TestConditionChecker (int64_t begin, int64_t end, int period, int threshold, int min_activation_height, int bit)
36
+ : m_begin{begin}, m_end{end}, m_period{period}, m_threshold{threshold}, m_min_activation_height{min_activation_height}, m_bit{bit}
36
37
{
37
38
assert (m_period > 0 );
38
39
assert (0 <= m_threshold && m_threshold <= m_period);
39
40
assert (0 <= m_bit && m_bit < 32 && m_bit < VERSIONBITS_NUM_BITS);
41
+ assert (0 <= m_min_activation_height);
40
42
}
41
43
42
44
bool Condition (const CBlockIndex* pindex, const Consensus::Params& params) const override { return Condition (pindex->nVersion ); }
43
45
int64_t BeginTime (const Consensus::Params& params) const override { return m_begin; }
44
46
int64_t EndTime (const Consensus::Params& params) const override { return m_end; }
45
47
int Period (const Consensus::Params& params) const override { return m_period; }
46
48
int Threshold (const Consensus::Params& params) const override { return m_threshold; }
49
+ int MinActivationHeight (const Consensus::Params& params) const override { return m_min_activation_height; }
47
50
48
51
ThresholdState GetStateFor (const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateFor (pindexPrev, dummy_params, m_cache); }
49
52
int GetStateSinceHeightFor (const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateSinceHeightFor (pindexPrev, dummy_params, m_cache); }
@@ -168,8 +171,9 @@ FUZZ_TARGET_INIT(versionbits, initialize)
168
171
never_active_test = true ;
169
172
}
170
173
}
174
+ int min_activation = fuzzed_data_provider.ConsumeIntegralInRange <int >(0 , period * max_periods);
171
175
172
- TestConditionChecker checker (start_time, timeout, period, threshold, bit);
176
+ TestConditionChecker checker (start_time, timeout, period, threshold, min_activation, bit);
173
177
174
178
// Early exit if the versions don't signal sensibly for the deployment
175
179
if (!checker.Condition (ver_signal)) return ;
@@ -306,11 +310,16 @@ FUZZ_TARGET_INIT(versionbits, initialize)
306
310
}
307
311
break ;
308
312
case ThresholdState::LOCKED_IN:
309
- assert (exp_state == ThresholdState::STARTED);
310
- assert (current_block->GetMedianTimePast () < checker.m_end );
311
- assert (blocks_sig >= threshold);
313
+ if (exp_state == ThresholdState::LOCKED_IN) {
314
+ assert (current_block->nHeight + 1 < min_activation);
315
+ } else {
316
+ assert (exp_state == ThresholdState::STARTED);
317
+ assert (current_block->GetMedianTimePast () < checker.m_end );
318
+ assert (blocks_sig >= threshold);
319
+ }
312
320
break ;
313
321
case ThresholdState::ACTIVE:
322
+ assert (always_active_test || min_activation <= current_block->nHeight + 1 );
314
323
assert (exp_state == ThresholdState::ACTIVE || exp_state == ThresholdState::LOCKED_IN);
315
324
break ;
316
325
case ThresholdState::FAILED:
0 commit comments