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

[3.2] Add chain api get_consensus_parameters #692

Merged
merged 3 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion plugins/chain_api_plugin/chain_api_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ void chain_api_plugin::plugin_startup() {
CHAIN_RW_CALL_ASYNC(push_transaction, chain_apis::read_write::push_transaction_results, 202, http_params_types::params_required),
CHAIN_RW_CALL_ASYNC(push_transactions, chain_apis::read_write::push_transactions_results, 202, http_params_types::params_required),
CHAIN_RW_CALL_ASYNC(send_transaction, chain_apis::read_write::send_transaction_results, 202, http_params_types::params_required),
CHAIN_RW_CALL_ASYNC(send_transaction2, chain_apis::read_write::send_transaction_results, 202, http_params_types::params_required)
CHAIN_RW_CALL_ASYNC(send_transaction2, chain_apis::read_write::send_transaction_results, 202, http_params_types::params_required),
CHAIN_RO_CALL(get_consensus_parameters, 200, http_params_types::no_params)
});

if (chain.account_queries_enabled()) {
Expand Down
13 changes: 12 additions & 1 deletion plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <eosio/chain/deep_mind.hpp>
#include <eosio/chain_plugin/trx_finality_status_processing.hpp>
#include <eosio/chain/permission_link_object.hpp>

#include <eosio/chain/global_property_object.hpp>
#include <eosio/chain/eosio_contract.hpp>

#include <eosio/resource_monitor_plugin/resource_monitor_plugin.hpp>
Expand Down Expand Up @@ -2742,6 +2742,17 @@ chain::symbol read_only::extract_core_symbol()const {
return core_symbol;
}

read_only::get_consensus_parameters_results
read_only::get_consensus_parameters(const get_consensus_parameters_params& ) const {
get_consensus_parameters_results results;

results.chain_config = db.get_global_properties().configuration;
results.kv_database_config = db.get_global_properties().kv_configuration;
Copy link
Member

@heifner heifner Jul 18, 2022

Choose a reason for hiding this comment

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

Remove this line. kv_configuration should not exist in Mandel and needs to be removed (or repurposed in the future).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's already in mandel ever since #8. Should an issue be made for its removal?

Copy link
Member

Choose a reason for hiding this comment

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

results.wasm_config = db.get_global_properties().wasm_configuration;

return results;
}

} // namespace chain_apis

fc::variant chain_plugin::get_log_trx_trace(const transaction_trace_ptr& trx_trace ) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <eosio/chain/plugin_interface.hpp>
#include <eosio/chain/types.hpp>
#include <eosio/chain/fixed_bytes.hpp>
#include <eosio/chain/kv_config.hpp>

#include <boost/container/flat_set.hpp>
#include <boost/multiprecision/cpp_int.hpp>
Expand Down Expand Up @@ -671,6 +672,13 @@ class read_only {

chain::symbol extract_core_symbol()const;

using get_consensus_parameters_params = empty;
struct get_consensus_parameters_results {
chain::chain_config chain_config;
chain::kv_database_config kv_database_config;
Copy link
Member

Choose a reason for hiding this comment

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

Remove this line and also from the FC_REFLECT

chain::wasm_config wasm_config;
};
get_consensus_parameters_results get_consensus_parameters(const get_consensus_parameters_params&) const;
};

class read_write {
Expand Down Expand Up @@ -905,4 +913,4 @@ FC_REFLECT( eosio::chain_apis::read_only::get_required_keys_params, (transaction
FC_REFLECT( eosio::chain_apis::read_only::get_required_keys_result, (required_keys) )
FC_REFLECT( eosio::chain_apis::read_only::compute_transaction_params, (transaction))
FC_REFLECT( eosio::chain_apis::read_only::compute_transaction_results, (transaction_id)(processed) )

FC_REFLECT( eosio::chain_apis::read_only::get_consensus_parameters_results, (chain_config)(kv_database_config)(wasm_config))
2 changes: 1 addition & 1 deletion plugins/net_api_plugin/net_api_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ using namespace eosio;
eosio::detail::net_api_plugin_empty result;

#define INVOKE_V_V(api_handle, call_name) \
body = parse_params<std::string, http_params_types::no_params_required>(body); \
body = parse_params<std::string, http_params_types::no_params>(body); \
api_handle.call_name(); \
eosio::detail::net_api_plugin_empty result;

Expand Down
1 change: 1 addition & 0 deletions programs/cleos/httpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ namespace eosio { namespace client { namespace http {
const string chain_func_base = "/v1/chain";
const string get_info_func = chain_func_base + "/get_info";
const string get_transaction_status_func = chain_func_base + "/get_transaction_status";
const string get_consensus_parameters_func = chain_func_base + "/get_consensus_parameters";
const string send_txn_func = chain_func_base + "/send_transaction";
const string push_txn_func = chain_func_base + "/push_transaction";
const string send2_txn_func = chain_func_base + "/send_transaction2";
Expand Down
9 changes: 9 additions & 0 deletions programs/cleos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ template<>
fc::variant call( const std::string& url,
const std::string& path) { return call( url, path, fc::variant() ); }

eosio::chain_apis::read_only::get_consensus_parameters_results get_consensus_parameters() {
return call(url, get_consensus_parameters_func).as<eosio::chain_apis::read_only::get_consensus_parameters_results>();
}

eosio::chain_apis::read_only::get_info_results get_info() {
return call(url, get_info_func).as<eosio::chain_apis::read_only::get_info_results>();
}
Expand Down Expand Up @@ -2796,6 +2800,11 @@ int main( int argc, char** argv ) {
std::cout << fc::json::to_pretty_string(call(get_transaction_status_func, arg)) << std::endl;
});

// get consensus parameters
get->add_subcommand("consensus_parameters", localized("Get current blockchain consensus parameters"))->callback([] {
std::cout << fc::json::to_pretty_string(get_consensus_parameters()) << std::endl;
});

// get block
string blockArg;
bool get_bhs = false;
Expand Down