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

v4.0.1 throws error at plugin initialization of state_history_plugin #1217

Closed
cshintov opened this issue May 30, 2023 · 1 comment · Fixed by #1241 or #1248
Closed

v4.0.1 throws error at plugin initialization of state_history_plugin #1217

cshintov opened this issue May 30, 2023 · 1 comment · Fixed by #1241 or #1248
Assignees
Labels
👍 lgtm OCI Work exclusive to OCI team
Milestone

Comments

@cshintov
Copy link

cshintov commented May 30, 2023

I was upgrading from v3.2.3 to v4.0.1.

At startup it throws the below error.

...
info  2023-05-29T13:53:02.366 nodeos    block_log.cpp:664             open                 ] Log has 40151990 blocks
info  2023-05-29T13:53:02.377 nodeos    http_plugin.cpp:258           plugin_initialize    ] configured http to listen on 0.0.0.0:8888
info  2023-05-29T13:53:02.377 nodeos    net_plugin.cpp:3673           plugin_initialize    ] Initialize net plugin
info  2023-05-29T13:53:02.377 nodeos    log.hpp:713                   open_log             ] trace_history.log has blocks 68543281-79258424
warn  2023-05-29T13:53:02.377 nodeos    state_history_plugin.c:490    plugin_initialize    ] 3110000 plugin_exception: Plugin exception
state history log prune configuration requires at least one block
    {}
    nodeos  log.hpp:319 operator()

error 2023-05-29T13:53:02.381 nodeos    main.cpp:161                  main                 ] 3110000 plugin_exception: Plugin exception

My config.ini, which was working with v3.2.3 without any errors.

....
trace-history = true

# enable chain state history (eosio::state_history_plugin)
chain-state-history = true

# the endpoint upon which to listen for incoming connections. Caution: only expose this port to your internal network. (eosio::state_history_plugin)
state-history-endpoint = 0.0.0.0:{{ env "NOMAD_PORT_history" }}

# enable debug mode for trace history (eosio::state_history_plugin)
trace-history-debug-mode = true

# if set, periodically prune the state history files to store only configured number of most recent blocks (eosio::state_history_plugin)
state-history-log-retain-blocks = 10713600
...

Spent some time going through the code.

The error is caused by this

319: EOS_ASSERT(conf.prune_blocks, chain::plugin_exception, "state history log prune configuration requires at least one block");

prune_config.prune_blocks is defined here

namespace state_history {
   struct prune_config {
      uint32_t                prune_blocks;                  //number of blocks to prune to when doing a prune
      size_t                  prune_threshold = 4*1024*1024; //(approximately) how many bytes need to be added before a prune is performed
      std::optional<size_t>   vacuum_on_close;               //when set, a vacuum is performed on dtor if log contains less than this many bytes
   };

   struct partition_config {
      fc::path retained_dir       = "retained";
      fc::path archive_dir        = "archive";
      uint32_t stride             = 1000000;
      uint32_t max_retained_files = UINT32_MAX;
   };
}

I haven't specified anything for prune_blocks in config, what should be a default config for it? Where can I refer a sample config.ini with it or doc? I don't see the corresponding config option anywhere in the docs regarding state_history_plugin.

In the code I couldn't figure out where prune_config gets its value. cpp is not my native language.

@heifner
Copy link
Member

heifner commented May 30, 2023

Thank you for the detailed report. Much appreciated.
This is a bug in the handling of the state-history-log-retain-blocks.

diff --git a/plugins/state_history_plugin/state_history_plugin.cpp b/plugins/state_history_plugin/state_history_plugin.cpp
index f78369319..7b478b618 100644
--- a/plugins/state_history_plugin/state_history_plugin.cpp
+++ b/plugins/state_history_plugin/state_history_plugin.cpp
@@ -353,7 +353,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

We will get it fixed in the next release.

@heifner heifner added bug Something isn't working and removed triage labels May 30, 2023
@heifner heifner added this to the Leap 4.0.2 milestone May 30, 2023
@bhazzard bhazzard added 👍 lgtm and removed bug Something isn't working labels Jun 1, 2023
@heifner heifner self-assigned this Jun 7, 2023
@heifner heifner moved this from Todo to In Progress in Team Backlog Jun 7, 2023
@heifner heifner added the OCI Work exclusive to OCI team label Jun 7, 2023
heifner added a commit that referenced this issue Jun 7, 2023
[4.0] SHiP: Fix state-history-log-retain-blocks option handling
heifner added a commit that referenced this issue Jun 7, 2023
[4.0 -> main] SHiP: Fix state-history-log-retain-blocks option handling
@github-project-automation github-project-automation bot moved this from In Progress to Done in Team Backlog Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👍 lgtm OCI Work exclusive to OCI team
Projects
Archived in project
4 participants