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

[5.0] more robust chain_api_plugin check in producer_plugin #2106

Merged
merged 2 commits into from
Jan 19, 2024

Conversation

spoonincode
Copy link
Member

Make this check more robust to handle the esoteric config pattern in #2104

Tests needed?

ilog("chain_api_plugin configured, defaulting read-only-threads to ${t}", ("t", _ro_thread_pool_size));
}
//appbase initializes configured plugins before auto-start plugins, so if chain_api_plugin is enabled it's
// initialized before producer_plugin (i.e. before this code here)
Copy link
Member Author

Choose a reason for hiding this comment

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

if (app().get_plugin("eosio::chain_api_plugin").get_state() == abstract_plugin::initialized) {
// default to 3 threads for non producer nodes running chain_api_plugin if not specified
_ro_thread_pool_size = 3;
ilog("chain_api_plugin configured, defaulting read-only-threads to ${t}", ("t", _ro_thread_pool_size));
Copy link
Member Author

Choose a reason for hiding this comment

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

Another approach would have been to change the previous check from == to find(), but I like asking appbase more directly instead of fishing in config items that this plugin doesn't "own".

The downside is that the check is reliant on plugin initialization ordering semantics that are arguably an implementation detail of appbase, and that producer_plugin will always remain an auto-start plugin. (Not for 5.0 but possibly in main) appbase might should have a new plugin state: enabled, and all plugins get marked enabled before they get initalize()ed, to avoid this dependency on ordering. (It's possible this isn't a plugin state() but rather some other new is_enabled() property on the plugin)

Copy link
Member

Choose a reason for hiding this comment

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

How about adding (producer_plugin) to APPBASE_PLUGIN_REQUIRES((chain_plugin)(http_plugin)) of chain_api_plugin.hpp.

Copy link
Member Author

Choose a reason for hiding this comment

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

That would require adding producer_plugin as a build dependency of chain_api_plugin -- target_link_libraries() etc. kinda gnarly when they really don't depend on each other.

@heifner
Copy link
Member

heifner commented Jan 18, 2024

warn  2024-01-18T17:53:08.874 plugin_te producer_plugin.cpp:1305      plugin_initialize    ] 13 N5boost10wrapexceptISt13runtime_errorEE: unable to find plugin: eosio::chain_api_plugin
rethrow unable to find plugin: eosio::chain_api_plugin: 
    {"what":"unable to find plugin: eosio::chain_api_plugin"}
    plugin_test  producer_plugin.cpp:1305 plugin_initialize

Maybe need:

if (auto* p = app().find_plugin("eosio::chain_api_plugin"); p->get_state() == abstract_plugin::initialized) {

@spoonincode
Copy link
Member Author

bummer I was hoping to avoid that mouthful

@ericpassmore
Copy link
Contributor

Note:start
group: STABILITY
category: BUG
summary: Add more robust configuration parsing and enhance check for chain_api_plugin. This change addresses failure to provide read-only transaction when using esoteric config pattern.
Note:end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

read-only-threads is required to submit /v1/chain/send_read_only_transaction
4 participants