From 5da119e5d0e61f0b583f0fe21b9a00ee815a3e46 Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Sun, 17 Dec 2023 19:02:26 +1000 Subject: [PATCH] versionbits: Change BIP9Stats to uint32_t types --- src/test/fuzz/versionbits.cpp | 10 +++++----- src/versionbits.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/fuzz/versionbits.cpp b/src/test/fuzz/versionbits.cpp index f52c17cffc1..8b30d1796c0 100644 --- a/src/test/fuzz/versionbits.cpp +++ b/src/test/fuzz/versionbits.cpp @@ -117,11 +117,11 @@ FUZZ_TARGET(versionbits, .init = initialize) FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); // making period/max_periods larger slows these tests down significantly - const int period = 32; + const uint32_t period = 32; const size_t max_periods = 16; const size_t max_blocks = 2 * period * max_periods; - const int threshold = fuzzed_data_provider.ConsumeIntegralInRange(1, period); + const uint32_t threshold = fuzzed_data_provider.ConsumeIntegralInRange(1, period); assert(0 < threshold && threshold <= period); // must be able to both pass and fail threshold! // too many blocks at 10min each might cause uint32_t time to overflow if @@ -199,7 +199,7 @@ FUZZ_TARGET(versionbits, .init = initialize) while (fuzzed_data_provider.remaining_bytes() > 0) { // early exit; no need for LIMITED_WHILE // all blocks in these periods either do or don't signal bool signal = fuzzed_data_provider.ConsumeBool(); - for (int b = 0; b < period; ++b) { + for (uint32_t b = 0; b < period; ++b) { blocks.mine_block(signal); } @@ -211,7 +211,7 @@ FUZZ_TARGET(versionbits, .init = initialize) // now we mine the final period and check that everything looks sane // count the number of signalling blocks - int blocks_sig = 0; + uint32_t blocks_sig = 0; // get the info for the first block of the period CBlockIndex* prev = blocks.tip(); @@ -230,7 +230,7 @@ FUZZ_TARGET(versionbits, .init = initialize) assert(exp_since <= prev_next_height); // mine (period-1) blocks and check state - for (int b = 1; b < period; ++b) { + for (uint32_t b = 1; b < period; ++b) { const bool signal = (signalling_mask >> (b % 32)) & 1; if (signal) ++blocks_sig; diff --git a/src/versionbits.h b/src/versionbits.h index 2f334081ab4..db76eadfa01 100644 --- a/src/versionbits.h +++ b/src/versionbits.h @@ -41,13 +41,13 @@ typedef std::map ThresholdConditionCache; /** Display status of an in-progress BIP9 softfork */ struct BIP9Stats { /** Length of blocks of the BIP9 signalling period */ - int period; + uint32_t period; /** Number of blocks with the version bit set required to activate the softfork */ - int threshold; + uint32_t threshold; /** Number of blocks elapsed since the beginning of the current period */ - int elapsed; + uint32_t elapsed; /** Number of blocks with the version bit set since the beginning of the current period */ - int count; + uint32_t count; /** False if there are not enough blocks left in this period to pass activation threshold */ bool possible; };