diff --git a/libraries/chainbase b/libraries/chainbase index 1dc531655d..a399c29b8e 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 1dc531655da7366ae6c0816b7d0862fb6327fedb +Subproject commit a399c29b8edfafb019eecef22b8d017cb76cec87 diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index f010155c6d..fdbe8726f7 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -2001,18 +2001,22 @@ namespace eosio { } uint32_t sync_manager::active_sync_fetch_span() const { - int32_t reversible_remaining = my_impl->chain_plug->chain().max_reversible_blocks_allowed(); - if (reversible_remaining <= 0) { - auto fork_db_size = my_impl->chain_plug->chain().fork_db_size(); - fc_wlog(logger, "max-reversible-blocks exceeded by ${ex}, fork_db_size ${fs}", - ("ex", -reversible_remaining)("fs", fork_db_size)); - reversible_remaining = 0; - } - if (reversible_remaining < sync_fetch_span) { + const uint32_t constrained_reversible_remaining = [&]() -> uint32_t { + const int32_t reversible_remaining = my_impl->chain_plug->chain().max_reversible_blocks_allowed(); + if (reversible_remaining <= 0) { + auto fork_db_size = my_impl->chain_plug->chain().fork_db_size(); + fc_wlog(logger, "max-reversible-blocks exceeded by ${ex}, fork_db_size ${fs}", + ("ex", -reversible_remaining)("fs", fork_db_size)); + return 0; + } + return reversible_remaining; + }(); + + if (constrained_reversible_remaining < sync_fetch_span) { auto fork_db_size = my_impl->chain_plug->chain().fork_db_size(); fc_wlog(logger, "sync-fetch-span ${sfs} restricted to ${r} by max-reversible-blocks, fork_db_size ${fs}", - ("sfs", sync_fetch_span)("r", reversible_remaining)("fs", fork_db_size)); - return reversible_remaining; + ("sfs", sync_fetch_span)("r", constrained_reversible_remaining)("fs", fork_db_size)); + return constrained_reversible_remaining; } return sync_fetch_span; } diff --git a/tests/test_snapshot_scheduler.cpp b/tests/test_snapshot_scheduler.cpp index 35e5e9faa9..1ae486ba7e 100644 --- a/tests/test_snapshot_scheduler.cpp +++ b/tests/test_snapshot_scheduler.cpp @@ -233,7 +233,7 @@ BOOST_AUTO_TEST_CASE(snapshot_scheduler_old_json) { unsigned found = 0; for(const std::filesystem::directory_entry& dir_entry : std::filesystem::directory_iterator(temp / "snapshots")) found += std::regex_search(dir_entry.path().filename().string(), snapshotfile_regex); - BOOST_REQUIRE_GE(found, 3); + BOOST_REQUIRE_EQUAL(found, 3u); } BOOST_AUTO_TEST_SUITE_END() diff --git a/unittests/savanna_proposer_policy_tests.cpp b/unittests/savanna_proposer_policy_tests.cpp index c2b99a56dc..3720aad199 100644 --- a/unittests/savanna_proposer_policy_tests.cpp +++ b/unittests/savanna_proposer_policy_tests.cpp @@ -23,7 +23,7 @@ BOOST_FIXTURE_TEST_CASE(policy_change_first_block_delay_check, savanna_cluster:: auto sb = A.produce_block(); // produce a block that will include the policy change transaction auto orig_producer = sb->producer; // save producer before transition auto start_slot = sb->timestamp.slot; - BOOST_REQUIRE_EQUAL(start_slot % prod_rep, 0); // validate that the policy change occurs on the first block of prod_rep + BOOST_REQUIRE_EQUAL(start_slot % prod_rep, 0u); // validate that the policy change occurs on the first block of prod_rep A.wait_for_producer(producers); // produce blocks until the new schedule will be active on next block produced BOOST_REQUIRE_EQUAL(A.head().block()->producer, // head block should still have been produced using @@ -33,7 +33,7 @@ BOOST_FIXTURE_TEST_CASE(policy_change_first_block_delay_check, savanna_cluster:: BOOST_REQUIRE(using_new_sched); // verify that we have just switched to new schedule BOOST_REQUIRE_NE(sb->producer, orig_producer); // and that the producer has changed auto end_slot = sb->timestamp.slot; - BOOST_REQUIRE_EQUAL(end_slot % prod_rep, 0); // validate that the policy change occurs on the first block of prod_rep + BOOST_REQUIRE_EQUAL(end_slot % prod_rep, 0u); // validate that the policy change occurs on the first block of prod_rep // under Savanna, a new policy becomes active on the first block of a prod_rep block round after: // 1. finishing the current round @@ -73,7 +73,7 @@ BOOST_FIXTURE_TEST_CASE(policy_change_sixth_block_delay_check, savanna_cluster:: BOOST_REQUIRE(using_new_sched); // verify that we have just switched to new schedule BOOST_REQUIRE_NE(sb->producer, orig_producer); // and that the producer has changed auto end_slot = sb->timestamp.slot; - BOOST_REQUIRE_EQUAL(end_slot % prod_rep, 0); // validate that the policy change occurs on the first block of prod_rep + BOOST_REQUIRE_EQUAL(end_slot % prod_rep, 0u); // validate that the policy change occurs on the first block of prod_rep // under Savanna, a new policy becomes active on the first block of a prod_rep block round after: // 1. finishing the current round @@ -113,7 +113,7 @@ BOOST_FIXTURE_TEST_CASE(policy_change_last_block_delay_check, savanna_cluster::c BOOST_REQUIRE(using_new_sched); // verify that we have just switched to new schedule BOOST_REQUIRE_NE(sb->producer, orig_producer); // and that the producer has changed auto end_slot = sb->timestamp.slot; - BOOST_REQUIRE_EQUAL(end_slot % prod_rep, 0); // validate that the policy change occurs on the first block of prod_rep + BOOST_REQUIRE_EQUAL(end_slot % prod_rep, 0u); // validate that the policy change occurs on the first block of prod_rep // under Savanna, a new policy becomes active on the first block of a prod_rep block round after: // 1. finishing the current round @@ -168,7 +168,7 @@ BOOST_FIXTURE_TEST_CASE(no_proposer_policy_change_without_finality, savanna_clus for (uint32_t i=0; iproducer != orig_producer) { - BOOST_REQUIRE_EQUAL(sb->timestamp.slot % prod_rep, 0); + BOOST_REQUIRE_EQUAL(sb->timestamp.slot % prod_rep, 0u); break; } } @@ -226,7 +226,7 @@ BOOST_FIXTURE_TEST_CASE(no_proposer_policy_change_without_finality_2, savanna_cl // ------------------------------------------------------------------------------- sb = A.produce_block(); BOOST_REQUIRE_NE(sb->producer, orig_producer); // verify switch has happened - BOOST_REQUIRE_EQUAL(sb->timestamp.slot % prod_rep, 0); // verify first block of a round + BOOST_REQUIRE_EQUAL(sb->timestamp.slot % prod_rep, 0u); // verify first block of a round } FC_LOG_AND_RETHROW() // ---------------------------------------------------------------------------------------------------