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

[4.0] SHiP: Fix state-history-log-retain-blocks option handling #1241

Merged
merged 1 commit into from
Jun 7, 2023
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 plugins/state_history_plugin/state_history_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ void state_history_plugin::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);
}