diff --git a/test/state/ethash_difficulty.cpp b/test/state/ethash_difficulty.cpp index 0d9bb0d51a..95eaac92b6 100644 --- a/test/state/ethash_difficulty.cpp +++ b/test/state/ethash_difficulty.cpp @@ -32,6 +32,8 @@ int64_t get_bomb_delay(evmc_revision rev) noexcept int64_t calculate_difficulty_pre_byzantium(int64_t parent_difficulty, int64_t parent_timestamp, int64_t current_timestamp, int64_t block_number, evmc_revision rev) { + static constexpr auto MIN_DIFFICULTY = int64_t{0x20000}; + // According to https://eips.ethereum.org/EIPS/eip-2 const auto period_count = block_number / 100'000; const auto offset = parent_difficulty / 2048; @@ -48,7 +50,8 @@ int64_t calculate_difficulty_pre_byzantium(int64_t parent_difficulty, int64_t pa else if (period_count == 2) diff += 1; - return diff; + // Adjust if below min difficulty `0x20000` + return std::max(MIN_DIFFICULTY, diff); } } // namespace