diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 67f51fc8bf..ba37c30284 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -88,8 +88,8 @@ add_library( eosio_chain transaction.cpp block.cpp block_header.cpp - block_header_state.cpp - block_state.cpp + block_header_state_legacy.cpp + block_state_legacy.cpp fork_database.cpp controller.cpp authorization_manager.cpp diff --git a/libraries/chain/block_header_state.cpp b/libraries/chain/block_header_state_legacy.cpp similarity index 94% rename from libraries/chain/block_header_state.cpp rename to libraries/chain/block_header_state_legacy.cpp index b7cd3036ac..7283c23ebf 100644 --- a/libraries/chain/block_header_state.cpp +++ b/libraries/chain/block_header_state_legacy.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -15,13 +15,13 @@ namespace eosio { namespace chain { } } - producer_authority block_header_state::get_scheduled_producer( block_timestamp_type t )const { + producer_authority block_header_state_legacy::get_scheduled_producer( block_timestamp_type t )const { auto index = t.slot % (active_schedule.producers.size() * config::producer_repetitions); index /= config::producer_repetitions; return active_schedule.producers[index]; } - uint32_t block_header_state::calc_dpos_last_irreversible( account_name producer_of_next_block )const { + uint32_t block_header_state_legacy::calc_dpos_last_irreversible( account_name producer_of_next_block )const { vector blocknums; blocknums.reserve( producer_to_last_implied_irb.size() ); for( auto& i : producer_to_last_implied_irb ) { blocknums.push_back( (i.first == producer_of_next_block) ? dpos_proposed_irreversible_blocknum : i.second); @@ -35,8 +35,8 @@ namespace eosio { namespace chain { return blocknums[ index ]; } - pending_block_header_state block_header_state::next( block_timestamp_type when, - uint16_t num_prev_blocks_to_confirm )const + pending_block_header_state block_header_state_legacy::next( block_timestamp_type when, + uint16_t num_prev_blocks_to_confirm )const { pending_block_header_state result; @@ -221,7 +221,7 @@ namespace eosio { namespace chain { return h; } - block_header_state pending_block_header_state::_finish_next( + block_header_state_legacy pending_block_header_state::_finish_next( const signed_block_header& h, const protocol_feature_set& pfs, const std::function(this) ) ); + block_header_state_legacy result( std::move( *static_cast(this) ) ); result.id = h.calculate_id(); result.header = h; @@ -317,7 +317,7 @@ namespace eosio { namespace chain { return result; } - block_header_state pending_block_header_state::finish_next( + block_header_state_legacy pending_block_header_state::finish_next( const signed_block_header& h, vector&& additional_signatures, const protocol_feature_set& pfs, @@ -347,7 +347,7 @@ namespace eosio { namespace chain { return result; } - block_header_state pending_block_header_state::finish_next( + block_header_state_legacy pending_block_header_state::finish_next( signed_block_header& h, const protocol_feature_set& pfs, const std::function&& _additional_signatures, const protocol_feature_set& pfs, @@ -390,12 +390,12 @@ namespace eosio { namespace chain { return next( h.timestamp, h.confirmed ).finish_next( h, std::move(_additional_signatures), pfs, validator, skip_validate_signee ); } - digest_type block_header_state::sig_digest()const { + digest_type block_header_state_legacy::sig_digest()const { auto header_bmroot = digest_type::hash( std::make_pair( header.digest(), blockroot_merkle.get_root() ) ); return digest_type::hash( std::make_pair(header_bmroot, pending_schedule.schedule_hash) ); } - void block_header_state::sign( const signer_callback_type& signer ) { + void block_header_state_legacy::sign( const signer_callback_type& signer ) { auto d = sig_digest(); auto sigs = signer( d ); @@ -408,7 +408,7 @@ namespace eosio { namespace chain { verify_signee(); } - void block_header_state::verify_signee( )const { + void block_header_state_legacy::verify_signee( )const { auto num_keys_in_authority = std::visit([](const auto &a){ return a.keys.size(); }, valid_block_signing_authority); EOS_ASSERT(1 + additional_signatures.size() <= num_keys_in_authority, wrong_signing_key, @@ -444,7 +444,7 @@ namespace eosio { namespace chain { /** * Reference cannot outlive *this. Assumes header_exts is not mutated after instatiation. */ - const vector& block_header_state::get_new_protocol_feature_activations()const { + const vector& block_header_state_legacy::get_new_protocol_feature_activations()const { static const vector no_activations{}; if( header_exts.count(protocol_feature_activation::extension_id()) == 0 ) @@ -453,7 +453,7 @@ namespace eosio { namespace chain { return std::get(header_exts.lower_bound(protocol_feature_activation::extension_id())->second).protocol_features; } - block_header_state::block_header_state( legacy::snapshot_block_header_state_v2&& snapshot ) + block_header_state_legacy::block_header_state_legacy( legacy::snapshot_block_header_state_v2&& snapshot ) { block_num = snapshot.block_num; dpos_proposed_irreversible_blocknum = snapshot.dpos_proposed_irreversible_blocknum; diff --git a/libraries/chain/block_state.cpp b/libraries/chain/block_state_legacy.cpp similarity index 68% rename from libraries/chain/block_state.cpp rename to libraries/chain/block_state_legacy.cpp index fd614a6118..ed59a7ce82 100644 --- a/libraries/chain/block_state.cpp +++ b/libraries/chain/block_state_legacy.cpp @@ -1,4 +1,4 @@ -#include +#include #include namespace eosio { namespace chain { @@ -47,13 +47,13 @@ namespace eosio { namespace chain { */ template - block_header_state inject_additional_signatures( pending_block_header_state&& cur, - signed_block& b, - const protocol_feature_set& pfs, - Extras&& ... extras ) + block_header_state_legacy inject_additional_signatures( pending_block_header_state&& cur, + signed_block& b, + const protocol_feature_set& pfs, + Extras&& ... extras ) { auto pfa = cur.prev_activated_protocol_features; - block_header_state result = std::move(cur).finish_next(b, pfs, std::forward(extras)...); + block_header_state_legacy result = std::move(cur).finish_next(b, pfs, std::forward(extras)...); if (!result.additional_signatures.empty()) { bool wtmsig_enabled = detail::is_builtin_activated(pfa, pfs, builtin_protocol_feature_t::wtmsig_block_signatures); @@ -74,28 +74,28 @@ namespace eosio { namespace chain { } - block_state::block_state( const block_header_state& prev, - signed_block_ptr b, - const protocol_feature_set& pfs, - const std::function&, const vector& )>& validator, bool skip_validate_signee ) - :block_header_state( prev.next( *b, extract_additional_signatures(b, pfs, prev.activated_protocol_features), pfs, validator, skip_validate_signee ) ) + :block_header_state_legacy( prev.next( *b, extract_additional_signatures(b, pfs, prev.activated_protocol_features), pfs, validator, skip_validate_signee ) ) ,block( std::move(b) ) {} - block_state::block_state( pending_block_header_state&& cur, - signed_block_ptr&& b, - deque&& trx_metas, - const protocol_feature_set& pfs, - const std::function&, - const vector& )>& validator, - const signer_callback_type& signer + block_state_legacy::block_state_legacy( pending_block_header_state&& cur, + signed_block_ptr&& b, + deque&& trx_metas, + const protocol_feature_set& pfs, + const std::function&, + const vector& )>& validator, + const signer_callback_type& signer ) - :block_header_state( inject_additional_signatures( std::move(cur), *b, pfs, validator, signer ) ) + :block_header_state_legacy( inject_additional_signatures( std::move(cur), *b, pfs, validator, signer ) ) ,block( std::move(b) ) ,_pub_keys_recovered( true ) // called by produce_block so signature recovery of trxs must have been done ,_cached_trxs( std::move(trx_metas) ) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 997e283896..37ff01f84b 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -113,7 +113,7 @@ class maybe_session { }; struct building_block { - building_block( const block_header_state& prev, + building_block( const block_header_state_legacy& prev, block_timestamp_type when, uint16_t num_prev_blocks_to_confirm, const vector& new_protocol_feature_activations ) @@ -143,13 +143,13 @@ struct assembled_block { }; struct completed_block { - block_state_ptr _block_state; + block_state_legacy_ptr _block_state; }; using block_stage_type = std::variant; struct pending_state { - pending_state( maybe_session&& s, const block_header_state& prev, + pending_state( maybe_session&& s, const block_header_state_legacy& prev, block_timestamp_type when, uint16_t num_prev_blocks_to_confirm, const vector& new_protocol_feature_activations ) @@ -232,7 +232,7 @@ struct controller_impl { chainbase::database db; block_log blog; std::optional pending; - block_state_ptr head; + block_state_legacy_ptr head; fork_database fork_db; resource_limits_manager resource_limits; subjective_billing subjective_bill; @@ -342,7 +342,7 @@ struct controller_impl { set_activation_handler(); set_activation_handler(); - self.irreversible_block.connect([this](const block_state_ptr& bsp) { + self.irreversible_block.connect([this](const block_state_legacy_ptr& bsp) { wasmif.current_lib(bsp->block_num); }); @@ -484,7 +484,7 @@ struct controller_impl { producer_authority_schedule initial_schedule = { 0, { producer_authority{config::system_account_name, block_signing_authority_v0{ 1, {{genesis.initial_key, 1}} } } } }; legacy::producer_schedule_type initial_legacy_schedule{ 0, {{config::system_account_name, genesis.initial_key}} }; - block_header_state genheader; + block_header_state_legacy genheader; genheader.active_schedule = initial_schedule; genheader.pending_schedule.schedule = initial_schedule; // NOTE: if wtmsig block signatures are enabled at genesis time this should be the hash of a producer authority schedule @@ -494,8 +494,8 @@ struct controller_impl { genheader.id = genheader.header.calculate_id(); genheader.block_num = genheader.header.block_num(); - head = std::make_shared(); - static_cast(*head) = genheader; + head = std::make_shared(); + static_cast(*head) = genheader; head->activated_protocol_features = std::make_shared(); head->block = std::make_shared(genheader.header); db.set_revision( head->block_num ); @@ -851,8 +851,8 @@ struct controller_impl { section.add_row(chain_snapshot_header(), db); }); - snapshot->write_section([this]( auto §ion ){ - section.template add_row(*head, db); + snapshot->write_section("eosio::chain::block_state", [this]( auto §ion ){ + section.template add_row(*head, db); }); controller_index_set::walk_indices([this, &snapshot]( auto utils ){ @@ -902,17 +902,17 @@ struct controller_impl { }); { /// load and upgrade the block header state - block_header_state head_header_state; + block_header_state_legacy head_header_state; using v2 = legacy::snapshot_block_header_state_v2; if (std::clamp(header.version, v2::minimum_version, v2::maximum_version) == header.version ) { - snapshot->read_section([this, &head_header_state]( auto §ion ) { + snapshot->read_section("eosio::chain::block_state", [this, &head_header_state]( auto §ion ) { legacy::snapshot_block_header_state_v2 legacy_header_state; section.read_row(legacy_header_state, db); - head_header_state = block_header_state(std::move(legacy_header_state)); + head_header_state = block_header_state_legacy(std::move(legacy_header_state)); }); } else { - snapshot->read_section([this,&head_header_state]( auto §ion ){ + snapshot->read_section("eosio::chain::block_state", [this,&head_header_state]( auto §ion ){ section.read_row(head_header_state, db); }); } @@ -926,8 +926,8 @@ struct controller_impl { ("block_log_last_num", blog_end) ); - head = std::make_shared(); - static_cast(*head) = head_header_state; + head = std::make_shared(); + static_cast(*head) = head_header_state; } controller_index_set::walk_indices([this, &snapshot, &header]( auto utils ){ @@ -2060,7 +2060,7 @@ struct controller_impl { } - void apply_block( controller::block_report& br, const block_state_ptr& bsp, controller::block_status s, + void apply_block( controller::block_report& br, const block_state_legacy_ptr& bsp, controller::block_status s, const trx_meta_cache_lookup& trx_lookup ) { try { try { @@ -2184,13 +2184,13 @@ struct controller_impl { // thread safe, expected to be called from thread other than the main thread - block_state_ptr create_block_state_i( const block_id_type& id, const signed_block_ptr& b, const block_header_state& prev ) { + block_state_legacy_ptr create_block_state_i( const block_id_type& id, const signed_block_ptr& b, const block_header_state_legacy& prev ) { auto trx_mroot = calculate_trx_merkle( b->transactions ); EOS_ASSERT( b->transaction_mroot == trx_mroot, block_validate_exception, "invalid block transaction merkle root ${b} != ${c}", ("b", b->transaction_mroot)("c", trx_mroot) ); const bool skip_validate_signee = false; - auto bsp = std::make_shared( + auto bsp = std::make_shared( prev, b, protocol_features.get_protocol_feature_set(), @@ -2206,7 +2206,7 @@ struct controller_impl { return bsp; } - std::future create_block_state_future( const block_id_type& id, const signed_block_ptr& b ) { + std::future create_block_state_future( const block_id_type& id, const signed_block_ptr& b ) { EOS_ASSERT( b, block_validate_exception, "null block" ); return post_async_task( thread_pool.get_executor(), [b, id, control=this]() { @@ -2223,7 +2223,7 @@ struct controller_impl { } // thread safe, expected to be called from thread other than the main thread - block_state_ptr create_block_state( const block_id_type& id, const signed_block_ptr& b ) { + block_state_legacy_ptr create_block_state( const block_id_type& id, const signed_block_ptr& b ) { EOS_ASSERT( b, block_validate_exception, "null block" ); // no reason for a block_state if fork_db already knows about block @@ -2238,7 +2238,7 @@ struct controller_impl { } void push_block( controller::block_report& br, - const block_state_ptr& bsp, + const block_state_legacy_ptr& bsp, const forked_branch_callback& forked_branch_cb, const trx_meta_cache_lookup& trx_lookup ) { @@ -2296,7 +2296,7 @@ struct controller_impl { emit( self.pre_accepted_block, b ); const bool skip_validate_signee = !conf.force_all_checks; - auto bsp = std::make_shared( + auto bsp = std::make_shared( *head, b, protocol_features.get_protocol_feature_set(), @@ -2334,7 +2334,7 @@ struct controller_impl { } FC_LOG_AND_RETHROW( ) } - void maybe_switch_forks( controller::block_report& br, const block_state_ptr& new_head, controller::block_status s, + void maybe_switch_forks( controller::block_report& br, const block_state_legacy_ptr& new_head, controller::block_status s, const forked_branch_callback& forked_branch_cb, const trx_meta_cache_lookup& trx_lookup ) { bool head_changed = true; @@ -2713,7 +2713,7 @@ struct controller_impl { wasmif.code_block_num_last_used(code_hash, vm_type, vm_version, block_num); } - block_state_ptr fork_db_head() const; + block_state_legacy_ptr fork_db_head() const; }; /// controller_impl thread_local platform_timer controller_impl::timer; @@ -2941,14 +2941,14 @@ void controller::start_block( block_timestamp_type when, bs, std::optional(), deadline ); } -block_state_ptr controller::finalize_block( block_report& br, const signer_callback_type& signer_callback ) { +block_state_legacy_ptr controller::finalize_block( block_report& br, const signer_callback_type& signer_callback ) { validate_db_available_size(); my->finalize_block(); auto& ab = std::get(my->pending->_block_stage); - auto bsp = std::make_shared( + auto bsp = std::make_shared( std::move( ab._pending_block_header_state ), std::move( ab._unsigned_block ), std::move( ab._trx_metas ), @@ -2980,16 +2980,16 @@ boost::asio::io_context& controller::get_thread_pool() { return my->thread_pool.get_executor(); } -std::future controller::create_block_state_future( const block_id_type& id, const signed_block_ptr& b ) { +std::future controller::create_block_state_future( const block_id_type& id, const signed_block_ptr& b ) { return my->create_block_state_future( id, b ); } -block_state_ptr controller::create_block_state( const block_id_type& id, const signed_block_ptr& b ) const { +block_state_legacy_ptr controller::create_block_state( const block_id_type& id, const signed_block_ptr& b ) const { return my->create_block_state( id, b ); } void controller::push_block( controller::block_report& br, - const block_state_ptr& bsp, + const block_state_legacy_ptr& bsp, const forked_branch_callback& forked_branch_cb, const trx_meta_cache_lookup& trx_lookup ) { @@ -3077,11 +3077,11 @@ account_name controller::head_block_producer()const { const block_header& controller::head_block_header()const { return my->head->header; } -block_state_ptr controller::head_block_state()const { +block_state_legacy_ptr controller::head_block_state()const { return my->head; } -block_state_ptr controller_impl::fork_db_head() const { +block_state_legacy_ptr controller_impl::fork_db_head() const { if( read_mode == db_read_mode::IRREVERSIBLE ) { // When in IRREVERSIBLE mode fork_db blocks are marked valid when they become irreversible so that // fork_db.head() returns irreversible block @@ -3199,12 +3199,12 @@ std::optional controller::fetch_block_header_by_number( uin return my->blog.read_block_header_by_num(block_num); } FC_CAPTURE_AND_RETHROW( (block_num) ) } -block_state_ptr controller::fetch_block_state_by_id( block_id_type id )const { +block_state_legacy_ptr controller::fetch_block_state_by_id( block_id_type id )const { auto state = my->fork_db.get_block(id); return state; } -block_state_ptr controller::fetch_block_state_by_number( uint32_t block_num )const { try { +block_state_legacy_ptr controller::fetch_block_state_by_number( uint32_t block_num )const { try { return my->fork_db.search_on_branch( fork_db_head_block_id(), block_num ); } FC_CAPTURE_AND_RETHROW( (block_num) ) } diff --git a/libraries/chain/deep_mind.cpp b/libraries/chain/deep_mind.cpp index 0c677a3049..7d740235cd 100644 --- a/libraries/chain/deep_mind.cpp +++ b/libraries/chain/deep_mind.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -72,7 +72,7 @@ namespace eosio::chain { fc_dlog(_logger, "START_BLOCK ${block_num}", ("block_num", block_num)); } - void deep_mind_handler::on_accepted_block(const std::shared_ptr& bsp) + void deep_mind_handler::on_accepted_block(const std::shared_ptr& bsp) { auto packed_blk = fc::raw::pack(*bsp); diff --git a/libraries/chain/fork_database.cpp b/libraries/chain/fork_database.cpp index 9a7f863914..16d15a62c4 100644 --- a/libraries/chain/fork_database.cpp +++ b/libraries/chain/fork_database.cpp @@ -20,8 +20,8 @@ namespace eosio { namespace chain { const uint32_t fork_database::min_supported_version = 1; const uint32_t fork_database::max_supported_version = 1; - // work around block_state::is_valid being private - inline bool block_state_is_valid( const block_state& bs ) { + // work around block_state_legacy::is_valid being private + inline bool block_state_is_valid( const block_state_legacy& bs ) { return bs.is_valid(); } @@ -34,16 +34,16 @@ namespace eosio { namespace chain { struct by_lib_block_num; struct by_prev; typedef multi_index_container< - block_state_ptr, + block_state_legacy_ptr, indexed_by< - hashed_unique< tag, member, std::hash>, - ordered_non_unique< tag, const_mem_fun >, + hashed_unique< tag, member, std::hash>, + ordered_non_unique< tag, const_mem_fun >, ordered_unique< tag, - composite_key< block_state, - global_fun, - member, - member, - member + composite_key< block_state_legacy, + global_fun, + member, + member, + member >, composite_key_compare< std::greater, @@ -55,7 +55,7 @@ namespace eosio { namespace chain { > > fork_multi_index_type; - bool first_preferred( const block_header_state& lhs, const block_header_state& rhs ) { + bool first_preferred( const block_header_state_legacy& lhs, const block_header_state_legacy& rhs ) { return std::tie( lhs.dpos_irreversible_blocknum, lhs.block_num ) > std::tie( rhs.dpos_irreversible_blocknum, rhs.block_num ); } @@ -65,11 +65,11 @@ namespace eosio { namespace chain { :datadir(data_dir) {} - std::shared_mutex mtx; - fork_multi_index_type index; - block_state_ptr root; // Only uses the block_header_state portion - block_state_ptr head; - std::filesystem::path datadir; + std::shared_mutex mtx; + fork_multi_index_type index; + block_state_legacy_ptr root; // Only uses the block_header_state_legacy portion + block_state_legacy_ptr head; + std::filesystem::path datadir; void open_impl( const std::function&, @@ -77,19 +77,19 @@ namespace eosio { namespace chain { void close_impl(); - block_header_state_ptr get_block_header_impl( const block_id_type& id )const; - block_state_ptr get_block_impl( const block_id_type& id )const; - void reset_impl( const block_header_state& root_bhs ); + block_header_state_legacy_ptr get_block_header_impl( const block_id_type& id )const; + block_state_legacy_ptr get_block_impl( const block_id_type& id )const; + void reset_impl( const block_header_state_legacy& root_bhs ); void rollback_head_to_root_impl(); void advance_root_impl( const block_id_type& id ); void remove_impl( const block_id_type& id ); branch_type fetch_branch_impl( const block_id_type& h, uint32_t trim_after_block_num )const; - block_state_ptr search_on_branch_impl( const block_id_type& h, uint32_t block_num )const; + block_state_legacy_ptr search_on_branch_impl( const block_id_type& h, uint32_t block_num )const; pair fetch_branch_from_impl( const block_id_type& first, const block_id_type& second )const; - void mark_valid_impl( const block_state_ptr& h ); + void mark_valid_impl( const block_state_legacy_ptr& h ); - void add_impl( const block_state_ptr& n, + void add_impl( const block_state_legacy_ptr& n, bool ignore_duplicate, bool validate, const std::function&, @@ -148,17 +148,17 @@ namespace eosio { namespace chain { ("max", fork_database::max_supported_version) ); - block_header_state bhs; + block_header_state_legacy bhs; fc::raw::unpack( ds, bhs ); reset_impl( bhs ); unsigned_int size; fc::raw::unpack( ds, size ); for( uint32_t i = 0, n = size.value; i < n; ++i ) { - block_state s; + block_state_legacy s; fc::raw::unpack( ds, s ); // do not populate transaction_metadatas, they will be created as needed in apply_block with appropriate key recovery s.header_exts = s.block->validate_and_extract_header_extensions(); - add_impl( std::make_shared( std::move( s ) ), false, true, validator ); + add_impl( std::make_shared( std::move( s ) ), false, true, validator ); } block_id_type head_id; fc::raw::unpack( ds, head_id ); @@ -207,7 +207,7 @@ namespace eosio { namespace chain { std::ofstream out( fork_db_dat.generic_string().c_str(), std::ios::out | std::ios::binary | std::ofstream::trunc ); fc::raw::pack( out, fork_database::magic_number ); fc::raw::pack( out, fork_database::max_supported_version ); // write out current version which is always max_supported_version - fc::raw::pack( out, *static_cast(&*root) ); + fc::raw::pack( out, *static_cast(&*root) ); uint32_t num_blocks_in_fork_db = index.size(); fc::raw::pack( out, unsigned_int{num_blocks_in_fork_db} ); @@ -260,15 +260,15 @@ namespace eosio { namespace chain { my->close_impl(); } - void fork_database::reset( const block_header_state& root_bhs ) { + void fork_database::reset( const block_header_state_legacy& root_bhs ) { std::lock_guard g( my->mtx ); my->reset_impl(root_bhs); } - void fork_database_impl::reset_impl( const block_header_state& root_bhs ) { + void fork_database_impl::reset_impl( const block_header_state_legacy& root_bhs ) { index.clear(); - root = std::make_shared(); - static_cast(*root) = root_bhs; + root = std::make_shared(); + static_cast(*root) = root_bhs; root->validated = true; head = root; } @@ -282,7 +282,7 @@ namespace eosio { namespace chain { auto& by_id_idx = index.get(); auto itr = by_id_idx.begin(); while (itr != by_id_idx.end()) { - by_id_idx.modify( itr, [&]( block_state_ptr& bsp ) { + by_id_idx.modify( itr, [&]( block_state_legacy_ptr& bsp ) { bsp->validated = false; } ); ++itr; @@ -328,12 +328,12 @@ namespace eosio { namespace chain { root = new_root; } - block_header_state_ptr fork_database::get_block_header( const block_id_type& id )const { + block_header_state_legacy_ptr fork_database::get_block_header( const block_id_type& id )const { std::shared_lock g( my->mtx ); return my->get_block_header_impl( id ); } - block_header_state_ptr fork_database_impl::get_block_header_impl( const block_id_type& id )const { + block_header_state_legacy_ptr fork_database_impl::get_block_header_impl( const block_id_type& id )const { if( root->id == id ) { return root; } @@ -342,10 +342,10 @@ namespace eosio { namespace chain { if( itr != index.end() ) return *itr; - return block_header_state_ptr(); + return block_header_state_legacy_ptr(); } - void fork_database_impl::add_impl( const block_state_ptr& n, + void fork_database_impl::add_impl( const block_state_legacy_ptr& n, bool ignore_duplicate, bool validate, const std::function&, @@ -382,7 +382,7 @@ namespace eosio { namespace chain { } } - void fork_database::add( const block_state_ptr& n, bool ignore_duplicate ) { + void fork_database::add( const block_state_legacy_ptr& n, bool ignore_duplicate ) { std::lock_guard g( my->mtx ); my->add_impl( n, ignore_duplicate, false, []( block_timestamp_type timestamp, @@ -392,17 +392,17 @@ namespace eosio { namespace chain { ); } - block_state_ptr fork_database::root()const { + block_state_legacy_ptr fork_database::root()const { std::shared_lock g( my->mtx ); return my->root; } - block_state_ptr fork_database::head()const { + block_state_legacy_ptr fork_database::head()const { std::shared_lock g( my->mtx ); return my->head; } - block_state_ptr fork_database::pending_head()const { + block_state_legacy_ptr fork_database::pending_head()const { std::shared_lock g( my->mtx ); const auto& indx = my->index.get(); @@ -430,12 +430,12 @@ namespace eosio { namespace chain { return result; } - block_state_ptr fork_database::search_on_branch( const block_id_type& h, uint32_t block_num )const { + block_state_legacy_ptr fork_database::search_on_branch( const block_id_type& h, uint32_t block_num )const { std::shared_lock g( my->mtx ); return my->search_on_branch_impl( h, block_num ); } - block_state_ptr fork_database_impl::search_on_branch_impl( const block_id_type& h, uint32_t block_num )const { + block_state_legacy_ptr fork_database_impl::search_on_branch_impl( const block_id_type& h, uint32_t block_num )const { for( auto s = get_block_impl(h); s; s = get_block_impl( s->header.previous ) ) { if( s->block_num == block_num ) return s; @@ -540,12 +540,12 @@ namespace eosio { namespace chain { } } - void fork_database::mark_valid( const block_state_ptr& h ) { + void fork_database::mark_valid( const block_state_legacy_ptr& h ) { std::lock_guard g( my->mtx ); my->mark_valid_impl( h ); } - void fork_database_impl::mark_valid_impl( const block_state_ptr& h ) { + void fork_database_impl::mark_valid_impl( const block_state_legacy_ptr& h ) { if( h->validated ) return; auto& by_id_idx = index.get(); @@ -555,7 +555,7 @@ namespace eosio { namespace chain { "block state not in fork database; cannot mark as valid", ("id", h->id) ); - by_id_idx.modify( itr, []( block_state_ptr& bsp ) { + by_id_idx.modify( itr, []( block_state_legacy_ptr& bsp ) { bsp->validated = true; } ); @@ -565,16 +565,16 @@ namespace eosio { namespace chain { } } - block_state_ptr fork_database::get_block(const block_id_type& id)const { + block_state_legacy_ptr fork_database::get_block(const block_id_type& id)const { std::shared_lock g( my->mtx ); return my->get_block_impl(id); } - block_state_ptr fork_database_impl::get_block_impl(const block_id_type& id)const { + block_state_legacy_ptr fork_database_impl::get_block_impl(const block_id_type& id)const { auto itr = index.find( id ); if( itr != index.end() ) return *itr; - return block_state_ptr(); + return block_state_legacy_ptr(); } } } /// eosio::chain diff --git a/libraries/chain/include/eosio/chain/block_header_state.hpp b/libraries/chain/include/eosio/chain/block_header_state_legacy.hpp similarity index 73% rename from libraries/chain/include/eosio/chain/block_header_state.hpp rename to libraries/chain/include/eosio/chain/block_header_state_legacy.hpp index 5b4d64ce48..3644bd2d88 100644 --- a/libraries/chain/include/eosio/chain/block_header_state.hpp +++ b/libraries/chain/include/eosio/chain/block_header_state_legacy.hpp @@ -24,7 +24,7 @@ namespace legacy { producer_schedule_type schedule; }; - /// from block_header_state_common + /// from block_header_state_legacy_common uint32_t block_num = 0; uint32_t dpos_proposed_irreversible_blocknum = 0; uint32_t dpos_irreversible_blocknum = 0; @@ -35,7 +35,7 @@ namespace legacy { public_key_type block_signing_key; vector confirm_count; - // from block_header_state + // from block_header_state_legacy block_id_type id; signed_block_header header; schedule_info pending_schedule; @@ -45,10 +45,10 @@ namespace legacy { using signer_callback_type = std::function(const digest_type&)>; -struct block_header_state; +struct block_header_state_legacy; namespace detail { - struct block_header_state_common { + struct block_header_state_legacy_common { uint32_t block_num = 0; uint32_t dpos_proposed_irreversible_blocknum = 0; uint32_t dpos_irreversible_blocknum = 0; @@ -71,7 +71,7 @@ namespace detail { builtin_protocol_feature_t feature_codename ); } -struct pending_block_header_state : public detail::block_header_state_common { +struct pending_block_header_state : public detail::block_header_state_legacy_common { protocol_feature_activation_set_ptr prev_activated_protocol_features; detail::schedule_info prev_pending_schedule; bool was_pending_promoted = false; @@ -87,34 +87,34 @@ struct pending_block_header_state : public detail::block_header_state_common { vector&& new_protocol_feature_activations, const protocol_feature_set& pfs)const; - block_header_state finish_next( const signed_block_header& h, - vector&& additional_signatures, - const protocol_feature_set& pfs, - const std::function&, - const vector& )>& validator, - bool skip_validate_signee = false )&&; - - block_header_state finish_next( signed_block_header& h, - const protocol_feature_set& pfs, - const std::function&, - const vector& )>& validator, - const signer_callback_type& signer )&&; + block_header_state_legacy finish_next( const signed_block_header& h, + vector&& additional_signatures, + const protocol_feature_set& pfs, + const std::function&, + const vector& )>& validator, + bool skip_validate_signee = false )&&; + + block_header_state_legacy finish_next( signed_block_header& h, + const protocol_feature_set& pfs, + const std::function&, + const vector& )>& validator, + const signer_callback_type& signer )&&; protected: - block_header_state _finish_next( const signed_block_header& h, - const protocol_feature_set& pfs, - const std::function&, - const vector& )>& validator )&&; + block_header_state_legacy _finish_next( const signed_block_header& h, + const protocol_feature_set& pfs, + const std::function&, + const vector& )>& validator )&&; }; /** - * @struct block_header_state + * @struct block_header_state_legacy * @brief defines the minimum state necessary to validate transaction headers */ -struct block_header_state : public detail::block_header_state_common { +struct block_header_state_legacy : public detail::block_header_state_legacy_common { block_id_type id; signed_block_header header; detail::schedule_info pending_schedule; @@ -125,23 +125,23 @@ struct block_header_state : public detail::block_header_state_common { /// duplication of work flat_multimap header_exts; - block_header_state() = default; + block_header_state_legacy() = default; - explicit block_header_state( detail::block_header_state_common&& base ) - :detail::block_header_state_common( std::move(base) ) + explicit block_header_state_legacy( detail::block_header_state_legacy_common&& base ) + :detail::block_header_state_legacy_common( std::move(base) ) {} - explicit block_header_state( legacy::snapshot_block_header_state_v2&& snapshot ); + explicit block_header_state_legacy( legacy::snapshot_block_header_state_v2&& snapshot ); pending_block_header_state next( block_timestamp_type when, uint16_t num_prev_blocks_to_confirm )const; - block_header_state next( const signed_block_header& h, - vector&& additional_signatures, - const protocol_feature_set& pfs, - const std::function&, - const vector& )>& validator, - bool skip_validate_signee = false )const; + block_header_state_legacy next( const signed_block_header& h, + vector&& additional_signatures, + const protocol_feature_set& pfs, + const std::function&, + const vector& )>& validator, + bool skip_validate_signee = false )const; bool has_pending_producers()const { return pending_schedule.schedule.producers.size(); } uint32_t calc_dpos_last_irreversible( account_name producer_of_next_block )const; @@ -155,11 +155,11 @@ struct block_header_state : public detail::block_header_state_common { const vector& get_new_protocol_feature_activations()const; }; -using block_header_state_ptr = std::shared_ptr; +using block_header_state_legacy_ptr = std::shared_ptr; } } /// namespace eosio::chain -FC_REFLECT( eosio::chain::detail::block_header_state_common, +FC_REFLECT( eosio::chain::detail::block_header_state_legacy_common, (block_num) (dpos_proposed_irreversible_blocknum) (dpos_irreversible_blocknum) @@ -177,7 +177,7 @@ FC_REFLECT( eosio::chain::detail::schedule_info, (schedule) ) -FC_REFLECT_DERIVED( eosio::chain::block_header_state, (eosio::chain::detail::block_header_state_common), +FC_REFLECT_DERIVED( eosio::chain::block_header_state_legacy, (eosio::chain::detail::block_header_state_legacy_common), (id) (header) (pending_schedule) diff --git a/libraries/chain/include/eosio/chain/block_state.hpp b/libraries/chain/include/eosio/chain/block_state.hpp deleted file mode 100644 index 4772094739..0000000000 --- a/libraries/chain/include/eosio/chain/block_state.hpp +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace eosio { namespace chain { - - struct block_state : public block_header_state { - block_state( const block_header_state& prev, - signed_block_ptr b, - const protocol_feature_set& pfs, - const std::function&, - const vector& )>& validator, - bool skip_validate_signee - ); - - block_state( pending_block_header_state&& cur, - signed_block_ptr&& b, // unsigned block - deque&& trx_metas, - const protocol_feature_set& pfs, - const std::function&, - const vector& )>& validator, - const signer_callback_type& signer - ); - - block_state() = default; - - - signed_block_ptr block; - - private: // internal use only, not thread safe - friend struct fc::reflector; - friend bool block_state_is_valid( const block_state& ); // work-around for multi-index access - friend struct controller_impl; - friend class fork_database; - friend struct fork_database_impl; - friend class unapplied_transaction_queue; - friend struct pending_state; - - bool is_valid()const { return validated; } - bool is_pub_keys_recovered()const { return _pub_keys_recovered; } - - deque extract_trxs_metas() { - _pub_keys_recovered = false; - auto result = std::move( _cached_trxs ); - _cached_trxs.clear(); - return result; - } - void set_trxs_metas( deque&& trxs_metas, bool keys_recovered ) { - _pub_keys_recovered = keys_recovered; - _cached_trxs = std::move( trxs_metas ); - } - const deque& trxs_metas()const { return _cached_trxs; } - - bool validated = false; - - bool _pub_keys_recovered = false; - /// this data is redundant with the data stored in block, but facilitates - /// recapturing transactions when we pop a block - deque _cached_trxs; - }; - - using block_state_ptr = std::shared_ptr; - using branch_type = deque; - -} } /// namespace eosio::chain - -FC_REFLECT_DERIVED( eosio::chain::block_state, (eosio::chain::block_header_state), (block)(validated) ) diff --git a/libraries/chain/include/eosio/chain/block_state_legacy.hpp b/libraries/chain/include/eosio/chain/block_state_legacy.hpp new file mode 100644 index 0000000000..2c4791104d --- /dev/null +++ b/libraries/chain/include/eosio/chain/block_state_legacy.hpp @@ -0,0 +1,72 @@ +#pragma once + +#include +#include +#include +#include + +namespace eosio { namespace chain { + + struct block_state_legacy : public block_header_state_legacy { + block_state_legacy( const block_header_state_legacy& prev, + signed_block_ptr b, + const protocol_feature_set& pfs, + const std::function&, + const vector& )>& validator, + bool skip_validate_signee + ); + + block_state_legacy( pending_block_header_state&& cur, + signed_block_ptr&& b, // unsigned block + deque&& trx_metas, + const protocol_feature_set& pfs, + const std::function&, + const vector& )>& validator, + const signer_callback_type& signer + ); + + block_state_legacy() = default; + + + signed_block_ptr block; + + private: // internal use only, not thread safe + friend struct fc::reflector; + friend bool block_state_is_valid( const block_state_legacy& ); // work-around for multi-index access + friend struct controller_impl; + friend class fork_database; + friend struct fork_database_impl; + friend class unapplied_transaction_queue; + friend struct pending_state; + + bool is_valid()const { return validated; } + bool is_pub_keys_recovered()const { return _pub_keys_recovered; } + + deque extract_trxs_metas() { + _pub_keys_recovered = false; + auto result = std::move( _cached_trxs ); + _cached_trxs.clear(); + return result; + } + void set_trxs_metas( deque&& trxs_metas, bool keys_recovered ) { + _pub_keys_recovered = keys_recovered; + _cached_trxs = std::move( trxs_metas ); + } + const deque& trxs_metas()const { return _cached_trxs; } + + bool validated = false; + + bool _pub_keys_recovered = false; + /// this data is redundant with the data stored in block, but facilitates + /// recapturing transactions when we pop a block + deque _cached_trxs; + }; + + using block_state_legacy_ptr = std::shared_ptr; + using branch_type = deque; + +} } /// namespace eosio::chain + +FC_REFLECT_DERIVED( eosio::chain::block_state_legacy, (eosio::chain::block_header_state_legacy), (block)(validated) ) diff --git a/libraries/chain/include/eosio/chain/controller.hpp b/libraries/chain/include/eosio/chain/controller.hpp index e25a201050..ca24e4da35 100644 --- a/libraries/chain/include/eosio/chain/controller.hpp +++ b/libraries/chain/include/eosio/chain/controller.hpp @@ -1,5 +1,5 @@ #pragma once -#include +#include #include #include #include @@ -161,14 +161,14 @@ namespace eosio { namespace chain { fc::microseconds total_time{}; }; - block_state_ptr finalize_block( block_report& br, const signer_callback_type& signer_callback ); + block_state_legacy_ptr finalize_block( block_report& br, const signer_callback_type& signer_callback ); void sign_block( const signer_callback_type& signer_callback ); void commit_block(); // thread-safe - std::future create_block_state_future( const block_id_type& id, const signed_block_ptr& b ); + std::future create_block_state_future( const block_id_type& id, const signed_block_ptr& b ); // thread-safe - block_state_ptr create_block_state( const block_id_type& id, const signed_block_ptr& b ) const; + block_state_legacy_ptr create_block_state( const block_id_type& id, const signed_block_ptr& b ) const; /** * @param br returns statistics for block @@ -177,7 +177,7 @@ namespace eosio { namespace chain { * @param trx_lookup user provided lookup function for externally cached transaction_metadata */ void push_block( block_report& br, - const block_state_ptr& bsp, + const block_state_legacy_ptr& bsp, const forked_branch_callback& cb, const trx_meta_cache_lookup& trx_lookup ); @@ -219,7 +219,7 @@ namespace eosio { namespace chain { block_id_type head_block_id()const; account_name head_block_producer()const; const block_header& head_block_header()const; - block_state_ptr head_block_state()const; + block_state_legacy_ptr head_block_state()const; uint32_t fork_db_head_block_num()const; block_id_type fork_db_head_block_id()const; @@ -247,10 +247,10 @@ namespace eosio { namespace chain { std::optional fetch_block_header_by_number( uint32_t block_num )const; // thread-safe std::optional fetch_block_header_by_id( const block_id_type& id )const; - // return block_state from forkdb, thread-safe - block_state_ptr fetch_block_state_by_number( uint32_t block_num )const; - // return block_state from forkdb, thread-safe - block_state_ptr fetch_block_state_by_id( block_id_type id )const; + // return block_state_legacy from forkdb, thread-safe + block_state_legacy_ptr fetch_block_state_by_number( uint32_t block_num )const; + // return block_state_legacy from forkdb, thread-safe + block_state_legacy_ptr fetch_block_state_by_id( block_id_type id )const; // thread-safe block_id_type get_block_id_for_num( uint32_t block_num )const; @@ -328,9 +328,9 @@ namespace eosio { namespace chain { signal block_start; // block_num signal pre_accepted_block; - signal accepted_block_header; - signal accepted_block; - signal irreversible_block; + signal accepted_block_header; + signal accepted_block; + signal irreversible_block; signal accepted_transaction; signal)> applied_transaction; signal bad_alloc; diff --git a/libraries/chain/include/eosio/chain/deep_mind.hpp b/libraries/chain/include/eosio/chain/deep_mind.hpp index 6ea659e5e3..ba630440a4 100644 --- a/libraries/chain/include/eosio/chain/deep_mind.hpp +++ b/libraries/chain/include/eosio/chain/deep_mind.hpp @@ -11,7 +11,7 @@ class generated_transaction_object; class table_id_object; struct key_value_object; class permission_object; -struct block_state; +struct block_state_legacy; struct protocol_feature; struct signed_transaction; struct packed_transaction; @@ -56,7 +56,7 @@ class deep_mind_handler void on_startup(chainbase::database& db, uint32_t head_block_num); void on_start_block(uint32_t block_num); - void on_accepted_block(const std::shared_ptr& bsp); + void on_accepted_block(const std::shared_ptr& bsp); void on_switch_forks(const block_id_type& old_head, const block_id_type& new_head); void on_onerror(const signed_transaction& etrx); void on_onblock(const signed_transaction& trx); diff --git a/libraries/chain/include/eosio/chain/fork_database.hpp b/libraries/chain/include/eosio/chain/fork_database.hpp index 56cf963fa2..2367631096 100644 --- a/libraries/chain/include/eosio/chain/fork_database.hpp +++ b/libraries/chain/include/eosio/chain/fork_database.hpp @@ -1,5 +1,5 @@ #pragma once -#include +#include #include namespace eosio { namespace chain { @@ -30,14 +30,14 @@ namespace eosio { namespace chain { const vector& )>& validator ); void close(); - block_header_state_ptr get_block_header( const block_id_type& id )const; - block_state_ptr get_block( const block_id_type& id )const; + block_header_state_legacy_ptr get_block_header( const block_id_type& id )const; + block_state_legacy_ptr get_block( const block_id_type& id )const; /** * Purges any existing blocks from the fork database and resets the root block_header_state to the provided value. * The head will also be reset to point to the root. */ - void reset( const block_header_state& root_bhs ); + void reset( const block_header_state_legacy& root_bhs ); /** * Removes validated flag from all blocks in fork database and resets head to point to the root. @@ -53,13 +53,13 @@ namespace eosio { namespace chain { * Add block state to fork database. * Must link to existing block in fork database or the root. */ - void add( const block_state_ptr& next_block, bool ignore_duplicate = false ); + void add( const block_state_legacy_ptr& next_block, bool ignore_duplicate = false ); void remove( const block_id_type& id ); - block_state_ptr root()const; - block_state_ptr head()const; - block_state_ptr pending_head()const; + block_state_legacy_ptr root()const; + block_state_legacy_ptr head()const; + block_state_legacy_ptr pending_head()const; /** * Returns the sequence of block states resulting from trimming the branch from the @@ -76,7 +76,7 @@ namespace eosio { namespace chain { * Returns the block state with a block number of `block_num` that is on the branch that * contains a block with an id of`h`, or the empty shared pointer if no such block can be found. */ - block_state_ptr search_on_branch( const block_id_type& h, uint32_t block_num )const; + block_state_legacy_ptr search_on_branch( const block_id_type& h, uint32_t block_num )const; /** * Given two head blocks, return two branches of the fork graph that @@ -86,7 +86,7 @@ namespace eosio { namespace chain { const block_id_type& second )const; - void mark_valid( const block_state_ptr& h ); + void mark_valid( const block_state_legacy_ptr& h ); static const uint32_t magic_number; diff --git a/libraries/chain/include/eosio/chain/snapshot_scheduler.hpp b/libraries/chain/include/eosio/chain/snapshot_scheduler.hpp index fd9475d438..cc32489a66 100644 --- a/libraries/chain/include/eosio/chain/snapshot_scheduler.hpp +++ b/libraries/chain/include/eosio/chain/snapshot_scheduler.hpp @@ -2,7 +2,7 @@ #include -#include +#include #include #include #include diff --git a/libraries/chain/include/eosio/chain/subjective_billing.hpp b/libraries/chain/include/eosio/chain/subjective_billing.hpp index d83ae3677b..839e9edba9 100644 --- a/libraries/chain/include/eosio/chain/subjective_billing.hpp +++ b/libraries/chain/include/eosio/chain/subjective_billing.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include @@ -81,7 +81,7 @@ class subjective_billing { } } - void remove_subjective_billing( const chain::block_state_ptr& bsp, uint32_t time_ordinal ) { + void remove_subjective_billing( const chain::block_state_legacy_ptr& bsp, uint32_t time_ordinal ) { if( !_trx_cache_index.empty() ) { for( const auto& receipt : bsp->block->transactions ) { if( std::holds_alternative(receipt.trx) ) { @@ -151,7 +151,7 @@ class subjective_billing { } } - void on_block( fc::logger& log, const chain::block_state_ptr& bsp, const fc::time_point& now ) { + void on_block( fc::logger& log, const chain::block_state_legacy_ptr& bsp, const fc::time_point& now ) { if( bsp == nullptr || _disabled ) return; const auto time_ordinal = time_ordinal_for(now); const auto orig_count = _account_subjective_bill_cache.size(); diff --git a/libraries/chain/include/eosio/chain/unapplied_transaction_queue.hpp b/libraries/chain/include/eosio/chain/unapplied_transaction_queue.hpp index 946ad65a8e..a413652297 100644 --- a/libraries/chain/include/eosio/chain/unapplied_transaction_queue.hpp +++ b/libraries/chain/include/eosio/chain/unapplied_transaction_queue.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -114,7 +114,7 @@ class unapplied_transaction_queue { return true; } - void clear_applied( const block_state_ptr& bs ) { + void clear_applied( const block_state_legacy_ptr& bs ) { if( empty() ) return; auto& idx = queue.get(); for( const auto& receipt : bs->block->transactions ) { @@ -136,7 +136,7 @@ class unapplied_transaction_queue { void add_forked( const branch_type& forked_branch ) { // forked_branch is in reverse order for( auto ritr = forked_branch.rbegin(), rend = forked_branch.rend(); ritr != rend; ++ritr ) { - const block_state_ptr& bsptr = *ritr; + const block_state_legacy_ptr& bsptr = *ritr; for( auto itr = bsptr->trxs_metas().begin(), end = bsptr->trxs_metas().end(); itr != end; ++itr ) { const auto& trx = *itr; auto insert_itr = queue.insert( { trx, trx_enum_type::forked } ); diff --git a/libraries/state_history/include/eosio/state_history/trace_converter.hpp b/libraries/state_history/include/eosio/state_history/trace_converter.hpp index b25aefedf9..24bfa5872b 100644 --- a/libraries/state_history/include/eosio/state_history/trace_converter.hpp +++ b/libraries/state_history/include/eosio/state_history/trace_converter.hpp @@ -1,13 +1,13 @@ #pragma once -#include +#include #include #include namespace eosio { namespace state_history { -using chain::block_state_ptr; +using chain::block_state_legacy_ptr; using chain::transaction_id_type; struct trace_converter { @@ -15,7 +15,7 @@ struct trace_converter { std::optional onblock_trace; void add_transaction(const transaction_trace_ptr& trace, const chain::packed_transaction_ptr& transaction); - void pack(boost::iostreams::filtering_ostreambuf& ds, bool trace_debug_mode, const block_state_ptr& block_state); + void pack(boost::iostreams::filtering_ostreambuf& ds, bool trace_debug_mode, const block_state_legacy_ptr& block_state_legacy); }; } // namespace state_history diff --git a/libraries/state_history/trace_converter.cpp b/libraries/state_history/trace_converter.cpp index 48a8733895..7d86e5cd8a 100644 --- a/libraries/state_history/trace_converter.cpp +++ b/libraries/state_history/trace_converter.cpp @@ -15,7 +15,7 @@ void trace_converter::add_transaction(const transaction_trace_ptr& trace, const } } -void trace_converter::pack(boost::iostreams::filtering_ostreambuf& obuf, bool trace_debug_mode, const block_state_ptr& block_state) { +void trace_converter::pack(boost::iostreams::filtering_ostreambuf& obuf, bool trace_debug_mode, const block_state_legacy_ptr& block_state) { std::vector traces; if (onblock_trace) traces.push_back(*onblock_trace); diff --git a/libraries/testing/tester.cpp b/libraries/testing/tester.cpp index 8a9b7a0ad6..10140d16a8 100644 --- a/libraries/testing/tester.cpp +++ b/libraries/testing/tester.cpp @@ -321,7 +321,7 @@ namespace eosio { namespace testing { control->add_indices(); if (lambda) lambda(); chain_transactions.clear(); - control->accepted_block.connect([this]( const block_state_ptr& block_state ){ + control->accepted_block.connect([this]( const block_state_legacy_ptr& block_state ){ FC_ASSERT( block_state->block ); for( auto receipt : block_state->block->transactions ) { if( std::holds_alternative(receipt.trx) ) { diff --git a/plugins/chain_interface/include/eosio/chain/plugin_interface.hpp b/plugins/chain_interface/include/eosio/chain/plugin_interface.hpp index 845314a558..23205bc96a 100644 --- a/plugins/chain_interface/include/eosio/chain/plugin_interface.hpp +++ b/plugins/chain_interface/include/eosio/chain/plugin_interface.hpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include @@ -16,9 +16,9 @@ namespace eosio::chain::plugin_interface { namespace channels { using pre_accepted_block = channel_decl; using rejected_block = channel_decl; - using accepted_block_header = channel_decl; - using accepted_block = channel_decl; - using irreversible_block = channel_decl; + using accepted_block_header = channel_decl; + using accepted_block = channel_decl; + using irreversible_block = channel_decl; using accepted_transaction = channel_decl; using applied_transaction = channel_decl; } @@ -34,8 +34,8 @@ namespace eosio::chain::plugin_interface { namespace incoming { namespace methods { - // synchronously push a block/trx to a single provider, block_state_ptr may be null - using block_sync = method_decl&, const block_state_ptr&), first_provider_policy>; + // synchronously push a block/trx to a single provider, block_state_legacy_ptr may be null + using block_sync = method_decl&, const block_state_legacy_ptr&), first_provider_policy>; using transaction_async = method_decl), first_provider_policy>; } } diff --git a/plugins/chain_plugin/account_query_db.cpp b/plugins/chain_plugin/account_query_db.cpp index 19c6d2c1ac..1d6a4ebaa2 100644 --- a/plugins/chain_plugin/account_query_db.cpp +++ b/plugins/chain_plugin/account_query_db.cpp @@ -194,7 +194,7 @@ namespace eosio::chain_apis { key_bimap.right.erase(key_range.first, key_range.second); } - bool is_rollback_required( const chain::block_state_ptr& bsp ) const { + bool is_rollback_required( const chain::block_state_legacy_ptr& bsp ) const { std::shared_lock read_lock(rw_mutex); const auto bnum = bsp->block->block_num(); const auto& index = permission_info_index.get(); @@ -233,7 +233,7 @@ namespace eosio::chain_apis { * at the HEAD state of the chain. * @param bsp - the block to rollback before */ - void rollback_to_before( const chain::block_state_ptr& bsp ) { + void rollback_to_before( const chain::block_state_legacy_ptr& bsp ) { const auto bnum = bsp->block->block_num(); auto& index = permission_info_index.get(); const auto& permission_by_owner = controller.db().get_index().indices().get(); @@ -305,7 +305,7 @@ namespace eosio::chain_apis { * the thread-safe data set * @param bsp */ - auto commit_block_prelock( const chain::block_state_ptr& bsp ) const { + auto commit_block_prelock( const chain::block_state_legacy_ptr& bsp ) const { permission_set_t updated; permission_set_t deleted; @@ -360,7 +360,7 @@ namespace eosio::chain_apis { * transaction traces need to be in the cache prior to this call * @param bsp */ - void commit_block(const chain::block_state_ptr& bsp ) { + void commit_block(const chain::block_state_legacy_ptr& bsp ) { permission_set_t updated; permission_set_t deleted; bool rollback_required = false; @@ -520,7 +520,7 @@ namespace eosio::chain_apis { } FC_LOG_AND_DROP(("ACCOUNT DB cache_transaction_trace ERROR")); } - void account_query_db::commit_block(const chain::block_state_ptr& block ) { + void account_query_db::commit_block(const chain::block_state_legacy_ptr& block ) { try { _impl->commit_block(block); } FC_LOG_AND_DROP(("ACCOUNT DB commit_block ERROR")); diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 4ccbc264c0..f3ebc7d614 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -1033,11 +1033,11 @@ void chain_plugin_impl::plugin_initialize(const variables_map& options) { }); accepted_block_header_connection = chain->accepted_block_header.connect( - [this]( const block_state_ptr& blk ) { + [this]( const block_state_legacy_ptr& blk ) { accepted_block_header_channel.publish( priority::medium, blk ); } ); - accepted_block_connection = chain->accepted_block.connect( [this]( const block_state_ptr& blk ) { + accepted_block_connection = chain->accepted_block.connect( [this]( const block_state_legacy_ptr& blk ) { if (_account_query_db) { _account_query_db->commit_block(blk); } @@ -1053,7 +1053,7 @@ void chain_plugin_impl::plugin_initialize(const variables_map& options) { accepted_block_channel.publish( priority::high, blk ); } ); - irreversible_block_connection = chain->irreversible_block.connect( [this]( const block_state_ptr& blk ) { + irreversible_block_connection = chain->irreversible_block.connect( [this]( const block_state_legacy_ptr& blk ) { if (_trx_retry_db) { _trx_retry_db->on_irreversible_block(blk); } @@ -1207,7 +1207,7 @@ chain_apis::read_only chain_plugin::get_read_only_api(const fc::microseconds& ht } -bool chain_plugin::accept_block(const signed_block_ptr& block, const block_id_type& id, const block_state_ptr& bsp ) { +bool chain_plugin::accept_block(const signed_block_ptr& block, const block_id_type& id, const block_state_legacy_ptr& bsp ) { return my->incoming_block_sync_method(block, id, bsp); } @@ -2036,7 +2036,7 @@ fc::variant read_only::get_block_info(const read_only::get_block_info_params& pa } fc::variant read_only::get_block_header_state(const get_block_header_state_params& params, const fc::time_point&) const { - block_state_ptr b; + block_state_legacy_ptr b; std::optional block_num; std::exception_ptr e; try { @@ -2054,13 +2054,13 @@ fc::variant read_only::get_block_header_state(const get_block_header_state_param EOS_ASSERT( b, unknown_block_exception, "Could not find reversible block: ${block}", ("block", params.block_num_or_id)); fc::variant vo; - fc::to_variant( static_cast(*b), vo ); + fc::to_variant( static_cast(*b), vo ); return vo; } void read_write::push_block(read_write::push_block_params&& params, next_function next) { try { - app().get_method()(std::make_shared( std::move(params) ), std::optional{}, block_state_ptr{}); + app().get_method()(std::make_shared( std::move(params) ), std::optional{}, block_state_legacy_ptr{}); } catch ( boost::interprocess::bad_alloc& ) { handle_db_exhaustion(); } catch ( const std::bad_alloc& ) { diff --git a/plugins/chain_plugin/include/eosio/chain_plugin/account_query_db.hpp b/plugins/chain_plugin/include/eosio/chain_plugin/account_query_db.hpp index ce95784319..164564057e 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/account_query_db.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/account_query_db.hpp @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include namespace eosio::chain_apis { @@ -40,7 +40,7 @@ namespace eosio::chain_apis { * uncommitted traces. * @param block */ - void commit_block(const chain::block_state_ptr& block ); + void commit_block(const chain::block_state_legacy_ptr& block ); /** * parameters for the get_accounts_by_authorizers RPC diff --git a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp index 512df8eb69..2a45273775 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp @@ -978,7 +978,7 @@ class chain_plugin : public plugin { chain_apis::read_write get_read_write_api(const fc::microseconds& http_max_response_time); chain_apis::read_only get_read_only_api(const fc::microseconds& http_max_response_time) const; - bool accept_block( const chain::signed_block_ptr& block, const chain::block_id_type& id, const chain::block_state_ptr& bsp ); + bool accept_block( const chain::signed_block_ptr& block, const chain::block_id_type& id, const chain::block_state_legacy_ptr& bsp ); void accept_transaction(const chain::packed_transaction_ptr& trx, chain::plugin_interface::next_function next); // Only call this after plugin_initialize()! diff --git a/plugins/chain_plugin/include/eosio/chain_plugin/trx_finality_status_processing.hpp b/plugins/chain_plugin/include/eosio/chain_plugin/trx_finality_status_processing.hpp index df1ec98f37..327fe7610d 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/trx_finality_status_processing.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/trx_finality_status_processing.hpp @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include #include @@ -42,9 +42,9 @@ namespace eosio::chain_apis { void signal_applied_transaction( const chain::transaction_trace_ptr& trace, const chain::packed_transaction_ptr& ptrx ); - void signal_accepted_block( const chain::block_state_ptr& bsp ); + void signal_accepted_block( const chain::block_state_legacy_ptr& bsp ); - void signal_irreversible_block( const chain::block_state_ptr& bsp ); + void signal_irreversible_block( const chain::block_state_legacy_ptr& bsp ); void signal_block_start( uint32_t block_num ); diff --git a/plugins/chain_plugin/include/eosio/chain_plugin/trx_retry_db.hpp b/plugins/chain_plugin/include/eosio/chain_plugin/trx_retry_db.hpp index ebad51a18a..201ce61322 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/trx_retry_db.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/trx_retry_db.hpp @@ -1,6 +1,6 @@ #pragma once #include -#include +#include #include namespace eosio::chain_apis { @@ -64,12 +64,12 @@ class trx_retry_db { /** * Attach to chain accepted_block signal */ - void on_accepted_block(const chain::block_state_ptr& block ); + void on_accepted_block(const chain::block_state_legacy_ptr& block ); /** * Attach to chain irreversible_block signal */ - void on_irreversible_block(const chain::block_state_ptr& block ); + void on_irreversible_block(const chain::block_state_legacy_ptr& block ); private: std::unique_ptr _impl; diff --git a/plugins/chain_plugin/test/test_account_query_db.cpp b/plugins/chain_plugin/test/test_account_query_db.cpp index 25de9faf51..ff168c87a1 100644 --- a/plugins/chain_plugin/test/test_account_query_db.cpp +++ b/plugins/chain_plugin/test/test_account_query_db.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include @@ -38,7 +38,7 @@ BOOST_FIXTURE_TEST_CASE(newaccount_test, validating_tester) { try { auto aq_db = account_query_db(*control); //link aq_db to the `accepted_block` signal on the controller - auto c2 = control->accepted_block.connect([&](const block_state_ptr& blk) { + auto c2 = control->accepted_block.connect([&](const block_state_legacy_ptr& blk) { aq_db.commit_block( blk); }); @@ -63,7 +63,7 @@ BOOST_FIXTURE_TEST_CASE(updateauth_test, validating_tester) { try { auto aq_db = account_query_db(*control); //link aq_db to the `accepted_block` signal on the controller - auto c = control->accepted_block.connect([&](const block_state_ptr& blk) { + auto c = control->accepted_block.connect([&](const block_state_legacy_ptr& blk) { aq_db.commit_block( blk); }); @@ -97,7 +97,7 @@ BOOST_FIXTURE_TEST_CASE(updateauth_test_multi_threaded, validating_tester) { try auto aq_db = account_query_db(*control); //link aq_db to the `accepted_block` signal on the controller - auto c = control->accepted_block.connect([&](const block_state_ptr& blk) { + auto c = control->accepted_block.connect([&](const block_state_legacy_ptr& blk) { aq_db.commit_block( blk); }); @@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(future_fork_test) { try { auto aq_db = account_query_db(*node_a.control); //link aq_db to the `accepted_block` signal on the controller - auto c = node_a.control->accepted_block.connect([&](const block_state_ptr& blk) { + auto c = node_a.control->accepted_block.connect([&](const block_state_legacy_ptr& blk) { aq_db.commit_block( blk); }); @@ -196,7 +196,7 @@ BOOST_AUTO_TEST_CASE(fork_test) { try { auto aq_db = account_query_db(*node_a.control); //link aq_db to the `accepted_block` signal on the controller - auto c = node_a.control->accepted_block.connect([&](const block_state_ptr& blk) { + auto c = node_a.control->accepted_block.connect([&](const block_state_legacy_ptr& blk) { aq_db.commit_block( blk); }); diff --git a/plugins/chain_plugin/test/test_trx_finality_status_processing.cpp b/plugins/chain_plugin/test/test_trx_finality_status_processing.cpp index 79217590a4..4f406b0e5c 100644 --- a/plugins/chain_plugin/test/test_trx_finality_status_processing.cpp +++ b/plugins/chain_plugin/test/test_trx_finality_status_processing.cpp @@ -78,7 +78,7 @@ chain::block_id_type make_block_id( uint32_t block_num ) { return block_id; } -chain::transaction_trace_ptr make_transaction_trace( const packed_transaction_ptr trx, uint32_t block_number, const eosio::chain::block_state_ptr& bs_ptr, +chain::transaction_trace_ptr make_transaction_trace( const packed_transaction_ptr trx, uint32_t block_number, const eosio::chain::block_state_legacy_ptr& bs_ptr, chain::transaction_receipt_header::status_enum status = eosio::chain::transaction_receipt_header::executed ) { return std::make_shared(chain::transaction_trace{ trx->id(), @@ -113,7 +113,7 @@ auto make_block_state( uint32_t block_num ) { auto priv_key = get_private_key( block->producer, "active" ); auto pub_key = get_public_key( block->producer, "active" ); - auto prev = std::make_shared(); + auto prev = std::make_shared(); auto header_bmroot = chain::digest_type::hash( std::make_pair( block->digest(), prev->blockroot_merkle.get_root())); auto sig_digest = chain::digest_type::hash( std::make_pair( header_bmroot, prev->pending_schedule.schedule_hash )); block->producer_signature = priv_key.sign( sig_digest ); @@ -136,7 +136,7 @@ auto make_block_state( uint32_t block_num ) { chain::block_signing_authority_v0{1, {{pub_key, 1}}}}}}; pbhs.active_schedule = schedule; pbhs.valid_block_signing_authority = chain::block_signing_authority_v0{1, {{pub_key, 1}}}; - auto bsp = std::make_shared( + auto bsp = std::make_shared( std::move( pbhs ), std::move( block ), deque(), @@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE(trx_finality_status_logic) { try { using trx_deque = eosio::chain::deque< std::tuple< chain::transaction_trace_ptr, packed_transaction_ptr > >; uint32_t bn = 20; - auto add = [&bn, &status](trx_deque& trx_pairs, const eosio::chain::block_state_ptr& bs_ptr) { + auto add = [&bn, &status](trx_deque& trx_pairs, const eosio::chain::block_state_legacy_ptr& bs_ptr) { auto trx = make_unique_trx(fc::seconds(2)); auto trace = make_transaction_trace( trx, bn, bs_ptr); trx_pairs.push_back(std::tuple(trace, trx)); @@ -183,7 +183,7 @@ BOOST_AUTO_TEST_CASE(trx_finality_status_logic) { try { // Create speculative block to begin applying transactions locally status.signal_block_start(bn); - const eosio::chain::block_state_ptr no_bs; + const eosio::chain::block_state_legacy_ptr no_bs; add(trx_pairs_20, no_bs); add(trx_pairs_20, no_bs); @@ -834,7 +834,7 @@ BOOST_AUTO_TEST_CASE(trx_finality_status_logic) { try { namespace { using trx_deque = eosio::chain::deque< std::tuple< chain::transaction_trace_ptr, packed_transaction_ptr > >; - const eosio::chain::block_state_ptr no_bs; + const eosio::chain::block_state_legacy_ptr no_bs; struct block_frame { static uint32_t last_used_block_num; @@ -844,7 +844,7 @@ namespace { const std::string time; trx_deque pre_block; trx_deque block; - chain::block_state_ptr bs; + chain::block_state_legacy_ptr bs; std::string context; block_frame(trx_finality_status_processing& finality_status, const char* block_time, uint32_t block_num = 0) @@ -914,7 +914,7 @@ namespace { } private: - void verify(const trx_deque& trx_pairs, const chain::block_state_ptr& bs, uint32_t begin, uint32_t end) { + void verify(const trx_deque& trx_pairs, const chain::block_state_legacy_ptr& bs, uint32_t begin, uint32_t end) { if (end == std::numeric_limits::max()) { end = block.size(); } diff --git a/plugins/chain_plugin/test/test_trx_retry_db.cpp b/plugins/chain_plugin/test/test_trx_retry_db.cpp index f17f3cbf98..d604b1fc28 100644 --- a/plugins/chain_plugin/test/test_trx_retry_db.cpp +++ b/plugins/chain_plugin/test/test_trx_retry_db.cpp @@ -152,7 +152,7 @@ auto make_block_state( uint32_t block_num, std::vectorproducer, "active" ); auto pub_key = get_public_key( block->producer, "active" ); - auto prev = std::make_shared(); + auto prev = std::make_shared(); auto header_bmroot = chain::digest_type::hash( std::make_pair( block->digest(), prev->blockroot_merkle.get_root())); auto sig_digest = chain::digest_type::hash( std::make_pair( header_bmroot, prev->pending_schedule.schedule_hash )); block->producer_signature = priv_key.sign( sig_digest ); @@ -175,7 +175,7 @@ auto make_block_state( uint32_t block_num, std::vector( + auto bsp = std::make_shared( std::move( pbhs ), std::move( block ), deque(), diff --git a/plugins/chain_plugin/trx_finality_status_processing.cpp b/plugins/chain_plugin/trx_finality_status_processing.cpp index c95a0c774c..3bf7e691de 100644 --- a/plugins/chain_plugin/trx_finality_status_processing.cpp +++ b/plugins/chain_plugin/trx_finality_status_processing.cpp @@ -15,7 +15,7 @@ namespace eosio::chain_apis { void signal_applied_transaction( const chain::transaction_trace_ptr& trace, const chain::packed_transaction_ptr& ptrx ); - void signal_accepted_block( const chain::block_state_ptr& bsp ); + void signal_accepted_block( const chain::block_state_legacy_ptr& bsp ); void handle_rollback(); @@ -47,7 +47,7 @@ namespace eosio::chain_apis { trx_finality_status_processing::~trx_finality_status_processing() = default; - void trx_finality_status_processing::signal_irreversible_block( const chain::block_state_ptr& bsp ) { + void trx_finality_status_processing::signal_irreversible_block( const chain::block_state_legacy_ptr& bsp ) { try { _my->_irr_block_id = bsp->id; _my->_irr_block_timestamp = bsp->block->timestamp; @@ -67,7 +67,7 @@ namespace eosio::chain_apis { } FC_LOG_AND_DROP(("Failed to signal applied transaction for finality status")); } - void trx_finality_status_processing::signal_accepted_block( const chain::block_state_ptr& bsp ) { + void trx_finality_status_processing::signal_accepted_block( const chain::block_state_legacy_ptr& bsp ) { try { _my->signal_accepted_block(bsp); } FC_LOG_AND_DROP(("Failed to signal accepted block for finality status")); @@ -139,7 +139,7 @@ namespace eosio::chain_apis { } } - void trx_finality_status_processing_impl::signal_accepted_block( const chain::block_state_ptr& bsp ) { + void trx_finality_status_processing_impl::signal_accepted_block( const chain::block_state_legacy_ptr& bsp ) { // if this block had any transactions, then we have processed everything we need to already if (bsp->id == _head_block_id) { return; diff --git a/plugins/chain_plugin/trx_retry_db.cpp b/plugins/chain_plugin/trx_retry_db.cpp index 9ba86794d4..4d0376cf99 100644 --- a/plugins/chain_plugin/trx_retry_db.cpp +++ b/plugins/chain_plugin/trx_retry_db.cpp @@ -161,13 +161,13 @@ struct trx_retry_db_impl { rollback_to( block_num ); } - void on_accepted_block(const chain::block_state_ptr& bsp ) { + void on_accepted_block(const chain::block_state_legacy_ptr& bsp ) { // good time to perform processing ack_ready_trxs_by_block_num( bsp->block_num ); retry_trxs(); } - void on_irreversible_block(const chain::block_state_ptr& bsp ) { + void on_irreversible_block(const chain::block_state_legacy_ptr& bsp ) { ack_ready_trxs_by_lib( bsp->block_num ); clear_expired( bsp->block->timestamp ); } @@ -321,13 +321,13 @@ void trx_retry_db::on_block_start( uint32_t block_num ) { } FC_LOG_AND_DROP(("trx retry block_start ERROR")); } -void trx_retry_db::on_accepted_block(const chain::block_state_ptr& block ) { +void trx_retry_db::on_accepted_block(const chain::block_state_legacy_ptr& block ) { try { _impl->on_accepted_block(block); } FC_LOG_AND_DROP(("trx retry accepted_block ERROR")); } -void trx_retry_db::on_irreversible_block(const chain::block_state_ptr& block ) { +void trx_retry_db::on_irreversible_block(const chain::block_state_legacy_ptr& block ) { try { _impl->on_irreversible_block(block); } FC_LOG_AND_DROP(("trx retry irreversible_block ERROR")); diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 8fae55068d..991d095b7c 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -528,11 +528,11 @@ namespace eosio { uint32_t get_chain_lib_num() const; uint32_t get_chain_head_num() const; - void on_accepted_block_header( const block_state_ptr& bs ); - void on_accepted_block( const block_state_ptr& bs ); + void on_accepted_block_header( const block_state_legacy_ptr& bs ); + void on_accepted_block( const block_state_legacy_ptr& bs ); void transaction_ack(const std::pair&); - void on_irreversible_block( const block_state_ptr& block ); + void on_irreversible_block( const block_state_legacy_ptr& block ); void start_expire_timer(); void start_monitors(); @@ -1090,7 +1090,7 @@ namespace eosio { // returns calculated number of blocks combined latency uint32_t calc_block_latency(); - void process_signed_block( const block_id_type& id, signed_block_ptr block, block_state_ptr bsp ); + void process_signed_block( const block_id_type& id, signed_block_ptr block, block_state_legacy_ptr bsp ); fc::variant_object get_logger_variant() const { fc::mutable_variant_object mvo; @@ -3689,7 +3689,7 @@ namespace eosio { return; } - block_state_ptr bsp; + block_state_legacy_ptr bsp; bool exception = false; try { // this may return null if block is not immediately ready to be processed @@ -3733,7 +3733,7 @@ namespace eosio { } // called from application thread - void connection::process_signed_block( const block_id_type& blk_id, signed_block_ptr block, block_state_ptr bsp ) { + void connection::process_signed_block( const block_id_type& blk_id, signed_block_ptr block, block_state_legacy_ptr bsp ) { controller& cc = my_impl->chain_plug->chain(); uint32_t blk_num = block_header::num_from_id(blk_id); // use c in this method instead of this to highlight that all methods called on c-> must be thread safe @@ -3882,7 +3882,7 @@ namespace eosio { } // called from application thread - void net_plugin_impl::on_accepted_block_header(const block_state_ptr& bs) { + void net_plugin_impl::on_accepted_block_header(const block_state_legacy_ptr& bs) { update_chain_info(); dispatcher->strand.post([bs]() { @@ -3891,13 +3891,13 @@ namespace eosio { }); } - void net_plugin_impl::on_accepted_block(const block_state_ptr& ) { + void net_plugin_impl::on_accepted_block(const block_state_legacy_ptr& ) { on_pending_schedule(chain_plug->chain().pending_producers()); on_active_schedule(chain_plug->chain().active_producers()); } // called from application thread - void net_plugin_impl::on_irreversible_block( const block_state_ptr& block) { + void net_plugin_impl::on_irreversible_block( const block_state_legacy_ptr& block) { fc_dlog( logger, "on_irreversible_block, blk num = ${num}, id = ${id}", ("num", block->block_num)("id", block->id) ); update_chain_info(); } @@ -4284,14 +4284,14 @@ namespace eosio { { chain::controller& cc = chain_plug->chain(); - cc.accepted_block_header.connect( [my = shared_from_this()]( const block_state_ptr& s ) { + cc.accepted_block_header.connect( [my = shared_from_this()]( const block_state_legacy_ptr& s ) { my->on_accepted_block_header( s ); } ); - cc.accepted_block.connect( [my = shared_from_this()]( const block_state_ptr& s ) { + cc.accepted_block.connect( [my = shared_from_this()]( const block_state_legacy_ptr& s ) { my->on_accepted_block( s ); } ); - cc.irreversible_block.connect( [my = shared_from_this()]( const block_state_ptr& s ) { + cc.irreversible_block.connect( [my = shared_from_this()]( const block_state_legacy_ptr& s ) { my->on_irreversible_block( s ); } ); } @@ -4755,4 +4755,4 @@ namespace eosio { update_p2p_connection_metrics({num_peers+num_bp_peers, num_clients, std::move(per_connection)}); start_conn_timer( connector_period, {}, timer_type::stats ); } -} // namespace eosio \ No newline at end of file +} // namespace eosio diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 8e6b207401..8ad75c7945 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -620,7 +620,7 @@ class producer_plugin_impl : public std::enable_shared_from_thischain(); auto before = _unapplied_transactions.size(); _unapplied_transactions.clear_applied(bsp); @@ -630,7 +630,7 @@ class producer_plugin_impl : public std::enable_shared_from_thisheader.producer)) _producer_watermarks.consider_new_watermark(bsp->header.producer, bsp->block_num, bsp->block->timestamp); } @@ -662,7 +662,7 @@ class producer_plugin_impl : public std::enable_shared_from_this& block_id, const block_state_ptr& bsp) { + bool on_incoming_block(const signed_block_ptr& block, const std::optional& block_id, const block_state_legacy_ptr& bsp) { auto& chain = chain_plug->chain(); if (in_producing_mode()) { fc_wlog(_log, "dropped incoming block #${num} id: ${id}", ("num", block->block_num())("id", block_id ? (*block_id).str() : "UNKNOWN")); @@ -690,7 +690,7 @@ class producer_plugin_impl : public std::enable_shared_from_this bsf; + std::future bsf; if (!bsp) { bsf = chain.create_block_state_future(id, block); } @@ -707,7 +707,7 @@ class producer_plugin_impl : public std::enable_shared_from_this().register_provider( - [this](const signed_block_ptr& block, const std::optional& block_id, const block_state_ptr& bsp) { + [this](const signed_block_ptr& block, const std::optional& block_id, const block_state_legacy_ptr& bsp) { return on_incoming_block(block, block_id, bsp); }); @@ -2635,7 +2635,7 @@ void producer_plugin_impl::produce_block() { chain.commit_block(); - block_state_ptr new_bs = chain.head_block_state(); + block_state_legacy_ptr new_bs = chain.head_block_state(); producer_plugin::produced_block_metrics metrics; br.total_time += fc::time_point::now() - start; diff --git a/plugins/producer_plugin/test/test_trx_full.cpp b/plugins/producer_plugin/test/test_trx_full.cpp index b07c1ec8ea..e664f081bd 100644 --- a/plugins/producer_plugin/test/test_trx_full.cpp +++ b/plugins/producer_plugin/test/test_trx_full.cpp @@ -68,7 +68,7 @@ auto make_unique_trx( const chain_id_type& chain_id ) { } // verify all trxs are in blocks only once -bool verify_equal( const std::deque& trxs, const std::deque& all_blocks) { +bool verify_equal( const std::deque& trxs, const std::deque& all_blocks) { std::set trxs_ids; // trx can appear more than once if they were aborted std::set blk_trxs_ids; @@ -126,10 +126,10 @@ BOOST_AUTO_TEST_CASE(producer) { auto[prod_plug, chain_plug] = plugin_fut.get(); auto chain_id = chain_plug->get_chain_id(); - std::deque all_blocks; + std::deque all_blocks; std::promise empty_blocks_promise; std::future empty_blocks_fut = empty_blocks_promise.get_future(); - auto ab = chain_plug->chain().accepted_block.connect( [&](const block_state_ptr& bsp) { + auto ab = chain_plug->chain().accepted_block.connect( [&](const block_state_legacy_ptr& bsp) { static int num_empty = std::numeric_limits::max(); all_blocks.push_back( bsp ); if( bsp->block->transactions.empty() ) { diff --git a/plugins/state_history_plugin/include/eosio/state_history_plugin/session.hpp b/plugins/state_history_plugin/include/eosio/state_history_plugin/session.hpp index 26af991d58..7692eb0be6 100644 --- a/plugins/state_history_plugin/include/eosio/state_history_plugin/session.hpp +++ b/plugins/state_history_plugin/include/eosio/state_history_plugin/session.hpp @@ -1,5 +1,5 @@ #pragma once -#include +#include #include #include #include @@ -26,7 +26,7 @@ struct send_queue_entry_base { struct session_base { virtual void send_update(bool changed) = 0; - virtual void send_update(const eosio::chain::block_state_ptr& block_state) = 0; + virtual void send_update(const eosio::chain::block_state_legacy_ptr& block_state) = 0; virtual ~session_base() = default; std::optional current_request; @@ -35,9 +35,9 @@ struct session_base { class send_update_send_queue_entry : public send_queue_entry_base { std::shared_ptr session; - const chain::block_state_ptr block_state; + const chain::block_state_legacy_ptr block_state; public: - send_update_send_queue_entry(std::shared_ptr s, chain::block_state_ptr block_state) + send_update_send_queue_entry(std::shared_ptr s, chain::block_state_legacy_ptr block_state) : session(std::move(s)) , block_state(std::move(block_state)){} @@ -123,7 +123,7 @@ class session_manager { } } - void send_update(const chain::block_state_ptr& block_state) { + void send_update(const chain::block_state_legacy_ptr& block_state) { for( auto& s : session_set ) { add_send_queue(s, std::make_unique(s, block_state)); } @@ -481,7 +481,7 @@ struct session : session_base, std::enable_shared_from_thismax_messages_in_flight) { session_mgr.pop_entry(false); @@ -553,7 +553,7 @@ struct session : session_base, std::enable_shared_from_this>(this->shared_from_this(), std::move(result))->send_entry(); } - void send_update(const chain::block_state_ptr& block_state) override { + void send_update(const chain::block_state_legacy_ptr& block_state) override { if (!current_request || !current_request->max_messages_in_flight) { session_mgr.pop_entry(false); return; diff --git a/plugins/state_history_plugin/state_history_plugin.cpp b/plugins/state_history_plugin/state_history_plugin.cpp index a779a50be0..83fcec261f 100644 --- a/plugins/state_history_plugin/state_history_plugin.cpp +++ b/plugins/state_history_plugin/state_history_plugin.cpp @@ -88,7 +88,7 @@ struct state_history_plugin_impl : std::enable_shared_from_thisblock_num) { @@ -107,7 +107,7 @@ struct state_history_plugin_impl : std::enable_shared_from_this& result) const { + void get_block(uint32_t block_num, const block_state_legacy_ptr& block_state, std::optional& result) const { auto p = get_block(block_num, block_state); if (p) result = fc::raw::pack(*p); @@ -201,7 +201,7 @@ struct state_history_plugin_impl : std::enable_shared_from_thisempty(); @@ -329,7 +329,7 @@ void state_history_plugin_impl::plugin_initialize(const variables_map& options) on_applied_transaction(std::get<0>(t), std::get<1>(t)); })); accepted_block_connection.emplace( - chain.accepted_block.connect([&](const block_state_ptr& p) { on_accepted_block(p); })); + chain.accepted_block.connect([&](const block_state_legacy_ptr& p) { on_accepted_block(p); })); block_start_connection.emplace( chain.block_start.connect([&](uint32_t block_num) { on_block_start(block_num); })); diff --git a/plugins/state_history_plugin/tests/session_test.cpp b/plugins/state_history_plugin/tests/session_test.cpp index e1bc439ef2..6ca9cfd3c5 100644 --- a/plugins/state_history_plugin/tests/session_test.cpp +++ b/plugins/state_history_plugin/tests/session_test.cpp @@ -123,7 +123,7 @@ struct mock_state_history_plugin { fc::logger& get_logger() { return logger; } - void get_block(uint32_t block_num, const eosio::chain::block_state_ptr& block_state, + void get_block(uint32_t block_num, const eosio::chain::block_state_legacy_ptr& block_state, std::optional& result) const { result.emplace().resize(16); } diff --git a/plugins/test_control_plugin/test_control_plugin.cpp b/plugins/test_control_plugin/test_control_plugin.cpp index 1f7192dc04..4ff52bc1fd 100644 --- a/plugins/test_control_plugin/test_control_plugin.cpp +++ b/plugins/test_control_plugin/test_control_plugin.cpp @@ -15,9 +15,9 @@ class test_control_plugin_impl { void kill_on_head(account_name prod, uint32_t where_in_seq); private: - void accepted_block(const chain::block_state_ptr& bsp); - void applied_irreversible_block(const chain::block_state_ptr& bsp); - void process_next_block_state(const chain::block_state_ptr& bsp); + void accepted_block(const chain::block_state_legacy_ptr& bsp); + void applied_irreversible_block(const chain::block_state_legacy_ptr& bsp); + void process_next_block_state_legacy(const chain::block_state_legacy_ptr& bsp); std::optional _accepted_block_connection; std::optional _irreversible_block_connection; @@ -32,11 +32,11 @@ class test_control_plugin_impl { void test_control_plugin_impl::connect() { _irreversible_block_connection.emplace( - _chain.irreversible_block.connect( [&]( const chain::block_state_ptr& bs ) { + _chain.irreversible_block.connect( [&]( const chain::block_state_legacy_ptr& bs ) { applied_irreversible_block( bs ); } )); _accepted_block_connection = - _chain.accepted_block.connect( [&]( const chain::block_state_ptr& bs ) { + _chain.accepted_block.connect( [&]( const chain::block_state_legacy_ptr& bs ) { accepted_block( bs ); } ); } @@ -46,17 +46,17 @@ void test_control_plugin_impl::disconnect() { _irreversible_block_connection.reset(); } -void test_control_plugin_impl::applied_irreversible_block(const chain::block_state_ptr& bsp) { +void test_control_plugin_impl::applied_irreversible_block(const chain::block_state_legacy_ptr& bsp) { if (_track_lib) - process_next_block_state(bsp); + process_next_block_state_legacy(bsp); } -void test_control_plugin_impl::accepted_block(const chain::block_state_ptr& bsp) { +void test_control_plugin_impl::accepted_block(const chain::block_state_legacy_ptr& bsp) { if (_track_head) - process_next_block_state(bsp); + process_next_block_state_legacy(bsp); } -void test_control_plugin_impl::process_next_block_state(const chain::block_state_ptr& bsp) { +void test_control_plugin_impl::process_next_block_state_legacy(const chain::block_state_legacy_ptr& bsp) { // Tests expect the shutdown only after signaling a producer shutdown and seeing a full production cycle const auto block_time = _chain.head_block_time() + fc::microseconds(chain::config::block_interval_us); const auto& producer_authority = bsp->get_scheduled_producer(block_time); diff --git a/plugins/trace_api_plugin/include/eosio/trace_api/chain_extraction.hpp b/plugins/trace_api_plugin/include/eosio/trace_api/chain_extraction.hpp index cb56ddca00..9a588161e9 100644 --- a/plugins/trace_api_plugin/include/eosio/trace_api/chain_extraction.hpp +++ b/plugins/trace_api_plugin/include/eosio/trace_api/chain_extraction.hpp @@ -31,12 +31,12 @@ class chain_extraction_impl_type { } /// connect to chain controller accepted_block signal - void signal_accepted_block( const chain::block_state_ptr& bsp ) { + void signal_accepted_block( const chain::block_state_legacy_ptr& bsp ) { on_accepted_block( bsp ); } /// connect to chain controller irreversible_block signal - void signal_irreversible_block( const chain::block_state_ptr& bsp ) { + void signal_irreversible_block( const chain::block_state_legacy_ptr& bsp ) { on_irreversible_block( bsp ); } @@ -63,11 +63,11 @@ class chain_extraction_impl_type { } } - void on_accepted_block(const chain::block_state_ptr& block_state) { + void on_accepted_block(const chain::block_state_legacy_ptr& block_state) { store_block_trace( block_state ); } - void on_irreversible_block( const chain::block_state_ptr& block_state ) { + void on_irreversible_block( const chain::block_state_legacy_ptr& block_state ) { store_lib( block_state ); } @@ -80,7 +80,7 @@ class chain_extraction_impl_type { onblock_trace.reset(); } - void store_block_trace( const chain::block_state_ptr& block_state ) { + void store_block_trace( const chain::block_state_legacy_ptr& block_state ) { try { using transaction_trace_t = transaction_trace_v3; auto bt = create_block_trace( block_state ); @@ -117,7 +117,7 @@ class chain_extraction_impl_type { } } - void store_lib( const chain::block_state_ptr& bsp ) { + void store_lib( const chain::block_state_legacy_ptr& bsp ) { try { store.append_lib( bsp->block_num ); } catch( ... ) { diff --git a/plugins/trace_api_plugin/include/eosio/trace_api/extract_util.hpp b/plugins/trace_api_plugin/include/eosio/trace_api/extract_util.hpp index cec44ab10b..d0f143bc1f 100644 --- a/plugins/trace_api_plugin/include/eosio/trace_api/extract_util.hpp +++ b/plugins/trace_api_plugin/include/eosio/trace_api/extract_util.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include namespace eosio { namespace trace_api { @@ -63,7 +63,7 @@ inline TransactionTrace to_transaction_trace( const cache_trace& t ) { return r; } -inline block_trace_v2 create_block_trace( const chain::block_state_ptr& bsp ) { +inline block_trace_v2 create_block_trace( const chain::block_state_legacy_ptr& bsp ) { block_trace_v2 r; r.id = bsp->id; r.number = bsp->block_num; diff --git a/plugins/trace_api_plugin/test/include/eosio/trace_api/test_common.hpp b/plugins/trace_api_plugin/test/include/eosio/trace_api/test_common.hpp index 7208683bd2..37a2a359ab 100644 --- a/plugins/trace_api_plugin/test/include/eosio/trace_api/test_common.hpp +++ b/plugins/trace_api_plugin/test/include/eosio/trace_api/test_common.hpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -71,7 +71,7 @@ namespace eosio::trace_api { auto priv_key = get_private_key( block->producer, "active" ); auto pub_key = get_public_key( block->producer, "active" ); - auto prev = std::make_shared(); + auto prev = std::make_shared(); auto header_bmroot = chain::digest_type::hash( std::make_pair( block->digest(), prev->blockroot_merkle.get_root())); auto sig_digest = chain::digest_type::hash( std::make_pair( header_bmroot, prev->pending_schedule.schedule_hash )); block->producer_signature = priv_key.sign( sig_digest ); @@ -92,7 +92,7 @@ namespace eosio::trace_api { chain::block_signing_authority_v0{1, {{pub_key, 1}}}}}}; pbhs.active_schedule = schedule; pbhs.valid_block_signing_authority = chain::block_signing_authority_v0{1, {{pub_key, 1}}}; - auto bsp = std::make_shared( + auto bsp = std::make_shared( std::move( pbhs ), std::move( block ), eosio::chain::deque(), diff --git a/plugins/trace_api_plugin/test/test_extraction.cpp b/plugins/trace_api_plugin/test/test_extraction.cpp index 3403ef1dc5..22450e1997 100644 --- a/plugins/trace_api_plugin/test/test_extraction.cpp +++ b/plugins/trace_api_plugin/test/test_extraction.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -136,7 +136,7 @@ struct extraction_test_fixture { extraction_impl.signal_applied_transaction(trace, ptrx); } - void signal_accepted_block( const chain::block_state_ptr& bsp ) { + void signal_accepted_block( const chain::block_state_legacy_ptr& bsp ) { extraction_impl.signal_accepted_block(bsp); } diff --git a/plugins/trace_api_plugin/trace_api_plugin.cpp b/plugins/trace_api_plugin/trace_api_plugin.cpp index 8a412f8b27..a05da93e62 100644 --- a/plugins/trace_api_plugin/trace_api_plugin.cpp +++ b/plugins/trace_api_plugin/trace_api_plugin.cpp @@ -377,14 +377,14 @@ struct trace_api_plugin_impl { })); accepted_block_connection.emplace( - chain.accepted_block.connect([this](const chain::block_state_ptr& p) { + chain.accepted_block.connect([this](const chain::block_state_legacy_ptr& p) { emit_killer([&](){ extraction->signal_accepted_block(p); }); })); irreversible_block_connection.emplace( - chain.irreversible_block.connect([this](const chain::block_state_ptr& p) { + chain.irreversible_block.connect([this](const chain::block_state_legacy_ptr& p) { emit_killer([&](){ extraction->signal_irreversible_block(p); }); diff --git a/unittests/api_tests.cpp b/unittests/api_tests.cpp index 20eced06f6..294c3eb062 100644 --- a/unittests/api_tests.cpp +++ b/unittests/api_tests.cpp @@ -1470,8 +1470,8 @@ void transaction_tests(T& chain) { auto& t = std::get<0>(x); if (t && t->receipt && t->receipt->status != transaction_receipt::executed) { trace = t; } } ); - block_state_ptr bsp; - auto c2 = chain.control->accepted_block.connect([&](const block_state_ptr& b) { bsp = b; }); + block_state_legacy_ptr bsp; + auto c2 = chain.control->accepted_block.connect([&](const block_state_legacy_ptr& b) { bsp = b; }); // test error handling on deferred transaction failure auto test_trace = CALL_TEST_FUNCTION(chain, "test_transaction", "send_transaction_trigger_error_handler", {}); diff --git a/unittests/block_tests.cpp b/unittests/block_tests.cpp index 2236758dcf..92e48c095f 100644 --- a/unittests/block_tests.cpp +++ b/unittests/block_tests.cpp @@ -217,10 +217,10 @@ BOOST_AUTO_TEST_CASE(broadcasted_block_test) signed_block_ptr bcasted_blk_by_prod_node; signed_block_ptr bcasted_blk_by_recv_node; - producer_node.control->accepted_block.connect( [&](const block_state_ptr& bs) { + producer_node.control->accepted_block.connect( [&](const block_state_legacy_ptr& bs) { bcasted_blk_by_prod_node = bs->block; }); - receiving_node.control->accepted_block.connect( [&](const block_state_ptr& bs) { + receiving_node.control->accepted_block.connect( [&](const block_state_legacy_ptr& bs) { bcasted_blk_by_recv_node = bs->block; }); diff --git a/unittests/chain_tests.cpp b/unittests/chain_tests.cpp index 7079baac99..5045fb7dc7 100644 --- a/unittests/chain_tests.cpp +++ b/unittests/chain_tests.cpp @@ -149,8 +149,8 @@ BOOST_AUTO_TEST_CASE( signal_validated_blocks ) try { tester chain; tester validator; - block_state_ptr accepted_bsp; - auto c = chain.control->accepted_block.connect([&](const block_state_ptr& b) { + block_state_legacy_ptr accepted_bsp; + auto c = chain.control->accepted_block.connect([&](const block_state_legacy_ptr& b) { BOOST_CHECK(b); BOOST_CHECK(chain.control->fetch_block_state_by_id(b->id) == b); BOOST_CHECK(chain.control->fetch_block_state_by_number(b->block_num) == b); // verify it can be found (has to be validated) @@ -162,8 +162,8 @@ BOOST_AUTO_TEST_CASE( signal_validated_blocks ) try { BOOST_CHECK(chain.control->fetch_block_header_by_id(b->id)->calculate_id() == b->id); accepted_bsp = b; }); - block_state_ptr validated_bsp; - auto c2 = validator.control->accepted_block.connect([&](const block_state_ptr& b) { + block_state_legacy_ptr validated_bsp; + auto c2 = validator.control->accepted_block.connect([&](const block_state_legacy_ptr& b) { BOOST_CHECK(b); BOOST_CHECK(validator.control->fetch_block_state_by_id(b->id) == b); BOOST_CHECK(validator.control->fetch_block_state_by_number(b->block_num) == b); // verify it can be found (has to be validated) diff --git a/unittests/forked_tests.cpp b/unittests/forked_tests.cpp index b375773391..c5b4e38a80 100644 --- a/unittests/forked_tests.cpp +++ b/unittests/forked_tests.cpp @@ -351,9 +351,9 @@ BOOST_AUTO_TEST_CASE( validator_accepts_valid_blocks ) try { auto id = n1.control->head_block_id(); - block_state_ptr first_block; + block_state_legacy_ptr first_block; - auto c = n2.control->accepted_block.connect( [&]( const block_state_ptr& bsp) { + auto c = n2.control->accepted_block.connect( [&]( const block_state_legacy_ptr& bsp) { first_block = bsp; } ); @@ -697,7 +697,7 @@ BOOST_AUTO_TEST_CASE( push_block_returns_forked_transactions ) try { // test forked blocks signal accepted_block in order, required by trace_api_plugin std::vector accepted_blocks; - auto conn = c.control->accepted_block.connect( [&]( const block_state_ptr& bsp) { + auto conn = c.control->accepted_block.connect( [&]( const block_state_legacy_ptr& bsp) { accepted_blocks.emplace_back( bsp->block ); } ); diff --git a/unittests/state_history_tests.cpp b/unittests/state_history_tests.cpp index b1089da989..f6e0b65755 100644 --- a/unittests/state_history_tests.cpp +++ b/unittests/state_history_tests.cpp @@ -619,7 +619,7 @@ struct state_history_tester : state_history_tester_logs, tester { trace_converter.add_transaction(std::get<0>(t), std::get<1>(t)); }); - control.accepted_block.connect([&](const block_state_ptr& block_state) { + control.accepted_block.connect([&](const block_state_legacy_ptr& block_state) { eosio::state_history_log_header header{.magic = eosio::ship_magic(eosio::ship_current_version, 0), .block_id = block_state->id, .payload_size = 0}; diff --git a/unittests/unapplied_transaction_queue_tests.cpp b/unittests/unapplied_transaction_queue_tests.cpp index 5665a9246b..718ec79637 100644 --- a/unittests/unapplied_transaction_queue_tests.cpp +++ b/unittests/unapplied_transaction_queue_tests.cpp @@ -43,7 +43,7 @@ auto create_test_block_state( deque trx_metas ) { auto priv_key = eosio::testing::base_tester::get_private_key( block->producer, "active" ); auto pub_key = eosio::testing::base_tester::get_public_key( block->producer, "active" ); - auto prev = std::make_shared(); + auto prev = std::make_shared(); auto header_bmroot = digest_type::hash( std::make_pair( block->digest(), prev->blockroot_merkle.get_root() ) ); auto sig_digest = digest_type::hash( std::make_pair(header_bmroot, prev->pending_schedule.schedule_hash) ); block->producer_signature = priv_key.sign( sig_digest ); @@ -63,7 +63,7 @@ auto create_test_block_state( deque trx_metas ) { producer_authority_schedule schedule = { 0, { producer_authority{block->producer, block_signing_authority_v0{ 1, {{pub_key, 1}} } } } }; pbhs.active_schedule = schedule; pbhs.valid_block_signing_authority = block_signing_authority_v0{ 1, {{pub_key, 1}} }; - auto bsp = std::make_shared( + auto bsp = std::make_shared( std::move( pbhs ), std::move( block ), std::move( trx_metas ),