Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.0] various different signedness warning fixes #625

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/chainbase
24 changes: 14 additions & 10 deletions plugins/net_plugin/net_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_snapshot_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was originally more sloppy and it's why it was >=3; I forgot to change this to ==3 after making it more strict. Not a big enough deal to go back to 5.0 to fix this imo

}

BOOST_AUTO_TEST_SUITE_END()
12 changes: 6 additions & 6 deletions unittests/savanna_proposer_policy_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -168,7 +168,7 @@ BOOST_FIXTURE_TEST_CASE(no_proposer_policy_change_without_finality, savanna_clus
for (uint32_t i=0; i<prod_rep; ++i) {
sb = A.produce_block();
if (sb->producer != orig_producer) {
BOOST_REQUIRE_EQUAL(sb->timestamp.slot % prod_rep, 0);
BOOST_REQUIRE_EQUAL(sb->timestamp.slot % prod_rep, 0u);
break;
}
}
Expand Down Expand Up @@ -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()

// ---------------------------------------------------------------------------------------------------
Expand Down