Skip to content

Commit

Permalink
Merge pull request #1248 from AntelopeIO/GH-1217-ship-main
Browse files Browse the repository at this point in the history
[4.0 -> main] SHiP: Fix state-history-log-retain-blocks option handling
  • Loading branch information
heifner authored Jun 7, 2023
2 parents 60eb61b + 3778e33 commit 1c607bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/state_history_plugin/state_history_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ void state_history_plugin_impl::plugin_initialize(const variables_map& options)

state_history_log_config ship_log_conf;
if (options.count("state-history-log-retain-blocks")) {
auto ship_log_prune_conf = ship_log_conf.emplace<state_history::prune_config>();
auto& ship_log_prune_conf = ship_log_conf.emplace<state_history::prune_config>();
ship_log_prune_conf.prune_blocks = options.at("state-history-log-retain-blocks").as<uint32_t>();
//the arbitrary limit of 1000 here is mainly so that there is enough buffer for newly applied forks to be delivered to clients
// before getting pruned out. ideally pruning would have been smart enough to know not to prune reversible blocks
Expand Down
17 changes: 17 additions & 0 deletions plugins/state_history_plugin/tests/plugin_config_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,21 @@ BOOST_AUTO_TEST_CASE(state_history_plugin_default_tests) {
auto* config = std::get_if<eosio::state_history::partition_config>(&plugin.trace_log()->config());
BOOST_REQUIRE(config);
BOOST_CHECK_EQUAL(config->max_retained_files, UINT32_MAX);
}

BOOST_AUTO_TEST_CASE(state_history_plugin_retain_blocks_tests) {
fc::temp_directory tmp;
appbase::scoped_app app;

auto tmp_path = tmp.path().string();
std::array args = {"test_state_history", "--trace-history", "--state-history-log-retain-blocks", "4242",
"--disable-replay-opts", "--data-dir", tmp_path.c_str()};

BOOST_CHECK(app->initialize<eosio::state_history_plugin>(args.size(), const_cast<char**>(args.data())));
auto& plugin = app->get_plugin<eosio::state_history_plugin>();

BOOST_REQUIRE(plugin.trace_log());
auto* config = std::get_if<eosio::state_history::prune_config>(&plugin.trace_log()->config());
BOOST_REQUIRE(config);
BOOST_CHECK_EQUAL(config->prune_blocks, 4242);
}

0 comments on commit 1c607bd

Please sign in to comment.