diff --git a/contracts/enable-kv/README.md b/contracts/enable-kv/README.md index 68634ab5307..05abb641ea2 100644 --- a/contracts/enable-kv/README.md +++ b/contracts/enable-kv/README.md @@ -7,7 +7,7 @@ This README illustrates the steps for usage of enable-kv.sh script with kv_map a ## Steps Bring up nodeos in a different terminal 1. export PATH=$EOS_2_1_0/build/bin:$PATH -1. nodeos -e -p eosio --plugin eosio::producer_plugin --plugin eosio::producer_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::http_plugin --plugin eosio::history_plugin --plugin eosio::history_api_plugin --filter-on=* --access-control-allow-origin=* --contracts-console --http-validate-host=false --verbose-http-errors --max-transaction-time=1000 --backing-store chainbase --data-dir=datadir +1. nodeos -e -p eosio --plugin eosio::producer_plugin --plugin eosio::producer_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::http_plugin --access-control-allow-origin=* --contracts-console --http-validate-host=false --verbose-http-errors --max-transaction-time=1000 --backing-store chainbase --data-dir=datadir In the first terminal 1. $EOS_2_1_0/contracts/enable-kv/enable-kv.sh -c $EOS_2_1_0/build/contracts/contracts/ diff --git a/docs/01_nodeos/03_plugins/index.md b/docs/01_nodeos/03_plugins/index.md index 5c9aac2ca42..4dfb0a8a99e 100644 --- a/docs/01_nodeos/03_plugins/index.md +++ b/docs/01_nodeos/03_plugins/index.md @@ -12,8 +12,6 @@ For information on specific plugins, just select from the list below: * [`chain_api_plugin`](chain_api_plugin/index.md) * [`chain_plugin`](chain_plugin/index.md) * [`db_size_api_plugin`](db_size_api_plugin/index.md) -* [`history_api_plugin`](history_api_plugin/index.md) -* [`history_plugin`](history_plugin/index.md) * [`http_client_plugin`](http_client_plugin/index.md) * [`http_plugin`](http_plugin/index.md) * [`login_plugin`](login_plugin/index.md) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index eb9232dd164..3a3446535a9 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -6,8 +6,6 @@ add_subdirectory(chain_plugin) add_subdirectory(chain_api_plugin) add_subdirectory(producer_plugin) add_subdirectory(producer_api_plugin) -add_subdirectory(history_plugin) -add_subdirectory(history_api_plugin) add_subdirectory(state_history_plugin) add_subdirectory(trace_api_plugin) add_subdirectory(signature_provider_plugin) diff --git a/plugins/history_api_plugin/CMakeLists.txt b/plugins/history_api_plugin/CMakeLists.txt deleted file mode 100644 index 1858af33b02..00000000000 --- a/plugins/history_api_plugin/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -file( GLOB HEADERS "include/eosio/history_api_plugin/*.hpp" ) -add_library( history_api_plugin - history_api_plugin.cpp - ${HEADERS} ) - -target_link_libraries( history_api_plugin history_plugin chain_plugin http_plugin appbase ) -target_include_directories( history_api_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/plugins/history_api_plugin/history_api_plugin.cpp b/plugins/history_api_plugin/history_api_plugin.cpp deleted file mode 100644 index c435371f42e..00000000000 --- a/plugins/history_api_plugin/history_api_plugin.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include - -#include - -namespace eosio { - -using namespace eosio; - -static appbase::abstract_plugin& _history_api_plugin = app().register_plugin(); - -history_api_plugin::history_api_plugin(){} -history_api_plugin::~history_api_plugin(){} - -void history_api_plugin::set_program_options(options_description&, options_description&) {} -void history_api_plugin::plugin_initialize(const variables_map&) {} - -#define CALL_WITH_400(api_name, api_handle, api_namespace, call_name, params_type) \ -{std::string("/v1/" #api_name "/" #call_name), \ - [api_handle](string, string body, url_response_callback cb) mutable { \ - try { \ - auto params = parse_params(body);\ - fc::variant result( api_handle.call_name( std::move(params) ) ); \ - cb(200, std::move(result)); \ - } catch (...) { \ - http_plugin::handle_exception(#api_name, #call_name, body, cb); \ - } \ - }} - -#define CHAIN_RO_CALL(call_name, params_type) CALL_WITH_400(history, ro_api, history_apis::read_only, call_name, params_type) -//#define CHAIN_RW_CALL(call_name) CALL(history, rw_api, history_apis::read_write, call_name) - -void history_api_plugin::plugin_startup() { - ilog( "starting history_api_plugin" ); - auto ro_api = app().get_plugin().get_read_only_api(); - //auto rw_api = app().get_plugin().get_read_write_api(); - - app().get_plugin().add_api({ -// CHAIN_RO_CALL(get_transaction), - CHAIN_RO_CALL(get_actions, http_params_types::params_required), - CHAIN_RO_CALL(get_transaction, http_params_types::params_required), - CHAIN_RO_CALL(get_key_accounts, http_params_types::params_required), - CHAIN_RO_CALL(get_controlled_accounts, http_params_types::params_required) - }); -} - -void history_api_plugin::plugin_shutdown() {} - -} diff --git a/plugins/history_api_plugin/include/eosio/history_api_plugin/history_api_plugin.hpp b/plugins/history_api_plugin/include/eosio/history_api_plugin/history_api_plugin.hpp deleted file mode 100644 index 557ac1b48b1..00000000000 --- a/plugins/history_api_plugin/include/eosio/history_api_plugin/history_api_plugin.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include -#include -#include - -#include - -namespace eosio { - - using namespace appbase; - - class history_api_plugin : public plugin { - public: - APPBASE_PLUGIN_REQUIRES((history_plugin)(chain_plugin)(http_plugin)) - - history_api_plugin(); - virtual ~history_api_plugin(); - - virtual void set_program_options(options_description&, options_description&) override; - - void plugin_initialize(const variables_map&); - void plugin_startup(); - void plugin_shutdown(); - - private: - }; - -} diff --git a/plugins/history_plugin/CMakeLists.txt b/plugins/history_plugin/CMakeLists.txt deleted file mode 100644 index 1eca3d247e0..00000000000 --- a/plugins/history_plugin/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -file(GLOB HEADERS "include/eosio/history_plugin/*.hpp") -add_library( history_plugin - history_plugin.cpp - ${HEADERS} ) - -target_link_libraries( history_plugin chain_plugin eosio_chain appbase ) -target_include_directories( history_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/plugins/history_plugin/history_plugin.cpp b/plugins/history_plugin/history_plugin.cpp deleted file mode 100644 index c655aac8303..00000000000 --- a/plugins/history_plugin/history_plugin.cpp +++ /dev/null @@ -1,594 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -namespace eosio { - using namespace chain; - using boost::signals2::scoped_connection; - - static appbase::abstract_plugin& _history_plugin = app().register_plugin(); - - - struct account_history_object : public chainbase::object { - OBJECT_CTOR( account_history_object ); - - id_type id; - account_name account; ///< the name of the account which has this action in its history - uint64_t action_sequence_num = 0; ///< the sequence number of the relevant action (global) - int32_t account_sequence_num = 0; ///< the sequence number for this account (per-account) - }; - - struct action_history_object : public chainbase::object { - - OBJECT_CTOR( action_history_object, (packed_action_trace) ); - - id_type id; - uint64_t action_sequence_num; ///< the sequence number of the relevant action - - shared_string packed_action_trace; - uint32_t block_num; - block_timestamp_type block_time; - transaction_id_type trx_id; - }; - using account_history_id_type = account_history_object::id_type; - using action_history_id_type = action_history_object::id_type; - - - struct by_action_sequence_num; - struct by_account_action_seq; - struct by_trx_id_act_seq; - - using action_history_index = chainbase::shared_multi_index_container< - action_history_object, - indexed_by< - ordered_unique, member>, - ordered_unique, member>, - ordered_unique, - composite_key< action_history_object, - member, - member - > - > - > - >; - - using account_history_index = chainbase::shared_multi_index_container< - account_history_object, - indexed_by< - ordered_unique, member>, - ordered_unique, - composite_key< account_history_object, - member, - member - > - > - > - >; - -} /// namespace eosio - -CHAINBASE_SET_INDEX_TYPE(eosio::account_history_object, eosio::account_history_index) -CHAINBASE_SET_INDEX_TYPE(eosio::action_history_object, eosio::action_history_index) - -namespace eosio { - - template - static void remove(chainbase::database& db, const account_name& account_name, const permission_name& permission) - { - const auto& idx = db.get_index(); - auto& mutable_idx = db.get_mutable_index(); - while(!idx.empty()) { - auto key = boost::make_tuple(account_name, permission); - const auto& itr = idx.lower_bound(key); - if (itr == idx.end()) - break; - - const auto& range_end = idx.upper_bound(key); - if (itr == range_end) - break; - - mutable_idx.remove(*itr); - } - } - - static void add(chainbase::database& db, const vector& keys, const account_name& name, const permission_name& permission) - { - for (auto pub_key_weight : keys ) { - db.create([&](public_key_history_object& obj) { - obj.public_key = pub_key_weight.key; - obj.name = name; - obj.permission = permission; - }); - } - } - - static void add(chainbase::database& db, const vector& controlling_accounts, const account_name& account_name, const permission_name& permission) - { - for (auto controlling_account : controlling_accounts ) { - db.create([&](account_control_history_object& obj) { - obj.controlled_account = account_name; - obj.controlled_permission = permission; - obj.controlling_account = controlling_account.permission.actor; - }); - } - } - - struct filter_entry { - name receiver; - name action; - name actor; - - std::tuple key() const { - return std::make_tuple(receiver, action, actor); - } - - friend bool operator<( const filter_entry& a, const filter_entry& b ) { - return a.key() < b.key(); - } - }; - - class history_plugin_impl { - public: - bool bypass_filter = false; - std::set filter_on; - std::set filter_out; - chain_plugin* chain_plug = nullptr; - std::optional applied_transaction_connection; - - bool filter(const action_trace& act) { - bool pass_on = false; - if (bypass_filter) { - pass_on = true; - } - if (filter_on.find({ act.receiver, {}, {} }) != filter_on.end()) { - pass_on = true; - } - if (filter_on.find({ act.receiver, act.act.name, {} }) != filter_on.end()) { - pass_on = true; - } - for (const auto& a : act.act.authorization) { - if (filter_on.find({ act.receiver, {}, a.actor }) != filter_on.end()) { - pass_on = true; - } - if (filter_on.find({ act.receiver, act.act.name, a.actor }) != filter_on.end()) { - pass_on = true; - } - } - - if (!pass_on) { return false; } - - if (filter_out.find({ act.receiver, {}, {} }) != filter_out.end()) { - return false; - } - if (filter_out.find({ act.receiver, act.act.name, {} }) != filter_out.end()) { - return false; - } - for (const auto& a : act.act.authorization) { - if (filter_out.find({ act.receiver, {}, a.actor }) != filter_out.end()) { - return false; - } - if (filter_out.find({ act.receiver, act.act.name, a.actor }) != filter_out.end()) { - return false; - } - } - - return true; - } - - set account_set( const action_trace& act ) { - set result; - - result.insert( act.receiver ); - for( const auto& a : act.act.authorization ) { - if( bypass_filter || - filter_on.find({ act.receiver, {}, {}}) != filter_on.end() || - filter_on.find({ act.receiver, {}, a.actor}) != filter_on.end() || - filter_on.find({ act.receiver, act.act.name, {}}) != filter_on.end() || - filter_on.find({ act.receiver, act.act.name, a.actor }) != filter_on.end() ) { - if ((filter_out.find({ act.receiver, {}, {} }) == filter_out.end()) && - (filter_out.find({ act.receiver, {}, a.actor }) == filter_out.end()) && - (filter_out.find({ act.receiver, act.act.name, {} }) == filter_out.end()) && - (filter_out.find({ act.receiver, act.act.name, a.actor }) == filter_out.end())) { - result.insert( a.actor ); - } - } - } - return result; - } - - void record_account_action( account_name n, const action_trace& act ) { - auto& chain = chain_plug->chain(); - chainbase::database& db = const_cast( chain.db() ); // Override read-only access to state DB (highly unrecommended practice!) - - const auto& idx = db.get_index(); - auto itr = idx.lower_bound( boost::make_tuple( name(n.to_uint64_t()+1), 0 ) ); - - uint64_t asn = 0; - if( itr != idx.begin() ) --itr; - if( itr->account == n ) - asn = itr->account_sequence_num + 1; - - const auto& a = db.create( [&]( auto& aho ) { - aho.account = n; - aho.action_sequence_num = act.receipt->global_sequence; - aho.account_sequence_num = asn; - }); - } - - void on_system_action( const action_trace& at ) { - auto& chain = chain_plug->chain(); - chainbase::database& db = const_cast( chain.db() ); // Override read-only access to state DB (highly unrecommended practice!) - if( at.act.name == "newaccount"_n ) - { - const auto create = at.act.data_as(); - add(db, create.owner.keys, create.name, "owner"_n); - add(db, create.owner.accounts, create.name, "owner"_n); - add(db, create.active.keys, create.name, "active"_n); - add(db, create.active.accounts, create.name, "active"_n); - } - else if( at.act.name == "updateauth"_n ) - { - const auto update = at.act.data_as(); - remove(db, update.account, update.permission); - remove(db, update.account, update.permission); - add(db, update.auth.keys, update.account, update.permission); - add(db, update.auth.accounts, update.account, update.permission); - } - else if( at.act.name == "deleteauth"_n ) - { - const auto del = at.act.data_as(); - remove(db, del.account, del.permission); - remove(db, del.account, del.permission); - } - } - - void on_action_trace( const action_trace& at ) { - if( filter( at ) ) { - //idump((fc::json::to_pretty_string(at))); - auto& chain = chain_plug->chain(); - chainbase::database& db = const_cast( chain.db() ); // Override read-only access to state DB (highly unrecommended practice!) - - db.create( [&]( auto& aho ) { - auto ps = fc::raw::pack_size( at ); - aho.packed_action_trace.resize_and_fill(ps, [&at](char* data, std::size_t size) { - fc::datastream ds( data, size ); - fc::raw::pack( ds, at ); - }); - aho.action_sequence_num = at.receipt->global_sequence; - aho.block_num = chain.head_block_num() + 1; - aho.block_time = chain.pending_block_time(); - aho.trx_id = at.trx_id; - }); - - auto aset = account_set( at ); - for( auto a : aset ) { - record_account_action( a, at ); - } - } - if( at.receiver == chain::config::system_account_name ) - on_system_action( at ); - } - - void on_applied_transaction( const transaction_trace_ptr& trace ) { - if( !trace->receipt || (trace->receipt->status != transaction_receipt_header::executed && - trace->receipt->status != transaction_receipt_header::soft_fail) ) - return; - for( const auto& atrace : trace->action_traces ) { - if( !atrace.receipt ) continue; - on_action_trace( atrace ); - } - } - }; - - history_plugin::history_plugin() - :my(std::make_shared()) { - } - - history_plugin::~history_plugin() { - } - - - - void history_plugin::set_program_options(options_description& cli, options_description& cfg) { - cfg.add_options() - ("filter-on,f", bpo::value>()->composing(), - "Track actions which match receiver:action:actor. Actor may be blank to include all. Action and Actor both blank allows all from Recieiver. Receiver may not be blank.") - ; - cfg.add_options() - ("filter-out,F", bpo::value>()->composing(), - "Do not track actions which match receiver:action:actor. Action and Actor both blank excludes all from Reciever. Actor blank excludes all from reciever:action. Receiver may not be blank.") - ; - } - - void history_plugin::plugin_initialize(const variables_map& options) { - try { - if( options.count( "filter-on" )) { - auto fo = options.at( "filter-on" ).as>(); - for( auto& s : fo ) { - if( s == "*" || s == "\"*\"" ) { - my->bypass_filter = true; - wlog( "--filter-on * enabled. This can fill shared_mem, causing nodeos to stop." ); - break; - } - std::vector v; - boost::split( v, s, boost::is_any_of( ":" )); - EOS_ASSERT( v.size() == 3, fc::invalid_arg_exception, "Invalid value ${s} for --filter-on", ("s", s)); - filter_entry fe{eosio::chain::name(v[0]), eosio::chain::name(v[1]), eosio::chain::name(v[2])}; - EOS_ASSERT( fe.receiver.to_uint64_t(), fc::invalid_arg_exception, - "Invalid value ${s} for --filter-on", ("s", s)); - my->filter_on.insert( fe ); - } - } - if( options.count( "filter-out" )) { - auto fo = options.at( "filter-out" ).as>(); - for( auto& s : fo ) { - std::vector v; - boost::split( v, s, boost::is_any_of( ":" )); - EOS_ASSERT( v.size() == 3, fc::invalid_arg_exception, "Invalid value ${s} for --filter-out", ("s", s)); - filter_entry fe{eosio::chain::name(v[0]), eosio::chain::name(v[1]), eosio::chain::name(v[2])}; - EOS_ASSERT( fe.receiver.to_uint64_t(), fc::invalid_arg_exception, - "Invalid value ${s} for --filter-out", ("s", s)); - my->filter_out.insert( fe ); - } - } - - my->chain_plug = app().find_plugin(); - EOS_ASSERT( my->chain_plug, chain::missing_chain_plugin_exception, "" ); - auto& chain = my->chain_plug->chain(); - - chainbase::database& db = const_cast( chain.db() ); // Override read-only access to state DB (highly unrecommended practice!) - // TODO: Use separate chainbase database for managing the state of the history_plugin (or remove deprecated history_plugin entirely) - db.add_index(); - db.add_index(); - db.add_index(); - db.add_index(); - - my->applied_transaction_connection.emplace( - chain.applied_transaction.connect( [&]( std::tuple t ) { - my->on_applied_transaction( std::get<0>(t) ); - } )); - } FC_LOG_AND_RETHROW() - } - - void history_plugin::plugin_startup() { - } - - void history_plugin::plugin_shutdown() { - my->applied_transaction_connection.reset(); - } - - - - - namespace history_apis { - read_only::get_actions_result read_only::get_actions( const read_only::get_actions_params& params )const { - edump((params)); - auto& chain = history->chain_plug->chain(); - const auto& db = chain.db(); - const auto abi_serializer_max_time = history->chain_plug->get_abi_serializer_max_time(); - - const auto& idx = db.get_index(); - - int32_t start = 0; - int32_t pos = params.pos ? *params.pos : -1; - int32_t end = 0; - int32_t offset = params.offset ? *params.offset : -20; - auto n = params.account_name; - idump((pos)); - if( pos == -1 ) { - auto itr = idx.lower_bound( boost::make_tuple( name(n.to_uint64_t()+1), 0 ) ); - if( itr == idx.begin() ) { - if( itr->account == n ) - pos = itr->account_sequence_num+1; - } else if( itr != idx.begin() ) --itr; - - if( itr->account == n ) - pos = itr->account_sequence_num + 1; - } - - if( pos== -1 ) pos = 0xfffffff; - - if( offset > 0 ) { - start = pos; - end = start + offset; - } else { - start = pos + offset; - if( start > pos ) start = 0; - end = pos; - } - EOS_ASSERT( end >= start, chain::plugin_exception, "end position is earlier than start position" ); - - idump((start)(end)); - - auto start_itr = idx.lower_bound( boost::make_tuple( n, start ) ); - auto end_itr = idx.upper_bound( boost::make_tuple( n, end) ); - - auto start_time = fc::time_point::now(); - auto end_time = start_time; - - get_actions_result result; - result.last_irreversible_block = chain.last_irreversible_block_num(); - while( start_itr != end_itr ) { - const auto& a = db.get( start_itr->action_sequence_num ); - fc::datastream ds( a.packed_action_trace.data(), a.packed_action_trace.size() ); - action_trace t; - fc::raw::unpack( ds, t ); - result.actions.emplace_back( ordered_action_result{ - start_itr->action_sequence_num, - start_itr->account_sequence_num, - a.block_num, a.block_time, - chain.to_variant_with_abi(t, abi_serializer::create_yield_function( abi_serializer_max_time )) - }); - - end_time = fc::time_point::now(); - if( end_time - start_time > fc::microseconds(100000) ) { - result.time_limit_exceeded_error = true; - break; - } - ++start_itr; - } - return result; - } - - - read_only::get_transaction_result read_only::get_transaction( const read_only::get_transaction_params& p )const { - auto& chain = history->chain_plug->chain(); - const auto abi_serializer_max_time = history->chain_plug->get_abi_serializer_max_time(); - - transaction_id_type input_id; - auto input_id_length = p.id.size(); - try { - FC_ASSERT( input_id_length <= 64, "hex string is too long to represent an actual transaction id" ); - FC_ASSERT( input_id_length >= 8, "hex string representing transaction id should be at least 8 characters long to avoid excessive collisions" ); - input_id = transaction_id_type(p.id); - } EOS_RETHROW_EXCEPTIONS(transaction_id_type_exception, "Invalid transaction ID: ${transaction_id}", ("transaction_id", p.id)) - - auto txn_id_matched = [&input_id, input_id_size = input_id_length/2, no_half_byte_at_end = (input_id_length % 2 == 0)] - ( const transaction_id_type &id ) -> bool // hex prefix comparison - { - bool whole_byte_prefix_matches = memcmp( input_id.data(), id.data(), input_id_size ) == 0; - if( !whole_byte_prefix_matches || no_half_byte_at_end ) - return whole_byte_prefix_matches; - - // check if half byte at end of specified part of input_id matches - return (*(input_id.data() + input_id_size) & 0xF0) == (*(id.data() + input_id_size) & 0xF0); - }; - - const auto& db = chain.db(); - const auto& idx = db.get_index(); - auto itr = idx.lower_bound( boost::make_tuple( input_id ) ); - - bool in_history = (itr != idx.end() && txn_id_matched(itr->trx_id) ); - - if( !in_history && !p.block_num_hint ) { - EOS_THROW(tx_not_found, "Transaction ${id} not found in history and no block hint was given", ("id",p.id)); - } - - get_transaction_result result; - - if( in_history ) { - result.id = itr->trx_id; - result.last_irreversible_block = chain.last_irreversible_block_num(); - result.block_num = itr->block_num; - result.block_time = itr->block_time; - - while( itr != idx.end() && itr->trx_id == result.id ) { - - fc::datastream ds( itr->packed_action_trace.data(), itr->packed_action_trace.size() ); - action_trace t; - fc::raw::unpack( ds, t ); - result.traces.emplace_back( chain.to_variant_with_abi(t, abi_serializer::create_yield_function( abi_serializer_max_time )) ); - - ++itr; - } - - auto blk = chain.fetch_block_by_number( result.block_num ); - if( blk || chain.is_building_block() ) { - const auto& receipts = blk ? blk->transactions : chain.get_pending_trx_receipts(); - for (const auto &receipt: receipts) { - if (std::holds_alternative(receipt.trx)) { - auto &pt = std::get(receipt.trx); - if (pt.id() == result.id) { - fc::mutable_variant_object r("receipt", receipt); - fc::variant v = chain.to_variant_with_abi(pt.get_transaction(), abi_serializer::create_yield_function( abi_serializer_max_time )); - fc::mutable_variant_object tmp(v.get_object()); - const auto* sigs = pt.get_signatures(); - tmp("signatures", sigs != nullptr ? *sigs : vector()); - const auto* context_free_data = pt.get_context_free_data(); - tmp("context_free_data", context_free_data != nullptr ? *context_free_data : vector()); - r("trx", std::move(tmp) ); - result.trx = move(r); - break; - } - } else { - auto &id = std::get(receipt.trx); - if (id == result.id) { - fc::mutable_variant_object r("receipt", receipt); - result.trx = move(r); - break; - } - } - } - } - } else { - auto blk = chain.fetch_block_by_number(*p.block_num_hint); - bool found = false; - if (blk) { - for (const auto& receipt: blk->transactions) { - if (std::holds_alternative(receipt.trx)) { - auto& pt = std::get(receipt.trx); - const auto& id = pt.id(); - if( txn_id_matched(id) ) { - result.id = id; - result.last_irreversible_block = chain.last_irreversible_block_num(); - result.block_num = *p.block_num_hint; - result.block_time = blk->timestamp; - fc::mutable_variant_object r("receipt", receipt); - fc::variant v = chain.to_variant_with_abi(pt.get_transaction(), abi_serializer::create_yield_function( abi_serializer_max_time )); - fc::mutable_variant_object tmp(v.get_object()); - const auto* sigs = pt.get_signatures(); - tmp("signatures", sigs != nullptr ? *sigs : vector()); - const auto* context_free_data = pt.get_context_free_data(); - tmp("context_free_data", context_free_data != nullptr ? *context_free_data : vector()); - r("trx", std::move(tmp) ); - result.trx = move(r); - found = true; - break; - } - } else { - auto& id = std::get(receipt.trx); - if( txn_id_matched(id) ) { - result.id = id; - result.last_irreversible_block = chain.last_irreversible_block_num(); - result.block_num = *p.block_num_hint; - result.block_time = blk->timestamp; - fc::mutable_variant_object r("receipt", receipt); - result.trx = move(r); - found = true; - break; - } - } - } - } - - if (!found) { - EOS_THROW(tx_not_found, "Transaction ${id} not found in history or in block number ${n}", ("id",p.id)("n", *p.block_num_hint)); - } - } - - return result; - } - - read_only::get_key_accounts_results read_only::get_key_accounts(const get_key_accounts_params& params) const { - std::set accounts; - const auto& db = history->chain_plug->chain().db(); - const auto& pub_key_idx = db.get_index(); - auto range = pub_key_idx.equal_range( params.public_key ); - for (auto obj = range.first; obj != range.second; ++obj) - accounts.insert(obj->name); - return {vector(accounts.begin(), accounts.end())}; - } - - read_only::get_controlled_accounts_results read_only::get_controlled_accounts(const get_controlled_accounts_params& params) const { - std::set accounts; - const auto& db = history->chain_plug->chain().db(); - const auto& account_control_idx = db.get_index(); - auto range = account_control_idx.equal_range( params.controlling_account ); - for (auto obj = range.first; obj != range.second; ++obj) - accounts.insert(obj->controlled_account); - return {vector(accounts.begin(), accounts.end())}; - } - - } /// history_apis - - - -} /// namespace eosio diff --git a/plugins/history_plugin/include/eosio/history_plugin/account_control_history_object.hpp b/plugins/history_plugin/include/eosio/history_plugin/account_control_history_object.hpp deleted file mode 100644 index 29529876440..00000000000 --- a/plugins/history_plugin/include/eosio/history_plugin/account_control_history_object.hpp +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include -#include - -namespace eosio { -using chain::account_name; -using chain::permission_name; -using chain::shared_vector; -using chain::transaction_id_type; -using namespace boost::multi_index; - -class account_control_history_object : public chainbase::object { - OBJECT_CTOR(account_control_history_object) - - id_type id; - account_name controlled_account; - permission_name controlled_permission; - account_name controlling_account; -}; - -struct by_id; -struct by_controlling; -struct by_controlled_authority; -using account_control_history_multi_index = chainbase::shared_multi_index_container< - account_control_history_object, - indexed_by< - ordered_unique, BOOST_MULTI_INDEX_MEMBER(account_control_history_object, account_control_history_object::id_type, id)>, - ordered_unique, - composite_key< account_control_history_object, - member, - member - > - >, - ordered_unique, - composite_key< account_control_history_object, - member, - member, - member - > - > - > ->; - -typedef chainbase::generic_index account_control_history_index; - -} - -CHAINBASE_SET_INDEX_TYPE( eosio::account_control_history_object, eosio::account_control_history_multi_index ) - -FC_REFLECT( eosio::account_control_history_object, (controlled_account)(controlled_permission)(controlling_account) ) - diff --git a/plugins/history_plugin/include/eosio/history_plugin/history_plugin.hpp b/plugins/history_plugin/include/eosio/history_plugin/history_plugin.hpp deleted file mode 100644 index 365d902f428..00000000000 --- a/plugins/history_plugin/include/eosio/history_plugin/history_plugin.hpp +++ /dev/null @@ -1,151 +0,0 @@ -#pragma once -#include - -#include - -namespace fc { class variant; } - -namespace eosio { - using chain::transaction_id_type; - using std::shared_ptr; - using namespace appbase; - using chain::name; - using chain::uint128_t; - - typedef shared_ptr history_ptr; - typedef shared_ptr history_const_ptr; - -namespace history_apis { - -class read_only { - history_const_ptr history; - - public: - read_only(history_const_ptr&& history) - : history(history) {} - - - struct get_actions_params { - chain::account_name account_name; - std::optional pos; /// a absolute sequence positon -1 is the end/last action - std::optional offset; ///< the number of actions relative to pos, negative numbers return [pos-offset,pos), positive numbers return [pos,pos+offset) - }; - - struct ordered_action_result { - uint64_t global_action_seq = 0; - int32_t account_action_seq = 0; - uint32_t block_num; - chain::block_timestamp_type block_time; - fc::variant action_trace; - }; - - struct get_actions_result { - vector actions; - uint32_t last_irreversible_block; - std::optional time_limit_exceeded_error; - }; - - - get_actions_result get_actions( const get_actions_params& )const; - - - struct get_transaction_params { - string id; - std::optional block_num_hint; - }; - - struct get_transaction_result { - transaction_id_type id; - fc::variant trx; - chain::block_timestamp_type block_time; - uint32_t block_num = 0; - uint32_t last_irreversible_block = 0; - vector traces; - }; - - get_transaction_result get_transaction( const get_transaction_params& )const; - - - - - /* - struct ordered_transaction_results { - uint32_t seq_num; - chain::transaction_id_type transaction_id; - fc::variant transaction; - }; - - get_transactions_results get_transactions(const get_transactions_params& params) const; - */ - - - struct get_key_accounts_params { - chain::public_key_type public_key; - }; - struct get_key_accounts_results { - vector account_names; - }; - get_key_accounts_results get_key_accounts(const get_key_accounts_params& params) const; - - - struct get_controlled_accounts_params { - chain::account_name controlling_account; - }; - struct get_controlled_accounts_results { - vector controlled_accounts; - }; - get_controlled_accounts_results get_controlled_accounts(const get_controlled_accounts_params& params) const; -}; - - -} // namespace history_apis - - -/** - * This plugin tracks all actions and keys associated with a set of configured accounts. It enables - * wallets to paginate queries for history. - * - * An action will be included in the account's history if any of the following: - * - receiver - * - any account named in auth list - * - * A key will be linked to an account if the key is referneced in authorities of updateauth or newaccount - */ -class history_plugin : public plugin { - public: - APPBASE_PLUGIN_REQUIRES((chain_plugin)) - - history_plugin(); - virtual ~history_plugin(); - - virtual void set_program_options(options_description& cli, options_description& cfg) override; - - void plugin_initialize(const variables_map& options); - void plugin_startup(); - void plugin_shutdown(); - - history_apis::read_only get_read_only_api()const { return history_apis::read_only(history_const_ptr(my)); } - - private: - history_ptr my; -}; - -} /// namespace eosio - -FC_REFLECT( eosio::history_apis::read_only::get_actions_params, (account_name)(pos)(offset) ) -FC_REFLECT( eosio::history_apis::read_only::get_actions_result, (actions)(last_irreversible_block)(time_limit_exceeded_error) ) -FC_REFLECT( eosio::history_apis::read_only::ordered_action_result, (global_action_seq)(account_action_seq)(block_num)(block_time)(action_trace) ) - -FC_REFLECT( eosio::history_apis::read_only::get_transaction_params, (id)(block_num_hint) ) -FC_REFLECT( eosio::history_apis::read_only::get_transaction_result, (id)(trx)(block_time)(block_num)(last_irreversible_block)(traces) ) -/* -FC_REFLECT(eosio::history_apis::read_only::get_transaction_params, (transaction_id) ) -FC_REFLECT(eosio::history_apis::read_only::get_transaction_results, (transaction_id)(transaction) ) -FC_REFLECT(eosio::history_apis::read_only::get_transactions_params, (account_name)(skip_seq)(num_seq) ) -FC_REFLECT(eosio::history_apis::read_only::ordered_transaction_results, (seq_num)(transaction_id)(transaction) ) -FC_REFLECT(eosio::history_apis::read_only::get_transactions_results, (transactions)(time_limit_exceeded_error) ) -*/ -FC_REFLECT(eosio::history_apis::read_only::get_key_accounts_params, (public_key) ) -FC_REFLECT(eosio::history_apis::read_only::get_key_accounts_results, (account_names) ) -FC_REFLECT(eosio::history_apis::read_only::get_controlled_accounts_params, (controlling_account) ) -FC_REFLECT(eosio::history_apis::read_only::get_controlled_accounts_results, (controlled_accounts) ) diff --git a/plugins/history_plugin/include/eosio/history_plugin/public_key_history_object.hpp b/plugins/history_plugin/include/eosio/history_plugin/public_key_history_object.hpp deleted file mode 100644 index 79b10e36d90..00000000000 --- a/plugins/history_plugin/include/eosio/history_plugin/public_key_history_object.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#include -#include - -namespace eosio { -using chain::account_name; -using chain::public_key_type; -using chain::permission_name; -using namespace boost::multi_index; - -class public_key_history_object : public chainbase::object { - OBJECT_CTOR(public_key_history_object) - - id_type id; - public_key_type public_key; - account_name name; - permission_name permission; -}; - -struct by_id; -struct by_pub_key; -struct by_account_permission_name; -using public_key_history_multi_index = chainbase::shared_multi_index_container< - public_key_history_object, - indexed_by< - ordered_unique, BOOST_MULTI_INDEX_MEMBER(public_key_history_object, public_key_history_object::id_type, id)>, - ordered_unique, - composite_key< public_key_history_object, - member, - member - > - >, - ordered_unique, - composite_key< public_key_history_object, - member, - member, - member - > - > - > ->; - -typedef chainbase::generic_index public_key_history_index; - -} - -CHAINBASE_SET_INDEX_TYPE( eosio::public_key_history_object, eosio::public_key_history_multi_index ) - -FC_REFLECT( eosio::public_key_history_object, (public_key)(name)(permission) ) - diff --git a/programs/nodeos/CMakeLists.txt b/programs/nodeos/CMakeLists.txt index e3b3dca54d9..a1cd5c2e58f 100644 --- a/programs/nodeos/CMakeLists.txt +++ b/programs/nodeos/CMakeLists.txt @@ -44,10 +44,8 @@ endif() target_link_libraries( ${NODE_EXECUTABLE_NAME} PRIVATE appbase version PRIVATE -Wl,${whole_archive_flag} login_plugin -Wl,${no_whole_archive_flag} - PRIVATE -Wl,${whole_archive_flag} history_plugin -Wl,${no_whole_archive_flag} PRIVATE -Wl,${whole_archive_flag} state_history_plugin -Wl,${no_whole_archive_flag} PRIVATE -Wl,${whole_archive_flag} trace_api_plugin -Wl,${no_whole_archive_flag} - PRIVATE -Wl,${whole_archive_flag} history_api_plugin -Wl,${no_whole_archive_flag} PRIVATE -Wl,${whole_archive_flag} chain_api_plugin -Wl,${no_whole_archive_flag} PRIVATE -Wl,${whole_archive_flag} net_plugin -Wl,${no_whole_archive_flag} PRIVATE -Wl,${whole_archive_flag} net_api_plugin -Wl,${no_whole_archive_flag} diff --git a/tests/Cluster.py b/tests/Cluster.py index 5e40e91ceee..244925c8780 100644 --- a/tests/Cluster.py +++ b/tests/Cluster.py @@ -314,7 +314,7 @@ def insertSpecificExtraNodeosArgs(node, insertStr): if self.staging: cmdArr.append("--nogen") - nodeosArgs="--max-transaction-time -1 --abi-serializer-max-time-ms 990000 --filter-on \"*\" --p2p-max-nodes-per-host %d" % (totalNodes) + nodeosArgs="--max-transaction-time -1 --abi-serializer-max-time-ms 990000 --p2p-max-nodes-per-host %d" % (totalNodes) if not self.walletd: nodeosArgs += " --plugin eosio::wallet_api_plugin" if Utils.Debug: diff --git a/tests/consensus-validation-malicious-producers.py b/tests/consensus-validation-malicious-producers.py index 16b98f84083..855497cf0fa 100755 --- a/tests/consensus-validation-malicious-producers.py +++ b/tests/consensus-validation-malicious-producers.py @@ -103,8 +103,8 @@ producer-name = initu plugin = eosio::producer_plugin plugin = eosio::chain_api_plugin -plugin = eosio::history_plugin -plugin = eosio::history_api_plugin""" +plugin = eosio::trace_api_plugin +trace-no-abis = true""" config01="""genesis-json = ./genesis.json @@ -123,8 +123,8 @@ producer-name = defproducerb plugin = eosio::producer_plugin plugin = eosio::chain_api_plugin -plugin = eosio::history_plugin -plugin = eosio::history_api_plugin""" +plugin = eosio::trace_api_plugin +trace-no-abis = true""" producers="""producer-name = defproducerd @@ -324,10 +324,9 @@ def myTest(transWillEnterBlock): Print("Get details for transaction %s" % (transId)) transaction=node2.getTransaction(transId, exitOnError=True) - signature=transaction["transaction"]["signatures"][0] + signature=transaction["signatures"][0] - blockNum=int(transaction["transaction"]["ref_block_num"]) - blockNum += 1 + blockNum=int(transaction["block_num"]) Print("Our transaction is in block %d" % (blockNum)) block=node2.getBlock(blockNum, exitOnError=True) diff --git a/tests/p2p_tests/dawn_515/test.sh b/tests/p2p_tests/dawn_515/test.sh index adcf78e9e4d..5c5640a2833 100755 --- a/tests/p2p_tests/dawn_515/test.sh +++ b/tests/p2p_tests/dawn_515/test.sh @@ -44,7 +44,8 @@ p2p-server-address = localhost:9876 plugin = eosio::producer_plugin plugin = eosio::chain_api_plugin plugin = eosio::net_plugin -plugin = eosio::history_api_plugin +plugin = eosio::trace_api_plugin +trace-no-abis = true http-server-address = 127.0.0.1:8888 blocks-dir = blocks p2p-listen-endpoint = 0.0.0.0:9876 diff --git a/tests/plugin_http_api_test.py b/tests/plugin_http_api_test.py index ff0b89ba952..1c80a671548 100755 --- a/tests/plugin_http_api_test.py +++ b/tests/plugin_http_api_test.py @@ -57,9 +57,9 @@ def startEnv(self) : "eosio::chain_api_plugin", "eosio::http_plugin", "eosio::db_size_api_plugin") - nodeos_flags = (" --data-dir=%s --trace-dir=%s --trace-no-abis --filter-on=%s --access-control-allow-origin=%s " + nodeos_flags = (" --data-dir=%s --trace-dir=%s --trace-no-abis --access-control-allow-origin=%s " "--contracts-console --http-validate-host=%s --verbose-http-errors " - "--p2p-peer-address localhost:9011 ") % (self.data_dir, self.data_dir, "\"*\"", "\'*\'", "false") + "--p2p-peer-address localhost:9011 ") % (self.data_dir, self.data_dir, "\'*\'", "false") start_nodeos_cmd = ("%s -e -p eosio %s %s ") % (Utils.EosServerPath, nodeos_plugins, nodeos_flags) self.nodeos.launchCmd(start_nodeos_cmd, self.node_id) time.sleep(self.sleep_s) diff --git a/tests/resource_monitor_plugin_test.py b/tests/resource_monitor_plugin_test.py index cc138b68d12..db2835a1a04 100755 --- a/tests/resource_monitor_plugin_test.py +++ b/tests/resource_monitor_plugin_test.py @@ -78,7 +78,7 @@ def prepareDirectories(): def runNodeos(extraNodeosArgs, myTimeout): """Startup nodeos, wait for timeout (before forced shutdown) and collect output.""" if debug: Print("Launching nodeos process.") - cmd="programs/nodeos/nodeos --config-dir rsmStaging/etc -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --data-dir " + dataDir + " " + cmd="programs/nodeos/nodeos --config-dir rsmStaging/etc -e -p eosio --plugin eosio::chain_api_plugin --data-dir " + dataDir + " " cmd=cmd + extraNodeosArgs; if debug: Print("cmd: %s" % (cmd)) diff --git a/tutorials/bios-boot-tutorial/bios-boot-tutorial.py b/tutorials/bios-boot-tutorial/bios-boot-tutorial.py index 1daf37c4ba4..60924f2af35 100755 --- a/tutorials/bios-boot-tutorial/bios-boot-tutorial.py +++ b/tutorials/bios-boot-tutorial/bios-boot-tutorial.py @@ -97,8 +97,7 @@ def startNode(nodeIndex, account): run('mkdir -p ' + dir) otherOpts = ''.join(list(map(lambda i: ' --p2p-peer-address localhost:' + str(9000 + i), range(nodeIndex)))) if not nodeIndex: otherOpts += ( - ' --plugin eosio::history_plugin' - ' --plugin eosio::history_api_plugin' + ' --plugin eosio::trace_api_plugin --trace-no-abis ' ) cmd = ( args.nodeos +