From e8e00fcf519da28c1cc3a2eddeff9305621fd204 Mon Sep 17 00:00:00 2001 From: Emory Barlow Date: Wed, 21 Nov 2018 10:23:02 -0500 Subject: [PATCH 001/111] Fix requires in spec file to resolve dependency resolution issues with rpms --- scripts/generate_rpm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate_rpm.sh b/scripts/generate_rpm.sh index a35efde71ec..f4f682e61cf 100644 --- a/scripts/generate_rpm.sh +++ b/scripts/generate_rpm.sh @@ -30,7 +30,7 @@ Version: ${VERSION} License: MIT Vendor: ${VENDOR} Source: ${URL} -Requires: openssl-devel.x86_64, gmp-devel.x86_64, libstdc++-devel.x86_64, bzip2.x86_64, bzip2-devel.x86_64, mongodb.x86_64, mongodb-server.x86_64 +Requires: openssl-devel, gmp-devel, libstdc++-devel, bzip2, bzip2-devel, mongodb, mongodb-server URL: ${URL} Packager: ${VENDOR} <${EMAIL}> Summary: ${DESC} From 5ee8c6cb91f98fd4756a0bdc7f53299df223f452 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 21 Nov 2018 15:15:27 -0600 Subject: [PATCH 002/111] Remove unneeded req_trx vector --- plugins/net_plugin/net_plugin.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 8979cd53095..1469d11aef1 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -665,8 +665,6 @@ namespace eosio { public: uint32_t just_send_it_max = 0; - vector req_trx; - std::multimap received_blocks; std::multimap received_transactions; @@ -1684,13 +1682,6 @@ namespace eosio { } received_transactions.erase(range.first, range.second); - for (auto ref = req_trx.begin(); ref != req_trx.end(); ++ref) { - if (*ref == id) { - req_trx.erase(ref); - break; - } - } - if( my_impl->local_txns.get().find( id ) != my_impl->local_txns.end( ) ) { //found fc_dlog(logger, "found trxid in local_trxs" ); return; @@ -1797,7 +1788,6 @@ namespace eosio { time_point()} ); req.req_trx.ids.push_back( t ); - req_trx.push_back( t ); } else { fc_dlog(logger,"big msg manager found txn id in table, ${id}",("id", t)); From 0a562823efa7911b36f3434630cd11b407b82114 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 21 Nov 2018 15:30:59 -0600 Subject: [PATCH 003/111] Remove needless copy of signed_block. Only create pending_notify if needed. --- plugins/net_plugin/net_plugin.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 1469d11aef1..32281aed94f 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1617,17 +1617,17 @@ namespace eosio { net_message msg(bsum); uint32_t packsiz = fc::raw::pack_size(msg); uint32_t msgsiz = packsiz + sizeof(packsiz); - notice_message pending_notify; block_id_type bid = bsum.id(); uint32_t bnum = bsum.block_num(); - pending_notify.known_blocks.mode = normal; - pending_notify.known_blocks.ids.push_back( bid ); - pending_notify.known_trx.mode = none; peer_block_state pbstate = {bid, bnum, false,true,time_point()}; // skip will be empty if our producer emitted this block so just send it if (( large_msg_notify && msgsiz > just_send_it_max) && !skips.empty()) { fc_ilog(logger, "block size is ${ms}, sending notify",("ms", msgsiz)); + notice_message pending_notify; + pending_notify.known_blocks.mode = normal; + pending_notify.known_blocks.ids.push_back( bid ); + pending_notify.known_trx.mode = none; my_impl->send_all(pending_notify, [&skips, pbstate](connection_ptr c) -> bool { if (skips.find(c) != skips.end() || !c->current()) return false; @@ -1646,7 +1646,7 @@ namespace eosio { continue; } cp->add_peer_block(pbstate); - cp->enqueue( bsum ); + cp->enqueue( msg ); } } } From b4c3094e48bd4ef614ae6199a8d2ebc72c037b68 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 21 Nov 2018 17:07:43 -0600 Subject: [PATCH 004/111] Remove unused blk_buffer --- plugins/net_plugin/net_plugin.cpp | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 32281aed94f..b2feb573077 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -467,7 +467,6 @@ namespace eosio { fc::message_buffer<1024*1024> pending_message_buffer; fc::optional outstanding_read_bytes; - vector blk_buffer; struct queued_write { std::shared_ptr> buff; @@ -1195,22 +1194,6 @@ namespace eosio { bool connection::process_next_message(net_plugin_impl& impl, uint32_t message_length) { try { - // If it is a signed_block, then save the raw message for the cache - // This must be done before we unpack the message. - // This code is copied from fc::io::unpack(..., unsigned_int) - auto index = pending_message_buffer.read_index(); - uint64_t which = 0; char b = 0; uint8_t by = 0; - do { - pending_message_buffer.peek(&b, 1, index); - which |= uint32_t(uint8_t(b) & 0x7f) << by; - by += 7; - } while( uint8_t(b) & 0x80 && by < 32); - - if (which == uint64_t(net_message::tag::value)) { - blk_buffer.resize(message_length); - auto index = pending_message_buffer.read_index(); - pending_message_buffer.peek(blk_buffer.data(), message_length, index); - } auto ds = pending_message_buffer.create_datastream(); net_message msg; fc::raw::unpack(ds, msg); From bb72d47721ffff328d94b857b469bfac283fac9b Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 27 Nov 2018 13:43:45 -0500 Subject: [PATCH 005/111] Make signed_block copy constructor private to avoid accidental copies. --- libraries/chain/include/eosio/chain/block.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/chain/include/eosio/chain/block.hpp b/libraries/chain/include/eosio/chain/block.hpp index 0e85b167df8..a00e029744a 100644 --- a/libraries/chain/include/eosio/chain/block.hpp +++ b/libraries/chain/include/eosio/chain/block.hpp @@ -55,9 +55,13 @@ namespace eosio { namespace chain { /** */ struct signed_block : public signed_block_header { - using signed_block_header::signed_block_header; + private: + signed_block( const signed_block& ) = default; + public: signed_block() = default; signed_block( const signed_block_header& h ):signed_block_header(h){} + signed_block( signed_block&& ) = default; + signed_block clone() const { return *this; } vector transactions; /// new or generated transactions extensions_type block_extensions; From f1d16f2fc1a32599b5979b1bb84da6e37c9cde23 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 27 Nov 2018 13:46:09 -0500 Subject: [PATCH 006/111] move signed_block instead of making copy --- libraries/chain/block_log.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/block_log.cpp b/libraries/chain/block_log.cpp index dc769cc9612..439ad5b5d61 100644 --- a/libraries/chain/block_log.cpp +++ b/libraries/chain/block_log.cpp @@ -473,7 +473,7 @@ namespace eosio { namespace chain { old_block_stream.read( reinterpret_cast(&tmp_pos), sizeof(tmp_pos) ); } if( pos != tmp_pos ) { - bad_block = tmp; + bad_block.emplace(std::move(tmp)); break; } From dfe8f77558e72443ea03b1d8a884ba789667728b Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 27 Nov 2018 13:46:58 -0500 Subject: [PATCH 007/111] Avoid copy constructor for push_block --- plugins/chain_plugin/chain_plugin.cpp | 6 +++--- .../include/eosio/chain_plugin/chain_plugin.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index ad67318528b..cd8e6a96a90 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -901,7 +901,7 @@ bool chain_plugin::import_reversible_blocks( const fc::path& reversible_dir, new_reversible.create( [&]( auto& ubo ) { ubo.blocknum = num; - ubo.set_block( std::make_shared(tmp) ); + ubo.set_block( std::make_shared(std::move(tmp)) ); }); end = num; } @@ -1526,9 +1526,9 @@ fc::variant read_only::get_block_header_state(const get_block_header_state_param return vo; } -void read_write::push_block(const read_write::push_block_params& params, next_function next) { +void read_write::push_block(read_write::push_block_params params, next_function next) { try { - app().get_method()(std::make_shared(params)); + app().get_method()(std::make_shared(std::move(params))); next(read_write::push_block_results{}); } catch ( boost::interprocess::bad_alloc& ) { chain_plugin::handle_db_exhaustion(); 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 832f0b24485..26e6015dd6f 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp @@ -569,7 +569,7 @@ class read_write { using push_block_params = chain::signed_block; using push_block_results = empty; - void push_block(const push_block_params& params, chain::plugin_interface::next_function next); + void push_block(push_block_params params, chain::plugin_interface::next_function next); using push_transaction_params = fc::variant_object; struct push_transaction_results { From b23017248569c242eb5c55419cf3df5923191beb Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 27 Nov 2018 13:47:43 -0500 Subject: [PATCH 008/111] Add which comment --- plugins/net_plugin/include/eosio/net_plugin/protocol.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp b/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp index a736a9ff464..36cb9c70bda 100644 --- a/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp +++ b/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp @@ -139,7 +139,7 @@ namespace eosio { notice_message, request_message, sync_request_message, - signed_block, + signed_block, // which = 7 packed_transaction>; } // namespace eosio From 6b18a1b789be3968811899c0dff76e96c3c7893f Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 27 Nov 2018 13:48:31 -0500 Subject: [PATCH 009/111] Update tests for private signed_block copy constructor --- unittests/block_tests.cpp | 4 ++-- unittests/forked_tests.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/unittests/block_tests.cpp b/unittests/block_tests.cpp index 10a10dc2060..cd6af935ec6 100644 --- a/unittests/block_tests.cpp +++ b/unittests/block_tests.cpp @@ -21,7 +21,7 @@ BOOST_AUTO_TEST_CASE(block_with_invalid_tx_test) auto b = main.produce_block(); // Make a copy of the valid block and corrupt the transaction - auto copy_b = std::make_shared(*b); + auto copy_b = std::make_shared(std::move(*b)); auto signed_tx = copy_b->transactions.back().trx.get().get_signed_transaction(); auto& act = signed_tx.actions.back(); auto act_data = act.data_as(); @@ -57,7 +57,7 @@ std::pair corrupt_trx_in_block(validating_te signed_block_ptr b = main.produce_block_no_validation(); // Make a copy of the valid block and corrupt the transaction - auto copy_b = std::make_shared(*b); + auto copy_b = std::make_shared(b->clone()); auto signed_tx = copy_b->transactions.back().trx.get().get_signed_transaction(); // Corrupt one signature signed_tx.signatures.clear(); diff --git a/unittests/forked_tests.cpp b/unittests/forked_tests.cpp index d4c8e4d3bd4..9543a791174 100644 --- a/unittests/forked_tests.cpp +++ b/unittests/forked_tests.cpp @@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE( fork_with_bad_block ) try { auto& fork = forks.at(j); if (j <= i) { - auto copy_b = std::make_shared(*b); + auto copy_b = std::make_shared(b->clone()); if (j == i) { // corrupt this block fork.block_merkle = remote.control->head_block_state()->blockroot_merkle; @@ -277,9 +277,9 @@ BOOST_AUTO_TEST_CASE( forking ) try { } wlog( "end push c2 blocks to c1" ); wlog( "now push dan's block to c1 but first corrupt it so it is a bad block" ); - auto bad_block = *b; + signed_block bad_block = std::move(*b); bad_block.transaction_mroot = bad_block.previous; - auto bad_block_bs = c.control->create_block_state_future( std::make_shared(bad_block) ); + auto bad_block_bs = c.control->create_block_state_future( std::make_shared(std::move(bad_block)) ); c.control->abort_block(); BOOST_REQUIRE_EXCEPTION(c.control->push_block( bad_block_bs ), fc::exception, [] (const fc::exception &ex)->bool { From a4a9ded0dfa49fdb554ed0143492acb84fe273c1 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 27 Nov 2018 13:51:41 -0500 Subject: [PATCH 010/111] Avoid making copies of signed_block --- plugins/net_plugin/net_plugin.cpp | 148 +++++++++++++++++++----------- 1 file changed, 92 insertions(+), 56 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index b2feb573077..62e4bc4dec6 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -60,8 +60,6 @@ namespace eosio { using socket_ptr = std::shared_ptr; - using net_message_ptr = shared_ptr; - struct node_transaction_state { transaction_id_type id; time_point_sec expires; /// time after which this may be purged. @@ -217,7 +215,8 @@ namespace eosio { void handle_message( connection_ptr c, const notice_message &msg); void handle_message( connection_ptr c, const request_message &msg); void handle_message( connection_ptr c, const sync_request_message &msg); - void handle_message( connection_ptr c, const signed_block &msg); + void handle_message( connection_ptr c, const signed_block &msg) = delete; // signed_block_ptr overload used instead + void handle_message( connection_ptr c, const signed_block_ptr &msg); void handle_message( connection_ptr c, const packed_transaction &msg); void start_conn_timer(boost::asio::steady_timer::duration du, std::weak_ptr from_connection); @@ -557,6 +556,8 @@ namespace eosio { void stop_send(); void enqueue( const net_message &msg, bool trigger_send = true ); + void enqueue_block( const signed_block_ptr& sb, bool trigger_send = true ); + void enqueue_buffer( const std::shared_ptr>& send_buffer, bool trigger_send, go_away_reason close_after_send ); void cancel_sync(go_away_reason); void flush_queues(); bool enqueue_sync_block(); @@ -612,13 +613,18 @@ namespace eosio { } }; - struct msgHandler : public fc::visitor { + struct msg_handler : public fc::visitor { net_plugin_impl &impl; connection_ptr c; - msgHandler( net_plugin_impl &imp, connection_ptr conn) : impl(imp), c(conn) {} + msg_handler( net_plugin_impl &imp, connection_ptr conn) : impl(imp), c(conn) {} + + void operator()( signed_block& msg ) const + { + impl.handle_message( c, std::make_shared( std::move( msg ))); + } template - void operator()(const T &msg) const + void operator()( const T& msg ) const { impl.handle_message( c, msg); } @@ -669,7 +675,7 @@ namespace eosio { void bcast_transaction (const packed_transaction& msg); void rejected_transaction (const transaction_id_type& msg); - void bcast_block (const signed_block& msg); + void bcast_block (const block_state_ptr& bs); void rejected_block (const block_id_type &id); void recv_block (connection_ptr conn, const block_id_type& msg, uint32_t bnum); @@ -895,7 +901,7 @@ namespace eosio { if (bstack.back()->previous == lib_id || bstack.back()->previous == remote_head_id) { count = bstack.size(); while (bstack.size()) { - enqueue(*bstack.back()); + enqueue_block( bstack.back() ); bstack.pop_back(); } } @@ -916,7 +922,7 @@ namespace eosio { signed_block_ptr b = cc.fetch_block_by_id(blkid); if(b) { fc_dlog(logger,"found block for id at num ${n}",("n",b->block_num())); - enqueue(net_message(*b)); + enqueue_block( b ); } else { ilog("fetch block by id returned null, id ${id} on block ${c} of ${s} for ${p}", @@ -1075,7 +1081,7 @@ namespace eosio { try { signed_block_ptr sb = cc.fetch_block_by_number(num); if(sb) { - enqueue( *sb, trigger_send); + enqueue_block( sb, trigger_send); return true; } } catch ( ... ) { @@ -1084,22 +1090,47 @@ namespace eosio { return false; } - void connection::enqueue( const net_message &m, bool trigger_send ) { + void connection::enqueue( const net_message& m, bool trigger_send ) { go_away_reason close_after_send = no_reason; if (m.contains()) { close_after_send = m.get().reason; } uint32_t payload_size = fc::raw::pack_size( m ); - char * header = reinterpret_cast(&payload_size); - size_t header_size = sizeof(payload_size); + char* header = reinterpret_cast(&payload_size); + size_t header_size = sizeof(payload_size); size_t buffer_size = header_size + payload_size; auto send_buffer = std::make_shared>(buffer_size); fc::datastream ds( send_buffer->data(), buffer_size); ds.write( header, header_size ); fc::raw::pack( ds, m ); + + enqueue_buffer( send_buffer, trigger_send, close_after_send ); + } + + void connection::enqueue_block( const signed_block_ptr& sb, bool trigger_send ) { + // this implementation is to avoid copy of signed_block to net_message + int which = 7; // matches which of net_message for signed_block + + uint32_t which_size = fc::raw::pack_size( unsigned_int( which )); + uint32_t payload_size = which_size + fc::raw::pack_size( *sb ); + + char* header = reinterpret_cast(&payload_size); + size_t header_size = sizeof(payload_size); + size_t buffer_size = header_size + payload_size; + + auto send_buffer = std::make_shared>(buffer_size); + fc::datastream ds( send_buffer->data(), buffer_size); + ds.write( header, header_size ); + fc::raw::pack( ds, unsigned_int( which )); + fc::raw::pack( ds, *sb ); + + enqueue_buffer( send_buffer, true, no_reason ); + } + + void connection::enqueue_buffer( const std::shared_ptr>& send_buffer, bool trigger_send, go_away_reason close_after_send ) { connection_wptr weak_this = shared_from_this(); queue_write(send_buffer,trigger_send, [weak_this, close_after_send](boost::system::error_code ec, std::size_t ) { @@ -1197,7 +1228,7 @@ namespace eosio { auto ds = pending_message_buffer.create_datastream(); net_message msg; fc::raw::unpack(ds, msg); - msgHandler m(impl, shared_from_this() ); + msg_handler m(impl, shared_from_this() ); msg.visit(m); } catch( const fc::exception& e ) { edump((e.to_detail_string() )); @@ -1589,49 +1620,55 @@ namespace eosio { //------------------------------------------------------------------------ - void dispatch_manager::bcast_block (const signed_block &bsum) { + void dispatch_manager::bcast_block (const block_state_ptr& bs) { std::set skips; - auto range = received_blocks.equal_range(bsum.id()); + auto range = received_blocks.equal_range(bs->id); for (auto org = range.first; org != range.second; ++org) { skips.insert(org->second); } received_blocks.erase(range.first, range.second); - net_message msg(bsum); - uint32_t packsiz = fc::raw::pack_size(msg); - uint32_t msgsiz = packsiz + sizeof(packsiz); - block_id_type bid = bsum.id(); - uint32_t bnum = bsum.block_num(); + block_id_type bid = bs->id; + uint32_t bnum = bs->block_num; + peer_block_state pbstate = {bid, bnum, false, true, time_point()}; - peer_block_state pbstate = {bid, bnum, false,true,time_point()}; // skip will be empty if our producer emitted this block so just send it - if (( large_msg_notify && msgsiz > just_send_it_max) && !skips.empty()) { - fc_ilog(logger, "block size is ${ms}, sending notify",("ms", msgsiz)); - notice_message pending_notify; - pending_notify.known_blocks.mode = normal; - pending_notify.known_blocks.ids.push_back( bid ); - pending_notify.known_trx.mode = none; - my_impl->send_all(pending_notify, [&skips, pbstate](connection_ptr c) -> bool { - if (skips.find(c) != skips.end() || !c->current()) - return false; - - bool unknown = c->add_peer_block(pbstate); - if (!unknown) { - elog("${p} already has knowledge of block ${b}", ("p",c->peer_name())("b",pbstate.block_num)); - } - return unknown; - }); + if( large_msg_notify ) { + int which = 7; + uint32_t whichsiz = fc::raw::pack_size( unsigned_int( which ) ); + uint32_t packsiz = whichsiz + fc::raw::pack_size( *bs->block ); + uint32_t msgsiz = packsiz + sizeof(packsiz); + + if( (msgsiz > just_send_it_max) && !skips.empty() ) { + fc_ilog( logger, "block size is ${ms}, sending notify", ("ms", msgsiz)); + notice_message pending_notify; + pending_notify.known_blocks.mode = normal; + pending_notify.known_blocks.ids.push_back( bid ); + pending_notify.known_trx.mode = none; + my_impl->send_all( pending_notify, [&skips, pbstate]( connection_ptr c ) -> bool { + if( skips.find( c ) != skips.end() || !c->current()) + return false; + + bool unknown = c->add_peer_block( pbstate ); + if( !unknown ) { + elog( "${p} already has knowledge of block ${b}", ("p", c->peer_name())( "b", pbstate.block_num )); + } + return unknown; + } ); + + return; + } } - else { - pbstate.is_known = true; - for (auto cp : my_impl->connections) { - if (skips.find(cp) != skips.end() || !cp->current()) { - continue; - } - cp->add_peer_block(pbstate); - cp->enqueue( msg ); + + pbstate.is_known = true; + for( auto cp : my_impl->connections ) { + if( skips.find( cp ) != skips.end() || !cp->current() ) { + continue; } + cp->add_peer_block( pbstate ); + cp->enqueue_block( bs->block ); } + } void dispatch_manager::recv_block (connection_ptr c, const block_id_type& id, uint32_t bnum) { @@ -1689,7 +1726,7 @@ namespace eosio { my_impl->local_txns.insert(std::move(nts)); if( !large_msg_notify || bufsiz <= just_send_it_max) { - my_impl->send_all( trx, [id, &skips, trx_expiration](connection_ptr c) -> bool { + my_impl->send_all( msg, [id, &skips, trx_expiration](connection_ptr c) -> bool { if( skips.find(c) != skips.end() || c->syncing ) { return false; } @@ -2484,10 +2521,10 @@ namespace eosio { }); } - void net_plugin_impl::handle_message( connection_ptr c, const signed_block &msg) { + void net_plugin_impl::handle_message( connection_ptr c, const signed_block_ptr& msg) { controller &cc = chain_plug->chain(); - block_id_type blk_id = msg.id(); - uint32_t blk_num = msg.block_num(); + block_id_type blk_id = msg->id(); + uint32_t blk_num = msg->block_num(); fc_dlog(logger, "canceling wait on ${p}", ("p",c->peer_name())); c->cancel_wait(); @@ -2502,14 +2539,13 @@ namespace eosio { } dispatcher->recv_block(c, blk_id, blk_num); - fc::microseconds age( fc::time_point::now() - msg.timestamp); + fc::microseconds age( fc::time_point::now() - msg->timestamp); peer_ilog(c, "received signed_block : #${n} block age in secs = ${age}", ("n",blk_num)("age",age.to_seconds())); go_away_reason reason = fatal_other; try { - signed_block_ptr sbp = std::make_shared(msg); - chain_plug->accept_block(sbp); //, sync_master->is_active(c)); + chain_plug->accept_block(msg); //, sync_master->is_active(c)); reason = no_reason; } catch( const unlinkable_block_exception &ex) { peer_elog(c, "bad signed_block : ${m}", ("m",ex.what())); @@ -2532,7 +2568,7 @@ namespace eosio { update_block_num ubn(blk_num); if( reason == no_reason ) { - for (const auto &recpt : msg.transactions) { + for (const auto &recpt : msg->transactions) { auto id = (recpt.trx.which() == 0) ? recpt.trx.get() : recpt.trx.get().id(); auto ltx = local_txns.get().find(id); if( ltx != local_txns.end()) { @@ -2662,10 +2698,10 @@ namespace eosio { void net_plugin_impl::accepted_block(const block_state_ptr& block) { fc_dlog(logger,"signaled, id = ${id}",("id", block->id)); - dispatcher->bcast_block(*block->block); + dispatcher->bcast_block(block); } - void net_plugin_impl::irreversible_block(const block_state_ptr&block) { + void net_plugin_impl::irreversible_block(const block_state_ptr& block) { fc_dlog(logger,"signaled, id = ${id}",("id", block->id)); } From 0213c88e7b2f4504dc8fd50ee609110c8a2c77be Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 27 Nov 2018 16:29:42 -0500 Subject: [PATCH 011/111] Use rvalue for signed_block --- plugins/chain_plugin/chain_plugin.cpp | 4 ++-- .../chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index cd8e6a96a90..215837fae46 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -1526,9 +1526,9 @@ fc::variant read_only::get_block_header_state(const get_block_header_state_param return vo; } -void read_write::push_block(read_write::push_block_params params, next_function next) { +void read_write::push_block(read_write::push_block_params&& params, next_function next) { try { - app().get_method()(std::make_shared(std::move(params))); + app().get_method()(std::make_shared(std::forward(params))); next(read_write::push_block_results{}); } catch ( boost::interprocess::bad_alloc& ) { chain_plugin::handle_db_exhaustion(); 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 26e6015dd6f..9be045700db 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp @@ -569,7 +569,7 @@ class read_write { using push_block_params = chain::signed_block; using push_block_results = empty; - void push_block(push_block_params params, chain::plugin_interface::next_function next); + void push_block(push_block_params&& params, chain::plugin_interface::next_function next); using push_transaction_params = fc::variant_object; struct push_transaction_results { From 466483852a115106fd3ca32a8ece49b790f6536c Mon Sep 17 00:00:00 2001 From: Emory Barlow Date: Tue, 27 Nov 2018 17:17:50 -0500 Subject: [PATCH 012/111] Update buildkite pipeline to use new queues --- .buildkite/pipeline.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 1cd49460163..3c7f63def07 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -442,7 +442,7 @@ steps: cd /data/job/build/packages && bash generate_package.sh deb label: ":ubuntu: 18.04 Package builder" agents: - - "role=linux-builder" + queue: "automation-large-builder-fleet" artifact_paths: - "build/packages/*.deb" plugins: @@ -469,7 +469,7 @@ steps: cd /data/job/build/packages && bash generate_package.sh rpm label: ":fedora: Package builder" agents: - - "role=linux-builder" + queue: "automation-large-builder-fleet" artifact_paths: - "build/packages/x86_64/*.rpm" plugins: @@ -496,7 +496,7 @@ steps: cd /data/job/build/packages && bash generate_package.sh rpm label: ":centos: Package builder" agents: - - "role=linux-builder" + queue: "automation-large-builder-fleet" artifact_paths: - "build/packages/x86_64/*.rpm" plugins: From 26bf33bea126bcf47facd98096f4ce429550b4c5 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 27 Nov 2018 17:35:20 -0500 Subject: [PATCH 013/111] Special case msg_handler visit of signed_block to avoid hidden move from net_message --- plugins/net_plugin/net_plugin.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 62e4bc4dec6..b591ef1ad0d 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -618,15 +618,20 @@ namespace eosio { connection_ptr c; msg_handler( net_plugin_impl &imp, connection_ptr conn) : impl(imp), c(conn) {} - void operator()( signed_block& msg ) const - { - impl.handle_message( c, std::make_shared( std::move( msg ))); + void operator()( const signed_block& msg ) const { + EOS_ASSERT( false, plugin_config_exception, "visit(signed_block&&) should be called" ); + } + void operator()( signed_block& msg ) const { + EOS_ASSERT( false, plugin_config_exception, "visit(signed_block&&) should be called" ); + } + void operator()( signed_block&& msg ) const { + impl.handle_message( c, std::make_shared( std::forward( msg ))); } template - void operator()( const T& msg ) const + void operator()( T&& msg ) const { - impl.handle_message( c, msg); + impl.handle_message( c, std::forward(msg) ); } }; @@ -1229,7 +1234,11 @@ namespace eosio { net_message msg; fc::raw::unpack(ds, msg); msg_handler m(impl, shared_from_this() ); - msg.visit(m); + if( msg.contains() ) { + m( std::move( msg.get() ) ); + } else { + msg.visit( m ); + } } catch( const fc::exception& e ) { edump((e.to_detail_string() )); impl.close( shared_from_this() ); From 3d994149257e36d0a74d31c9cd8c0018b909c077 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 27 Nov 2018 17:36:00 -0500 Subject: [PATCH 014/111] pass along trigger_send --- plugins/net_plugin/net_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index b591ef1ad0d..49212e2d8ed 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1132,7 +1132,7 @@ namespace eosio { fc::raw::pack( ds, unsigned_int( which )); fc::raw::pack( ds, *sb ); - enqueue_buffer( send_buffer, true, no_reason ); + enqueue_buffer( send_buffer, trigger_send, no_reason ); } void connection::enqueue_buffer( const std::shared_ptr>& send_buffer, bool trigger_send, go_away_reason close_after_send ) { From 07deed1a0d40a3cad2e2de607931026358e21078 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 27 Nov 2018 19:36:51 -0500 Subject: [PATCH 015/111] Use move for rvalue --- plugins/chain_plugin/chain_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 215837fae46..cf7a34ebd01 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -1528,7 +1528,7 @@ fc::variant read_only::get_block_header_state(const get_block_header_state_param void read_write::push_block(read_write::push_block_params&& params, next_function next) { try { - app().get_method()(std::make_shared(std::forward(params))); + app().get_method()(std::make_shared(std::move(params))); next(read_write::push_block_results{}); } catch ( boost::interprocess::bad_alloc& ) { chain_plugin::handle_db_exhaustion(); From 08c303e128211c8a2113eb920b7e430bbe746456 Mon Sep 17 00:00:00 2001 From: Greg Lee Date: Tue, 27 Nov 2018 20:36:05 -0500 Subject: [PATCH 016/111] Added Mongo History API link --- plugins/COMMUNITY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/COMMUNITY.md b/plugins/COMMUNITY.md index db7d2139d83..b4f6db992d9 100644 --- a/plugins/COMMUNITY.md +++ b/plugins/COMMUNITY.md @@ -13,6 +13,7 @@ Third parties are encouraged to make pull requests to this file (`develop` branc | SQL | https://github.com/asiniscalchi/eosio_sql_plugin | | Watch for specific actions and send them to an HTTP URL | https://github.com/eosauthority/eosio-watcher-plugin | | ZMQ / history | https://github.com/cc32d9/eos_zmq_plugin | +| Mongo History API | https://github.com/CryptoLions/EOS-mongo-history-API | ## DISCLAIMER: From 15e610ca292ecef8778613131b0176bda1988a73 Mon Sep 17 00:00:00 2001 From: Greg Lee Date: Tue, 27 Nov 2018 20:39:37 -0500 Subject: [PATCH 017/111] Added ZMQ Light History API --- plugins/COMMUNITY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/COMMUNITY.md b/plugins/COMMUNITY.md index b4f6db992d9..37a74877f0f 100644 --- a/plugins/COMMUNITY.md +++ b/plugins/COMMUNITY.md @@ -13,6 +13,7 @@ Third parties are encouraged to make pull requests to this file (`develop` branc | SQL | https://github.com/asiniscalchi/eosio_sql_plugin | | Watch for specific actions and send them to an HTTP URL | https://github.com/eosauthority/eosio-watcher-plugin | | ZMQ / history | https://github.com/cc32d9/eos_zmq_plugin | +| ZMQ Light History API | https://github.com/cc32d9/eos_zmq_light_api | | Mongo History API | https://github.com/CryptoLions/EOS-mongo-history-API | ## DISCLAIMER: From 97d2e977fea2c89ed0cc1d2ce77ffffd0ade5622 Mon Sep 17 00:00:00 2001 From: Greg Lee Date: Tue, 27 Nov 2018 20:42:43 -0500 Subject: [PATCH 018/111] Added Chintai ZMQ Watcher --- plugins/COMMUNITY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/COMMUNITY.md b/plugins/COMMUNITY.md index 37a74877f0f..87b6c56aca9 100644 --- a/plugins/COMMUNITY.md +++ b/plugins/COMMUNITY.md @@ -14,6 +14,7 @@ Third parties are encouraged to make pull requests to this file (`develop` branc | Watch for specific actions and send them to an HTTP URL | https://github.com/eosauthority/eosio-watcher-plugin | | ZMQ / history | https://github.com/cc32d9/eos_zmq_plugin | | ZMQ Light History API | https://github.com/cc32d9/eos_zmq_light_api | +| Chintai ZMQ Watcher | https://github.com/acoutts/chintai-zeromq-watcher-plugin | | Mongo History API | https://github.com/CryptoLions/EOS-mongo-history-API | ## DISCLAIMER: From 5fea075f1aa9952e526ba1654fe4def3bf441efe Mon Sep 17 00:00:00 2001 From: Greg Lee Date: Tue, 27 Nov 2018 20:46:43 -0500 Subject: [PATCH 019/111] Added State History API --- plugins/COMMUNITY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/COMMUNITY.md b/plugins/COMMUNITY.md index 87b6c56aca9..55cce74a33b 100644 --- a/plugins/COMMUNITY.md +++ b/plugins/COMMUNITY.md @@ -16,6 +16,7 @@ Third parties are encouraged to make pull requests to this file (`develop` branc | ZMQ Light History API | https://github.com/cc32d9/eos_zmq_light_api | | Chintai ZMQ Watcher | https://github.com/acoutts/chintai-zeromq-watcher-plugin | | Mongo History API | https://github.com/CryptoLions/EOS-mongo-history-API | +| State History API | https://github.com/acoutts/EOS-state-history-API | ## DISCLAIMER: From bdd072626a7611e05e8e71513d4a91d34a1a4cbe Mon Sep 17 00:00:00 2001 From: evsward Date: Wed, 28 Nov 2018 10:03:21 +0800 Subject: [PATCH 020/111] Stop the unix_server from listening in shutdown stage as well. --- plugins/http_plugin/http_plugin.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/http_plugin/http_plugin.cpp b/plugins/http_plugin/http_plugin.cpp index d9be006bb45..d1247c7d491 100644 --- a/plugins/http_plugin/http_plugin.cpp +++ b/plugins/http_plugin/http_plugin.cpp @@ -548,6 +548,8 @@ namespace eosio { my->server.stop_listening(); if(my->https_server.is_listening()) my->https_server.stop_listening(); + if(my->unix_server.is_listening()) + my->unix_server.stop_listening(); } void http_plugin::add_handler(const string& url, const url_handler& handler) { From 9b036b432c241bcb5f506ab179988ef63c08f053 Mon Sep 17 00:00:00 2001 From: Jeeyong Um Date: Sun, 2 Dec 2018 19:54:13 +0900 Subject: [PATCH 021/111] Update LICENSE path --- contracts/asserter/asserter.cpp | 2 +- contracts/asserter/asserter.hpp | 2 +- contracts/eosio.system/delegate_bandwidth.cpp | 2 +- contracts/eosio.system/eosio.system.hpp | 2 +- contracts/eosio.system/native.hpp | 2 +- contracts/eosio.system/voting.cpp | 2 +- contracts/eosio.token/eosio.token.cpp | 2 +- contracts/eosio.token/eosio.token.hpp | 2 +- contracts/eosiolib/action.h | 2 +- contracts/eosiolib/action.hpp | 2 +- contracts/eosiolib/chain.h | 2 +- contracts/eosiolib/compiler_builtins.h | 2 +- contracts/eosiolib/core_symbol.hpp.in | 2 +- contracts/eosiolib/crypto.h | 2 +- contracts/eosiolib/datastream.hpp | 2 +- contracts/eosiolib/db.h | 2 +- contracts/eosiolib/eosio.hpp | 2 +- contracts/eosiolib/fixed_key.hpp | 2 +- contracts/eosiolib/memory.h | 2 +- contracts/eosiolib/memory.hpp | 2 +- contracts/eosiolib/multi_index.hpp | 2 +- contracts/eosiolib/permission.h | 2 +- contracts/eosiolib/permission.hpp | 2 +- contracts/eosiolib/print.h | 2 +- contracts/eosiolib/print.hpp | 2 +- contracts/eosiolib/system.h | 2 +- contracts/eosiolib/transaction.h | 2 +- contracts/eosiolib/transaction.hpp | 2 +- contracts/eosiolib/types.h | 2 +- contracts/eosiolib/types.hpp | 2 +- contracts/eosiolib/varint.hpp | 2 +- contracts/noop/noop.cpp | 2 +- contracts/proxy/proxy.cpp | 2 +- contracts/proxy/proxy.hpp | 2 +- contracts/skeleton/skeleton.hpp | 2 +- contracts/stltest/stltest.cpp | 2 +- contracts/test_api/test_action.cpp | 2 +- contracts/test_api/test_api.cpp | 2 +- contracts/test_api/test_api.hpp | 2 +- contracts/test_api/test_api_common.hpp | 2 +- contracts/test_api/test_chain.cpp | 2 +- contracts/test_api/test_checktime.cpp | 2 +- contracts/test_api/test_compiler_builtins.cpp | 2 +- contracts/test_api/test_crypto.cpp | 2 +- contracts/test_api/test_permission.cpp | 2 +- contracts/test_api/test_print.cpp | 2 +- contracts/test_api/test_transaction.cpp | 2 +- contracts/test_api/test_types.cpp | 2 +- contracts/test_api_db/test_api_db.cpp | 2 +- contracts/test_api_mem/test_api_mem.cpp | 2 +- contracts/test_api_mem/test_memory.cpp | 2 +- contracts/test_api_multi_index/test_api_multi_index.cpp | 2 +- contracts/test_ram_limit/test_ram_limit.cpp | 2 +- contracts/tic_tac_toe/tic_tac_toe.cpp | 2 +- contracts/tic_tac_toe/tic_tac_toe.hpp | 2 +- libraries/chain/abi_serializer.cpp | 2 +- libraries/chain/asset.cpp | 2 +- libraries/chain/authorization_manager.cpp | 2 +- libraries/chain/block_header.cpp | 2 +- libraries/chain/block_log.cpp | 2 +- libraries/chain/chain_config.cpp | 2 +- libraries/chain/chain_id_type.cpp | 2 +- libraries/chain/eosio_contract.cpp | 2 +- libraries/chain/genesis_state.cpp | 2 +- libraries/chain/genesis_state_root_key.cpp.in | 2 +- libraries/chain/include/eosio/chain/abi_def.hpp | 2 +- libraries/chain/include/eosio/chain/abi_serializer.hpp | 2 +- libraries/chain/include/eosio/chain/account_object.hpp | 2 +- libraries/chain/include/eosio/chain/action.hpp | 2 +- libraries/chain/include/eosio/chain/action_receipt.hpp | 2 +- libraries/chain/include/eosio/chain/apply_context.hpp | 2 +- libraries/chain/include/eosio/chain/asset.hpp | 2 +- libraries/chain/include/eosio/chain/authority.hpp | 2 +- libraries/chain/include/eosio/chain/authority_checker.hpp | 2 +- libraries/chain/include/eosio/chain/authorization_manager.hpp | 2 +- libraries/chain/include/eosio/chain/block_log.hpp | 2 +- libraries/chain/include/eosio/chain/block_state.hpp | 2 +- libraries/chain/include/eosio/chain/block_summary_object.hpp | 2 +- libraries/chain/include/eosio/chain/chain_config.hpp | 2 +- libraries/chain/include/eosio/chain/chain_id_type.hpp | 2 +- libraries/chain/include/eosio/chain/chain_snapshot.hpp | 2 +- libraries/chain/include/eosio/chain/config.hpp | 2 +- libraries/chain/include/eosio/chain/contract_table_objects.hpp | 2 +- libraries/chain/include/eosio/chain/core_symbol.hpp.in | 2 +- libraries/chain/include/eosio/chain/database_utils.hpp | 2 +- libraries/chain/include/eosio/chain/eosio_contract.hpp | 2 +- libraries/chain/include/eosio/chain/exceptions.hpp | 2 +- libraries/chain/include/eosio/chain/fixed_key.hpp | 2 +- .../chain/include/eosio/chain/generated_transaction_object.hpp | 2 +- libraries/chain/include/eosio/chain/genesis_state.hpp | 2 +- libraries/chain/include/eosio/chain/global_property_object.hpp | 2 +- libraries/chain/include/eosio/chain/multi_index_includes.hpp | 2 +- libraries/chain/include/eosio/chain/parallel_markers.hpp | 2 +- libraries/chain/include/eosio/chain/permission_link_object.hpp | 2 +- libraries/chain/include/eosio/chain/permission_object.hpp | 2 +- libraries/chain/include/eosio/chain/producer_object.hpp | 2 +- libraries/chain/include/eosio/chain/protocol.hpp | 2 +- libraries/chain/include/eosio/chain/reversible_block_object.hpp | 2 +- libraries/chain/include/eosio/chain/snapshot.hpp | 2 +- libraries/chain/include/eosio/chain/symbol.hpp | 2 +- libraries/chain/include/eosio/chain/trace.hpp | 2 +- libraries/chain/include/eosio/chain/transaction.hpp | 2 +- libraries/chain/include/eosio/chain/transaction_metadata.hpp | 2 +- libraries/chain/include/eosio/chain/transaction_object.hpp | 2 +- libraries/chain/include/eosio/chain/types.hpp | 2 +- libraries/chain/include/eosio/chain/wast_to_wasm.hpp | 2 +- libraries/chain/transaction.cpp | 2 +- libraries/chain/wast_to_wasm.cpp | 2 +- plugins/bnet_plugin/include/eosio/bnet_plugin/bnet_plugin.hpp | 2 +- plugins/chain_api_plugin/chain_api_plugin.cpp | 2 +- .../include/eosio/chain_api_plugin/chain_api_plugin.hpp | 2 +- .../chain_interface/include/eosio/chain/plugin_interface.hpp | 2 +- plugins/chain_plugin/chain_plugin.cpp | 2 +- .../chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp | 2 +- plugins/db_size_api_plugin/db_size_api_plugin.cpp | 2 +- .../include/eosio/db_size_api_plugin/db_size_api_plugin.hpp | 2 +- plugins/faucet_testnet_plugin/faucet_testnet_plugin.cpp | 2 +- .../eosio/faucet_testnet_plugin/faucet_testnet_plugin.hpp | 2 +- plugins/history_api_plugin/history_api_plugin.cpp | 2 +- .../include/eosio/history_api_plugin/history_api_plugin.hpp | 2 +- .../eosio/history_plugin/account_control_history_object.hpp | 2 +- .../include/eosio/history_plugin/history_plugin.hpp | 2 +- .../include/eosio/history_plugin/public_key_history_object.hpp | 2 +- plugins/http_client_plugin/http_client_plugin.cpp | 2 +- .../include/eosio/http_client_plugin/http_client_plugin.hpp | 2 +- plugins/http_plugin/http_plugin.cpp | 2 +- plugins/http_plugin/include/eosio/http_plugin/http_plugin.hpp | 2 +- .../login_plugin/include/eosio/login_plugin/login_plugin.hpp | 2 +- plugins/login_plugin/login_plugin.cpp | 2 +- .../include/eosio/mongo_db_plugin/mongo_db_plugin.hpp | 2 +- plugins/mongo_db_plugin/mongo_db_plugin.cpp | 2 +- .../include/eosio/net_api_plugin/net_api_plugin.hpp | 2 +- plugins/net_api_plugin/net_api_plugin.cpp | 2 +- plugins/net_plugin/include/eosio/net_plugin/net_plugin.hpp | 2 +- plugins/net_plugin/include/eosio/net_plugin/protocol.hpp | 2 +- plugins/net_plugin/net_plugin.cpp | 2 +- .../include/eosio/producer_api_plugin/producer_api_plugin.hpp | 2 +- plugins/producer_api_plugin/producer_api_plugin.cpp | 2 +- .../include/eosio/producer_plugin/producer_plugin.hpp | 2 +- plugins/producer_plugin/producer_plugin.cpp | 2 +- .../include/eosio/state_history_plugin/state_history_log.hpp | 2 +- .../include/eosio/state_history_plugin/state_history_plugin.hpp | 2 +- .../eosio/state_history_plugin/state_history_serialization.hpp | 2 +- plugins/state_history_plugin/state_history_plugin.cpp | 2 +- .../include/eosio/template_plugin/template_plugin.hpp | 2 +- plugins/template_plugin/template_plugin.cpp | 2 +- .../eosio/test_control_api_plugin/test_control_api_plugin.hpp | 2 +- plugins/test_control_api_plugin/test_control_api_plugin.cpp | 2 +- .../include/eosio/test_control_plugin/test_control_plugin.hpp | 2 +- plugins/test_control_plugin/test_control_plugin.cpp | 2 +- .../include/eosio/txn_test_gen_plugin/txn_test_gen_plugin.hpp | 2 +- plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp | 2 +- .../include/eosio/wallet_api_plugin/wallet_api_plugin.hpp | 2 +- plugins/wallet_api_plugin/wallet_api_plugin.cpp | 2 +- plugins/wallet_plugin/include/eosio/wallet_plugin/wallet.hpp | 2 +- .../wallet_plugin/include/eosio/wallet_plugin/wallet_api.hpp | 2 +- .../include/eosio/wallet_plugin/wallet_manager.hpp | 2 +- .../wallet_plugin/include/eosio/wallet_plugin/wallet_plugin.hpp | 2 +- plugins/wallet_plugin/se_wallet.cpp | 2 +- plugins/wallet_plugin/wallet.cpp | 2 +- plugins/wallet_plugin/wallet_manager.cpp | 2 +- plugins/wallet_plugin/wallet_plugin.cpp | 2 +- plugins/wallet_plugin/yubihsm_wallet.cpp | 2 +- programs/cleos/config.hpp.in | 2 +- programs/cleos/help_text.cpp | 2 +- programs/cleos/help_text.hpp | 2 +- programs/cleos/httpc.hpp | 2 +- programs/cleos/localize.hpp | 2 +- programs/cleos/main.cpp | 2 +- programs/eosio-launcher/config.hpp.in | 2 +- programs/eosio-launcher/main.cpp | 2 +- programs/keosd/config.hpp.in | 2 +- programs/keosd/main.cpp | 2 +- programs/nodeos/config.hpp.in | 2 +- tests/main.cpp | 2 +- tests/wallet_tests.cpp | 2 +- unittests/abi_tests.cpp | 2 +- unittests/api_tests.cpp | 2 +- unittests/block_tests.cpp | 2 +- unittests/block_timestamp_tests.cpp | 2 +- unittests/contracts/deferred_test/deferred_test.cpp | 2 +- unittests/database_tests.cpp | 2 +- unittests/eosio_system_tester.hpp | 2 +- unittests/include/config.hpp.in | 2 +- unittests/main.cpp | 2 +- unittests/message_buffer_tests.cpp | 2 +- unittests/misc_tests.cpp | 2 +- unittests/ram_tests.cpp | 2 +- unittests/snapshot_tests.cpp | 2 +- unittests/special_accounts_tests.cpp | 2 +- 190 files changed, 190 insertions(+), 190 deletions(-) diff --git a/contracts/asserter/asserter.cpp b/contracts/asserter/asserter.cpp index f64ea509a1f..c89db1fc709 100644 --- a/contracts/asserter/asserter.cpp +++ b/contracts/asserter/asserter.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include /// defines assert_def struct (abi) diff --git a/contracts/asserter/asserter.hpp b/contracts/asserter/asserter.hpp index 99680870c04..01d4b343e3f 100644 --- a/contracts/asserter/asserter.hpp +++ b/contracts/asserter/asserter.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/contracts/eosio.system/delegate_bandwidth.cpp b/contracts/eosio.system/delegate_bandwidth.cpp index 1e190e9fe3c..d37ee0554ea 100644 --- a/contracts/eosio.system/delegate_bandwidth.cpp +++ b/contracts/eosio.system/delegate_bandwidth.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include "eosio.system.hpp" diff --git a/contracts/eosio.system/eosio.system.hpp b/contracts/eosio.system/eosio.system.hpp index a33238a1eaa..f66375aef0b 100644 --- a/contracts/eosio.system/eosio.system.hpp +++ b/contracts/eosio.system/eosio.system.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/eosio.system/native.hpp b/contracts/eosio.system/native.hpp index e6395807395..e2bcb319575 100644 --- a/contracts/eosio.system/native.hpp +++ b/contracts/eosio.system/native.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/eosio.system/voting.cpp b/contracts/eosio.system/voting.cpp index 166f1707cd7..bf82c913802 100644 --- a/contracts/eosio.system/voting.cpp +++ b/contracts/eosio.system/voting.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include "eosio.system.hpp" diff --git a/contracts/eosio.token/eosio.token.cpp b/contracts/eosio.token/eosio.token.cpp index 351d81c47c5..4570b19b5c9 100644 --- a/contracts/eosio.token/eosio.token.cpp +++ b/contracts/eosio.token/eosio.token.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include "eosio.token.hpp" diff --git a/contracts/eosio.token/eosio.token.hpp b/contracts/eosio.token/eosio.token.hpp index 15875134777..48312c9edb4 100644 --- a/contracts/eosio.token/eosio.token.hpp +++ b/contracts/eosio.token/eosio.token.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/eosiolib/action.h b/contracts/eosiolib/action.h index 3e686fe469d..f8deba837b8 100644 --- a/contracts/eosiolib/action.h +++ b/contracts/eosiolib/action.h @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/contracts/eosiolib/action.hpp b/contracts/eosiolib/action.hpp index 11028f09e93..d4538c2972e 100644 --- a/contracts/eosiolib/action.hpp +++ b/contracts/eosiolib/action.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/contracts/eosiolib/chain.h b/contracts/eosiolib/chain.h index 8477968be9e..ec4f219b4b9 100644 --- a/contracts/eosiolib/chain.h +++ b/contracts/eosiolib/chain.h @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/eosiolib/compiler_builtins.h b/contracts/eosiolib/compiler_builtins.h index 3e0d9435357..c2dc09bb356 100644 --- a/contracts/eosiolib/compiler_builtins.h +++ b/contracts/eosiolib/compiler_builtins.h @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/eosiolib/core_symbol.hpp.in b/contracts/eosiolib/core_symbol.hpp.in index 4a60220b6a9..3262d2aad10 100644 --- a/contracts/eosiolib/core_symbol.hpp.in +++ b/contracts/eosiolib/core_symbol.hpp.in @@ -1,5 +1,5 @@ /** @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE * * \warning This file is machine generated. DO NOT EDIT. See core_symbol.hpp.in for changes. */ diff --git a/contracts/eosiolib/crypto.h b/contracts/eosiolib/crypto.h index 916c25954f7..0133762c43b 100644 --- a/contracts/eosiolib/crypto.h +++ b/contracts/eosiolib/crypto.h @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/contracts/eosiolib/datastream.hpp b/contracts/eosiolib/datastream.hpp index 65666e78cc4..97aed9f4cf7 100644 --- a/contracts/eosiolib/datastream.hpp +++ b/contracts/eosiolib/datastream.hpp @@ -1,6 +1,6 @@ /** * @file datastream.hpp - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/contracts/eosiolib/db.h b/contracts/eosiolib/db.h index d2c01b6b15d..f112ef5bf6d 100644 --- a/contracts/eosiolib/db.h +++ b/contracts/eosiolib/db.h @@ -1,6 +1,6 @@ /** * @file db.h - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE * @brief Defines C API for interfacing with blockchain database */ #pragma once diff --git a/contracts/eosiolib/eosio.hpp b/contracts/eosiolib/eosio.hpp index 3e850a69dea..2126abb3203 100644 --- a/contracts/eosiolib/eosio.hpp +++ b/contracts/eosiolib/eosio.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/contracts/eosiolib/fixed_key.hpp b/contracts/eosiolib/fixed_key.hpp index eb04a45b46c..4e8cd8241da 100644 --- a/contracts/eosiolib/fixed_key.hpp +++ b/contracts/eosiolib/fixed_key.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/eosiolib/memory.h b/contracts/eosiolib/memory.h index 58e5a482b3d..474e7c7b598 100644 --- a/contracts/eosiolib/memory.h +++ b/contracts/eosiolib/memory.h @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/eosiolib/memory.hpp b/contracts/eosiolib/memory.hpp index 4a4f56a1c48..f2abbf898d2 100644 --- a/contracts/eosiolib/memory.hpp +++ b/contracts/eosiolib/memory.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/eosiolib/multi_index.hpp b/contracts/eosiolib/multi_index.hpp index d7082559059..cba34f103a0 100644 --- a/contracts/eosiolib/multi_index.hpp +++ b/contracts/eosiolib/multi_index.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/eosiolib/permission.h b/contracts/eosiolib/permission.h index 8acd07fd553..743b499bca8 100644 --- a/contracts/eosiolib/permission.h +++ b/contracts/eosiolib/permission.h @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/contracts/eosiolib/permission.hpp b/contracts/eosiolib/permission.hpp index a6956f5dd28..668fa79bff9 100644 --- a/contracts/eosiolib/permission.hpp +++ b/contracts/eosiolib/permission.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/eosiolib/print.h b/contracts/eosiolib/print.h index 63fd1da9d54..ab7dfcc8ade 100644 --- a/contracts/eosiolib/print.h +++ b/contracts/eosiolib/print.h @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/eosiolib/print.hpp b/contracts/eosiolib/print.hpp index a90a277cf47..84bdf263aa3 100644 --- a/contracts/eosiolib/print.hpp +++ b/contracts/eosiolib/print.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/contracts/eosiolib/system.h b/contracts/eosiolib/system.h index 62a5cfeef51..b7d3e614107 100644 --- a/contracts/eosiolib/system.h +++ b/contracts/eosiolib/system.h @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/contracts/eosiolib/transaction.h b/contracts/eosiolib/transaction.h index dd7c05ded17..fa51c114126 100644 --- a/contracts/eosiolib/transaction.h +++ b/contracts/eosiolib/transaction.h @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/contracts/eosiolib/transaction.hpp b/contracts/eosiolib/transaction.hpp index 1586b92b09b..2b5e1f1fb2a 100644 --- a/contracts/eosiolib/transaction.hpp +++ b/contracts/eosiolib/transaction.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/contracts/eosiolib/types.h b/contracts/eosiolib/types.h index 120c896cd87..1611df2aad2 100644 --- a/contracts/eosiolib/types.h +++ b/contracts/eosiolib/types.h @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/eosiolib/types.hpp b/contracts/eosiolib/types.hpp index d535f49e922..f1e7c10dcd1 100644 --- a/contracts/eosiolib/types.hpp +++ b/contracts/eosiolib/types.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/contracts/eosiolib/varint.hpp b/contracts/eosiolib/varint.hpp index b8240839aa0..dcc444f20d6 100644 --- a/contracts/eosiolib/varint.hpp +++ b/contracts/eosiolib/varint.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/noop/noop.cpp b/contracts/noop/noop.cpp index 67f3f101f14..6699eca57c9 100644 --- a/contracts/noop/noop.cpp +++ b/contracts/noop/noop.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/contracts/proxy/proxy.cpp b/contracts/proxy/proxy.cpp index ff27e5d5af2..3d243fd4e02 100644 --- a/contracts/proxy/proxy.cpp +++ b/contracts/proxy/proxy.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/contracts/proxy/proxy.hpp b/contracts/proxy/proxy.hpp index fd439e3c274..924edd24b10 100644 --- a/contracts/proxy/proxy.hpp +++ b/contracts/proxy/proxy.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/skeleton/skeleton.hpp b/contracts/skeleton/skeleton.hpp index ec28c3d168b..2b621b6f2ed 100644 --- a/contracts/skeleton/skeleton.hpp +++ b/contracts/skeleton/skeleton.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/contracts/stltest/stltest.cpp b/contracts/stltest/stltest.cpp index 79828877f98..baf975ff703 100644 --- a/contracts/stltest/stltest.cpp +++ b/contracts/stltest/stltest.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ // include entire libc #include diff --git a/contracts/test_api/test_action.cpp b/contracts/test_api/test_action.cpp index 496b30fcc37..20eacaa1bd8 100644 --- a/contracts/test_api/test_action.cpp +++ b/contracts/test_api/test_action.cpp @@ -1,6 +1,6 @@ /** * @file action_test.cpp - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/contracts/test_api/test_api.cpp b/contracts/test_api/test_api.cpp index 9ddcb712752..ce7b44d6c9f 100644 --- a/contracts/test_api/test_api.cpp +++ b/contracts/test_api/test_api.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/contracts/test_api/test_api.hpp b/contracts/test_api/test_api.hpp index 4dc5711e3a1..5406dff5520 100644 --- a/contracts/test_api/test_api.hpp +++ b/contracts/test_api/test_api.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include "test_api_common.hpp" diff --git a/contracts/test_api/test_api_common.hpp b/contracts/test_api/test_api_common.hpp index 8d63a535089..d78afa29bb3 100644 --- a/contracts/test_api/test_api_common.hpp +++ b/contracts/test_api/test_api_common.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/contracts/test_api/test_chain.cpp b/contracts/test_api/test_chain.cpp index 6c71eb78eda..22f4ca4f914 100644 --- a/contracts/test_api/test_chain.cpp +++ b/contracts/test_api/test_chain.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/contracts/test_api/test_checktime.cpp b/contracts/test_api/test_checktime.cpp index 4f6bef4659a..a227ee91b04 100644 --- a/contracts/test_api/test_checktime.cpp +++ b/contracts/test_api/test_checktime.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/contracts/test_api/test_compiler_builtins.cpp b/contracts/test_api/test_compiler_builtins.cpp index 1492110b82e..a7571b0a2ce 100644 --- a/contracts/test_api/test_compiler_builtins.cpp +++ b/contracts/test_api/test_compiler_builtins.cpp @@ -1,6 +1,6 @@ /** * @file test_compiler_builtins.cpp - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/contracts/test_api/test_crypto.cpp b/contracts/test_api/test_crypto.cpp index 526ec4170af..3b96e6e6fad 100644 --- a/contracts/test_api/test_crypto.cpp +++ b/contracts/test_api/test_crypto.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/contracts/test_api/test_permission.cpp b/contracts/test_api/test_permission.cpp index 824e8434b7d..f26c120a0a1 100644 --- a/contracts/test_api/test_permission.cpp +++ b/contracts/test_api/test_permission.cpp @@ -1,6 +1,6 @@ /** * @file action_test.cpp - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/contracts/test_api/test_print.cpp b/contracts/test_api/test_print.cpp index 310834037b2..a042ff6f57a 100644 --- a/contracts/test_api/test_print.cpp +++ b/contracts/test_api/test_print.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/contracts/test_api/test_transaction.cpp b/contracts/test_api/test_transaction.cpp index 95030419f58..cc1128ae5f6 100644 --- a/contracts/test_api/test_transaction.cpp +++ b/contracts/test_api/test_transaction.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/contracts/test_api/test_types.cpp b/contracts/test_api/test_types.cpp index d3cf87b9614..bc9dca52e2a 100644 --- a/contracts/test_api/test_types.cpp +++ b/contracts/test_api/test_types.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/contracts/test_api_db/test_api_db.cpp b/contracts/test_api_db/test_api_db.cpp index 706734ba967..d603477a631 100644 --- a/contracts/test_api_db/test_api_db.cpp +++ b/contracts/test_api_db/test_api_db.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include "../test_api/test_api.hpp" diff --git a/contracts/test_api_mem/test_api_mem.cpp b/contracts/test_api_mem/test_api_mem.cpp index e01bba16378..ce59249425d 100644 --- a/contracts/test_api_mem/test_api_mem.cpp +++ b/contracts/test_api_mem/test_api_mem.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include "../test_api/test_api.hpp" diff --git a/contracts/test_api_mem/test_memory.cpp b/contracts/test_api_mem/test_memory.cpp index d3f387fd8b1..3e1eb52243e 100644 --- a/contracts/test_api_mem/test_memory.cpp +++ b/contracts/test_api_mem/test_memory.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/contracts/test_api_multi_index/test_api_multi_index.cpp b/contracts/test_api_multi_index/test_api_multi_index.cpp index 9c5713385ad..828a1d75b88 100644 --- a/contracts/test_api_multi_index/test_api_multi_index.cpp +++ b/contracts/test_api_multi_index/test_api_multi_index.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include "../test_api/test_api.hpp" diff --git a/contracts/test_ram_limit/test_ram_limit.cpp b/contracts/test_ram_limit/test_ram_limit.cpp index 136c27aa72c..c162cea6585 100644 --- a/contracts/test_ram_limit/test_ram_limit.cpp +++ b/contracts/test_ram_limit/test_ram_limit.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/contracts/tic_tac_toe/tic_tac_toe.cpp b/contracts/tic_tac_toe/tic_tac_toe.cpp index ebc5cc46203..a6eb62eccf6 100644 --- a/contracts/tic_tac_toe/tic_tac_toe.cpp +++ b/contracts/tic_tac_toe/tic_tac_toe.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include "tic_tac_toe.hpp" diff --git a/contracts/tic_tac_toe/tic_tac_toe.hpp b/contracts/tic_tac_toe/tic_tac_toe.hpp index 4339ab212e1..f4f32982ff6 100644 --- a/contracts/tic_tac_toe/tic_tac_toe.hpp +++ b/contracts/tic_tac_toe/tic_tac_toe.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/libraries/chain/abi_serializer.cpp b/libraries/chain/abi_serializer.cpp index b5f67e51059..2f453e0cf93 100644 --- a/libraries/chain/abi_serializer.cpp +++ b/libraries/chain/abi_serializer.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/libraries/chain/asset.cpp b/libraries/chain/asset.cpp index 142e04cffa3..580156f6d21 100644 --- a/libraries/chain/asset.cpp +++ b/libraries/chain/asset.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/libraries/chain/authorization_manager.cpp b/libraries/chain/authorization_manager.cpp index 832f69c71cd..dd4de2ce22b 100644 --- a/libraries/chain/authorization_manager.cpp +++ b/libraries/chain/authorization_manager.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/libraries/chain/block_header.cpp b/libraries/chain/block_header.cpp index 8ba95b705e2..d623406fd25 100644 --- a/libraries/chain/block_header.cpp +++ b/libraries/chain/block_header.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/libraries/chain/block_log.cpp b/libraries/chain/block_log.cpp index 439ad5b5d61..41e9756483e 100644 --- a/libraries/chain/block_log.cpp +++ b/libraries/chain/block_log.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/libraries/chain/chain_config.cpp b/libraries/chain/chain_config.cpp index 974675749fb..35c77f8325d 100644 --- a/libraries/chain/chain_config.cpp +++ b/libraries/chain/chain_config.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/libraries/chain/chain_id_type.cpp b/libraries/chain/chain_id_type.cpp index efddb213c6f..898b8170d1d 100644 --- a/libraries/chain/chain_id_type.cpp +++ b/libraries/chain/chain_id_type.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/libraries/chain/eosio_contract.cpp b/libraries/chain/eosio_contract.cpp index e41fe815834..8d1a8dc7562 100644 --- a/libraries/chain/eosio_contract.cpp +++ b/libraries/chain/eosio_contract.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/libraries/chain/genesis_state.cpp b/libraries/chain/genesis_state.cpp index 40257a6168b..23d8986e5bd 100644 --- a/libraries/chain/genesis_state.cpp +++ b/libraries/chain/genesis_state.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/libraries/chain/genesis_state_root_key.cpp.in b/libraries/chain/genesis_state_root_key.cpp.in index 6530698e33a..11bbde26397 100644 --- a/libraries/chain/genesis_state_root_key.cpp.in +++ b/libraries/chain/genesis_state_root_key.cpp.in @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/libraries/chain/include/eosio/chain/abi_def.hpp b/libraries/chain/include/eosio/chain/abi_def.hpp index f00dd19884d..9b1d211d623 100644 --- a/libraries/chain/include/eosio/chain/abi_def.hpp +++ b/libraries/chain/include/eosio/chain/abi_def.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/abi_serializer.hpp b/libraries/chain/include/eosio/chain/abi_serializer.hpp index 221424e041e..9fa375e9363 100644 --- a/libraries/chain/include/eosio/chain/abi_serializer.hpp +++ b/libraries/chain/include/eosio/chain/abi_serializer.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/account_object.hpp b/libraries/chain/include/eosio/chain/account_object.hpp index 8a945512b3c..b995a8508a1 100644 --- a/libraries/chain/include/eosio/chain/account_object.hpp +++ b/libraries/chain/include/eosio/chain/account_object.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/action.hpp b/libraries/chain/include/eosio/chain/action.hpp index 9eb989bda91..9912e2f31b7 100644 --- a/libraries/chain/include/eosio/chain/action.hpp +++ b/libraries/chain/include/eosio/chain/action.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/action_receipt.hpp b/libraries/chain/include/eosio/chain/action_receipt.hpp index 9b5d138117f..17fe4f46713 100644 --- a/libraries/chain/include/eosio/chain/action_receipt.hpp +++ b/libraries/chain/include/eosio/chain/action_receipt.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/apply_context.hpp b/libraries/chain/include/eosio/chain/apply_context.hpp index f0662ca5c05..1bb8e0e4cf8 100644 --- a/libraries/chain/include/eosio/chain/apply_context.hpp +++ b/libraries/chain/include/eosio/chain/apply_context.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/asset.hpp b/libraries/chain/include/eosio/chain/asset.hpp index 2c1f2bb4fc3..a1855619b97 100644 --- a/libraries/chain/include/eosio/chain/asset.hpp +++ b/libraries/chain/include/eosio/chain/asset.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/authority.hpp b/libraries/chain/include/eosio/chain/authority.hpp index d59382de2c9..373deb56120 100644 --- a/libraries/chain/include/eosio/chain/authority.hpp +++ b/libraries/chain/include/eosio/chain/authority.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/authority_checker.hpp b/libraries/chain/include/eosio/chain/authority_checker.hpp index 068cc5a9137..f17eeac10bf 100644 --- a/libraries/chain/include/eosio/chain/authority_checker.hpp +++ b/libraries/chain/include/eosio/chain/authority_checker.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/authorization_manager.hpp b/libraries/chain/include/eosio/chain/authorization_manager.hpp index 9a75b5f80b1..4db064e8ffb 100644 --- a/libraries/chain/include/eosio/chain/authorization_manager.hpp +++ b/libraries/chain/include/eosio/chain/authorization_manager.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/block_log.hpp b/libraries/chain/include/eosio/chain/block_log.hpp index 24ff0ad2835..26e1dcb41fa 100644 --- a/libraries/chain/include/eosio/chain/block_log.hpp +++ b/libraries/chain/include/eosio/chain/block_log.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/block_state.hpp b/libraries/chain/include/eosio/chain/block_state.hpp index 6870d04f5b2..2292392ade4 100644 --- a/libraries/chain/include/eosio/chain/block_state.hpp +++ b/libraries/chain/include/eosio/chain/block_state.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/block_summary_object.hpp b/libraries/chain/include/eosio/chain/block_summary_object.hpp index d0224c9a9d5..0bb24ee7976 100644 --- a/libraries/chain/include/eosio/chain/block_summary_object.hpp +++ b/libraries/chain/include/eosio/chain/block_summary_object.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/chain_config.hpp b/libraries/chain/include/eosio/chain/chain_config.hpp index f51a8b238f6..37b73cb51fe 100644 --- a/libraries/chain/include/eosio/chain/chain_config.hpp +++ b/libraries/chain/include/eosio/chain/chain_config.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/chain_id_type.hpp b/libraries/chain/include/eosio/chain/chain_id_type.hpp index 3b583a65997..c227bd15d0c 100644 --- a/libraries/chain/include/eosio/chain/chain_id_type.hpp +++ b/libraries/chain/include/eosio/chain/chain_id_type.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/chain_snapshot.hpp b/libraries/chain/include/eosio/chain/chain_snapshot.hpp index 7174e69c5b9..3b3e64f264f 100644 --- a/libraries/chain/include/eosio/chain/chain_snapshot.hpp +++ b/libraries/chain/include/eosio/chain/chain_snapshot.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/config.hpp b/libraries/chain/include/eosio/chain/config.hpp index 307b36aab00..877ae02b5f4 100644 --- a/libraries/chain/include/eosio/chain/config.hpp +++ b/libraries/chain/include/eosio/chain/config.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/contract_table_objects.hpp b/libraries/chain/include/eosio/chain/contract_table_objects.hpp index 8be51a98daf..dc6b25b0501 100644 --- a/libraries/chain/include/eosio/chain/contract_table_objects.hpp +++ b/libraries/chain/include/eosio/chain/contract_table_objects.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/core_symbol.hpp.in b/libraries/chain/include/eosio/chain/core_symbol.hpp.in index ee8e368296d..c07f1ae267d 100644 --- a/libraries/chain/include/eosio/chain/core_symbol.hpp.in +++ b/libraries/chain/include/eosio/chain/core_symbol.hpp.in @@ -1,5 +1,5 @@ /** @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE * * \warning This file is machine generated. DO NOT EDIT. See core_symbol.hpp.in for changes. */ diff --git a/libraries/chain/include/eosio/chain/database_utils.hpp b/libraries/chain/include/eosio/chain/database_utils.hpp index eee26bce1c0..19de97bd3da 100644 --- a/libraries/chain/include/eosio/chain/database_utils.hpp +++ b/libraries/chain/include/eosio/chain/database_utils.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/eosio_contract.hpp b/libraries/chain/include/eosio/chain/eosio_contract.hpp index 88566b30982..1bf9163827e 100644 --- a/libraries/chain/include/eosio/chain/eosio_contract.hpp +++ b/libraries/chain/include/eosio/chain/eosio_contract.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/exceptions.hpp b/libraries/chain/include/eosio/chain/exceptions.hpp index 01a42793e94..6c3e504d349 100644 --- a/libraries/chain/include/eosio/chain/exceptions.hpp +++ b/libraries/chain/include/eosio/chain/exceptions.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/fixed_key.hpp b/libraries/chain/include/eosio/chain/fixed_key.hpp index 1839225a4f9..5dd90f901ad 100644 --- a/libraries/chain/include/eosio/chain/fixed_key.hpp +++ b/libraries/chain/include/eosio/chain/fixed_key.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/generated_transaction_object.hpp b/libraries/chain/include/eosio/chain/generated_transaction_object.hpp index 6d3e74dd558..24db926b4a8 100644 --- a/libraries/chain/include/eosio/chain/generated_transaction_object.hpp +++ b/libraries/chain/include/eosio/chain/generated_transaction_object.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/genesis_state.hpp b/libraries/chain/include/eosio/chain/genesis_state.hpp index 7b1da43043f..364f505629e 100644 --- a/libraries/chain/include/eosio/chain/genesis_state.hpp +++ b/libraries/chain/include/eosio/chain/genesis_state.hpp @@ -1,7 +1,7 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/global_property_object.hpp b/libraries/chain/include/eosio/chain/global_property_object.hpp index fe9ae85db10..7f3c09cccf5 100644 --- a/libraries/chain/include/eosio/chain/global_property_object.hpp +++ b/libraries/chain/include/eosio/chain/global_property_object.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/multi_index_includes.hpp b/libraries/chain/include/eosio/chain/multi_index_includes.hpp index 5d2deaf04d0..2bb5485194c 100644 --- a/libraries/chain/include/eosio/chain/multi_index_includes.hpp +++ b/libraries/chain/include/eosio/chain/multi_index_includes.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/parallel_markers.hpp b/libraries/chain/include/eosio/chain/parallel_markers.hpp index c78ebdabdae..7436f970630 100644 --- a/libraries/chain/include/eosio/chain/parallel_markers.hpp +++ b/libraries/chain/include/eosio/chain/parallel_markers.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/permission_link_object.hpp b/libraries/chain/include/eosio/chain/permission_link_object.hpp index 9930b647ad8..b7b4ea76f57 100644 --- a/libraries/chain/include/eosio/chain/permission_link_object.hpp +++ b/libraries/chain/include/eosio/chain/permission_link_object.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/permission_object.hpp b/libraries/chain/include/eosio/chain/permission_object.hpp index ee43f0e52a7..7db580b74d8 100644 --- a/libraries/chain/include/eosio/chain/permission_object.hpp +++ b/libraries/chain/include/eosio/chain/permission_object.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/producer_object.hpp b/libraries/chain/include/eosio/chain/producer_object.hpp index a2bb729dcc2..61d23870280 100644 --- a/libraries/chain/include/eosio/chain/producer_object.hpp +++ b/libraries/chain/include/eosio/chain/producer_object.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/protocol.hpp b/libraries/chain/include/eosio/chain/protocol.hpp index 134f953fb85..389e9c08723 100644 --- a/libraries/chain/include/eosio/chain/protocol.hpp +++ b/libraries/chain/include/eosio/chain/protocol.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/reversible_block_object.hpp b/libraries/chain/include/eosio/chain/reversible_block_object.hpp index e0502b7e72f..ea9a4c9e122 100644 --- a/libraries/chain/include/eosio/chain/reversible_block_object.hpp +++ b/libraries/chain/include/eosio/chain/reversible_block_object.hpp @@ -1,7 +1,7 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/snapshot.hpp b/libraries/chain/include/eosio/chain/snapshot.hpp index 47f69dd07e2..499fbe29960 100644 --- a/libraries/chain/include/eosio/chain/snapshot.hpp +++ b/libraries/chain/include/eosio/chain/snapshot.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/symbol.hpp b/libraries/chain/include/eosio/chain/symbol.hpp index 3d6a4f72b35..f32541ed61c 100644 --- a/libraries/chain/include/eosio/chain/symbol.hpp +++ b/libraries/chain/include/eosio/chain/symbol.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/trace.hpp b/libraries/chain/include/eosio/chain/trace.hpp index 03750bd512e..58de120bdd8 100644 --- a/libraries/chain/include/eosio/chain/trace.hpp +++ b/libraries/chain/include/eosio/chain/trace.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/transaction.hpp b/libraries/chain/include/eosio/chain/transaction.hpp index 895d3ee4fb8..c1515599d26 100644 --- a/libraries/chain/include/eosio/chain/transaction.hpp +++ b/libraries/chain/include/eosio/chain/transaction.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/libraries/chain/include/eosio/chain/transaction_metadata.hpp b/libraries/chain/include/eosio/chain/transaction_metadata.hpp index c5eb0c790f4..2de337cdee2 100644 --- a/libraries/chain/include/eosio/chain/transaction_metadata.hpp +++ b/libraries/chain/include/eosio/chain/transaction_metadata.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/transaction_object.hpp b/libraries/chain/include/eosio/chain/transaction_object.hpp index 0d049267e8e..50a7eb62cdd 100644 --- a/libraries/chain/include/eosio/chain/transaction_object.hpp +++ b/libraries/chain/include/eosio/chain/transaction_object.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/types.hpp b/libraries/chain/include/eosio/chain/types.hpp index 4610f24c891..9319a853258 100644 --- a/libraries/chain/include/eosio/chain/types.hpp +++ b/libraries/chain/include/eosio/chain/types.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/include/eosio/chain/wast_to_wasm.hpp b/libraries/chain/include/eosio/chain/wast_to_wasm.hpp index e77d23b1360..1493f2f99f7 100644 --- a/libraries/chain/include/eosio/chain/wast_to_wasm.hpp +++ b/libraries/chain/include/eosio/chain/wast_to_wasm.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/libraries/chain/transaction.cpp b/libraries/chain/transaction.cpp index 6e6639bac52..891a5ab453d 100644 --- a/libraries/chain/transaction.cpp +++ b/libraries/chain/transaction.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/libraries/chain/wast_to_wasm.cpp b/libraries/chain/wast_to_wasm.cpp index 6a2ca2e1bbc..09add7a0b6e 100644 --- a/libraries/chain/wast_to_wasm.cpp +++ b/libraries/chain/wast_to_wasm.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/bnet_plugin/include/eosio/bnet_plugin/bnet_plugin.hpp b/plugins/bnet_plugin/include/eosio/bnet_plugin/bnet_plugin.hpp index 5a749ea44ef..9eb3a54c9a4 100644 --- a/plugins/bnet_plugin/include/eosio/bnet_plugin/bnet_plugin.hpp +++ b/plugins/bnet_plugin/include/eosio/bnet_plugin/bnet_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/chain_api_plugin/chain_api_plugin.cpp b/plugins/chain_api_plugin/chain_api_plugin.cpp index f07e48a7f04..8b9fd3f843c 100644 --- a/plugins/chain_api_plugin/chain_api_plugin.cpp +++ b/plugins/chain_api_plugin/chain_api_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/chain_api_plugin/include/eosio/chain_api_plugin/chain_api_plugin.hpp b/plugins/chain_api_plugin/include/eosio/chain_api_plugin/chain_api_plugin.hpp index ad64fcaa1d3..9a854cf0b56 100644 --- a/plugins/chain_api_plugin/include/eosio/chain_api_plugin/chain_api_plugin.hpp +++ b/plugins/chain_api_plugin/include/eosio/chain_api_plugin/chain_api_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/chain_interface/include/eosio/chain/plugin_interface.hpp b/plugins/chain_interface/include/eosio/chain/plugin_interface.hpp index 7303768cab4..6079e34c01b 100644 --- a/plugins/chain_interface/include/eosio/chain/plugin_interface.hpp +++ b/plugins/chain_interface/include/eosio/chain/plugin_interface.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index cf7a34ebd01..cc4ce4cba06 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include 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 9be045700db..7367d4d44f7 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/db_size_api_plugin/db_size_api_plugin.cpp b/plugins/db_size_api_plugin/db_size_api_plugin.cpp index 13b717c0789..8eed8b388ed 100644 --- a/plugins/db_size_api_plugin/db_size_api_plugin.cpp +++ b/plugins/db_size_api_plugin/db_size_api_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/db_size_api_plugin/include/eosio/db_size_api_plugin/db_size_api_plugin.hpp b/plugins/db_size_api_plugin/include/eosio/db_size_api_plugin/db_size_api_plugin.hpp index 2b0b46bc7ff..54a2d8ef63b 100644 --- a/plugins/db_size_api_plugin/include/eosio/db_size_api_plugin/db_size_api_plugin.hpp +++ b/plugins/db_size_api_plugin/include/eosio/db_size_api_plugin/db_size_api_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/faucet_testnet_plugin/faucet_testnet_plugin.cpp b/plugins/faucet_testnet_plugin/faucet_testnet_plugin.cpp index 39374e692cd..d6f8f53e7b3 100644 --- a/plugins/faucet_testnet_plugin/faucet_testnet_plugin.cpp +++ b/plugins/faucet_testnet_plugin/faucet_testnet_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/faucet_testnet_plugin/include/eosio/faucet_testnet_plugin/faucet_testnet_plugin.hpp b/plugins/faucet_testnet_plugin/include/eosio/faucet_testnet_plugin/faucet_testnet_plugin.hpp index 849745044a1..f59b1ef9bb3 100644 --- a/plugins/faucet_testnet_plugin/include/eosio/faucet_testnet_plugin/faucet_testnet_plugin.hpp +++ b/plugins/faucet_testnet_plugin/include/eosio/faucet_testnet_plugin/faucet_testnet_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/history_api_plugin/history_api_plugin.cpp b/plugins/history_api_plugin/history_api_plugin.cpp index bd78dede086..f9030d8c91c 100644 --- a/plugins/history_api_plugin/history_api_plugin.cpp +++ b/plugins/history_api_plugin/history_api_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/history_api_plugin/include/eosio/history_api_plugin/history_api_plugin.hpp b/plugins/history_api_plugin/include/eosio/history_api_plugin/history_api_plugin.hpp index 52ac764a45d..5e6dd936e24 100644 --- a/plugins/history_api_plugin/include/eosio/history_api_plugin/history_api_plugin.hpp +++ b/plugins/history_api_plugin/include/eosio/history_api_plugin/history_api_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/history_plugin/include/eosio/history_plugin/account_control_history_object.hpp b/plugins/history_plugin/include/eosio/history_plugin/account_control_history_object.hpp index 55aec70abe5..5005c279f5a 100644 --- a/plugins/history_plugin/include/eosio/history_plugin/account_control_history_object.hpp +++ b/plugins/history_plugin/include/eosio/history_plugin/account_control_history_object.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/history_plugin/include/eosio/history_plugin/history_plugin.hpp b/plugins/history_plugin/include/eosio/history_plugin/history_plugin.hpp index b6801b30a29..4cfb2588e46 100644 --- a/plugins/history_plugin/include/eosio/history_plugin/history_plugin.hpp +++ b/plugins/history_plugin/include/eosio/history_plugin/history_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/history_plugin/include/eosio/history_plugin/public_key_history_object.hpp b/plugins/history_plugin/include/eosio/history_plugin/public_key_history_object.hpp index 996aff7c04b..2e8e37f0049 100644 --- a/plugins/history_plugin/include/eosio/history_plugin/public_key_history_object.hpp +++ b/plugins/history_plugin/include/eosio/history_plugin/public_key_history_object.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/http_client_plugin/http_client_plugin.cpp b/plugins/http_client_plugin/http_client_plugin.cpp index dc27ac34681..cb9d7c8e580 100644 --- a/plugins/http_client_plugin/http_client_plugin.cpp +++ b/plugins/http_client_plugin/http_client_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/http_client_plugin/include/eosio/http_client_plugin/http_client_plugin.hpp b/plugins/http_client_plugin/include/eosio/http_client_plugin/http_client_plugin.hpp index b4bb8a5740e..95803bed1f8 100644 --- a/plugins/http_client_plugin/include/eosio/http_client_plugin/http_client_plugin.hpp +++ b/plugins/http_client_plugin/include/eosio/http_client_plugin/http_client_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/http_plugin/http_plugin.cpp b/plugins/http_plugin/http_plugin.cpp index d1247c7d491..3838d577c80 100644 --- a/plugins/http_plugin/http_plugin.cpp +++ b/plugins/http_plugin/http_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/http_plugin/include/eosio/http_plugin/http_plugin.hpp b/plugins/http_plugin/include/eosio/http_plugin/http_plugin.hpp index 7f9aedb01e4..c7bc1ebb2b6 100644 --- a/plugins/http_plugin/include/eosio/http_plugin/http_plugin.hpp +++ b/plugins/http_plugin/include/eosio/http_plugin/http_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/login_plugin/include/eosio/login_plugin/login_plugin.hpp b/plugins/login_plugin/include/eosio/login_plugin/login_plugin.hpp index 0bd5d59efed..29c2660c6f3 100644 --- a/plugins/login_plugin/include/eosio/login_plugin/login_plugin.hpp +++ b/plugins/login_plugin/include/eosio/login_plugin/login_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/login_plugin/login_plugin.cpp b/plugins/login_plugin/login_plugin.cpp index 5a7bc5eae3e..0aeac67dce4 100644 --- a/plugins/login_plugin/login_plugin.cpp +++ b/plugins/login_plugin/login_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/mongo_db_plugin/include/eosio/mongo_db_plugin/mongo_db_plugin.hpp b/plugins/mongo_db_plugin/include/eosio/mongo_db_plugin/mongo_db_plugin.hpp index b9456898b6d..3b636651056 100644 --- a/plugins/mongo_db_plugin/include/eosio/mongo_db_plugin/mongo_db_plugin.hpp +++ b/plugins/mongo_db_plugin/include/eosio/mongo_db_plugin/mongo_db_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/mongo_db_plugin/mongo_db_plugin.cpp b/plugins/mongo_db_plugin/mongo_db_plugin.cpp index 3ef0ee252ac..00ca0b1ed71 100644 --- a/plugins/mongo_db_plugin/mongo_db_plugin.cpp +++ b/plugins/mongo_db_plugin/mongo_db_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/net_api_plugin/include/eosio/net_api_plugin/net_api_plugin.hpp b/plugins/net_api_plugin/include/eosio/net_api_plugin/net_api_plugin.hpp index 57c5929777e..3c7e1e232ac 100644 --- a/plugins/net_api_plugin/include/eosio/net_api_plugin/net_api_plugin.hpp +++ b/plugins/net_api_plugin/include/eosio/net_api_plugin/net_api_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/net_api_plugin/net_api_plugin.cpp b/plugins/net_api_plugin/net_api_plugin.cpp index caa31bdad63..3b7327c4313 100644 --- a/plugins/net_api_plugin/net_api_plugin.cpp +++ b/plugins/net_api_plugin/net_api_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/net_plugin/include/eosio/net_plugin/net_plugin.hpp b/plugins/net_plugin/include/eosio/net_plugin/net_plugin.hpp index 2c7683ccb5e..d732b18cf0c 100644 --- a/plugins/net_plugin/include/eosio/net_plugin/net_plugin.hpp +++ b/plugins/net_plugin/include/eosio/net_plugin/net_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp b/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp index 36cb9c70bda..23f8fd341b0 100644 --- a/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp +++ b/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 49212e2d8ed..32cdaf778a7 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/plugins/producer_api_plugin/include/eosio/producer_api_plugin/producer_api_plugin.hpp b/plugins/producer_api_plugin/include/eosio/producer_api_plugin/producer_api_plugin.hpp index 4e7a5925f8a..137ef7b0703 100644 --- a/plugins/producer_api_plugin/include/eosio/producer_api_plugin/producer_api_plugin.hpp +++ b/plugins/producer_api_plugin/include/eosio/producer_api_plugin/producer_api_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/producer_api_plugin/producer_api_plugin.cpp b/plugins/producer_api_plugin/producer_api_plugin.cpp index 13599d5f834..7fcde1ac98c 100644 --- a/plugins/producer_api_plugin/producer_api_plugin.cpp +++ b/plugins/producer_api_plugin/producer_api_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp b/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp index f2e50e92849..7fc653d2034 100644 --- a/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp +++ b/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 5d2cd5637c4..6112b8dbd92 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_log.hpp b/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_log.hpp index a580529c5d5..1644d29a404 100644 --- a/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_log.hpp +++ b/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_log.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_plugin.hpp b/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_plugin.hpp index ce532d1c89e..f3429e2d190 100644 --- a/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_plugin.hpp +++ b/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp b/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp index b20f264598e..e4a1811cbbd 100644 --- a/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp +++ b/plugins/state_history_plugin/include/eosio/state_history_plugin/state_history_serialization.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/state_history_plugin/state_history_plugin.cpp b/plugins/state_history_plugin/state_history_plugin.cpp index e625af5052a..67b61587440 100644 --- a/plugins/state_history_plugin/state_history_plugin.cpp +++ b/plugins/state_history_plugin/state_history_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/plugins/template_plugin/include/eosio/template_plugin/template_plugin.hpp b/plugins/template_plugin/include/eosio/template_plugin/template_plugin.hpp index 52b88b12ea0..3217b3b1640 100644 --- a/plugins/template_plugin/include/eosio/template_plugin/template_plugin.hpp +++ b/plugins/template_plugin/include/eosio/template_plugin/template_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/template_plugin/template_plugin.cpp b/plugins/template_plugin/template_plugin.cpp index 74dc6d7a508..d8a738c30bc 100644 --- a/plugins/template_plugin/template_plugin.cpp +++ b/plugins/template_plugin/template_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/plugins/test_control_api_plugin/include/eosio/test_control_api_plugin/test_control_api_plugin.hpp b/plugins/test_control_api_plugin/include/eosio/test_control_api_plugin/test_control_api_plugin.hpp index feac39a95ff..b9c165b8993 100644 --- a/plugins/test_control_api_plugin/include/eosio/test_control_api_plugin/test_control_api_plugin.hpp +++ b/plugins/test_control_api_plugin/include/eosio/test_control_api_plugin/test_control_api_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/test_control_api_plugin/test_control_api_plugin.cpp b/plugins/test_control_api_plugin/test_control_api_plugin.cpp index 16510b06460..307cccc197e 100644 --- a/plugins/test_control_api_plugin/test_control_api_plugin.cpp +++ b/plugins/test_control_api_plugin/test_control_api_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/test_control_plugin/include/eosio/test_control_plugin/test_control_plugin.hpp b/plugins/test_control_plugin/include/eosio/test_control_plugin/test_control_plugin.hpp index 0a40d9b6e36..96badb10c83 100644 --- a/plugins/test_control_plugin/include/eosio/test_control_plugin/test_control_plugin.hpp +++ b/plugins/test_control_plugin/include/eosio/test_control_plugin/test_control_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/test_control_plugin/test_control_plugin.cpp b/plugins/test_control_plugin/test_control_plugin.cpp index f2d630c6c59..483e859c30f 100644 --- a/plugins/test_control_plugin/test_control_plugin.cpp +++ b/plugins/test_control_plugin/test_control_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/txn_test_gen_plugin/include/eosio/txn_test_gen_plugin/txn_test_gen_plugin.hpp b/plugins/txn_test_gen_plugin/include/eosio/txn_test_gen_plugin/txn_test_gen_plugin.hpp index b33e4835158..ebfe3bfb77c 100644 --- a/plugins/txn_test_gen_plugin/include/eosio/txn_test_gen_plugin/txn_test_gen_plugin.hpp +++ b/plugins/txn_test_gen_plugin/include/eosio/txn_test_gen_plugin/txn_test_gen_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp index 6b4753e9919..db47668c755 100644 --- a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp +++ b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/wallet_api_plugin/include/eosio/wallet_api_plugin/wallet_api_plugin.hpp b/plugins/wallet_api_plugin/include/eosio/wallet_api_plugin/wallet_api_plugin.hpp index 74fc2878943..611eed638d9 100644 --- a/plugins/wallet_api_plugin/include/eosio/wallet_api_plugin/wallet_api_plugin.hpp +++ b/plugins/wallet_api_plugin/include/eosio/wallet_api_plugin/wallet_api_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/wallet_api_plugin/wallet_api_plugin.cpp b/plugins/wallet_api_plugin/wallet_api_plugin.cpp index 315ce810b16..0d88ec2966d 100644 --- a/plugins/wallet_api_plugin/wallet_api_plugin.cpp +++ b/plugins/wallet_api_plugin/wallet_api_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet.hpp b/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet.hpp index e8b7c91a7e3..480e7a32a44 100644 --- a/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet.hpp +++ b/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_api.hpp b/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_api.hpp index 0c80be0d880..0627eceff33 100644 --- a/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_api.hpp +++ b/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_api.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_manager.hpp b/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_manager.hpp index efc10f1a7f9..e73bc32d971 100644 --- a/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_manager.hpp +++ b/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_manager.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_plugin.hpp b/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_plugin.hpp index 1b0986fe8f9..c23911fa6fb 100644 --- a/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_plugin.hpp +++ b/plugins/wallet_plugin/include/eosio/wallet_plugin/wallet_plugin.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/plugins/wallet_plugin/se_wallet.cpp b/plugins/wallet_plugin/se_wallet.cpp index b292495c5cc..8b43d569881 100644 --- a/plugins/wallet_plugin/se_wallet.cpp +++ b/plugins/wallet_plugin/se_wallet.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/wallet_plugin/wallet.cpp b/plugins/wallet_plugin/wallet.cpp index accb2f948b9..53d57697ccd 100644 --- a/plugins/wallet_plugin/wallet.cpp +++ b/plugins/wallet_plugin/wallet.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/plugins/wallet_plugin/wallet_manager.cpp b/plugins/wallet_plugin/wallet_manager.cpp index d851d8156f6..15a39c9d9bd 100644 --- a/plugins/wallet_plugin/wallet_manager.cpp +++ b/plugins/wallet_plugin/wallet_manager.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/wallet_plugin/wallet_plugin.cpp b/plugins/wallet_plugin/wallet_plugin.cpp index 0416227b3a4..cfd435390a6 100644 --- a/plugins/wallet_plugin/wallet_plugin.cpp +++ b/plugins/wallet_plugin/wallet_plugin.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/plugins/wallet_plugin/yubihsm_wallet.cpp b/plugins/wallet_plugin/yubihsm_wallet.cpp index d3856ad8ee5..682fc02bbb0 100644 --- a/plugins/wallet_plugin/yubihsm_wallet.cpp +++ b/plugins/wallet_plugin/yubihsm_wallet.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/programs/cleos/config.hpp.in b/programs/cleos/config.hpp.in index 18673e9c8c2..3fe2051d74c 100644 --- a/programs/cleos/config.hpp.in +++ b/programs/cleos/config.hpp.in @@ -1,5 +1,5 @@ /** @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE * * \warning This file is machine generated. DO NOT EDIT. See config.hpp.in for changes. */ diff --git a/programs/cleos/help_text.cpp b/programs/cleos/help_text.cpp index 84173e0dda8..b1f9161a54d 100644 --- a/programs/cleos/help_text.cpp +++ b/programs/cleos/help_text.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include "help_text.hpp" #include "localize.hpp" diff --git a/programs/cleos/help_text.hpp b/programs/cleos/help_text.hpp index cb0f21a828e..dbae493d714 100644 --- a/programs/cleos/help_text.hpp +++ b/programs/cleos/help_text.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once #include diff --git a/programs/cleos/httpc.hpp b/programs/cleos/httpc.hpp index 54e60866fbc..8d8ba5d67bc 100644 --- a/programs/cleos/httpc.hpp +++ b/programs/cleos/httpc.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/programs/cleos/localize.hpp b/programs/cleos/localize.hpp index 72cd073e813..ea15ea3009b 100644 --- a/programs/cleos/localize.hpp +++ b/programs/cleos/localize.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index cca242ad26f..7abce5f79da 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE * @defgroup eosclienttool EOSIO Command Line Client Reference * @brief Tool for sending transactions and querying state from @ref nodeos * @ingroup eosclienttool diff --git a/programs/eosio-launcher/config.hpp.in b/programs/eosio-launcher/config.hpp.in index 1bb4d10b59a..f60e6ab19e5 100644 --- a/programs/eosio-launcher/config.hpp.in +++ b/programs/eosio-launcher/config.hpp.in @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE * * \warning This file is machine generated. DO NOT EDIT. See config.hpp.in for changes. */ diff --git a/programs/eosio-launcher/main.cpp b/programs/eosio-launcher/main.cpp index 597e473b677..55a027b6928 100644 --- a/programs/eosio-launcher/main.cpp +++ b/programs/eosio-launcher/main.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE * @brief launch testnet nodes **/ #include diff --git a/programs/keosd/config.hpp.in b/programs/keosd/config.hpp.in index a7d34f390dc..370f88db1a9 100644 --- a/programs/keosd/config.hpp.in +++ b/programs/keosd/config.hpp.in @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE * * \warning This file is machine generated. DO NOT EDIT. See config.hpp.in for changes. */ diff --git a/programs/keosd/main.cpp b/programs/keosd/main.cpp index c457af3c0e3..efbf2d567f2 100644 --- a/programs/keosd/main.cpp +++ b/programs/keosd/main.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/programs/nodeos/config.hpp.in b/programs/nodeos/config.hpp.in index ac595383297..dbeba72a3d1 100644 --- a/programs/nodeos/config.hpp.in +++ b/programs/nodeos/config.hpp.in @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE * * \warning This file is machine generated. DO NOT EDIT. See config.hpp.in for changes. */ diff --git a/tests/main.cpp b/tests/main.cpp index ad2b5846210..0644ce80545 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/tests/wallet_tests.cpp b/tests/wallet_tests.cpp index 0891b030906..17264a6ce43 100644 --- a/tests/wallet_tests.cpp +++ b/tests/wallet_tests.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/unittests/abi_tests.cpp b/unittests/abi_tests.cpp index 3ffcc5af263..3fab0b8ffb8 100644 --- a/unittests/abi_tests.cpp +++ b/unittests/abi_tests.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/unittests/api_tests.cpp b/unittests/api_tests.cpp index 60bde1edd99..6404c6a35d9 100644 --- a/unittests/api_tests.cpp +++ b/unittests/api_tests.cpp @@ -1,6 +1,6 @@ /** * @file api_tests.cpp - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/unittests/block_tests.cpp b/unittests/block_tests.cpp index cd6af935ec6..1b0ead1c636 100644 --- a/unittests/block_tests.cpp +++ b/unittests/block_tests.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/unittests/block_timestamp_tests.cpp b/unittests/block_timestamp_tests.cpp index 297789c9089..5cf998a85aa 100644 --- a/unittests/block_timestamp_tests.cpp +++ b/unittests/block_timestamp_tests.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/unittests/contracts/deferred_test/deferred_test.cpp b/unittests/contracts/deferred_test/deferred_test.cpp index 95fc4316c8b..a30a7a2550e 100644 --- a/unittests/contracts/deferred_test/deferred_test.cpp +++ b/unittests/contracts/deferred_test/deferred_test.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/unittests/database_tests.cpp b/unittests/database_tests.cpp index ac97f6c21a6..7cb35e85be5 100644 --- a/unittests/database_tests.cpp +++ b/unittests/database_tests.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/unittests/eosio_system_tester.hpp b/unittests/eosio_system_tester.hpp index 345ab49c436..194d52330ea 100644 --- a/unittests/eosio_system_tester.hpp +++ b/unittests/eosio_system_tester.hpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma once diff --git a/unittests/include/config.hpp.in b/unittests/include/config.hpp.in index cd6dd6435e8..8483e4dd73c 100644 --- a/unittests/include/config.hpp.in +++ b/unittests/include/config.hpp.in @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ namespace eosio { namespace unittests { namespace config { diff --git a/unittests/main.cpp b/unittests/main.cpp index ad2b5846210..0644ce80545 100644 --- a/unittests/main.cpp +++ b/unittests/main.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/unittests/message_buffer_tests.cpp b/unittests/message_buffer_tests.cpp index a0b6529f2c6..ccb69033e8e 100644 --- a/unittests/message_buffer_tests.cpp +++ b/unittests/message_buffer_tests.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/unittests/misc_tests.cpp b/unittests/misc_tests.cpp index 1a93b66e97a..392a4f625ff 100644 --- a/unittests/misc_tests.cpp +++ b/unittests/misc_tests.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include diff --git a/unittests/ram_tests.cpp b/unittests/ram_tests.cpp index 976e5b8cefe..6fe0eec6613 100644 --- a/unittests/ram_tests.cpp +++ b/unittests/ram_tests.cpp @@ -1,6 +1,6 @@ /** * @file api_tests.cpp - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-compare" diff --git a/unittests/snapshot_tests.cpp b/unittests/snapshot_tests.cpp index e5207ca7bb8..1534a49b5dc 100644 --- a/unittests/snapshot_tests.cpp +++ b/unittests/snapshot_tests.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include diff --git a/unittests/special_accounts_tests.cpp b/unittests/special_accounts_tests.cpp index 384b8e78ace..e3ad16fa9bc 100644 --- a/unittests/special_accounts_tests.cpp +++ b/unittests/special_accounts_tests.cpp @@ -1,6 +1,6 @@ /** * @file - * @copyright defined in eos/LICENSE.txt + * @copyright defined in eos/LICENSE */ #include #include From 8a811ad1452bb907637155806a8bf02d44fe2b93 Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Tue, 4 Dec 2018 11:47:37 -0500 Subject: [PATCH 022/111] add a test that reduces the size of the producer set to validate that it does not create protocol level issues --- unittests/producer_schedule_tests.cpp | 57 +++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/unittests/producer_schedule_tests.cpp b/unittests/producer_schedule_tests.cpp index 9ca0edecf82..1cf8bdaadec 100644 --- a/unittests/producer_schedule_tests.cpp +++ b/unittests/producer_schedule_tests.cpp @@ -260,4 +260,61 @@ BOOST_FIXTURE_TEST_CASE( producer_schedule_promotion_test, TESTER ) try { BOOST_REQUIRE_EQUAL( validate(), true ); } FC_LOG_AND_RETHROW() +BOOST_FIXTURE_TEST_CASE( producer_schedule_reduction, tester ) try { + create_accounts( {N(alice),N(bob),N(carol)} ); + produce_block(); + + auto compare_schedules = [&]( const vector& a, const producer_schedule_type& b ) { + return std::equal( a.begin(), a.end(), b.producers.begin(), b.producers.end() ); + }; + + auto res = set_producers( {N(alice),N(bob),N(carol)} ); + vector sch1 = { + {N(alice), get_public_key(N(alice), "active")}, + {N(bob), get_public_key(N(bob), "active")}, + {N(carol), get_public_key(N(carol), "active")} + }; + //wlog("set producer schedule to [alice,bob]"); + BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch1, *control->proposed_producers() ) ); + BOOST_CHECK_EQUAL( control->pending_producers().version, 0 ); + produce_block(); // Starts new block which promotes the proposed schedule to pending + BOOST_CHECK_EQUAL( control->pending_producers().version, 1 ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch1, control->pending_producers() ) ); + BOOST_CHECK_EQUAL( control->active_producers().version, 0 ); + produce_block(); + produce_block(); // Starts new block which promotes the pending schedule to active + BOOST_CHECK_EQUAL( control->active_producers().version, 1 ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch1, control->active_producers() ) ); + produce_blocks(7); + + res = set_producers( {N(alice),N(bob)} ); + vector sch2 = { + {N(alice), get_public_key(N(alice), "active")}, + {N(bob), get_public_key(N(bob), "active")} + }; + wlog("set producer schedule to [alice,bob,carol]"); + BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch2, *control->proposed_producers() ) ); + + produce_blocks(48); + BOOST_REQUIRE_EQUAL( control->head_block_producer(), N(bob) ); + BOOST_REQUIRE_EQUAL( control->pending_block_state()->header.producer, N(carol) ); + BOOST_CHECK_EQUAL( control->pending_producers().version, 2 ); + + produce_blocks(47); + BOOST_CHECK_EQUAL( control->active_producers().version, 1 ); + produce_blocks(1); + + BOOST_REQUIRE_EQUAL( control->head_block_producer(), N(carol) ); + BOOST_REQUIRE_EQUAL( control->pending_block_state()->header.producer, N(alice) ); + BOOST_CHECK_EQUAL( control->active_producers().version, 2 ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch2, control->active_producers() ) ); + + produce_blocks(2); + BOOST_CHECK_EQUAL( control->head_block_producer(), N(bob) ); + + BOOST_REQUIRE_EQUAL( validate(), true ); +} FC_LOG_AND_RETHROW() + BOOST_AUTO_TEST_SUITE_END() From bdebb506021454c157269ab95f6e581cecf49408 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 5 Dec 2018 15:31:21 +0000 Subject: [PATCH 023/111] remove x86_64 arch dep specification on AMI2 build script I can't find any reason we need to explcitly request the x86_64 versions of packages for AMI2. Removing this apparently extraneous specification makes the build script "just work" on new ARM8 instances --- scripts/eosio_build_amazon.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/eosio_build_amazon.sh b/scripts/eosio_build_amazon.sh index bac77e20563..1c96024b847 100644 --- a/scripts/eosio_build_amazon.sh +++ b/scripts/eosio_build_amazon.sh @@ -58,9 +58,9 @@ bzip2-devel.x86_64 openssl-devel.x86_64 gmp-devel.x86_64 libstdc++72.x86_64 \ python27.x86_64 python36-devel.x86_64 libedit-devel.x86_64 doxygen.x86_64 graphviz.x86_64) else - DEP_ARRAY=( git gcc.x86_64 gcc-c++.x86_64 autoconf automake libtool make bzip2 \ - bzip2-devel.x86_64 openssl-devel.x86_64 gmp-devel.x86_64 libstdc++.x86_64 \ - python3.x86_64 python3-devel.x86_64 libedit-devel.x86_64 doxygen.x86_64 graphviz.x86_64) + DEP_ARRAY=( git gcc gcc-c++ autoconf automake libtool make bzip2 \ + bzip2-devel openssl-devel gmp-devel libstdc++ \ + python3 python3-devel libedit-devel doxygen graphviz) fi COUNT=1 DISPLAY="" From 8633cdd3fe83b43feaba2072b0cb0fdf403f7e5b Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 5 Dec 2018 19:35:07 +0000 Subject: [PATCH 024/111] Use 64-bit float printing of 128-bit floats on non x86_64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For platforms other then x86_64, have the 128-bit float console print API (printqf()) convert to a 64-bit float before printing. While this loses precision it’s enough to get the unit tests for printqf() working on ARM8, which actually was the only unit_test unit test that failed on that platform. --- libraries/chain/wasm_interface.cpp | 8 ++++++-- unittests/api_tests.cpp | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/libraries/chain/wasm_interface.cpp b/libraries/chain/wasm_interface.cpp index 09607b7c6b7..28de213c1c2 100644 --- a/libraries/chain/wasm_interface.cpp +++ b/libraries/chain/wasm_interface.cpp @@ -1063,12 +1063,16 @@ class console_api : public context_aware_api { auto& console = context.get_console_stream(); auto orig_prec = console.precision(); +#ifdef __x86_64__ console.precision( std::numeric_limits::digits10 ); - extFloat80_t val_approx; f128M_to_extF80M(&val, &val_approx); context.console_append( *(long double*)(&val_approx) ); - +#else + console.precision( std::numeric_limits::digits10 ); + double val_approx = from_softfloat64( f128M_to_f64(&val) ); + context.console_append(val_approx); +#endif console.precision( orig_prec ); } } diff --git a/unittests/api_tests.cpp b/unittests/api_tests.cpp index 60bde1edd99..6b2ccf9a307 100644 --- a/unittests/api_tests.cpp +++ b/unittests/api_tests.cpp @@ -1723,14 +1723,23 @@ BOOST_FIXTURE_TEST_CASE(print_tests, TESTER) { try { BOOST_CHECK_EQUAL( tx9_act_cnsl.substr(start, end-start), "6.666666666666666e-07" ); // test printqf +#ifdef __x86_64__ + std::string expect1 = "5.000000000000000000e-01"; + std::string expect2 = "-3.750000000000000000e+00"; + std::string expect3 = "6.666666666666666667e-07"; +#else + std::string expect1 = "5.000000000000000e-01"; + std::string expect2 = "-3.750000000000000e+00"; + std::string expect3 = "6.666666666666667e-07"; +#endif auto tx10_trace = CALL_TEST_FUNCTION( *this, "test_print", "test_printqf", {} ); auto tx10_act_cnsl = tx10_trace->action_traces.front().console; start = 0; end = tx10_act_cnsl.find('\n', start); - BOOST_CHECK_EQUAL( tx10_act_cnsl.substr(start, end-start), "5.000000000000000000e-01" ); + BOOST_CHECK_EQUAL( tx10_act_cnsl.substr(start, end-start), expect1 ); start = end + 1; end = tx10_act_cnsl.find('\n', start); - BOOST_CHECK_EQUAL( tx10_act_cnsl.substr(start, end-start), "-3.750000000000000000e+00" ); + BOOST_CHECK_EQUAL( tx10_act_cnsl.substr(start, end-start), expect2 ); start = end + 1; end = tx10_act_cnsl.find('\n', start); - BOOST_CHECK_EQUAL( tx10_act_cnsl.substr(start, end-start), "6.666666666666666667e-07" ); + BOOST_CHECK_EQUAL( tx10_act_cnsl.substr(start, end-start), expect3 ); BOOST_REQUIRE_EQUAL( validate(), true ); } FC_LOG_AND_RETHROW() } From 6cb242e68a7bb62f34d6de9a1cdf8acb90f76ab3 Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Thu, 6 Dec 2018 10:17:26 -0500 Subject: [PATCH 025/111] prebump to 1.6.0 and add develop suffix --- CMakeLists.txt | 3 ++- Docker/README.md | 4 ++-- README.md | 16 ++++++++-------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c711ae90db9..21f5b281904 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,8 +34,9 @@ set( CMAKE_CXX_EXTENSIONS ON ) set( CXX_STANDARD_REQUIRED ON) set(VERSION_MAJOR 1) -set(VERSION_MINOR 5) +set(VERSION_MINOR 6) set(VERSION_PATCH 0) +set(VERSION_SUFFIX develop) if(VERSION_SUFFIX) set(VERSION_FULL "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_SUFFIX}") diff --git a/Docker/README.md b/Docker/README.md index 6647d61726f..4e22a07e419 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -20,10 +20,10 @@ cd eos/Docker docker build . -t eosio/eos ``` -The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.5.0 tag, you could do the following: +The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.6.0 tag, you could do the following: ```bash -docker build -t eosio/eos:v1.5.0 --build-arg branch=v1.5.0 . +docker build -t eosio/eos:v1.6.0 --build-arg branch=v1.6.0 . ``` By default, the symbol in eosio.system is set to SYS. You can override this using the symbol argument while building the docker image. diff --git a/README.md b/README.md index 9dbb16dc1c9..c1ce654c145 100644 --- a/README.md +++ b/README.md @@ -39,13 +39,13 @@ $ brew remove eosio ``` #### Ubuntu 18.04 Debian Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.5.0/eosio_1.5.0-1-ubuntu-18.04_amd64.deb -$ sudo apt install ./eosio_1.5.0-1-ubuntu-18.04_amd64.deb +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-develop-ubuntu-18.04_amd64.deb +$ sudo apt install ./eosio_1.6.0-develop-ubuntu-18.04_amd64.deb ``` #### Ubuntu 16.04 Debian Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.5.0/eosio_1.5.0-1-ubuntu-16.04_amd64.deb -$ sudo apt install ./eosio_1.5.0-1-ubuntu-16.04_amd64.deb +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-develop-ubuntu-16.04_amd64.deb +$ sudo apt install ./eosio_1.6.0-develop-ubuntu-16.04_amd64.deb ``` #### Debian Package Uninstall ```sh @@ -53,8 +53,8 @@ $ sudo apt remove eosio ``` #### Centos RPM Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.5.0/eosio-1.5.0-1.el7.x86_64.rpm -$ sudo yum install ./eosio-1.5.0-1.el7.x86_64.rpm +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-develop.el7.x86_64.rpm +$ sudo yum install ./eosio-1.6.0-develop.el7.x86_64.rpm ``` #### Centos RPM Package Uninstall ```sh @@ -62,8 +62,8 @@ $ sudo yum remove eosio.cdt ``` #### Fedora RPM Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.5.0/eosio-1.5.0-1.fc27.x86_64.rpm -$ sudo yum install ./eosio-1.5.0-1.fc27.x86_64.rpm +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-develop.fc27.x86_64.rpm +$ sudo yum install ./eosio-1.6.0-develop.fc27.x86_64.rpm ``` #### Fedora RPM Package Uninstall ```sh From d381ec0a53238f95f34e2be8a6bd8fb8e83a378f Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 28 Nov 2018 16:50:47 -0500 Subject: [PATCH 026/111] Do not broadcast block if peer lib is larger than block number --- plugins/net_plugin/net_plugin.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 49212e2d8ed..57f38982eb3 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1532,7 +1532,7 @@ namespace eosio { void sync_manager::verify_catchup(connection_ptr c, uint32_t num, block_id_type id) { request_message req; req.req_blocks.mode = catch_up; - for (auto cc : my_impl->connections) { + for (const auto& cc : my_impl->connections) { if (cc->fork_head == id || cc->fork_head_num > num) { req.req_blocks.mode = none; @@ -1598,7 +1598,7 @@ namespace eosio { source.reset(); block_id_type null_id; - for (auto cp : my_impl->connections) { + for (const auto& cp : my_impl->connections) { if (cp->fork_head == null_id) { continue; } @@ -1670,12 +1670,16 @@ namespace eosio { } pbstate.is_known = true; - for( auto cp : my_impl->connections ) { + for( auto& cp : my_impl->connections ) { if( skips.find( cp ) != skips.end() || !cp->current() ) { continue; } - cp->add_peer_block( pbstate ); - cp->enqueue_block( bs->block ); + bool has_block = cp->last_handshake_recv.last_irreversible_block_num >= bnum; + if( !has_block ) { + fc_dlog(logger, "bcast block ${b} to ${p}", ("b", bnum)("p", cp->peer_name())); + cp->add_peer_block( pbstate ); + cp->enqueue_block( bs->block ); + } } } @@ -1884,7 +1888,7 @@ namespace eosio { ("b",modes_str(c->last_req->req_blocks.mode))("t",modes_str(c->last_req->req_trx.mode))); return; } - for (auto conn : my_impl->connections) { + for (auto& conn : my_impl->connections) { if (conn == c || conn->last_req) { continue; } From e84520407a3e7650e4177cee5f1ed5ec9306655c Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Thu, 29 Nov 2018 14:54:34 -0500 Subject: [PATCH 027/111] Provide more efficient sha256_less --- plugins/net_plugin/net_plugin.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 57f38982eb3..34f352c000c 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -92,6 +92,14 @@ namespace eosio { struct by_expiry; struct by_block_num; + struct sha256_less { + bool operator()( const sha256& lhs, const sha256& rhs ) const { + return + std::tie(lhs._hash[0], lhs._hash[1], lhs._hash[2], lhs._hash[3]) < + std::tie(rhs._hash[0], rhs._hash[1], rhs._hash[2], rhs._hash[3]); + } + }; + typedef multi_index_container< node_transaction_state, indexed_by< @@ -99,7 +107,8 @@ namespace eosio { tag< by_id >, member < node_transaction_state, transaction_id_type, - &node_transaction_state::id > >, + &node_transaction_state::id >, + sha256_less >, ordered_non_unique< tag< by_expiry >, member< node_transaction_state, @@ -364,7 +373,7 @@ namespace eosio { typedef multi_index_container< transaction_state, indexed_by< - ordered_unique< tag, member >, + ordered_unique< tag, member, sha256_less >, ordered_non_unique< tag< by_expiry >, member< transaction_state,fc::time_point_sec,&transaction_state::expires >>, ordered_non_unique< tag, @@ -398,7 +407,7 @@ namespace eosio { typedef multi_index_container< eosio::peer_block_state, indexed_by< - ordered_unique< tag, member >, + ordered_unique< tag, member, sha256_less >, ordered_unique< tag, member > > > peer_block_state_index; From 2a32ee4b0a855cb24b892a535d7a3f5a78dd7b0c Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 30 Nov 2018 08:51:47 -0500 Subject: [PATCH 028/111] Simply by removing unused large_msg_notify --- plugins/net_plugin/net_plugin.cpp | 136 ++++-------------------------- 1 file changed, 18 insertions(+), 118 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 34f352c000c..da6a4b1d3f0 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -319,7 +319,6 @@ namespace eosio { constexpr auto def_resp_expected_wait = std::chrono::seconds(5); constexpr auto def_sync_fetch_span = 100; constexpr uint32_t def_max_just_send = 1500; // roughly 1 "mtu" - constexpr bool large_msg_notify = false; constexpr auto message_header_size = 4; @@ -346,28 +345,10 @@ namespace eosio { constexpr uint16_t net_version = proto_explicit_sync; - /** - * Index by id - * Index by is_known, block_num, validated_time, this is the order we will broadcast - * to peer. - * Index by is_noticed, validated_time - * - */ struct transaction_state { transaction_id_type id; - bool is_known_by_peer = false; ///< true if we sent or received this trx to this peer or received notice from peer - bool is_noticed_to_peer = false; ///< have we sent peer notice we know it (true if we receive from this peer) uint32_t block_num = 0; ///< the block number the transaction was included in time_point_sec expires; - time_point requested_time; /// in case we fetch large trx - }; - - struct update_txn_expiry { - time_point_sec new_expiry; - update_txn_expiry(time_point_sec e) : new_expiry(e) {} - void operator() (transaction_state& ts) { - ts.expires = new_expiry; - } }; typedef multi_index_container< @@ -396,9 +377,6 @@ namespace eosio { }; struct update_request_time { - void operator() (struct transaction_state &ts) { - ts.requested_time = time_point::now(); - } void operator () (struct eosio::peer_block_state &bs) { bs.requested_time = time_point::now(); } @@ -417,9 +395,6 @@ namespace eosio { void operator() (eosio::peer_block_state& bs) { bs.is_known = true; } - void operator() (transaction_state& ts) { - ts.is_known_by_peer = true; - } } set_is_known; @@ -827,7 +802,7 @@ namespace eosio { } void connection::txn_send(const vector &ids) { - for(auto t : ids) { + for(const auto& t : ids) { auto tx = my_impl->local_txns.get().find(t); if( tx != my_impl->local_txns.end() && tx->serialized_txn.size()) { my_impl->local_txns.modify( tx,incr_in_flight); @@ -1650,34 +1625,6 @@ namespace eosio { uint32_t bnum = bs->block_num; peer_block_state pbstate = {bid, bnum, false, true, time_point()}; - // skip will be empty if our producer emitted this block so just send it - if( large_msg_notify ) { - int which = 7; - uint32_t whichsiz = fc::raw::pack_size( unsigned_int( which ) ); - uint32_t packsiz = whichsiz + fc::raw::pack_size( *bs->block ); - uint32_t msgsiz = packsiz + sizeof(packsiz); - - if( (msgsiz > just_send_it_max) && !skips.empty() ) { - fc_ilog( logger, "block size is ${ms}, sending notify", ("ms", msgsiz)); - notice_message pending_notify; - pending_notify.known_blocks.mode = normal; - pending_notify.known_blocks.ids.push_back( bid ); - pending_notify.known_trx.mode = none; - my_impl->send_all( pending_notify, [&skips, pbstate]( connection_ptr c ) -> bool { - if( skips.find( c ) != skips.end() || !c->current()) - return false; - - bool unknown = c->add_peer_block( pbstate ); - if( !unknown ) { - elog( "${p} already has knowledge of block ${b}", ("p", c->peer_name())( "b", pbstate.block_num )); - } - return unknown; - } ); - - return; - } - } - pbstate.is_known = true; for( auto& cp : my_impl->connections ) { if( skips.find( cp ) != skips.end() || !cp->current() ) { @@ -1728,14 +1675,12 @@ namespace eosio { fc_dlog(logger, "found trxid in local_trxs" ); return; } - uint32_t packsiz = 0; - uint32_t bufsiz = 0; time_point_sec trx_expiration = trx.expiration(); net_message msg(trx); - packsiz = fc::raw::pack_size(msg); - bufsiz = packsiz + sizeof(packsiz); + uint32_t packsiz = fc::raw::pack_size(msg); + uint32_t bufsiz = packsiz + sizeof(packsiz); vector buff(bufsiz); fc::datastream ds( buff.data(), bufsiz); ds.write( reinterpret_cast(&packsiz), sizeof(packsiz) ); @@ -1747,44 +1692,18 @@ namespace eosio { 0, 0, 0}; my_impl->local_txns.insert(std::move(nts)); - if( !large_msg_notify || bufsiz <= just_send_it_max) { - my_impl->send_all( msg, [id, &skips, trx_expiration](connection_ptr c) -> bool { - if( skips.find(c) != skips.end() || c->syncing ) { - return false; - } - const auto& bs = c->trx_state.find(id); - bool unknown = bs == c->trx_state.end(); - if( unknown) { - c->trx_state.insert(transaction_state({id,true,true,0,trx_expiration,time_point() })); - fc_dlog(logger, "sending whole trx to ${n}", ("n",c->peer_name() ) ); - } else { - update_txn_expiry ute(trx_expiration); - c->trx_state.modify(bs, ute); - } - return unknown; - }); - } - else { - notice_message pending_notify; - pending_notify.known_trx.mode = normal; - pending_notify.known_trx.ids.push_back( id ); - pending_notify.known_blocks.mode = none; - my_impl->send_all(pending_notify, [id, &skips, trx_expiration](connection_ptr c) -> bool { - if (skips.find(c) != skips.end() || c->syncing) { - return false; - } - const auto& bs = c->trx_state.find(id); - bool unknown = bs == c->trx_state.end(); - if( unknown) { - fc_dlog(logger, "sending notice to ${n}", ("n",c->peer_name() ) ); - c->trx_state.insert(transaction_state({id,false,true,0,trx_expiration,time_point() })); - } else { - update_txn_expiry ute(trx_expiration); - c->trx_state.modify(bs, ute); - } - return unknown; - }); - } + my_impl->send_all( msg, [&id, &skips, trx_expiration](connection_ptr c) -> bool { + if( skips.find(c) != skips.end() || c->syncing ) { + return false; + } + const auto& bs = c->trx_state.find(id); + bool unknown = bs == c->trx_state.end(); + if( unknown ) { + c->trx_state.insert(transaction_state({id,0,trx_expiration})); + fc_dlog(logger, "sending whole trx to ${n}", ("n",c->peer_name() ) ); + } + return unknown; + }); } @@ -1813,30 +1732,10 @@ namespace eosio { req.req_trx.mode = none; req.req_blocks.mode = none; bool send_req = false; - controller &cc = my_impl->chain_plug->chain(); if (msg.known_trx.mode == normal) { req.req_trx.mode = normal; req.req_trx.pending = 0; - for( const auto& t : msg.known_trx.ids ) { - const auto &tx = my_impl->local_txns.get( ).find( t ); - - if( tx == my_impl->local_txns.end( ) ) { - fc_dlog(logger,"did not find ${id}",("id",t)); - - //At this point the details of the txn are not known, just its id. This - //effectively gives 120 seconds to learn of the details of the txn which - //will update the expiry in bcast_transaction - c->trx_state.insert( (transaction_state){t,true,true,0,time_point_sec(time_point::now()) + 120, - time_point()} ); - - req.req_trx.ids.push_back( t ); - } - else { - fc_dlog(logger,"big msg manager found txn id in table, ${id}",("id", t)); - } - } - send_req = !req.req_trx.ids.empty(); - fc_dlog(logger,"big msg manager send_req ids list has ${ids} entries", ("ids", req.req_trx.ids.size())); + send_req = false; } else if (msg.known_trx.mode != none) { elog ("passed a notice_message with something other than a normal on none known_trx"); @@ -1844,6 +1743,7 @@ namespace eosio { } if (msg.known_blocks.mode == normal) { req.req_blocks.mode = normal; + controller& cc = my_impl->chain_plug->chain(); for( const auto& blkid : msg.known_blocks.ids) { signed_block_ptr b; peer_block_state entry = {blkid,0,true,true,fc::time_point()}; @@ -1904,7 +1804,7 @@ namespace eosio { bool sendit = false; if (is_txn) { auto trx = conn->trx_state.get().find(tid); - sendit = trx != conn->trx_state.end() && trx->is_known_by_peer; + sendit = trx != conn->trx_state.end(); } else { auto blk = conn->blk_state.get().find(bid); From 0594dd5b1bdae02ff0cebea29d7d5b2746905c26 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 30 Nov 2018 09:11:19 -0500 Subject: [PATCH 029/111] Remove unused node_transaction_state.packed_txn --- plugins/net_plugin/net_plugin.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index da6a4b1d3f0..06a8b6ea94c 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -65,7 +65,6 @@ namespace eosio { time_point_sec expires; /// time after which this may be purged. /// Expires increased while the txn is /// "in flight" to anoher peer - packed_transaction packed_txn; vector serialized_txn; /// the received raw bundle uint32_t block_num = 0; /// block transaction was included in uint32_t true_block = 0; /// used to reset block_uum when request is 0 @@ -1687,7 +1686,6 @@ namespace eosio { fc::raw::pack( ds, msg ); node_transaction_state nts = {id, trx_expiration, - trx, std::move(buff), 0, 0, 0}; my_impl->local_txns.insert(std::move(nts)); From e44f205f4a9d593fa345142eab6321b936496316 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 30 Nov 2018 12:22:27 -0500 Subject: [PATCH 030/111] Store serialized transaction as shared_ptr to minimize copies --- plugins/net_plugin/net_plugin.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 06a8b6ea94c..860f86844c8 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -65,7 +65,7 @@ namespace eosio { time_point_sec expires; /// time after which this may be purged. /// Expires increased while the txn is /// "in flight" to anoher peer - vector serialized_txn; /// the received raw bundle + std::shared_ptr> serialized_txn; /// the received raw bundle uint32_t block_num = 0; /// block transaction was included in uint32_t true_block = 0; /// used to reset block_uum when request is 0 uint16_t requests = 0; /// the number of "in flight" requests for this txn @@ -189,7 +189,7 @@ namespace eosio { size_t count_open_sockets() const; template - void send_all( const net_message &msg, VerifierFunc verify ); + void send_all( const std::shared_ptr>& send_buffer, VerifierFunc verify ); void accepted_block_header(const block_state_ptr&); void accepted_block(const block_state_ptr&); @@ -774,7 +774,7 @@ namespace eosio { void connection::txn_send_pending(const vector &ids) { for(auto tx = my_impl->local_txns.begin(); tx != my_impl->local_txns.end(); ++tx ){ - if(tx->serialized_txn.size() && tx->block_num == 0) { + if(tx->serialized_txn->size() && tx->block_num == 0) { bool found = false; for(auto known : ids) { if( known == tx->id) { @@ -784,7 +784,7 @@ namespace eosio { } if(!found) { my_impl->local_txns.modify(tx,incr_in_flight); - queue_write(std::make_shared>(tx->serialized_txn), + queue_write(tx->serialized_txn, true, [tx_id=tx->id](boost::system::error_code ec, std::size_t ) { auto& local_txns = my_impl->local_txns; @@ -803,9 +803,9 @@ namespace eosio { void connection::txn_send(const vector &ids) { for(const auto& t : ids) { auto tx = my_impl->local_txns.get().find(t); - if( tx != my_impl->local_txns.end() && tx->serialized_txn.size()) { + if( tx != my_impl->local_txns.end() && tx->serialized_txn->size()) { my_impl->local_txns.modify( tx,incr_in_flight); - queue_write(std::make_shared>(tx->serialized_txn), + queue_write(tx->serialized_txn, true, [t](boost::system::error_code ec, std::size_t ) { auto& local_txns = my_impl->local_txns; @@ -1680,17 +1680,18 @@ namespace eosio { net_message msg(trx); uint32_t packsiz = fc::raw::pack_size(msg); uint32_t bufsiz = packsiz + sizeof(packsiz); - vector buff(bufsiz); - fc::datastream ds( buff.data(), bufsiz); + auto buff = std::make_shared>(bufsiz); + + fc::datastream ds( buff->data(), bufsiz); ds.write( reinterpret_cast(&packsiz), sizeof(packsiz) ); fc::raw::pack( ds, msg ); node_transaction_state nts = {id, trx_expiration, - std::move(buff), + buff, 0, 0, 0}; my_impl->local_txns.insert(std::move(nts)); - my_impl->send_all( msg, [&id, &skips, trx_expiration](connection_ptr c) -> bool { + my_impl->send_all( buff, [&id, &skips, trx_expiration](connection_ptr c) -> bool { if( skips.find(c) != skips.end() || c->syncing ) { return false; } @@ -2109,10 +2110,10 @@ namespace eosio { template - void net_plugin_impl::send_all( const net_message &msg, VerifierFunc verify) { + void net_plugin_impl::send_all( const std::shared_ptr>& send_buffer, VerifierFunc verify) { for( auto &c : connections) { - if( c->current() && verify( c)) { - c->enqueue( msg ); + if( c->current() && verify( c )) { + c->enqueue_buffer( send_buffer, true, no_reason ); } } } From 28301f28679da127c6c821b187cee2835da4d292 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 30 Nov 2018 13:01:47 -0500 Subject: [PATCH 031/111] Not possible for serialized_txn to be empty --- plugins/net_plugin/net_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 860f86844c8..7258055285d 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -774,7 +774,7 @@ namespace eosio { void connection::txn_send_pending(const vector &ids) { for(auto tx = my_impl->local_txns.begin(); tx != my_impl->local_txns.end(); ++tx ){ - if(tx->serialized_txn->size() && tx->block_num == 0) { + if( tx->block_num == 0 ) { bool found = false; for(auto known : ids) { if( known == tx->id) { @@ -803,7 +803,7 @@ namespace eosio { void connection::txn_send(const vector &ids) { for(const auto& t : ids) { auto tx = my_impl->local_txns.get().find(t); - if( tx != my_impl->local_txns.end() && tx->serialized_txn->size()) { + if( tx != my_impl->local_txns.end() ) { my_impl->local_txns.modify( tx,incr_in_flight); queue_write(tx->serialized_txn, true, From f403da80c45a81bf87f92ce1967c49d76ab8ae3b Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 30 Nov 2018 17:06:38 -0500 Subject: [PATCH 032/111] Remove find_plugin overhead --- plugins/net_plugin/net_plugin.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 7258055285d..69727fb8ebf 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -169,6 +169,7 @@ namespace eosio { string user_agent_name; chain_plugin* chain_plug = nullptr; + producer_plugin* producer_plug = nullptr; int started_sessions = 0; node_transaction_index local_txns; @@ -1058,7 +1059,6 @@ namespace eosio { } bool connection::enqueue_sync_block() { - controller& cc = app().find_plugin()->chain(); if (!peer_requested) return false; uint32_t num = ++peer_requested->last; @@ -1067,6 +1067,7 @@ namespace eosio { peer_requested.reset(); } try { + controller& cc = my_impl->chain_plug->chain(); signed_block_ptr sb = cc.fetch_block_by_number(num); if(sb) { enqueue_block( sb, trigger_send); @@ -2661,9 +2662,8 @@ namespace eosio { auto allowed_it = std::find(allowed_peers.begin(), allowed_peers.end(), msg.key); auto private_it = private_keys.find(msg.key); bool found_producer_key = false; - producer_plugin* pp = app().find_plugin(); - if(pp != nullptr) - found_producer_key = pp->is_producer_key(msg.key); + if(producer_plug != nullptr) + found_producer_key = producer_plug->is_producer_key(msg.key); if( allowed_it == allowed_peers.end() && private_it == private_keys.end() && !found_producer_key) { elog( "Peer ${peer} sent a handshake with an unauthorized key: ${key}.", ("peer", msg.p2p_address)("key", msg.key)); @@ -2723,9 +2723,8 @@ namespace eosio { auto private_key_itr = private_keys.find(signer); if(private_key_itr != private_keys.end()) return private_key_itr->second.sign(digest); - producer_plugin* pp = app().find_plugin(); - if(pp != nullptr && pp->get_state() == abstract_plugin::started) - return pp->sign_compact(signer, digest); + if(producer_plug != nullptr && producer_plug->get_state() == abstract_plugin::started) + return producer_plug->sign_compact(signer, digest); return chain::signature_type(); } @@ -2930,6 +2929,7 @@ namespace eosio { } void net_plugin::plugin_startup() { + my->producer_plug = app().find_plugin(); if( my->acceptor ) { my->acceptor->open(my->listen_endpoint.protocol()); my->acceptor->set_option(tcp::acceptor::reuse_address(true)); From 2678b5eb646056d008cc12fd4048e46815e0b869 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Sat, 1 Dec 2018 16:53:53 -0600 Subject: [PATCH 033/111] Minimize shared_ptr copies --- plugins/net_plugin/net_plugin.cpp | 170 ++++++++++++++---------------- 1 file changed, 78 insertions(+), 92 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 69727fb8ebf..a80ffc1019c 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -145,7 +145,7 @@ namespace eosio { }; possible_connections allowed_connections{None}; - connection_ptr find_connection( string host )const; + connection_ptr find_connection(const string& host)const; std::set< connection_ptr > connections; bool done = false; @@ -180,13 +180,13 @@ namespace eosio { channels::transaction_ack::channel_type::handle incoming_transaction_ack_subscription; - void connect( connection_ptr c ); - void connect( connection_ptr c, tcp::resolver::iterator endpoint_itr ); - bool start_session( connection_ptr c ); + void connect(const connection_ptr& c); + void connect(const connection_ptr& c, tcp::resolver::iterator endpoint_itr); + bool start_session(const connection_ptr& c); void start_listen_loop( ); - void start_read_message( connection_ptr c); + void start_read_message(const connection_ptr& c); - void close( connection_ptr c ); + void close(const connection_ptr& c); size_t count_open_sockets() const; template @@ -203,9 +203,9 @@ namespace eosio { bool is_valid( const handshake_message &msg); - void handle_message( connection_ptr c, const handshake_message &msg); - void handle_message( connection_ptr c, const chain_size_message &msg); - void handle_message( connection_ptr c, const go_away_message &msg ); + void handle_message(const connection_ptr& c, const handshake_message& msg); + void handle_message(const connection_ptr& c, const chain_size_message& msg); + void handle_message(const connection_ptr& c, const go_away_message& msg ); /** \name Peer Timestamps * Time message handling * @{ @@ -219,14 +219,14 @@ namespace eosio { * floating-double arithmetic with rounding done by the hardware. * This is necessary in order to avoid overflow and preserve precision. */ - void handle_message( connection_ptr c, const time_message &msg); + void handle_message(const connection_ptr& c, const time_message& msg); /** @} */ - void handle_message( connection_ptr c, const notice_message &msg); - void handle_message( connection_ptr c, const request_message &msg); - void handle_message( connection_ptr c, const sync_request_message &msg); - void handle_message( connection_ptr c, const signed_block &msg) = delete; // signed_block_ptr overload used instead - void handle_message( connection_ptr c, const signed_block_ptr &msg); - void handle_message( connection_ptr c, const packed_transaction &msg); + void handle_message(const connection_ptr& c, const notice_message& msg); + void handle_message(const connection_ptr& c, const request_message& msg); + void handle_message(const connection_ptr& c, const sync_request_message& msg); + void handle_message(const connection_ptr& c, const signed_block& msg) = delete; // signed_block_ptr overload used instead + void handle_message(const connection_ptr& c, const signed_block_ptr& msg); + void handle_message(const connection_ptr& c, const packed_transaction& msg); void start_conn_timer(boost::asio::steady_timer::duration du, std::weak_ptr from_connection); void start_txn_timer( ); @@ -507,10 +507,6 @@ namespace eosio { /** \name Peer Timestamps * Time message handling */ - /** @{ */ - /** \brief Convert an std::chrono nanosecond rep to a human readable string - */ - char* convert_tstamp(const tstamp& t); /** \brief Populate and queue time_message */ void send_time(); @@ -553,7 +549,7 @@ namespace eosio { void sync_timeout(boost::system::error_code ec); void fetch_timeout(boost::system::error_code ec); - void queue_write(std::shared_ptr> buff, + void queue_write(const std::shared_ptr>& buff, bool trigger_send, std::function callback); void do_queue_write(); @@ -600,7 +596,7 @@ namespace eosio { struct msg_handler : public fc::visitor { net_plugin_impl &impl; connection_ptr c; - msg_handler( net_plugin_impl &imp, connection_ptr conn) : impl(imp), c(conn) {} + msg_handler( net_plugin_impl &imp, const connection_ptr& conn) : impl(imp), c(conn) {} void operator()( const signed_block& msg ) const { EOS_ASSERT( false, plugin_config_exception, "visit(signed_block&&) should be called" ); @@ -643,16 +639,16 @@ namespace eosio { void set_state(stages s); bool sync_required(); void send_handshakes(); - bool is_active(connection_ptr conn); - void reset_lib_num(connection_ptr conn); - void request_next_chunk(connection_ptr conn = connection_ptr() ); - void start_sync(connection_ptr c, uint32_t target); - void reassign_fetch(connection_ptr c, go_away_reason reason); - void verify_catchup(connection_ptr c, uint32_t num, block_id_type id); - void rejected_block(connection_ptr c, uint32_t blk_num); - void recv_block(connection_ptr c, const block_id_type &blk_id, uint32_t blk_num); - void recv_handshake(connection_ptr c, const handshake_message& msg); - void recv_notice(connection_ptr c, const notice_message& msg); + bool is_active(const connection_ptr& conn); + void reset_lib_num(const connection_ptr& conn); + void request_next_chunk(const connection_ptr& conn = connection_ptr()); + void start_sync(const connection_ptr& c, uint32_t target); + void reassign_fetch(const connection_ptr& c, go_away_reason reason); + void verify_catchup(const connection_ptr& c, uint32_t num, const block_id_type& id); + void rejected_block(const connection_ptr& c, uint32_t blk_num); + void recv_block(const connection_ptr& c, const block_id_type& blk_id, uint32_t blk_num); + void recv_handshake(const connection_ptr& c, const handshake_message& msg); + void recv_notice(const connection_ptr& c, const notice_message& msg); }; class dispatch_manager { @@ -662,16 +658,16 @@ namespace eosio { std::multimap received_blocks; std::multimap received_transactions; - void bcast_transaction (const packed_transaction& msg); - void rejected_transaction (const transaction_id_type& msg); - void bcast_block (const block_state_ptr& bs); - void rejected_block (const block_id_type &id); + void bcast_transaction(const packed_transaction& msg); + void rejected_transaction(const transaction_id_type& msg); + void bcast_block(const block_state_ptr& bs); + void rejected_block(const block_id_type &id); - void recv_block (connection_ptr conn, const block_id_type& msg, uint32_t bnum); - void recv_transaction(connection_ptr conn, const transaction_id_type& id); - void recv_notice (connection_ptr conn, const notice_message& msg, bool generated); + void recv_block(const connection_ptr& conn, const block_id_type& msg, uint32_t bnum); + void recv_transaction(const connection_ptr& conn, const transaction_id_type& id); + void recv_notice(const connection_ptr& conn, const notice_message& msg, bool generated); - void retry_fetch (connection_ptr conn); + void retry_fetch(const connection_ptr& conn); }; //--------------------------------------------------------------------------- @@ -945,15 +941,6 @@ namespace eosio { enqueue(last_handshake_sent); } - char* connection::convert_tstamp(const tstamp& t) - { - const long long NsecPerSec{1000000000}; - time_t seconds = t / NsecPerSec; - strftime(ts, ts_buffer_size, "%F %T", localtime(&seconds)); - snprintf(ts+19, ts_buffer_size-19, ".%lld", t % NsecPerSec); - return ts; - } - void connection::send_time() { time_message xpkt; xpkt.org = rec; @@ -971,7 +958,7 @@ namespace eosio { enqueue(xpkt); } - void connection::queue_write(std::shared_ptr> buff, + void connection::queue_write(const std::shared_ptr>& buff, bool trigger_send, std::function callback) { write_queue.push_back({buff, callback}); @@ -1155,7 +1142,7 @@ namespace eosio { } ); } - void connection::fetch_wait( ) { + void connection::fetch_wait() { response_expected->expires_from_now( my_impl->resp_expected_period); connection_wptr c(shared_from_this()); response_expected->async_wait( [c]( boost::system::error_code ec){ @@ -1280,7 +1267,7 @@ namespace eosio { state = newstate; } - bool sync_manager::is_active(connection_ptr c) { + bool sync_manager::is_active(const connection_ptr& c) { if (state == head_catchup && c) { bool fhset = c->fork_head != block_id_type(); fc_dlog(logger, "fork_head_num = ${fn} fork_head set = ${s}", @@ -1290,7 +1277,7 @@ namespace eosio { return state != in_sync; } - void sync_manager::reset_lib_num(connection_ptr c) { + void sync_manager::reset_lib_num(const connection_ptr& c) { if(state == in_sync) { source.reset(); } @@ -1312,7 +1299,7 @@ namespace eosio { chain_plug->chain( ).fork_db_head_block_num( ) < sync_last_requested_num ); } - void sync_manager::request_next_chunk( connection_ptr conn ) { + void sync_manager::request_next_chunk( const connection_ptr& conn ) { uint32_t head_block = chain_plug->chain().fork_db_head_block_num(); if (head_block < sync_last_requested_num && source && source->current()) { @@ -1395,7 +1382,7 @@ namespace eosio { } } - void sync_manager::send_handshakes () + void sync_manager::send_handshakes() { for( auto &ci : my_impl->connections) { if( ci->current()) { @@ -1404,7 +1391,7 @@ namespace eosio { } } - void sync_manager::start_sync( connection_ptr c, uint32_t target) { + void sync_manager::start_sync(const connection_ptr& c, uint32_t target) { if( target > sync_known_lib_num) { sync_known_lib_num = target; } @@ -1428,7 +1415,7 @@ namespace eosio { request_next_chunk(c); } - void sync_manager::reassign_fetch(connection_ptr c, go_away_reason reason) { + void sync_manager::reassign_fetch(const connection_ptr& c, go_away_reason reason) { fc_ilog(logger, "reassign_fetch, our last req is ${cc}, next expected is ${ne} peer ${p}", ( "cc",sync_last_requested_num)("ne",sync_next_expected_num)("p",c->peer_name())); @@ -1439,7 +1426,7 @@ namespace eosio { } } - void sync_manager::recv_handshake (connection_ptr c, const handshake_message &msg) { + void sync_manager::recv_handshake(const connection_ptr& c, const handshake_message& msg) { controller& cc = chain_plug->chain(); uint32_t lib_num = cc.last_irreversible_block_num( ); uint32_t peer_lib = msg.last_irreversible_block_num; @@ -1494,7 +1481,7 @@ namespace eosio { if (head <= msg.head_num ) { fc_dlog(logger, "sync check state 3"); - verify_catchup (c, msg.head_num, msg.head_id); + verify_catchup(c, msg.head_num, msg.head_id); return; } else { @@ -1513,7 +1500,7 @@ namespace eosio { elog ("sync check failed to resolve status"); } - void sync_manager::verify_catchup(connection_ptr c, uint32_t num, block_id_type id) { + void sync_manager::verify_catchup(const connection_ptr& c, uint32_t num, const block_id_type& id) { request_message req; req.req_blocks.mode = catch_up; for (const auto& cc : my_impl->connections) { @@ -1539,14 +1526,14 @@ namespace eosio { c->enqueue( req ); } - void sync_manager::recv_notice (connection_ptr c, const notice_message &msg) { + void sync_manager::recv_notice(const connection_ptr& c, const notice_message& msg) { fc_ilog (logger, "sync_manager got ${m} block notice",("m",modes_str(msg.known_blocks.mode))); if (msg.known_blocks.mode == catch_up) { if (msg.known_blocks.ids.size() == 0) { elog ("got a catch up with ids size = 0"); } else { - verify_catchup(c, msg.known_blocks.pending, msg.known_blocks.ids.back()); + verify_catchup(c, msg.known_blocks.pending, msg.known_blocks.ids.back()); } } else { @@ -1556,7 +1543,7 @@ namespace eosio { } } - void sync_manager::rejected_block (connection_ptr c, uint32_t blk_num) { + void sync_manager::rejected_block(const connection_ptr& c, uint32_t blk_num) { if (state != in_sync ) { fc_ilog (logger, "block ${bn} not accepted from ${p}",("bn",blk_num)("p",c->peer_name())); sync_last_requested_num = 0; @@ -1566,7 +1553,7 @@ namespace eosio { send_handshakes(); } } - void sync_manager::recv_block (connection_ptr c, const block_id_type &blk_id, uint32_t blk_num) { + void sync_manager::recv_block(const connection_ptr& c, const block_id_type& blk_id, uint32_t blk_num) { fc_dlog(logger," got block ${bn} from ${p}",("bn",blk_num)("p",c->peer_name())); if (state == lib_catchup) { if (blk_num != sync_next_expected_num) { @@ -1613,7 +1600,7 @@ namespace eosio { //------------------------------------------------------------------------ - void dispatch_manager::bcast_block (const block_state_ptr& bs) { + void dispatch_manager::bcast_block(const block_state_ptr& bs) { std::set skips; auto range = received_blocks.equal_range(bs->id); for (auto org = range.first; org != range.second; ++org) { @@ -1640,7 +1627,7 @@ namespace eosio { } - void dispatch_manager::recv_block (connection_ptr c, const block_id_type& id, uint32_t bnum) { + void dispatch_manager::recv_block(const connection_ptr& c, const block_id_type& id, uint32_t bnum) { received_blocks.insert(std::make_pair(id, c)); if (c && c->last_req && @@ -1655,13 +1642,13 @@ namespace eosio { c->cancel_wait(); } - void dispatch_manager::rejected_block (const block_id_type& id) { + void dispatch_manager::rejected_block(const block_id_type& id) { fc_dlog(logger,"not sending rejected transaction ${tid}",("tid",id)); auto range = received_blocks.equal_range(id); received_blocks.erase(range.first, range.second); } - void dispatch_manager::bcast_transaction (const packed_transaction& trx) { + void dispatch_manager::bcast_transaction(const packed_transaction& trx) { std::set skips; transaction_id_type id = trx.id(); @@ -1692,7 +1679,7 @@ namespace eosio { 0, 0, 0}; my_impl->local_txns.insert(std::move(nts)); - my_impl->send_all( buff, [&id, &skips, trx_expiration](connection_ptr c) -> bool { + my_impl->send_all( buff, [&id, &skips, trx_expiration](const connection_ptr& c) -> bool { if( skips.find(c) != skips.end() || c->syncing ) { return false; } @@ -1707,7 +1694,7 @@ namespace eosio { } - void dispatch_manager::recv_transaction (connection_ptr c, const transaction_id_type& id) { + void dispatch_manager::recv_transaction(const connection_ptr& c, const transaction_id_type& id) { received_transactions.insert(std::make_pair(id, c)); if (c && c->last_req && @@ -1721,13 +1708,13 @@ namespace eosio { c->cancel_wait(); } - void dispatch_manager::rejected_transaction (const transaction_id_type& id) { + void dispatch_manager::rejected_transaction(const transaction_id_type& id) { fc_dlog(logger,"not sending rejected transaction ${tid}",("tid",id)); auto range = received_transactions.equal_range(id); received_transactions.erase(range.first, range.second); } - void dispatch_manager::recv_notice (connection_ptr c, const notice_message& msg, bool generated) { + void dispatch_manager::recv_notice(const connection_ptr& c, const notice_message& msg, bool generated) { request_message req; req.req_trx.mode = none; req.req_blocks.mode = none; @@ -1777,7 +1764,7 @@ namespace eosio { } } - void dispatch_manager::retry_fetch( connection_ptr c ) { + void dispatch_manager::retry_fetch(const connection_ptr& c) { if (!c->last_req) { return; } @@ -1827,7 +1814,7 @@ namespace eosio { //------------------------------------------------------------------------ - void net_plugin_impl::connect( connection_ptr c ) { + void net_plugin_impl::connect(const connection_ptr& c) { if( c->no_retry != go_away_reason::no_reason) { fc_dlog( logger, "Skipping connect due to go_away reason ${r}",("r", reason_str( c->no_retry ))); return; @@ -1869,7 +1856,7 @@ namespace eosio { }); } - void net_plugin_impl::connect( connection_ptr c, tcp::resolver::iterator endpoint_itr ) { + void net_plugin_impl::connect(const connection_ptr& c, tcp::resolver::iterator endpoint_itr) { if( c->no_retry != go_away_reason::no_reason) { string rsn = reason_str(c->no_retry); return; @@ -1900,7 +1887,7 @@ namespace eosio { } ); } - bool net_plugin_impl::start_session( connection_ptr con ) { + bool net_plugin_impl::start_session(const connection_ptr& con) { boost::asio::ip::tcp::no_delay nodelay( true ); boost::system::error_code ec; con->socket->set_option( nodelay, ec ); @@ -1922,7 +1909,7 @@ namespace eosio { } - void net_plugin_impl::start_listen_loop( ) { + void net_plugin_impl::start_listen_loop() { auto socket = std::make_shared( std::ref( app().get_io_service() ) ); acceptor->async_accept( *socket, [socket,this]( boost::system::error_code ec ) { if( !ec ) { @@ -1986,7 +1973,7 @@ namespace eosio { }); } - void net_plugin_impl::start_read_message( connection_ptr conn ) { + void net_plugin_impl::start_read_message(const connection_ptr& conn) { try { if(!conn->socket) { @@ -2111,7 +2098,7 @@ namespace eosio { template - void net_plugin_impl::send_all( const std::shared_ptr>& send_buffer, VerifierFunc verify) { + void net_plugin_impl::send_all(const std::shared_ptr>& send_buffer, VerifierFunc verify) { for( auto &c : connections) { if( c->current() && verify( c )) { c->enqueue_buffer( send_buffer, true, no_reason ); @@ -2119,7 +2106,7 @@ namespace eosio { } } - bool net_plugin_impl::is_valid( const handshake_message &msg) { + bool net_plugin_impl::is_valid(const handshake_message& msg) { // Do some basic validation of an incoming handshake_message, so things // that really aren't handshake messages can be quickly discarded without // affecting state. @@ -2144,12 +2131,11 @@ namespace eosio { return valid; } - void net_plugin_impl::handle_message( connection_ptr c, const chain_size_message &msg) { + void net_plugin_impl::handle_message(const connection_ptr& c, const chain_size_message& msg) { peer_ilog(c, "received chain_size_message"); - } - void net_plugin_impl::handle_message( connection_ptr c, const handshake_message &msg) { + void net_plugin_impl::handle_message(const connection_ptr& c, const handshake_message& msg) { peer_ilog(c, "received handshake_message"); if (!is_valid(msg)) { peer_elog( c, "bad handshake message"); @@ -2256,7 +2242,7 @@ namespace eosio { sync_master->recv_handshake(c,msg); } - void net_plugin_impl::handle_message( connection_ptr c, const go_away_message &msg ) { + void net_plugin_impl::handle_message(const connection_ptr& c, const go_away_message& msg) { string rsn = reason_str( msg.reason ); peer_ilog(c, "received go_away_message"); ilog( "received a go away message from ${p}, reason = ${r}", @@ -2269,7 +2255,7 @@ namespace eosio { close (c); } - void net_plugin_impl::handle_message(connection_ptr c, const time_message &msg) { + void net_plugin_impl::handle_message(const connection_ptr& c, const time_message& msg) { peer_ilog(c, "received time_message"); /* We've already lost however many microseconds it took to dispatch * the message, but it can't be helped. @@ -2302,7 +2288,7 @@ namespace eosio { c->rec = 0; } - void net_plugin_impl::handle_message( connection_ptr c, const notice_message &msg) { + void net_plugin_impl::handle_message(const connection_ptr& c, const notice_message& msg) { // peer tells us about one or more blocks or txns. When done syncing, forward on // notices of previously unknown blocks or txns, // @@ -2366,7 +2352,7 @@ namespace eosio { } } - void net_plugin_impl::handle_message( connection_ptr c, const request_message &msg) { + void net_plugin_impl::handle_message(const connection_ptr& c, const request_message& msg) { switch (msg.req_blocks.mode) { case catch_up : peer_ilog(c, "received request_message:catch_up"); @@ -2396,7 +2382,7 @@ namespace eosio { } - void net_plugin_impl::handle_message( connection_ptr c, const sync_request_message &msg) { + void net_plugin_impl::handle_message(const connection_ptr& c, const sync_request_message& msg) { if( msg.end_block == 0) { c->peer_requested.reset(); c->flush_queues(); @@ -2406,7 +2392,7 @@ namespace eosio { } } - void net_plugin_impl::handle_message( connection_ptr c, const packed_transaction &msg) { + void net_plugin_impl::handle_message(const connection_ptr& c, const packed_transaction& msg) { fc_dlog(logger, "got a packed transaction, cancel wait"); peer_ilog(c, "received packed_transaction"); controller& cc = my_impl->chain_plug->chain(); @@ -2443,7 +2429,7 @@ namespace eosio { }); } - void net_plugin_impl::handle_message( connection_ptr c, const signed_block_ptr& msg) { + void net_plugin_impl::handle_message(const connection_ptr& c, const signed_block_ptr& msg) { controller &cc = chain_plug->chain(); block_id_type blk_id = msg->id(); uint32_t blk_num = msg->block_num(); @@ -2602,7 +2588,7 @@ namespace eosio { start_conn_timer(connector_period, std::weak_ptr()); } - void net_plugin_impl::close( connection_ptr c ) { + void net_plugin_impl::close(const connection_ptr& c ) { if( c->peer_addr.empty( ) && c->socket->is_open() ) { if (num_clients == 0) { fc_wlog( logger, "num_clients already at 0"); @@ -3038,7 +3024,7 @@ namespace eosio { } return result; } - connection_ptr net_plugin_impl::find_connection( string host )const { + connection_ptr net_plugin_impl::find_connection(const string& host )const { for( const auto& c : connections ) if( c->peer_addr == host ) return c; return connection_ptr(); From ac374bb0ca913ee3ced5ca0ef042ff6543df3740 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Sat, 1 Dec 2018 22:25:31 -0600 Subject: [PATCH 034/111] Use sha256_less for all sets/maps with ids --- plugins/net_plugin/net_plugin.cpp | 160 ++++++++++++++---------------- 1 file changed, 77 insertions(+), 83 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index a80ffc1019c..42bf2a523d9 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -26,7 +25,6 @@ #include #include #include -#include using namespace eosio::chain::plugin_interface::compat; @@ -42,7 +40,6 @@ namespace eosio { using boost::asio::ip::tcp; using boost::asio::ip::address_v4; using boost::asio::ip::host_name; - using boost::intrusive::rbtree; using boost::multi_index_container; using fc::time_point; @@ -73,10 +70,10 @@ namespace eosio { struct update_in_flight { int32_t incr; - update_in_flight (int32_t delta) : incr (delta) {} + update_in_flight(int32_t delta) : incr(delta) {} void operator() (node_transaction_state& nts) { int32_t exp = nts.expires.sec_since_epoch(); - nts.expires = fc::time_point_sec (exp + incr * 60); + nts.expires = fc::time_point_sec(exp + incr * 60); if( nts.requests == 0 ) { nts.true_block = nts.block_num; nts.block_num = 0; @@ -183,7 +180,7 @@ namespace eosio { void connect(const connection_ptr& c); void connect(const connection_ptr& c, tcp::resolver::iterator endpoint_itr); bool start_session(const connection_ptr& c); - void start_listen_loop( ); + void start_listen_loop(); void start_read_message(const connection_ptr& c); void close(const connection_ptr& c); @@ -229,10 +226,10 @@ namespace eosio { void handle_message(const connection_ptr& c, const packed_transaction& msg); void start_conn_timer(boost::asio::steady_timer::duration du, std::weak_ptr from_connection); - void start_txn_timer( ); - void start_monitors( ); + void start_txn_timer(); + void start_monitors(); - void expire_txns( ); + void expire_txns(); void connection_monitor(std::weak_ptr from_connection); /** \name Peer Timestamps * Time message handling @@ -377,7 +374,7 @@ namespace eosio { }; struct update_request_time { - void operator () (struct eosio::peer_block_state &bs) { + void operator() (struct eosio::peer_block_state &bs) { bs.requested_time = time_point::now(); } } set_request_time; @@ -528,8 +525,8 @@ namespace eosio { const string peer_name(); - void txn_send_pending(const vector &ids); - void txn_send(const vector &txn_lis); + void txn_send_pending(const vector& ids); + void txn_send(const vector& txn_lis); void blk_send_branch(); void blk_send(const vector &txn_lis); @@ -541,7 +538,7 @@ namespace eosio { void cancel_sync(go_away_reason); void flush_queues(); bool enqueue_sync_block(); - void request_sync_blocks (uint32_t start, uint32_t end); + void request_sync_blocks(uint32_t start, uint32_t end); void cancel_wait(); void sync_wait(); @@ -655,13 +652,13 @@ namespace eosio { public: uint32_t just_send_it_max = 0; - std::multimap received_blocks; - std::multimap received_transactions; + std::multimap received_blocks; + std::multimap received_transactions; void bcast_transaction(const packed_transaction& msg); void rejected_transaction(const transaction_id_type& msg); void bcast_block(const block_state_ptr& bs); - void rejected_block(const block_id_type &id); + void rejected_block(const block_id_type& id); void recv_block(const connection_ptr& conn, const block_id_type& msg, uint32_t bnum); void recv_transaction(const connection_ptr& conn, const transaction_id_type& id); @@ -757,7 +754,7 @@ namespace eosio { connecting = false; syncing = false; if( last_req ) { - my_impl->dispatcher->retry_fetch (shared_from_this()); + my_impl->dispatcher->retry_fetch(shared_from_this()); } reset(); sent_handshake_count = 0; @@ -769,16 +766,11 @@ namespace eosio { pending_message_buffer.reset(); } - void connection::txn_send_pending(const vector &ids) { + void connection::txn_send_pending(const vector& ids) { + const std::set known_ids(ids.cbegin(), ids.cend()); for(auto tx = my_impl->local_txns.begin(); tx != my_impl->local_txns.end(); ++tx ){ if( tx->block_num == 0 ) { - bool found = false; - for(auto known : ids) { - if( known == tx->id) { - found = true; - break; - } - } + const bool found = known_ids.find(tx->id) != known_ids.cend(); if(!found) { my_impl->local_txns.modify(tx,incr_in_flight); queue_write(tx->serialized_txn, @@ -797,7 +789,7 @@ namespace eosio { } } - void connection::txn_send(const vector &ids) { + void connection::txn_send(const vector& ids) { for(const auto& t : ids) { auto tx = my_impl->local_txns.get().find(t); if( tx != my_impl->local_txns.end() ) { @@ -818,8 +810,8 @@ namespace eosio { } void connection::blk_send_branch() { - controller &cc = my_impl->chain_plug->chain(); - uint32_t head_num = cc.fork_db_head_block_num (); + controller& cc = my_impl->chain_plug->chain(); + uint32_t head_num = cc.fork_db_head_block_num(); notice_message note; note.known_blocks.mode = normal; note.known_blocks.pending = 0; @@ -848,12 +840,12 @@ namespace eosio { } head_id = cc.fork_db_head_block_id(); } - catch (const assert_exception &ex) { + catch (const assert_exception& ex) { elog( "unable to retrieve block info: ${n} for ${p}",("n",ex.to_string())("p",peer_name())); enqueue(note); return; } - catch (const fc::exception &ex) { + catch (const fc::exception& ex) { } catch (...) { } @@ -933,7 +925,7 @@ namespace eosio { syncing = false; } - void connection::send_handshake( ) { + void connection::send_handshake() { handshake_initializer::populate(last_handshake_sent); last_handshake_sent.generation = ++sent_handshake_count; fc_dlog(logger, "Sending handshake generation ${g} to ${ep}", @@ -1128,7 +1120,7 @@ namespace eosio { response_expected->cancel(); } - void connection::sync_wait( ) { + void connection::sync_wait() { response_expected->expires_from_now( my_impl->resp_expected_period); connection_wptr c(shared_from_this()); response_expected->async_wait( [c]( boost::system::error_code ec){ @@ -1158,12 +1150,12 @@ namespace eosio { void connection::sync_timeout( boost::system::error_code ec ) { if( !ec ) { - my_impl->sync_master->reassign_fetch (shared_from_this(),benign_other); + my_impl->sync_master->reassign_fetch(shared_from_this(), benign_other); } else if( ec == boost::asio::error::operation_aborted) { } else { - elog ("setting timer for sync request got error ${ec}",("ec", ec.message())); + elog("setting timer for sync request got error ${ec}",("ec", ec.message())); } } @@ -1179,21 +1171,21 @@ namespace eosio { void connection::fetch_timeout( boost::system::error_code ec ) { if( !ec ) { - if( pending_fetch.valid() && !( pending_fetch->req_trx.empty( ) || pending_fetch->req_blocks.empty( ) ) ) { - my_impl->dispatcher->retry_fetch (shared_from_this() ); + if( pending_fetch.valid() && !( pending_fetch->req_trx.empty() || pending_fetch->req_blocks.empty() ) ) { + my_impl->dispatcher->retry_fetch(shared_from_this()); } } else if( ec == boost::asio::error::operation_aborted ) { - if( !connected( ) ) { + if( !connected() ) { fc_dlog(logger, "fetch timeout was cancelled due to dead connection"); } } else { - elog( "setting timer for fetch request got error ${ec}", ("ec", ec.message( ) ) ); + elog( "setting timer for fetch request got error ${ec}", ("ec", ec.message() ) ); } } - void connection::request_sync_blocks (uint32_t start, uint32_t end) { + void connection::request_sync_blocks(uint32_t start, uint32_t end) { sync_request_message srm = {start,end}; enqueue( net_message(srm)); sync_wait(); @@ -1246,11 +1238,11 @@ namespace eosio { ,source() ,state(in_sync) { - chain_plug = app( ).find_plugin( ); + chain_plug = app().find_plugin(); EOS_ASSERT( chain_plug, chain::missing_chain_plugin_exception, "" ); } - constexpr auto sync_manager::stage_str(stages s ) { + constexpr auto sync_manager::stage_str(stages s) { switch (s) { case in_sync : return "in sync"; case lib_catchup: return "lib catchup"; @@ -1263,7 +1255,7 @@ namespace eosio { if (state == newstate) { return; } - fc_dlog(logger, "old state ${os} becoming ${ns}",("os",stage_str (state))("ns",stage_str (newstate))); + fc_dlog(logger, "old state ${os} becoming ${ns}",("os",stage_str(state))("ns",stage_str(newstate))); state = newstate; } @@ -1291,19 +1283,19 @@ namespace eosio { } } - bool sync_manager::sync_required( ) { + bool sync_manager::sync_required() { fc_dlog(logger, "last req = ${req}, last recv = ${recv} known = ${known} our head = ${head}", - ("req",sync_last_requested_num)("recv",sync_next_expected_num)("known",sync_known_lib_num)("head",chain_plug->chain( ).fork_db_head_block_num( ))); + ("req",sync_last_requested_num)("recv",sync_next_expected_num)("known",sync_known_lib_num)("head",chain_plug->chain().fork_db_head_block_num())); return( sync_last_requested_num < sync_known_lib_num || - chain_plug->chain( ).fork_db_head_block_num( ) < sync_last_requested_num ); + chain_plug->chain().fork_db_head_block_num() < sync_last_requested_num ); } void sync_manager::request_next_chunk( const connection_ptr& conn ) { uint32_t head_block = chain_plug->chain().fork_db_head_block_num(); if (head_block < sync_last_requested_num && source && source->current()) { - fc_ilog (logger, "ignoring request, head is ${h} last req = ${r} source is ${p}", + fc_ilog(logger, "ignoring request, head is ${h} last req = ${r} source is ${p}", ("h",head_block)("r",sync_last_requested_num)("p",source->peer_name())); return; } @@ -1420,7 +1412,7 @@ namespace eosio { ( "cc",sync_last_requested_num)("ne",sync_next_expected_num)("p",c->peer_name())); if (c == source) { - c->cancel_sync (reason); + c->cancel_sync(reason); sync_last_requested_num = 0; request_next_chunk(); } @@ -1428,7 +1420,7 @@ namespace eosio { void sync_manager::recv_handshake(const connection_ptr& c, const handshake_message& msg) { controller& cc = chain_plug->chain(); - uint32_t lib_num = cc.last_irreversible_block_num( ); + uint32_t lib_num = cc.last_irreversible_block_num(); uint32_t peer_lib = msg.last_irreversible_block_num; reset_lib_num(c); c->syncing = false; @@ -1436,16 +1428,16 @@ namespace eosio { //-------------------------------- // sync need checks; (lib == last irreversible block) // - // 0. my head block id == peer head id means we are all caugnt up block wise + // 0. my head block id == peer head id means we are all caught up block wise // 1. my head block num < peer lib - start sync locally // 2. my lib > peer head num - send an last_irr_catch_up notice if not the first generation // // 3 my head block num <= peer head block num - update sync state and send a catchup request - // 4 my head block num > peer block num ssend a notice catchup if this is not the first generation + // 4 my head block num > peer block num send a notice catchup if this is not the first generation // //----------------------------- - uint32_t head = cc.fork_db_head_block_num( ); + uint32_t head = cc.fork_db_head_block_num(); block_id_type head_id = cc.fork_db_head_block_id(); if (head_id == msg.head_id) { fc_dlog(logger, "sync check state 0"); @@ -1497,7 +1489,7 @@ namespace eosio { c->syncing = true; return; } - elog ("sync check failed to resolve status"); + elog("sync check failed to resolve status"); } void sync_manager::verify_catchup(const connection_ptr& c, uint32_t num, const block_id_type& id) { @@ -1513,7 +1505,8 @@ namespace eosio { if( req.req_blocks.mode == catch_up ) { c->fork_head = id; c->fork_head_num = num; - ilog ("got a catch_up notice while in ${s}, fork head num = ${fhn} target LIB = ${lib} next_expected = ${ne}", ("s",stage_str(state))("fhn",num)("lib",sync_known_lib_num)("ne", sync_next_expected_num)); + ilog("got a catch_up notice while in ${s}, fork head num = ${fhn} target LIB = ${lib} next_expected = ${ne}", + ("s",stage_str(state))("fhn",num)("lib",sync_known_lib_num)("ne", sync_next_expected_num)); if (state == lib_catchup) return; set_state(head_catchup); @@ -1527,10 +1520,10 @@ namespace eosio { } void sync_manager::recv_notice(const connection_ptr& c, const notice_message& msg) { - fc_ilog (logger, "sync_manager got ${m} block notice",("m",modes_str(msg.known_blocks.mode))); + fc_ilog(logger, "sync_manager got ${m} block notice",("m",modes_str(msg.known_blocks.mode))); if (msg.known_blocks.mode == catch_up) { if (msg.known_blocks.ids.size() == 0) { - elog ("got a catch up with ids size = 0"); + elog("got a catch up with ids size = 0"); } else { verify_catchup(c, msg.known_blocks.pending, msg.known_blocks.ids.back()); @@ -1538,14 +1531,14 @@ namespace eosio { } else { c->last_handshake_recv.last_irreversible_block_num = msg.known_trx.pending; - reset_lib_num (c); + reset_lib_num(c); start_sync(c, msg.known_trx.pending); } } void sync_manager::rejected_block(const connection_ptr& c, uint32_t blk_num) { if (state != in_sync ) { - fc_ilog (logger, "block ${bn} not accepted from ${p}",("bn",blk_num)("p",c->peer_name())); + fc_ilog(logger, "block ${bn} not accepted from ${p}",("bn",blk_num)("p",c->peer_name())); sync_last_requested_num = 0; source.reset(); my_impl->close(c); @@ -1557,14 +1550,14 @@ namespace eosio { fc_dlog(logger," got block ${bn} from ${p}",("bn",blk_num)("p",c->peer_name())); if (state == lib_catchup) { if (blk_num != sync_next_expected_num) { - fc_ilog (logger, "expected block ${ne} but got ${bn}",("ne",sync_next_expected_num)("bn",blk_num)); + fc_ilog(logger, "expected block ${ne} but got ${bn}",("ne",sync_next_expected_num)("bn",blk_num)); my_impl->close(c); return; } sync_next_expected_num = blk_num + 1; } if (state == head_catchup) { - fc_dlog (logger, "sync_manager in head_catchup state"); + fc_dlog(logger, "sync_manager in head_catchup state"); set_state(in_sync); source.reset(); @@ -1658,7 +1651,7 @@ namespace eosio { } received_transactions.erase(range.first, range.second); - if( my_impl->local_txns.get().find( id ) != my_impl->local_txns.end( ) ) { //found + if( my_impl->local_txns.get().find( id ) != my_impl->local_txns.end() ) { //found fc_dlog(logger, "found trxid in local_trxs" ); return; } @@ -1725,7 +1718,7 @@ namespace eosio { send_req = false; } else if (msg.known_trx.mode != none) { - elog ("passed a notice_message with something other than a normal on none known_trx"); + elog("passed a notice_message with something other than a normal on none known_trx"); return; } if (msg.known_blocks.mode == normal) { @@ -1753,7 +1746,7 @@ namespace eosio { } } else if (msg.known_blocks.mode != none) { - elog ("passed a notice_message with something other than a normal on none known_blocks"); + elog("passed a notice_message with something other than a normal on none known_blocks"); return; } fc_dlog( logger, "send req = ${sr}", ("sr",send_req)); @@ -1823,7 +1816,7 @@ namespace eosio { auto colon = c->peer_addr.find(':'); if (colon == std::string::npos || colon == 0) { - elog ("Invalid peer address. must be \"host:port\": ${p}", ("p",c->peer_addr)); + elog("Invalid peer address. must be \"host:port\": ${p}", ("p",c->peer_addr)); for ( auto itr : connections ) { if((*itr).peer_addr == c->peer_addr) { (*itr).reset(); @@ -1870,7 +1863,7 @@ namespace eosio { if (!c) return; if( !err && c->socket->is_open() ) { if (start_session( c )) { - c->send_handshake (); + c->send_handshake(); } } else { if( endpoint_itr != tcp::resolver::iterator() ) { @@ -1932,7 +1925,7 @@ namespace eosio { } } if (num_clients != visitors) { - ilog ("checking max client, visitors = ${v} num clients ${n}",("v",visitors)("n",num_clients)); + ilog("checking max client, visitors = ${v} num clients ${n}",("v",visitors)("n",num_clients)); num_clients = visitors; } if( from_addr < max_nodes_per_host && (max_client_count == 0 || num_clients < max_client_count )) { @@ -1951,7 +1944,7 @@ namespace eosio { fc_elog(logger, "Error max_client_count ${m} exceeded", ( "m", max_client_count) ); } - socket->close( ); + socket->close(); } } } else { @@ -2028,7 +2021,8 @@ namespace eosio { conn->pending_message_buffer.peek(&message_length, sizeof(message_length), index); if(message_length > def_send_buffer_size*2 || message_length == 0) { boost::system::error_code ec; - elog("incoming message length unexpected (${i}), from ${p}", ("i", message_length)("p",boost::lexical_cast(conn->socket->remote_endpoint(ec)))); + elog("incoming message length unexpected (${i}), from ${p}", + ("i", message_length)("p",boost::lexical_cast(conn->socket->remote_endpoint(ec)))); close(conn); return; } @@ -2143,7 +2137,7 @@ namespace eosio { return; } controller& cc = chain_plug->chain(); - uint32_t lib_num = cc.last_irreversible_block_num( ); + uint32_t lib_num = cc.last_irreversible_block_num(); uint32_t peer_lib = msg.last_irreversible_block_num; if( c->connecting ) { c->connecting = false; @@ -2252,7 +2246,7 @@ namespace eosio { c->node_id = msg.node_id; } c->flush_queues(); - close (c); + close(c); } void net_plugin_impl::handle_message(const connection_ptr& c, const time_message& msg) { @@ -2314,7 +2308,7 @@ namespace eosio { send_req = true; size_t known_sum = local_txns.size(); if( known_sum ) { - for( const auto& t : local_txns.get( ) ) { + for( const auto& t : local_txns.get() ) { req.req_trx.ids.push_back( t.id ); } } @@ -2322,7 +2316,7 @@ namespace eosio { break; } case normal: { - dispatcher->recv_notice (c, msg, false); + dispatcher->recv_notice(c, msg, false); } } @@ -2339,7 +2333,7 @@ namespace eosio { break; } case normal : { - dispatcher->recv_notice (c, msg, false); + dispatcher->recv_notice(c, msg, false); break; } default: { @@ -2356,7 +2350,7 @@ namespace eosio { switch (msg.req_blocks.mode) { case catch_up : peer_ilog(c, "received request_message:catch_up"); - c->blk_send_branch( ); + c->blk_send_branch(); break; case normal : peer_ilog(c, "received request_message:normal"); @@ -2511,21 +2505,21 @@ namespace eosio { transaction_check->expires_from_now( txn_exp_period); transaction_check->async_wait( [this](boost::system::error_code ec) { if( !ec) { - expire_txns( ); + expire_txns(); } else { elog( "Error from transaction check monitor: ${m}",( "m", ec.message())); - start_txn_timer( ); + start_txn_timer(); } }); } void net_plugin_impl::ticker() { - keepalive_timer->expires_from_now (keepalive_interval); - keepalive_timer->async_wait ([this](boost::system::error_code ec) { - ticker (); + keepalive_timer->expires_from_now(keepalive_interval); + keepalive_timer->async_wait([this](boost::system::error_code ec) { + ticker(); if (ec) { - wlog ("Peer keepalive ticked sooner than expected: ${m}", ("m", ec.message())); + wlog("Peer keepalive ticked sooner than expected: ${m}", ("m", ec.message())); } for (auto &c : connections ) { if (c->socket->is_open()) { @@ -2543,7 +2537,7 @@ namespace eosio { } void net_plugin_impl::expire_txns() { - start_txn_timer( ); + start_txn_timer(); auto &old = local_txns.get(); auto ex_up = old.upper_bound( time_point::now()); auto ex_lo = old.lower_bound( fc::time_point_sec( 0)); @@ -2588,8 +2582,8 @@ namespace eosio { start_conn_timer(connector_period, std::weak_ptr()); } - void net_plugin_impl::close(const connection_ptr& c ) { - if( c->peer_addr.empty( ) && c->socket->is_open() ) { + void net_plugin_impl::close(const connection_ptr& c) { + if( c->peer_addr.empty() && c->socket->is_open() ) { if (num_clients == 0) { fc_wlog( logger, "num_clients already at 0"); } @@ -3030,7 +3024,7 @@ namespace eosio { return connection_ptr(); } - uint16_t net_plugin_impl::to_protocol_version (uint16_t v) { + uint16_t net_plugin_impl::to_protocol_version(uint16_t v) { if (v >= net_version_base) { v -= net_version_base; return (v > net_version_range) ? 0 : v; From 7bcdcbc02d135eeba63689d6237afac232e3f1f2 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 3 Dec 2018 10:49:33 -0600 Subject: [PATCH 035/111] Add explicit constructors --- libraries/chain/include/eosio/chain/block.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/chain/include/eosio/chain/block.hpp b/libraries/chain/include/eosio/chain/block.hpp index a00e029744a..c052dab439d 100644 --- a/libraries/chain/include/eosio/chain/block.hpp +++ b/libraries/chain/include/eosio/chain/block.hpp @@ -19,22 +19,22 @@ namespace eosio { namespace chain { }; transaction_receipt_header():status(hard_fail){} - transaction_receipt_header( status_enum s ):status(s){} + explicit transaction_receipt_header( status_enum s ):status(s){} friend inline bool operator ==( const transaction_receipt_header& lhs, const transaction_receipt_header& rhs ) { return std::tie(lhs.status, lhs.cpu_usage_us, lhs.net_usage_words) == std::tie(rhs.status, rhs.cpu_usage_us, rhs.net_usage_words); } fc::enum_type status; - uint32_t cpu_usage_us; ///< total billed CPU usage (microseconds) + uint32_t cpu_usage_us = 0; ///< total billed CPU usage (microseconds) fc::unsigned_int net_usage_words; ///< total billed NET usage, so we can reconstruct resource state when skipping context free data... hard failures... }; struct transaction_receipt : public transaction_receipt_header { transaction_receipt():transaction_receipt_header(){} - transaction_receipt( transaction_id_type tid ):transaction_receipt_header(executed),trx(tid){} - transaction_receipt( packed_transaction ptrx ):transaction_receipt_header(executed),trx(ptrx){} + explicit transaction_receipt( transaction_id_type tid ):transaction_receipt_header(executed),trx(tid){} + explicit transaction_receipt( packed_transaction ptrx ):transaction_receipt_header(executed),trx(ptrx){} fc::static_variant trx; @@ -59,8 +59,9 @@ namespace eosio { namespace chain { signed_block( const signed_block& ) = default; public: signed_block() = default; - signed_block( const signed_block_header& h ):signed_block_header(h){} + explicit signed_block( const signed_block_header& h ):signed_block_header(h){} signed_block( signed_block&& ) = default; + signed_block& operator=(const signed_block&) = delete; signed_block clone() const { return *this; } vector transactions; /// new or generated transactions From de9742eeaebf88fec61410df140ff6fc3601ca7b Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 3 Dec 2018 10:50:59 -0600 Subject: [PATCH 036/111] Add accept_transaction that takes a packed_transaction_ptr to avoid copy --- plugins/chain_plugin/chain_plugin.cpp | 4 ++++ .../chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp | 1 + 2 files changed, 5 insertions(+) diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index cf7a34ebd01..cfe4ea38268 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -759,6 +759,10 @@ void chain_plugin::accept_transaction(const chain::packed_transaction& trx, next my->incoming_transaction_async_method(std::make_shared(trx), false, std::forward(next)); } +void chain_plugin::accept_transaction(const chain::packed_transaction_ptr& trx, next_function next) { + my->incoming_transaction_async_method(trx, false, std::forward(next)); +} + bool chain_plugin::block_is_on_preferred_chain(const block_id_type& block_id) { auto b = chain().fetch_block_by_number( block_header::num_from_id(block_id) ); return b && b->id() == block_id; 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 9be045700db..0f4af5dcd27 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp @@ -664,6 +664,7 @@ class chain_plugin : public plugin { void accept_block( const chain::signed_block_ptr& block ); void accept_transaction(const chain::packed_transaction& trx, chain::plugin_interface::next_function next); + void accept_transaction(const chain::packed_transaction_ptr& trx, chain::plugin_interface::next_function next); bool block_is_on_preferred_chain(const chain::block_id_type& block_id); From 7923af931a0e788676e546b79f88bf7c65ea47b4 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 3 Dec 2018 12:55:20 -0600 Subject: [PATCH 037/111] Pass id and packed_transaction by const& since never moved --- libraries/chain/include/eosio/chain/block.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/chain/include/eosio/chain/block.hpp b/libraries/chain/include/eosio/chain/block.hpp index c052dab439d..eee489e2961 100644 --- a/libraries/chain/include/eosio/chain/block.hpp +++ b/libraries/chain/include/eosio/chain/block.hpp @@ -33,8 +33,8 @@ namespace eosio { namespace chain { struct transaction_receipt : public transaction_receipt_header { transaction_receipt():transaction_receipt_header(){} - explicit transaction_receipt( transaction_id_type tid ):transaction_receipt_header(executed),trx(tid){} - explicit transaction_receipt( packed_transaction ptrx ):transaction_receipt_header(executed),trx(ptrx){} + explicit transaction_receipt( const transaction_id_type& tid ):transaction_receipt_header(executed),trx(tid){} + explicit transaction_receipt( const packed_transaction& ptrx ):transaction_receipt_header(executed),trx(ptrx){} fc::static_variant trx; From b4ad4a3f2c296673f4ef0d456b232450c5ba0f67 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 3 Dec 2018 13:16:36 -0600 Subject: [PATCH 038/111] Remove copy assignment operator. Remove used std::move. --- libraries/chain/include/eosio/chain/transaction.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/chain/include/eosio/chain/transaction.hpp b/libraries/chain/include/eosio/chain/transaction.hpp index 895d3ee4fb8..de343334e7a 100644 --- a/libraries/chain/include/eosio/chain/transaction.hpp +++ b/libraries/chain/include/eosio/chain/transaction.hpp @@ -102,6 +102,10 @@ namespace eosio { namespace chain { }; packed_transaction() = default; + packed_transaction(packed_transaction&&) = default; + explicit packed_transaction(const packed_transaction&) = default; + packed_transaction& operator=(const packed_transaction&) = delete; + packed_transaction& operator=(packed_transaction&&) = default; explicit packed_transaction(const transaction& t, compression_type _compression = none) { @@ -117,7 +121,7 @@ namespace eosio { namespace chain { explicit packed_transaction(signed_transaction&& t, compression_type _compression = none) :signatures(std::move(t.signatures)) { - set_transaction(t, std::move(t.context_free_data), _compression); + set_transaction(t, t.context_free_data, _compression); } uint32_t get_unprunable_size()const; From cfc3a857ef618cc4006a2f853cbfa87e2971acc3 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 3 Dec 2018 13:20:11 -0600 Subject: [PATCH 039/111] Minimize packed_transaction copies. Store packed_transaction_ptr in transaction_metadata. --- libraries/chain/controller.cpp | 8 ++-- .../eosio/chain/transaction_metadata.hpp | 12 +++--- plugins/bnet_plugin/bnet_plugin.cpp | 2 +- plugins/history_plugin/history_plugin.cpp | 4 +- .../include/eosio/net_plugin/protocol.hpp | 4 +- plugins/net_plugin/net_plugin.cpp | 43 ++++++++++++------- plugins/producer_plugin/producer_plugin.cpp | 5 ++- 7 files changed, 46 insertions(+), 32 deletions(-) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 4d980d5100a..c7dda941e01 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -1028,8 +1028,8 @@ struct controller_impl { trx_context.enforce_whiteblacklist = false; } else { bool skip_recording = replay_head_time && (time_point(trx->trx.expiration) <= *replay_head_time); - trx_context.init_for_input_trx( trx->packed_trx.get_unprunable_size(), - trx->packed_trx.get_prunable_size(), + trx_context.init_for_input_trx( trx->packed_trx->get_unprunable_size(), + trx->packed_trx->get_prunable_size(), trx->trx.signatures.size(), skip_recording); } @@ -1057,7 +1057,7 @@ struct controller_impl { transaction_receipt::status_enum s = (trx_context.delay == fc::seconds(0)) ? transaction_receipt::executed : transaction_receipt::delayed; - trace->receipt = push_receipt(trx->packed_trx, s, trx_context.billed_cpu_time_us, trace->net_usage); + trace->receipt = push_receipt(*trx->packed_trx, s, trx_context.billed_cpu_time_us, trace->net_usage); pending->_pending_block_state->trxs.emplace_back(trx); } else { transaction_receipt_header r; @@ -1203,7 +1203,7 @@ struct controller_impl { for( const auto& receipt : b->transactions ) { if( receipt.trx.contains()) { auto& pt = receipt.trx.get(); - auto mtrx = std::make_shared( pt ); + auto mtrx = std::make_shared( std::make_shared( pt ) ); if( !self.skip_auth_check() ) { std::weak_ptr mtrx_wp = mtrx; mtrx->signing_keys_future = async_thread_pool( [chain_id = this->chain_id, mtrx_wp]() { diff --git a/libraries/chain/include/eosio/chain/transaction_metadata.hpp b/libraries/chain/include/eosio/chain/transaction_metadata.hpp index c5eb0c790f4..7293e840c0c 100644 --- a/libraries/chain/include/eosio/chain/transaction_metadata.hpp +++ b/libraries/chain/include/eosio/chain/transaction_metadata.hpp @@ -18,7 +18,7 @@ class transaction_metadata { transaction_id_type id; transaction_id_type signed_id; signed_transaction trx; - packed_transaction packed_trx; + packed_transaction_ptr packed_trx; optional>> signing_keys; std::future>> signing_keys_future; bool accepted = false; @@ -26,17 +26,17 @@ class transaction_metadata { bool scheduled = false; explicit transaction_metadata( const signed_transaction& t, packed_transaction::compression_type c = packed_transaction::none ) - :trx(t),packed_trx(t, c) { + :trx(t),packed_trx(std::make_shared(t, c)) { id = trx.id(); //raw_packed = fc::raw::pack( static_cast(trx) ); - signed_id = digest_type::hash(packed_trx); + signed_id = digest_type::hash(*packed_trx); } - explicit transaction_metadata( const packed_transaction& ptrx ) - :trx( ptrx.get_signed_transaction() ), packed_trx(ptrx) { + explicit transaction_metadata( const packed_transaction_ptr& ptrx ) + :trx( ptrx->get_signed_transaction() ), packed_trx(ptrx) { id = trx.id(); //raw_packed = fc::raw::pack( static_cast(trx) ); - signed_id = digest_type::hash(packed_trx); + signed_id = digest_type::hash(*packed_trx); } const flat_set& recover_keys( const chain_id_type& chain_id ) { diff --git a/plugins/bnet_plugin/bnet_plugin.cpp b/plugins/bnet_plugin/bnet_plugin.cpp index 392df4b31eb..ce0a096b531 100644 --- a/plugins/bnet_plugin/bnet_plugin.cpp +++ b/plugins/bnet_plugin/bnet_plugin.cpp @@ -765,7 +765,7 @@ namespace eosio { return false; - auto ptrx_ptr = std::make_shared( start->trx->packed_trx ); + auto ptrx_ptr = start->trx->packed_trx; idx.modify( start, [&]( auto& stat ) { stat.mark_known_by_peer(); diff --git a/plugins/history_plugin/history_plugin.cpp b/plugins/history_plugin/history_plugin.cpp index 8245215b061..d802fc2ee78 100644 --- a/plugins/history_plugin/history_plugin.cpp +++ b/plugins/history_plugin/history_plugin.cpp @@ -504,7 +504,7 @@ namespace eosio { for (const auto &receipt: blk->transactions) { if (receipt.trx.contains()) { auto &pt = receipt.trx.get(); - auto mtrx = transaction_metadata(pt); + auto mtrx = transaction_metadata(std::make_shared(pt)); if (mtrx.id == result.id) { fc::mutable_variant_object r("receipt", receipt); r("trx", chain.to_variant_with_abi(mtrx.trx, abi_serializer_max_time)); @@ -528,7 +528,7 @@ namespace eosio { for (const auto& receipt: blk->transactions) { if (receipt.trx.contains()) { auto& pt = receipt.trx.get(); - auto mtrx = transaction_metadata(pt); + auto mtrx = transaction_metadata(std::make_shared(pt)); if( txn_id_matched(mtrx.id) ) { result.id = mtrx.id; result.last_irreversible_block = chain.last_irreversible_block_num(); diff --git a/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp b/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp index 36cb9c70bda..629ea571373 100644 --- a/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp +++ b/plugins/net_plugin/include/eosio/net_plugin/protocol.hpp @@ -139,8 +139,8 @@ namespace eosio { notice_message, request_message, sync_request_message, - signed_block, // which = 7 - packed_transaction>; + signed_block, // which = 7 + packed_transaction>; // which = 8 } // namespace eosio diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 42bf2a523d9..32154a9aab0 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -223,7 +223,8 @@ namespace eosio { void handle_message(const connection_ptr& c, const sync_request_message& msg); void handle_message(const connection_ptr& c, const signed_block& msg) = delete; // signed_block_ptr overload used instead void handle_message(const connection_ptr& c, const signed_block_ptr& msg); - void handle_message(const connection_ptr& c, const packed_transaction& msg); + void handle_message(const connection_ptr& c, const packed_transaction& msg) = delete; // packed_transaction_ptr overload used instead + void handle_message(const connection_ptr& c, const packed_transaction_ptr& msg); void start_conn_timer(boost::asio::steady_timer::duration du, std::weak_ptr from_connection); void start_txn_timer(); @@ -596,14 +597,24 @@ namespace eosio { msg_handler( net_plugin_impl &imp, const connection_ptr& conn) : impl(imp), c(conn) {} void operator()( const signed_block& msg ) const { - EOS_ASSERT( false, plugin_config_exception, "visit(signed_block&&) should be called" ); + EOS_ASSERT( false, plugin_config_exception, "operator()(signed_block&&) should be called" ); } void operator()( signed_block& msg ) const { - EOS_ASSERT( false, plugin_config_exception, "visit(signed_block&&) should be called" ); + EOS_ASSERT( false, plugin_config_exception, "operator()(signed_block&&) should be called" ); } + void operator()( const packed_transaction& msg ) const { + EOS_ASSERT( false, plugin_config_exception, "operator()(packed_transaction&&) should be called" ); + } + void operator()( packed_transaction& msg ) const { + EOS_ASSERT( false, plugin_config_exception, "operator()(packed_transaction&&) should be called" ); + } + void operator()( signed_block&& msg ) const { impl.handle_message( c, std::make_shared( std::forward( msg ))); } + void operator()( packed_transaction&& msg ) const { + impl.handle_message( c, std::make_shared( std::forward( msg ))); + } template void operator()( T&& msg ) const @@ -655,7 +666,7 @@ namespace eosio { std::multimap received_blocks; std::multimap received_transactions; - void bcast_transaction(const packed_transaction& msg); + void bcast_transaction(const packed_transaction_ptr& trx); void rejected_transaction(const transaction_id_type& msg); void bcast_block(const block_state_ptr& bs); void rejected_block(const block_id_type& id); @@ -1199,6 +1210,8 @@ namespace eosio { msg_handler m(impl, shared_from_this() ); if( msg.contains() ) { m( std::move( msg.get() ) ); + } else if( msg.contains() ) { + m( std::move( msg.get() ) ); } else { msg.visit( m ); } @@ -1641,9 +1654,9 @@ namespace eosio { received_blocks.erase(range.first, range.second); } - void dispatch_manager::bcast_transaction(const packed_transaction& trx) { + void dispatch_manager::bcast_transaction(const packed_transaction_ptr& trx) { std::set skips; - transaction_id_type id = trx.id(); + transaction_id_type id = trx->id(); auto range = received_transactions.equal_range(id); for (auto org = range.first; org != range.second; ++org) { @@ -1656,9 +1669,9 @@ namespace eosio { return; } - time_point_sec trx_expiration = trx.expiration(); + time_point_sec trx_expiration = trx->expiration(); - net_message msg(trx); + net_message msg(*trx); // todo remove copy uint32_t packsiz = fc::raw::pack_size(msg); uint32_t bufsiz = packsiz + sizeof(packsiz); auto buff = std::make_shared>(bufsiz); @@ -2386,7 +2399,7 @@ namespace eosio { } } - void net_plugin_impl::handle_message(const connection_ptr& c, const packed_transaction& msg) { + void net_plugin_impl::handle_message(const connection_ptr& c, const packed_transaction_ptr& trx) { fc_dlog(logger, "got a packed transaction, cancel wait"); peer_ilog(c, "received packed_transaction"); controller& cc = my_impl->chain_plug->chain(); @@ -2398,28 +2411,28 @@ namespace eosio { fc_dlog(logger, "got a txn during sync - dropping"); return; } - transaction_id_type tid = msg.id(); + transaction_id_type tid = trx->id(); c->cancel_wait(); if(local_txns.get().find(tid) != local_txns.end()) { fc_dlog(logger, "got a duplicate transaction - dropping"); return; } dispatcher->recv_transaction(c, tid); - chain_plug->accept_transaction(msg, [=](const static_variant& result) { + chain_plug->accept_transaction(trx, [c, this, trx](const static_variant& result) { if (result.contains()) { peer_dlog(c, "bad packed_transaction : ${m}", ("m",result.get()->what())); } else { auto trace = result.get(); if (!trace->except) { fc_dlog(logger, "chain accepted transaction"); - dispatcher->bcast_transaction(msg); + this->dispatcher->bcast_transaction(trx); return; } peer_elog(c, "bad packed_transaction : ${m}", ("m",trace->except->what())); } - dispatcher->rejected_transaction(tid); + dispatcher->rejected_transaction(trx->id()); }); } @@ -2627,7 +2640,7 @@ namespace eosio { dispatcher->rejected_transaction(id); } else { fc_ilog(logger,"signaled ACK, trx-id = ${id}",("id", id)); - dispatcher->bcast_transaction(*results.second); + dispatcher->bcast_transaction(results.second); } } @@ -2899,7 +2912,7 @@ namespace eosio { my->chain_plug = app().find_plugin(); EOS_ASSERT( my->chain_plug, chain::missing_chain_plugin_exception, "" ); - my->chain_id = app().get_plugin().get_chain_id(); + my->chain_id = my->chain_plug->get_chain_id(); fc::rand_pseudo_bytes( my->node_id.data(), my->node_id.data_size()); ilog( "my node_id is ${id}", ("id", my->node_id)); diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 5d2cd5637c4..13e752a7fc0 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -345,6 +345,7 @@ class producer_plugin_impl : public std::enable_shared_from_this>> _pending_incoming_transactions; void on_incoming_transaction_async(const packed_transaction_ptr& trx, bool persist_until_expired, next_function next) { + //todo remove chain_plugin lookup chain::controller& chain = app().get_plugin().chain(); if (!chain.pending_block_state()) { _pending_incoming_transactions.emplace_back(trx, persist_until_expired, next); @@ -401,7 +402,7 @@ class producer_plugin_impl : public std::enable_shared_from_this(*trx), deadline); + auto trace = chain.push_transaction(std::make_shared(trx), deadline); if (trace->except) { if (failure_is_subjective(*trace->except, deadline_is_subjective)) { _pending_incoming_transactions.emplace_back(trx, persist_until_expired, next); @@ -1134,7 +1135,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool apply_trxs.reserve(unapplied_trxs.size()); auto calculate_transaction_category = [&](const transaction_metadata_ptr& trx) { - if (trx->packed_trx.expiration() < pbs->header.timestamp.to_time_point()) { + if (trx->packed_trx->expiration() < pbs->header.timestamp.to_time_point()) { return tx_category::EXPIRED; } else if (persisted_by_id.find(trx->id) != persisted_by_id.end()) { return tx_category::PERSISTED; From 8109f0aa1b4534e3632a92f549f83f43b6c51827 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 3 Dec 2018 13:39:58 -0600 Subject: [PATCH 040/111] Cache chain_plugin lookup --- plugins/producer_plugin/producer_plugin.cpp | 54 +++++++++++---------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 13e752a7fc0..ad80df46cee 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -144,6 +144,7 @@ class producer_plugin_impl : public std::enable_shared_from_this().chain(); + chain::controller& chain = chain_plug->chain(); const auto hbn = bsp->block_num; auto new_block_header = bsp->header; new_block_header.timestamp = new_block_header.timestamp.next(); @@ -292,7 +293,7 @@ class producer_plugin_impl : public std::enable_shared_from_thistimestamp < (fc::time_point::now() + fc::seconds( 7 )), block_from_the_future, "received a block from the future, ignoring it: ${id}", ("id", id) ); - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = chain_plug->chain(); /* de-dupe here... no point in aborting block if we already know the block */ auto existing = chain.fetch_block_by_id( id ); @@ -314,7 +315,7 @@ class producer_plugin_impl : public std::enable_shared_from_this().handle_guard_exception(e); + chain_plug->handle_guard_exception(e); return; } catch( const fc::exception& e ) { elog((e.to_detail_string())); @@ -345,8 +346,7 @@ class producer_plugin_impl : public std::enable_shared_from_this>> _pending_incoming_transactions; void on_incoming_transaction_async(const packed_transaction_ptr& trx, bool persist_until_expired, next_function next) { - //todo remove chain_plugin lookup - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = chain_plug->chain(); if (!chain.pending_block_state()) { _pending_incoming_transactions.emplace_back(trx, persist_until_expired, next); return; @@ -429,7 +429,7 @@ class producer_plugin_impl : public std::enable_shared_from_this().handle_guard_exception(e); + chain_plug->handle_guard_exception(e); } catch ( boost::interprocess::bad_alloc& ) { chain_plugin::handle_db_exhaustion(); } CATCH_AND_CALL(send_response); @@ -600,6 +600,8 @@ make_keosd_signature_provider(const std::shared_ptr& impl, void producer_plugin::plugin_initialize(const boost::program_options::variables_map& options) { try { + my->chain_plug = app().find_plugin(); + EOS_ASSERT( my->chain_plug, plugin_config_exception, "chain_plugin not found" ); my->_options = &options; LOAD_VALUE_SET(options, "producer-name", my->_producers, types::account_name) @@ -718,7 +720,7 @@ void producer_plugin::plugin_startup() ilog("producer plugin: plugin_startup() begin"); - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = my->chain_plug->chain(); EOS_ASSERT( my->_producers.empty() || chain.get_read_mode() == chain::db_read_mode::SPECULATIVE, plugin_config_exception, "node cannot have any producer-name configured because block production is impossible when read_mode is not \"speculative\"" ); @@ -774,7 +776,7 @@ void producer_plugin::resume() { // re-evaluate that now // if (my->_pending_block_mode == pending_block_mode::speculating) { - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = my->chain_plug->chain(); chain.abort_block(); my->schedule_production_loop(); } @@ -809,13 +811,13 @@ void producer_plugin::update_runtime_options(const runtime_options& options) { } if (check_speculating && my->_pending_block_mode == pending_block_mode::speculating) { - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = my->chain_plug->chain(); chain.abort_block(); my->schedule_production_loop(); } if (options.subjective_cpu_leeway_us) { - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = my->chain_plug->chain(); chain.set_subjective_cpu_leeway(fc::microseconds(*options.subjective_cpu_leeway_us)); } } @@ -830,21 +832,21 @@ producer_plugin::runtime_options producer_plugin::get_runtime_options() const { } void producer_plugin::add_greylist_accounts(const greylist_params& params) { - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = my->chain_plug->chain(); for (auto &acc : params.accounts) { chain.add_resource_greylist(acc); } } void producer_plugin::remove_greylist_accounts(const greylist_params& params) { - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = my->chain_plug->chain(); for (auto &acc : params.accounts) { chain.remove_resource_greylist(acc); } } producer_plugin::greylist_params producer_plugin::get_greylist() const { - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = my->chain_plug->chain(); greylist_params result; const auto& list = chain.get_resource_greylist(); result.accounts.reserve(list.size()); @@ -855,7 +857,7 @@ producer_plugin::greylist_params producer_plugin::get_greylist() const { } producer_plugin::whitelist_blacklist producer_plugin::get_whitelist_blacklist() const { - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = my->chain_plug->chain(); return { chain.get_actor_whitelist(), chain.get_actor_blacklist(), @@ -867,7 +869,7 @@ producer_plugin::whitelist_blacklist producer_plugin::get_whitelist_blacklist() } void producer_plugin::set_whitelist_blacklist(const producer_plugin::whitelist_blacklist& params) { - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = my->chain_plug->chain(); if(params.actor_whitelist.valid()) chain.set_actor_whitelist(*params.actor_whitelist); if(params.actor_blacklist.valid()) chain.set_actor_blacklist(*params.actor_blacklist); if(params.contract_whitelist.valid()) chain.set_contract_whitelist(*params.contract_whitelist); @@ -877,7 +879,7 @@ void producer_plugin::set_whitelist_blacklist(const producer_plugin::whitelist_b } producer_plugin::integrity_hash_information producer_plugin::get_integrity_hash() const { - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = my->chain_plug->chain(); auto reschedule = fc::make_scoped_exit([this](){ my->schedule_production_loop(); @@ -894,7 +896,7 @@ producer_plugin::integrity_hash_information producer_plugin::get_integrity_hash( } producer_plugin::snapshot_information producer_plugin::create_snapshot() const { - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = my->chain_plug->chain(); auto reschedule = fc::make_scoped_exit([this](){ my->schedule_production_loop(); @@ -925,7 +927,7 @@ producer_plugin::snapshot_information producer_plugin::create_snapshot() const { } optional producer_plugin_impl::calculate_next_block_time(const account_name& producer_name, const block_timestamp_type& current_block_time) const { - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = chain_plug->chain(); const auto& hbs = chain.head_block_state(); const auto& active_schedule = hbs->active_schedule.producers; @@ -981,7 +983,7 @@ optional producer_plugin_impl::calculate_next_block_time(const a } fc::time_point producer_plugin_impl::calculate_pending_block_time() const { - const chain::controller& chain = app().get_plugin().chain(); + const chain::controller& chain = chain_plug->chain(); const fc::time_point now = fc::time_point::now(); const fc::time_point base = std::max(now, chain.head_block_time()); const int64_t min_time_to_next_block = (config::block_interval_us) - (base.time_since_epoch().count() % (config::block_interval_us) ); @@ -1002,7 +1004,7 @@ enum class tx_category { producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool &last_block) { - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = chain_plug->chain(); if( chain.get_read_mode() == chain::db_read_mode::READ_ONLY ) return start_block_result::waiting; @@ -1192,7 +1194,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool num_applied++; } } catch ( const guard_exception& e ) { - app().get_plugin().handle_guard_exception(e); + chain_plug->handle_guard_exception(e); return start_block_result::failed; } FC_LOG_AND_DROP(); } @@ -1277,7 +1279,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool num_applied++; } } catch ( const guard_exception& e ) { - app().get_plugin().handle_guard_exception(e); + chain_plug->handle_guard_exception(e); return start_block_result::failed; } FC_LOG_AND_DROP(); @@ -1324,7 +1326,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool } void producer_plugin_impl::schedule_production_loop() { - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = chain_plug->chain(); _timer.cancel(); std::weak_ptr weak_this = shared_from_this(); @@ -1435,7 +1437,7 @@ bool producer_plugin_impl::maybe_produce_block() { produce_block(); return true; } catch ( const guard_exception& e ) { - app().get_plugin().handle_guard_exception(e); + chain_plug->handle_guard_exception(e); return false; } FC_LOG_AND_DROP(); } catch ( boost::interprocess::bad_alloc&) { @@ -1444,7 +1446,7 @@ bool producer_plugin_impl::maybe_produce_block() { } fc_dlog(_log, "Aborting block due to produce_block error"); - chain::controller& chain = app().get_plugin().chain(); + chain::controller& chain = chain_plug->chain(); chain.abort_block(); return false; } @@ -1467,7 +1469,7 @@ static auto maybe_make_debug_time_logger() -> fc::optional().chain(); + chain::controller& chain = chain_plug->chain(); const auto& pbs = chain.pending_block_state(); const auto& hbs = chain.head_block_state(); EOS_ASSERT(pbs, missing_pending_block_state, "pending_block_state does not exist but it should, another plugin may have corrupted it"); From a0f7ae0acf17d50afc1082bd7d1678e718888fbf Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 3 Dec 2018 14:06:04 -0600 Subject: [PATCH 041/111] Update tester for transaction_metadata packed_transaction_ptr --- libraries/testing/tester.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/testing/tester.cpp b/libraries/testing/tester.cpp index a2307904da3..bcf811434d5 100644 --- a/libraries/testing/tester.cpp +++ b/libraries/testing/tester.cpp @@ -333,7 +333,7 @@ namespace eosio { namespace testing { { try { if( !control->pending_block_state() ) _start_block(control->head_block_time() + fc::microseconds(config::block_interval_us)); - auto r = control->push_transaction( std::make_shared(trx), deadline, billed_cpu_time_us ); + auto r = control->push_transaction( std::make_shared(std::make_shared(trx)), deadline, billed_cpu_time_us ); if( r->except_ptr ) std::rethrow_exception( r->except_ptr ); if( r->except ) throw *r->except; return r; From 81502d275429731a027e4f8c94d247beb10d968d Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 3 Dec 2018 15:12:37 -0600 Subject: [PATCH 042/111] Remove packed_tansaction to net_message copy --- plugins/net_plugin/net_plugin.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 32154a9aab0..21dbed7cdb7 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1671,14 +1671,22 @@ namespace eosio { time_point_sec trx_expiration = trx->expiration(); - net_message msg(*trx); // todo remove copy - uint32_t packsiz = fc::raw::pack_size(msg); - uint32_t bufsiz = packsiz + sizeof(packsiz); - auto buff = std::make_shared>(bufsiz); - - fc::datastream ds( buff->data(), bufsiz); - ds.write( reinterpret_cast(&packsiz), sizeof(packsiz) ); - fc::raw::pack( ds, msg ); + // this implementation is to avoid copy of packed_transaction to net_message + int which = 8; // matches which of net_message for packed_transaction + + uint32_t which_size = fc::raw::pack_size( unsigned_int( which )); + uint32_t payload_size = which_size + fc::raw::pack_size( *trx ); + + char* header = reinterpret_cast(&payload_size); + size_t header_size = sizeof(payload_size); + size_t buffer_size = header_size + payload_size; + + auto buff = std::make_shared>(buffer_size); + fc::datastream ds( buff->data(), buffer_size); + ds.write( header, header_size ); + fc::raw::pack( ds, unsigned_int( which )); + fc::raw::pack( ds, *trx ); + node_transaction_state nts = {id, trx_expiration, buff, From 86e581ab3351cc3ae8942ec5fc4f3a4dce7a8b0d Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 4 Dec 2018 13:53:18 -0600 Subject: [PATCH 043/111] Remove unused constructor --- libraries/chain/include/eosio/chain/transaction.hpp | 5 ----- unittests/abi_tests.cpp | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/libraries/chain/include/eosio/chain/transaction.hpp b/libraries/chain/include/eosio/chain/transaction.hpp index de343334e7a..b3fb7c5d7e0 100644 --- a/libraries/chain/include/eosio/chain/transaction.hpp +++ b/libraries/chain/include/eosio/chain/transaction.hpp @@ -107,11 +107,6 @@ namespace eosio { namespace chain { packed_transaction& operator=(const packed_transaction&) = delete; packed_transaction& operator=(packed_transaction&&) = default; - explicit packed_transaction(const transaction& t, compression_type _compression = none) - { - set_transaction(t, _compression); - } - explicit packed_transaction(const signed_transaction& t, compression_type _compression = none) :signatures(t.signatures) { diff --git a/unittests/abi_tests.cpp b/unittests/abi_tests.cpp index 3ffcc5af263..d9498a2594d 100644 --- a/unittests/abi_tests.cpp +++ b/unittests/abi_tests.cpp @@ -1475,7 +1475,7 @@ public_key_type get_public_key( name keyname, string role ) { BOOST_AUTO_TEST_CASE(packed_transaction) { try { - chain::transaction txn; + chain::signed_transaction txn; txn.ref_block_num = 1; txn.ref_block_prefix = 2; txn.expiration.from_iso_string("2021-12-20T15:30"); From bd3b2084d4a4e2ff551868ca762850d9f3544f78 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 4 Dec 2018 15:31:53 -0600 Subject: [PATCH 044/111] Explicitly disable copy/move construction --- .../include/eosio/chain/transaction_metadata.hpp | 12 ++++++++---- plugins/history_plugin/history_plugin.cpp | 13 ++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/libraries/chain/include/eosio/chain/transaction_metadata.hpp b/libraries/chain/include/eosio/chain/transaction_metadata.hpp index 7293e840c0c..ef50c0c6400 100644 --- a/libraries/chain/include/eosio/chain/transaction_metadata.hpp +++ b/libraries/chain/include/eosio/chain/transaction_metadata.hpp @@ -25,16 +25,20 @@ class transaction_metadata { bool implicit = false; bool scheduled = false; + transaction_metadata() = delete; + transaction_metadata(const transaction_metadata&) = delete; + transaction_metadata(transaction_metadata&&) = delete; + transaction_metadata operator=(transaction_metadata&) = delete; + transaction_metadata operator=(transaction_metadata&&) = delete; + explicit transaction_metadata( const signed_transaction& t, packed_transaction::compression_type c = packed_transaction::none ) - :trx(t),packed_trx(std::make_shared(t, c)) { - id = trx.id(); + :id(t.id()), trx(t), packed_trx(std::make_shared(t, c)) { //raw_packed = fc::raw::pack( static_cast(trx) ); signed_id = digest_type::hash(*packed_trx); } explicit transaction_metadata( const packed_transaction_ptr& ptrx ) - :trx( ptrx->get_signed_transaction() ), packed_trx(ptrx) { - id = trx.id(); + :id(ptrx->id()), trx( ptrx->get_signed_transaction() ), packed_trx(ptrx) { //raw_packed = fc::raw::pack( static_cast(trx) ); signed_id = digest_type::hash(*packed_trx); } diff --git a/plugins/history_plugin/history_plugin.cpp b/plugins/history_plugin/history_plugin.cpp index d802fc2ee78..0be3d9f11ca 100644 --- a/plugins/history_plugin/history_plugin.cpp +++ b/plugins/history_plugin/history_plugin.cpp @@ -504,10 +504,9 @@ namespace eosio { for (const auto &receipt: blk->transactions) { if (receipt.trx.contains()) { auto &pt = receipt.trx.get(); - auto mtrx = transaction_metadata(std::make_shared(pt)); - if (mtrx.id == result.id) { + if (pt.id() == result.id) { fc::mutable_variant_object r("receipt", receipt); - r("trx", chain.to_variant_with_abi(mtrx.trx, abi_serializer_max_time)); + r("trx", chain.to_variant_with_abi(pt.get_signed_transaction(), abi_serializer_max_time)); result.trx = move(r); break; } @@ -528,14 +527,14 @@ namespace eosio { for (const auto& receipt: blk->transactions) { if (receipt.trx.contains()) { auto& pt = receipt.trx.get(); - auto mtrx = transaction_metadata(std::make_shared(pt)); - if( txn_id_matched(mtrx.id) ) { - result.id = mtrx.id; + const auto& id = pt.id(); + if( txn_id_matched(id) ) { + result.id = id; result.last_irreversible_block = chain.last_irreversible_block_num(); result.block_num = *p.block_num_hint; result.block_time = blk->timestamp; fc::mutable_variant_object r("receipt", receipt); - r("trx", chain.to_variant_with_abi(mtrx.trx, abi_serializer_max_time)); + r("trx", chain.to_variant_with_abi(pt.get_signed_transaction(), abi_serializer_max_time)); result.trx = move(r); found = true; break; From e9e9fe02f6f0b71060aa2ff2d6d5fd40dac663c5 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 5 Dec 2018 16:09:26 -0600 Subject: [PATCH 045/111] Remove inflight update of node_transaction_state as it is not needed --- plugins/net_plugin/net_plugin.cpp | 105 ++++++++++-------------------- 1 file changed, 33 insertions(+), 72 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 21dbed7cdb7..90374ebef0e 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -45,7 +45,6 @@ namespace eosio { using fc::time_point; using fc::time_point_sec; using eosio::chain::transaction_id_type; - namespace bip = boost::interprocess; class connection; @@ -60,31 +59,10 @@ namespace eosio { struct node_transaction_state { transaction_id_type id; time_point_sec expires; /// time after which this may be purged. - /// Expires increased while the txn is - /// "in flight" to anoher peer - std::shared_ptr> serialized_txn; /// the received raw bundle uint32_t block_num = 0; /// block transaction was included in - uint32_t true_block = 0; /// used to reset block_uum when request is 0 - uint16_t requests = 0; /// the number of "in flight" requests for this txn + std::shared_ptr> serialized_txn; /// the received raw bundle }; - struct update_in_flight { - int32_t incr; - update_in_flight(int32_t delta) : incr(delta) {} - void operator() (node_transaction_state& nts) { - int32_t exp = nts.expires.sec_since_epoch(); - nts.expires = fc::time_point_sec(exp + incr * 60); - if( nts.requests == 0 ) { - nts.true_block = nts.block_num; - nts.block_num = 0; - } - nts.requests += incr; - if( nts.requests == 0 ) { - nts.block_num = nts.true_block; - } - } - } incr_in_flight(1), decr_in_flight(-1); - struct by_expiry; struct by_block_num; @@ -231,6 +209,7 @@ namespace eosio { void start_monitors(); void expire_txns(); + void expire_local_txns(); void connection_monitor(std::weak_ptr from_connection); /** \name Peer Timestamps * Time message handling @@ -400,12 +379,7 @@ namespace eosio { uint32_t new_bnum; update_block_num(uint32_t bnum) : new_bnum(bnum) {} void operator() (node_transaction_state& nts) { - if (nts.requests ) { - nts.true_block = new_bnum; - } - else { - nts.block_num = new_bnum; - } + nts.block_num = new_bnum; } void operator() (transaction_state& ts) { ts.block_num = new_bnum; @@ -779,23 +753,11 @@ namespace eosio { void connection::txn_send_pending(const vector& ids) { const std::set known_ids(ids.cbegin(), ids.cend()); + my_impl->expire_local_txns(); for(auto tx = my_impl->local_txns.begin(); tx != my_impl->local_txns.end(); ++tx ){ - if( tx->block_num == 0 ) { - const bool found = known_ids.find(tx->id) != known_ids.cend(); - if(!found) { - my_impl->local_txns.modify(tx,incr_in_flight); - queue_write(tx->serialized_txn, - true, - [tx_id=tx->id](boost::system::error_code ec, std::size_t ) { - auto& local_txns = my_impl->local_txns; - auto tx = local_txns.get().find(tx_id); - if (tx != local_txns.end()) { - local_txns.modify(tx, decr_in_flight); - } else { - fc_wlog(logger, "Local pending TX erased before queued_write called callback"); - } - }); - } + const bool found = known_ids.find( tx->id ) != known_ids.cend(); + if( !found ) { + queue_write( tx->serialized_txn, true, []( boost::system::error_code ec, std::size_t ) {} ); } } } @@ -804,18 +766,7 @@ namespace eosio { for(const auto& t : ids) { auto tx = my_impl->local_txns.get().find(t); if( tx != my_impl->local_txns.end() ) { - my_impl->local_txns.modify( tx,incr_in_flight); - queue_write(tx->serialized_txn, - true, - [t](boost::system::error_code ec, std::size_t ) { - auto& local_txns = my_impl->local_txns; - auto tx = local_txns.get().find(t); - if (tx != local_txns.end()) { - local_txns.modify(tx, decr_in_flight); - } else { - fc_wlog(logger, "Local TX erased before queued_write called callback"); - } - }); + queue_write( tx->serialized_txn, true, []( boost::system::error_code ec, std::size_t ) {} ); } } } @@ -1687,10 +1638,7 @@ namespace eosio { fc::raw::pack( ds, unsigned_int( which )); fc::raw::pack( ds, *trx ); - node_transaction_state nts = {id, - trx_expiration, - buff, - 0, 0, 0}; + node_transaction_state nts = {id, trx_expiration, 0, buff}; my_impl->local_txns.insert(std::move(nts)); my_impl->send_all( buff, [&id, &skips, trx_expiration](const connection_ptr& c) -> bool { @@ -1701,7 +1649,7 @@ namespace eosio { bool unknown = bs == c->trx_state.end(); if( unknown ) { c->trx_state.insert(transaction_state({id,0,trx_expiration})); - fc_dlog(logger, "sending whole trx to ${n}", ("n",c->peer_name() ) ); + fc_dlog(logger, "sending trx to ${n}", ("n",c->peer_name() ) ); } return unknown; }); @@ -2559,23 +2507,36 @@ namespace eosio { void net_plugin_impl::expire_txns() { start_txn_timer(); - auto &old = local_txns.get(); - auto ex_up = old.upper_bound( time_point::now()); - auto ex_lo = old.lower_bound( fc::time_point_sec( 0)); - old.erase( ex_lo, ex_up); - auto &stale = local_txns.get(); - controller &cc = chain_plug->chain(); - uint32_t bn = cc.last_irreversible_block_num(); - stale.erase( stale.lower_bound(1), stale.upper_bound(bn) ); + auto now = time_point::now(); + auto start_size = local_txns.size(); + + expire_local_txns(); + + controller& cc = chain_plug->chain(); + uint32_t lib = cc.last_irreversible_block_num(); for ( auto &c : connections ) { auto &stale_txn = c->trx_state.get(); - stale_txn.erase( stale_txn.lower_bound(1), stale_txn.upper_bound(bn) ); + stale_txn.erase( stale_txn.lower_bound(1), stale_txn.upper_bound(lib) ); auto &stale_txn_e = c->trx_state.get(); stale_txn_e.erase(stale_txn_e.lower_bound(time_point_sec()), stale_txn_e.upper_bound(time_point::now())); auto &stale_blk = c->blk_state.get(); - stale_blk.erase( stale_blk.lower_bound(1), stale_blk.upper_bound(bn) ); + stale_blk.erase( stale_blk.lower_bound(1), stale_blk.upper_bound(lib) ); } + fc_dlog(logger, "expire_txns ${n}us size ${s} removed ${r}", + ("n", time_point::now() - now)("s", start_size)("r", start_size - local_txns.size()) ); + } + + void net_plugin_impl::expire_local_txns() { + auto& old = local_txns.get(); + auto ex_lo = old.lower_bound( fc::time_point_sec(0) ); + auto ex_up = old.upper_bound( time_point::now() ); + old.erase( ex_lo, ex_up ); + + auto& stale = local_txns.get(); + controller& cc = chain_plug->chain(); + uint32_t lib = cc.last_irreversible_block_num(); + stale.erase( stale.lower_bound(1), stale.upper_bound(lib) ); } void net_plugin_impl::connection_monitor(std::weak_ptr from_connection) { From f3255af5276b616ffc7dd796c9e52b9e5ccf0df5 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 5 Dec 2018 16:35:57 -0600 Subject: [PATCH 046/111] Remove connections for unused signals that only logged --- plugins/net_plugin/net_plugin.cpp | 32 ------------------------------- 1 file changed, 32 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 90374ebef0e..c4a5e7ddf76 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -167,13 +167,7 @@ namespace eosio { template void send_all( const std::shared_ptr>& send_buffer, VerifierFunc verify ); - void accepted_block_header(const block_state_ptr&); void accepted_block(const block_state_ptr&); - void irreversible_block(const block_state_ptr&); - void accepted_transaction(const transaction_metadata_ptr&); - void applied_transaction(const transaction_trace_ptr&); - void accepted_confirmation(const header_confirmation&); - void transaction_ack(const std::pair&); bool is_valid( const handshake_message &msg); @@ -2576,32 +2570,11 @@ namespace eosio { c->close(); } - void net_plugin_impl::accepted_block_header(const block_state_ptr& block) { - fc_dlog(logger,"signaled, id = ${id}",("id", block->id)); - } - void net_plugin_impl::accepted_block(const block_state_ptr& block) { fc_dlog(logger,"signaled, id = ${id}",("id", block->id)); dispatcher->bcast_block(block); } - void net_plugin_impl::irreversible_block(const block_state_ptr& block) { - fc_dlog(logger,"signaled, id = ${id}",("id", block->id)); - } - - void net_plugin_impl::accepted_transaction(const transaction_metadata_ptr& md) { - fc_dlog(logger,"signaled, id = ${id}",("id", md->id)); -// dispatcher->bcast_transaction(md->packed_trx); - } - - void net_plugin_impl::applied_transaction(const transaction_trace_ptr& txn) { - fc_dlog(logger,"signaled, id = ${id}",("id", txn->id)); - } - - void net_plugin_impl::accepted_confirmation(const header_confirmation& head) { - fc_dlog(logger,"signaled, id = ${id}",("id", head.block_id)); - } - void net_plugin_impl::transaction_ack(const std::pair& results) { transaction_id_type id = results.second->id(); if (results.first) { @@ -2908,12 +2881,7 @@ namespace eosio { } chain::controller&cc = my->chain_plug->chain(); { - cc.accepted_block_header.connect( boost::bind(&net_plugin_impl::accepted_block_header, my.get(), _1)); cc.accepted_block.connect( boost::bind(&net_plugin_impl::accepted_block, my.get(), _1)); - cc.irreversible_block.connect( boost::bind(&net_plugin_impl::irreversible_block, my.get(), _1)); - cc.accepted_transaction.connect( boost::bind(&net_plugin_impl::accepted_transaction, my.get(), _1)); - cc.applied_transaction.connect( boost::bind(&net_plugin_impl::applied_transaction, my.get(), _1)); - cc.accepted_confirmation.connect( boost::bind(&net_plugin_impl::accepted_confirmation, my.get(), _1)); } my->incoming_transaction_ack_subscription = app().get_channel().subscribe(boost::bind(&net_plugin_impl::transaction_ack, my.get(), _1)); From 52a6f193aa3a06833165fc36d3a52407769c732f Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 5 Dec 2018 19:22:40 -0600 Subject: [PATCH 047/111] Fix sync check for lib --- plugins/net_plugin/net_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index c4a5e7ddf76..1990a1dd269 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1388,7 +1388,7 @@ namespace eosio { // // 0. my head block id == peer head id means we are all caught up block wise // 1. my head block num < peer lib - start sync locally - // 2. my lib > peer head num - send an last_irr_catch_up notice if not the first generation + // 2. my lib > peer lib - send an last_irr_catch_up notice if not the first generation // // 3 my head block num <= peer head block num - update sync state and send a catchup request // 4 my head block num > peer block num send a notice catchup if this is not the first generation @@ -1415,7 +1415,7 @@ namespace eosio { } return; } - if (lib_num > msg.head_num ) { + if (lib_num > msg.last_irreversible_block_num ) { fc_dlog(logger, "sync check state 2"); if (msg.generation > 1 || c->protocol_version > proto_base) { notice_message note; From e95bad05fb090c0fd98cbabae57003286c294c74 Mon Sep 17 00:00:00 2001 From: arhag Date: Mon, 10 Dec 2018 12:00:37 -0500 Subject: [PATCH 048/111] add a test that verifies proposing an empty producer schedule does not break things --- unittests/producer_schedule_tests.cpp | 79 ++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/unittests/producer_schedule_tests.cpp b/unittests/producer_schedule_tests.cpp index 1cf8bdaadec..a7279499656 100644 --- a/unittests/producer_schedule_tests.cpp +++ b/unittests/producer_schedule_tests.cpp @@ -274,7 +274,7 @@ BOOST_FIXTURE_TEST_CASE( producer_schedule_reduction, tester ) try { {N(bob), get_public_key(N(bob), "active")}, {N(carol), get_public_key(N(carol), "active")} }; - //wlog("set producer schedule to [alice,bob]"); + wlog("set producer schedule to [alice,bob,carol]"); BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); BOOST_CHECK_EQUAL( true, compare_schedules( sch1, *control->proposed_producers() ) ); BOOST_CHECK_EQUAL( control->pending_producers().version, 0 ); @@ -293,7 +293,7 @@ BOOST_FIXTURE_TEST_CASE( producer_schedule_reduction, tester ) try { {N(alice), get_public_key(N(alice), "active")}, {N(bob), get_public_key(N(bob), "active")} }; - wlog("set producer schedule to [alice,bob,carol]"); + wlog("set producer schedule to [alice,bob]"); BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); BOOST_CHECK_EQUAL( true, compare_schedules( sch2, *control->proposed_producers() ) ); @@ -317,4 +317,79 @@ BOOST_FIXTURE_TEST_CASE( producer_schedule_reduction, tester ) try { BOOST_REQUIRE_EQUAL( validate(), true ); } FC_LOG_AND_RETHROW() +BOOST_FIXTURE_TEST_CASE( empty_producer_schedule_has_no_effect, tester ) try { + create_accounts( {N(alice),N(bob),N(carol)} ); + produce_block(); + + auto compare_schedules = [&]( const vector& a, const producer_schedule_type& b ) { + return std::equal( a.begin(), a.end(), b.producers.begin(), b.producers.end() ); + }; + + auto res = set_producers( {N(alice),N(bob)} ); + vector sch1 = { + {N(alice), get_public_key(N(alice), "active")}, + {N(bob), get_public_key(N(bob), "active")} + }; + wlog("set producer schedule to [alice,bob]"); + BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch1, *control->proposed_producers() ) ); + BOOST_CHECK_EQUAL( control->pending_producers().producers.size(), 0 ); + + // Start a new block which promotes the proposed schedule to pending + produce_block(); + BOOST_CHECK_EQUAL( control->pending_producers().version, 1 ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch1, control->pending_producers() ) ); + BOOST_CHECK_EQUAL( control->active_producers().version, 0 ); + + // Start a new block which promotes the pending schedule to active + produce_block(); + BOOST_CHECK_EQUAL( control->active_producers().version, 1 ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch1, control->active_producers() ) ); + produce_blocks(7); + + res = set_producers( {} ); + wlog("set producer schedule to []"); + BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); + BOOST_CHECK_EQUAL( control->proposed_producers()->producers.size(), 0 ); + BOOST_CHECK_EQUAL( control->proposed_producers()->version, 2 ); + + produce_blocks(12); + BOOST_CHECK_EQUAL( control->pending_producers().version, 1 ); + + // Empty producer schedule does get promoted from proposed to pending + produce_block(); + BOOST_CHECK_EQUAL( control->pending_producers().version, 2 ); + BOOST_CHECK_EQUAL( false, control->proposed_producers().valid() ); + + // However it should not get promoted from pending to active + produce_blocks(24); + BOOST_CHECK_EQUAL( control->active_producers().version, 1 ); + BOOST_CHECK_EQUAL( control->pending_producers().version, 2 ); + + // Setting a new producer schedule should still use version 2 + res = set_producers( {N(alice),N(bob),N(carol)} ); + vector sch2 = { + {N(alice), get_public_key(N(alice), "active")}, + {N(bob), get_public_key(N(bob), "active")}, + {N(carol), get_public_key(N(carol), "active")} + }; + wlog("set producer schedule to [alice,bob,carol]"); + BOOST_REQUIRE_EQUAL( true, control->proposed_producers().valid() ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch2, *control->proposed_producers() ) ); + BOOST_CHECK_EQUAL( control->proposed_producers()->version, 2 ); + + // Produce enough blocks to promote the proposed schedule to pending, which it can do because the existing pending has zero producers + produce_blocks(24); + BOOST_CHECK_EQUAL( control->active_producers().version, 1 ); + BOOST_CHECK_EQUAL( control->pending_producers().version, 2 ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch2, control->pending_producers() ) ); + + // Produce enough blocks to promote the pending schedule to active + produce_blocks(24); + BOOST_CHECK_EQUAL( control->active_producers().version, 2 ); + BOOST_CHECK_EQUAL( true, compare_schedules( sch2, control->active_producers() ) ); + + BOOST_REQUIRE_EQUAL( validate(), true ); +} FC_LOG_AND_RETHROW() + BOOST_AUTO_TEST_SUITE_END() From 118ec39662a78bae302a824f49baf537cdf843f4 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Mon, 10 Dec 2018 14:51:00 -0500 Subject: [PATCH 049/111] Allow disablement of net_plugin's listen socket Disable net_plugin's listen socket when p2p-listen-endpoint is empty. This is useful for security and for an easier way of running multiple nodeos without it conflicting when you don't actually need to service incoming connections. --- plugins/net_plugin/net_plugin.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 49212e2d8ed..0076aaa78a8 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -2935,7 +2935,7 @@ namespace eosio { my->use_socket_read_watermark = options.at( "use-socket-read-watermark" ).as(); my->resolver = std::make_shared( std::ref( app().get_io_service())); - if( options.count( "p2p-listen-endpoint" )) { + if( options.count( "p2p-listen-endpoint" ) && options.at("p2p-listen-endpoint").as().length()) { my->p2p_address = options.at( "p2p-listen-endpoint" ).as(); auto host = my->p2p_address.substr( 0, my->p2p_address.find( ':' )); auto port = my->p2p_address.substr( host.size() + 1, my->p2p_address.size()); @@ -2946,21 +2946,22 @@ namespace eosio { my->listen_endpoint = *my->resolver->resolve( query ); my->acceptor.reset( new tcp::acceptor( app().get_io_service())); - } - if( options.count( "p2p-server-address" )) { - my->p2p_address = options.at( "p2p-server-address" ).as(); - } else { - if( my->listen_endpoint.address().to_v4() == address_v4::any()) { - boost::system::error_code ec; - auto host = host_name( ec ); - if( ec.value() != boost::system::errc::success ) { - FC_THROW_EXCEPTION( fc::invalid_arg_exception, - "Unable to retrieve host_name. ${msg}", ("msg", ec.message())); + if( options.count( "p2p-server-address" )) { + my->p2p_address = options.at( "p2p-server-address" ).as(); + } else { + if( my->listen_endpoint.address().to_v4() == address_v4::any()) { + boost::system::error_code ec; + auto host = host_name( ec ); + if( ec.value() != boost::system::errc::success ) { + FC_THROW_EXCEPTION( fc::invalid_arg_exception, + "Unable to retrieve host_name. ${msg}", ("msg", ec.message())); + + } + auto port = my->p2p_address.substr( my->p2p_address.find( ':' ), my->p2p_address.size()); + my->p2p_address = host + port; } - auto port = my->p2p_address.substr( my->p2p_address.find( ':' ), my->p2p_address.size()); - my->p2p_address = host + port; } } From c9126e4c66cb0b4c38ebf8544eb23bddab5bc591 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 11 Dec 2018 12:24:24 -0600 Subject: [PATCH 050/111] More descriptive memo to distinguish from other transfers --- tests/Cluster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Cluster.py b/tests/Cluster.py index f26c5980339..06a5357e9af 100644 --- a/tests/Cluster.py +++ b/tests/Cluster.py @@ -896,7 +896,7 @@ def bios_bootstrap(totalNodes, biosHost, biosPort, walletMgr, silent=False): contract="eosio.token" action="transfer" for name, keys in producerKeys.items(): - data="{\"from\":\"eosio\",\"to\":\"%s\",\"quantity\":\"%s\",\"memo\":\"%s\"}" % (name, initialFunds, "init transfer") + data="{\"from\":\"eosio\",\"to\":\"%s\",\"quantity\":\"%s\",\"memo\":\"%s\"}" % (name, initialFunds, "init eosio transfer") opts="--permission eosio@active" if name != "eosio": trans=biosNode.pushMessage(contract, action, data, opts) From ce7d2406b78b9778875ac170e4f65a767c07204a Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 11 Dec 2018 12:24:36 -0600 Subject: [PATCH 051/111] Revert "Fix sync check for lib" This reverts commit 52a6f193aa3a06833165fc36d3a52407769c732f. --- plugins/net_plugin/net_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 1990a1dd269..c4a5e7ddf76 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -1388,7 +1388,7 @@ namespace eosio { // // 0. my head block id == peer head id means we are all caught up block wise // 1. my head block num < peer lib - start sync locally - // 2. my lib > peer lib - send an last_irr_catch_up notice if not the first generation + // 2. my lib > peer head num - send an last_irr_catch_up notice if not the first generation // // 3 my head block num <= peer head block num - update sync state and send a catchup request // 4 my head block num > peer block num send a notice catchup if this is not the first generation @@ -1415,7 +1415,7 @@ namespace eosio { } return; } - if (lib_num > msg.last_irreversible_block_num ) { + if (lib_num > msg.head_num ) { fc_dlog(logger, "sync check state 2"); if (msg.generation > 1 || c->protocol_version > proto_base) { notice_message note; From 92f41ce9c0473a9e30b82660f2408e2f5e4972ce Mon Sep 17 00:00:00 2001 From: ovi Date: Wed, 12 Dec 2018 12:51:11 +0200 Subject: [PATCH 052/111] Update the bios-boot-tutorial.py script and readme.md: 1. args.contracts_dir doesn't end in a forward slash, therefor when it is concatenated with a subpath, the subpath has to start with a forward slash; this pattern is present in other similar variables as well 2. system contract has to be initialized before it can be used (e.g. creating staked acconts) 3. commands list updated to include the new addition stepInitSystemContract 4. readme.md updated as well to reflect the current status of the script and requirements --- tutorials/bios-boot-tutorial/README.md | 15 ++++++- .../bios-boot-tutorial/bios-boot-tutorial.py | 44 ++++++++++--------- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/tutorials/bios-boot-tutorial/README.md b/tutorials/bios-boot-tutorial/README.md index bebba5f4a04..7b6b5af6972 100644 --- a/tutorials/bios-boot-tutorial/README.md +++ b/tutorials/bios-boot-tutorial/README.md @@ -2,12 +2,23 @@ The `bios-boot-tutorial.py` script simulates the EOSIO bios boot sequence. -The script can be run with no arguments directly from the `tutorials/bios-boot-tutorial` directory. +Prerequisites: + +1. eosio binaries (keosd, nodeos) +2. system contracts binaries (built eosio.contracts) +3. python 3.x + + +Assumming you installed the precompiled eosio binaries, and they were installed in /user/local/bin, +and assumming you have built the eosio.contracts and they are located in /Users/test/eos/contracts/eosio.contracts/ folder, +and assuming you have installed python 3.x version, +this is the simplest command to start the script: + ```bash $ cd tutorials/bios-boot-tutorial -$ ./bios-boot-tutorial.py +$ python3 bios-boot-tutorial.py --cleos="/usr/local/bin/cleos --wallet-url http://127.0.0.1:6666 " --nodeos=/usr/local/bin/nodeos --keosd="/usr/local/bin/keosd" --contracts-dir="/Users/test/eos/contracts/eosio.contracts/" -a ``` See [EOSIO Documentation Wiki: Tutorial - Bios Boot](https://github.com/EOSIO/eos/wiki/Tutorial-Bios-Boot-Sequence) for additional information. diff --git a/tutorials/bios-boot-tutorial/bios-boot-tutorial.py b/tutorials/bios-boot-tutorial/bios-boot-tutorial.py index 59a1590d4d6..358d3b963b8 100755 --- a/tutorials/bios-boot-tutorial/bios-boot-tutorial.py +++ b/tutorials/bios-boot-tutorial/bios-boot-tutorial.py @@ -284,17 +284,20 @@ def stepStartBoot(): startNode(0, {'name': 'eosio', 'pvt': args.private_key, 'pub': args.public_key}) sleep(1.5) def stepInstallSystemContracts(): - run(args.cleos + 'set contract eosio.token ' + args.contracts_dir + 'eosio.token/') - run(args.cleos + 'set contract eosio.msig ' + args.contracts_dir + 'eosio.msig/') + run(args.cleos + 'set contract eosio.token ' + args.contracts_dir + '/eosio.token/') + run(args.cleos + 'set contract eosio.msig ' + args.contracts_dir + '/eosio.msig/') def stepCreateTokens(): run(args.cleos + 'push action eosio.token create \'["eosio", "10000000000.0000 %s"]\' -p eosio.token' % (args.symbol)) totalAllocation = allocateFunds(0, len(accounts)) run(args.cleos + 'push action eosio.token issue \'["eosio", "%s", "memo"]\' -p eosio' % intToCurrency(totalAllocation)) sleep(1) def stepSetSystemContract(): - retry(args.cleos + 'set contract eosio ' + args.contracts_dir + 'eosio.system/') + retry(args.cleos + 'set contract eosio ' + args.contracts_dir + '/eosio.system/') sleep(1) run(args.cleos + 'push action eosio setpriv' + jsonArg(['eosio.msig', 1]) + '-p eosio@active') +def stepInitSystemContract(): + run(args.cleos + 'push action eosio init' + jsonArg(['0', '4,SYS']) + '-p eosio@active') + sleep(1) def stepCreateStakedAccounts(): createStakedAccounts(0, len(accounts)) def stepRegProducers(): @@ -326,23 +329,24 @@ def stepLog(): parser = argparse.ArgumentParser() commands = [ - ('k', 'kill', stepKillAll, True, "Kill all nodeos and keosd processes"), - ('w', 'wallet', stepStartWallet, True, "Start keosd, create wallet, fill with keys"), - ('b', 'boot', stepStartBoot, True, "Start boot node"), - ('s', 'sys', createSystemAccounts, True, "Create system accounts (eosio.*)"), - ('c', 'contracts', stepInstallSystemContracts, True, "Install system contracts (token, msig)"), - ('t', 'tokens', stepCreateTokens, True, "Create tokens"), - ('S', 'sys-contract', stepSetSystemContract, True, "Set system contract"), - ('T', 'stake', stepCreateStakedAccounts, True, "Create staked accounts"), - ('p', 'reg-prod', stepRegProducers, True, "Register producers"), - ('P', 'start-prod', stepStartProducers, True, "Start producers"), - ('v', 'vote', stepVote, True, "Vote for producers"), - ('R', 'claim', claimRewards, True, "Claim rewards"), - ('x', 'proxy', stepProxyVotes, True, "Proxy votes"), - ('q', 'resign', stepResign, True, "Resign eosio"), - ('m', 'msg-replace', msigReplaceSystem, False, "Replace system contract using msig"), - ('X', 'xfer', stepTransfer, False, "Random transfer tokens (infinite loop)"), - ('l', 'log', stepLog, True, "Show tail of node's log"), + ('k', 'kill', stepKillAll, True, "Kill all nodeos and keosd processes"), + ('w', 'wallet', stepStartWallet, True, "Start keosd, create wallet, fill with keys"), + ('b', 'boot', stepStartBoot, True, "Start boot node"), + ('s', 'sys', createSystemAccounts, True, "Create system accounts (eosio.*)"), + ('c', 'contracts', stepInstallSystemContracts, True, "Install system contracts (token, msig)"), + ('t', 'tokens', stepCreateTokens, True, "Create tokens"), + ('S', 'sys-contract', stepSetSystemContract, True, "Set system contract"), + ('I', 'init-sys-contract', stepInitSystemContract, True, "Initialiaze system contract"), + ('T', 'stake', stepCreateStakedAccounts, True, "Create staked accounts"), + ('p', 'reg-prod', stepRegProducers, True, "Register producers"), + ('P', 'start-prod', stepStartProducers, True, "Start producers"), + ('v', 'vote', stepVote, True, "Vote for producers"), + ('R', 'claim', claimRewards, True, "Claim rewards"), + ('x', 'proxy', stepProxyVotes, True, "Proxy votes"), + ('q', 'resign', stepResign, True, "Resign eosio"), + ('m', 'msg-replace', msigReplaceSystem, False, "Replace system contract using msig"), + ('X', 'xfer', stepTransfer, False, "Random transfer tokens (infinite loop)"), + ('l', 'log', stepLog, True, "Show tail of node's log"), ] parser.add_argument('--public-key', metavar='', help="EOSIO Public Key", default='EOS8Znrtgwt8TfpmbVpTKvA2oB8Nqey625CLN8bCN3TEbgx86Dsvr', dest="public_key") From e1ff121812a58b7e917d9bf298f790b17c06ded2 Mon Sep 17 00:00:00 2001 From: ovi Date: Thu, 13 Dec 2018 13:32:05 +0200 Subject: [PATCH 053/111] README.md refactored - correcting spelling errors, and caps - better bash commands - simpler command line to launch the script - improved prerequisites - include steps to follow after prerequisites --- tutorials/bios-boot-tutorial/README.md | 39 +++++++++++++++++++------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/tutorials/bios-boot-tutorial/README.md b/tutorials/bios-boot-tutorial/README.md index 7b6b5af6972..d39a70289ef 100644 --- a/tutorials/bios-boot-tutorial/README.md +++ b/tutorials/bios-boot-tutorial/README.md @@ -2,23 +2,42 @@ The `bios-boot-tutorial.py` script simulates the EOSIO bios boot sequence. -Prerequisites: +``Prerequisites``: -1. eosio binaries (keosd, nodeos) -2. system contracts binaries (built eosio.contracts) -3. python 3.x +1. Python 3.x +2. CMake +3. git +``Steps``: -Assumming you installed the precompiled eosio binaries, and they were installed in /user/local/bin, -and assumming you have built the eosio.contracts and they are located in /Users/test/eos/contracts/eosio.contracts/ folder, -and assuming you have installed python 3.x version, -this is the simplest command to start the script: +1. Install eosio binaries by following the steps outlined in below tutorial +https://github.com/EOSIO/eos#mac-os-x-brew-install +2. Compile eosio.contracts ```bash -$ cd tutorials/bios-boot-tutorial +$ cd ~ +$ git clone https://github.com/EOSIO/eosio.contracts.git +$ cd ./eosio.contracts/ +$ ./build.sh +$ pwd + +``` + +3. Make note of the directory where the contracts where compiled +The last command in the previous step printed on the bash console the contracts' directory, make note of it, we'll reference it from now on as `YOU_CONTRACTS_DIRECTORY` + +4. Launch the `bios-boot-tutorial.py` script +Minimal command line to launch the scrip + +```bash +$ cd ~ +$ git clone https://github.com/EOSIO/eos.git +$ cd ./eos/tutorials/bios-boot-tutorial/ +$ python3 bios-boot-tutorial.py --cleos="cleos --wallet-url http://127.0.0.1:6666 " --nodeos=nodeos --keosd=keosd --contracts-dir="/YOU_CONTRACTS_DIRECTORY/" -a -$ python3 bios-boot-tutorial.py --cleos="/usr/local/bin/cleos --wallet-url http://127.0.0.1:6666 " --nodeos=/usr/local/bin/nodeos --keosd="/usr/local/bin/keosd" --contracts-dir="/Users/test/eos/contracts/eosio.contracts/" -a ``` See [EOSIO Documentation Wiki: Tutorial - Bios Boot](https://github.com/EOSIO/eos/wiki/Tutorial-Bios-Boot-Sequence) for additional information. + + From 45496bcac7d05c8291c4a480b8391d510f140aa2 Mon Sep 17 00:00:00 2001 From: ovi Date: Thu, 13 Dec 2018 13:35:47 +0200 Subject: [PATCH 054/111] Correct typos --- tutorials/bios-boot-tutorial/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorials/bios-boot-tutorial/README.md b/tutorials/bios-boot-tutorial/README.md index d39a70289ef..0cd98cf62fc 100644 --- a/tutorials/bios-boot-tutorial/README.md +++ b/tutorials/bios-boot-tutorial/README.md @@ -24,11 +24,11 @@ $ pwd ``` -3. Make note of the directory where the contracts where compiled +3. Make note of the directory where the contracts were compiled The last command in the previous step printed on the bash console the contracts' directory, make note of it, we'll reference it from now on as `YOU_CONTRACTS_DIRECTORY` 4. Launch the `bios-boot-tutorial.py` script -Minimal command line to launch the scrip +Minimal command line to launch the script ```bash $ cd ~ From b9b8d02e05841e07412b76b487178a537d6d6526 Mon Sep 17 00:00:00 2001 From: ovi Date: Thu, 13 Dec 2018 14:08:06 +0200 Subject: [PATCH 055/111] Correct link format --- tutorials/bios-boot-tutorial/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/bios-boot-tutorial/README.md b/tutorials/bios-boot-tutorial/README.md index 0cd98cf62fc..44ad4c9f2fa 100644 --- a/tutorials/bios-boot-tutorial/README.md +++ b/tutorials/bios-boot-tutorial/README.md @@ -11,7 +11,7 @@ The `bios-boot-tutorial.py` script simulates the EOSIO bios boot sequence. ``Steps``: 1. Install eosio binaries by following the steps outlined in below tutorial -https://github.com/EOSIO/eos#mac-os-x-brew-install +[Install eosio binaries steps](https://github.com/EOSIO/eos#mac-os-x-brew-install) 2. Compile eosio.contracts From 800b0ec633ec14e365447d13c83295993d5c12ad Mon Sep 17 00:00:00 2001 From: ovi Date: Thu, 13 Dec 2018 14:29:29 +0200 Subject: [PATCH 056/111] Add eosio.cdt steps --- tutorials/bios-boot-tutorial/README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tutorials/bios-boot-tutorial/README.md b/tutorials/bios-boot-tutorial/README.md index 44ad4c9f2fa..433e813418b 100644 --- a/tutorials/bios-boot-tutorial/README.md +++ b/tutorials/bios-boot-tutorial/README.md @@ -11,9 +11,12 @@ The `bios-boot-tutorial.py` script simulates the EOSIO bios boot sequence. ``Steps``: 1. Install eosio binaries by following the steps outlined in below tutorial -[Install eosio binaries steps](https://github.com/EOSIO/eos#mac-os-x-brew-install) +[Install eosio binaries](https://github.com/EOSIO/eos#mac-os-x-brew-install) -2. Compile eosio.contracts +2. Install eosio.cdt binaries by following the steps outlined in below tutorial +[Install eosio.cdt binaries](https://github.com/EOSIO/eosio.cdt#binary-releases) + +3. Compile eosio.contracts ```bash $ cd ~ @@ -24,11 +27,11 @@ $ pwd ``` -3. Make note of the directory where the contracts were compiled +4. Make note of the directory where the contracts were compiled The last command in the previous step printed on the bash console the contracts' directory, make note of it, we'll reference it from now on as `YOU_CONTRACTS_DIRECTORY` -4. Launch the `bios-boot-tutorial.py` script -Minimal command line to launch the script +5. Launch the `bios-boot-tutorial.py` script +Minimal command line to launch the script below, make sure you replace `YOU_CONTRACTS_DIRECTORY` with actual directory ```bash $ cd ~ From f5f6c8d1beb03391cf91ea461aae23c6f1d4c96b Mon Sep 17 00:00:00 2001 From: ovi Date: Thu, 13 Dec 2018 16:28:40 +0200 Subject: [PATCH 057/111] Better name for eosio contracts directory --- tutorials/bios-boot-tutorial/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tutorials/bios-boot-tutorial/README.md b/tutorials/bios-boot-tutorial/README.md index 433e813418b..62f2a878fd7 100644 --- a/tutorials/bios-boot-tutorial/README.md +++ b/tutorials/bios-boot-tutorial/README.md @@ -28,16 +28,16 @@ $ pwd ``` 4. Make note of the directory where the contracts were compiled -The last command in the previous step printed on the bash console the contracts' directory, make note of it, we'll reference it from now on as `YOU_CONTRACTS_DIRECTORY` +The last command in the previous step printed on the bash console the contracts' directory, make note of it, we'll reference it from now on as `EOSIO_CONTRACTS_DIRECTORY` 5. Launch the `bios-boot-tutorial.py` script -Minimal command line to launch the script below, make sure you replace `YOU_CONTRACTS_DIRECTORY` with actual directory +Minimal command line to launch the script below, make sure you replace `EOSIO_CONTRACTS_DIRECTORY` with actual directory ```bash $ cd ~ $ git clone https://github.com/EOSIO/eos.git $ cd ./eos/tutorials/bios-boot-tutorial/ -$ python3 bios-boot-tutorial.py --cleos="cleos --wallet-url http://127.0.0.1:6666 " --nodeos=nodeos --keosd=keosd --contracts-dir="/YOU_CONTRACTS_DIRECTORY/" -a +$ python3 bios-boot-tutorial.py --cleos="cleos --wallet-url http://127.0.0.1:6666 " --nodeos=nodeos --keosd=keosd --contracts-dir="/EOSIO_CONTRACTS_DIRECTORY/" -a ``` From c2bee207b1b14196bfef31c10d45bec7154f3840 Mon Sep 17 00:00:00 2001 From: ovi Date: Thu, 13 Dec 2018 19:19:25 +0200 Subject: [PATCH 058/111] dummy checkin to trigger another build --- tutorials/bios-boot-tutorial/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tutorials/bios-boot-tutorial/README.md b/tutorials/bios-boot-tutorial/README.md index 62f2a878fd7..ea353898086 100644 --- a/tutorials/bios-boot-tutorial/README.md +++ b/tutorials/bios-boot-tutorial/README.md @@ -41,6 +41,4 @@ $ python3 bios-boot-tutorial.py --cleos="cleos --wallet-url http://127.0.0.1:666 ``` -See [EOSIO Documentation Wiki: Tutorial - Bios Boot](https://github.com/EOSIO/eos/wiki/Tutorial-Bios-Boot-Sequence) for additional information. - - +See [EOSIO Documentation Wiki: Tutorial - Bios Boot](https://github.com/EOSIO/eos/wiki/Tutorial-Bios-Boot-Sequence) for additional information. \ No newline at end of file From ab2565c54a23e9c320f4e1a4510031d8279d2c4d Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Mon, 3 Dec 2018 08:22:09 -0600 Subject: [PATCH 059/111] Added scrit to support recursive search for files with FC_REFLECT or FC_REFLECT_ENUM to verify order and completeness. Supports comments with @swap to support different order from definition and @ignore to ignore a specific field for reflection. Still need to support FC_REFLECT_DERIVED. GH #3127 --- tools/validate_reflection.py | 713 +++++++++++++++++++++++++++++++++++ 1 file changed, 713 insertions(+) create mode 100755 tools/validate_reflection.py diff --git a/tools/validate_reflection.py b/tools/validate_reflection.py new file mode 100755 index 00000000000..ac97446f88a --- /dev/null +++ b/tools/validate_reflection.py @@ -0,0 +1,713 @@ +#!/usr/bin/env python3 + +import argparse +import re +import os +import sys +import traceback + +############################################################### +# validate_reflection +# +# +# Looks for files with FC_REFLECT macros. Requires fields to match class definition (provided in same file), +# unless the FC_REFLECT is proceeded by "// @ignore , , ..., " to indicate that field1, +# field2, ... fieldN are not reflected and/or "// @swap , , ..., " to indicate that +# field1, field2, ... fieldN are not in the same order as the class definition. +# +# NOTE: If swapping fields the script expects you to only indicate fields that are not in the expected order, +# so once it runs into the swapped field, it will remove that field from the order and expect the remaining in +# that order, so if the class has field1, field2, field3, and field4, and the reflect macro has the order +# field1, field3, field2, then field4, it should indicate swapping field2. This will remove field2 from the +# expected order and the rest will now match. Or else it should indicated swapping field3, since the remaining +# fields will also match the order. But both field2 and field3 should not be indicated. +# +# +# +############################################################### + + +temp_dir = "temp_dir" + + +parser = argparse.ArgumentParser(add_help=False) +parser.add_argument('-?', action='help', default=argparse.SUPPRESS, + help=argparse._('show this help message and exit')) +parser.add_argument('-d', '--debug', help="generate debug output into \"./%s\"" % (temp_dir), action='store_true') +parser.add_argument('-r', '--recurse', help="recurse through an entire directory (if directory provided for \"file\"", action='store_true') +parser.add_argument('-x', '--extension', type=str, help="extensions array to allow for directory and recursive search. Defaults to \".hpp\" and \".cpp\".", action='append') +parser.add_argument('-e', '--exit-on-error', help="Exit immediately when a validation error is discovered. Default is to run validation on all files and directories provided.", action='store_true') +parser.add_argument('files', metavar='file', nargs='+', type=str, help="File containing nodes info in JSON format.") +args = parser.parse_args() + +recurse = args.recurse +if args.debug: + if not os.path.exists(temp_dir): + os.mkdir(temp_dir) + debug_file = open(temp_dir + "/validate_reflect.debug", "w") +else: + debug_file = None +extensions = [] +if args.extension is None or len(args.extension) == 0: + extensions = [".hpp",".cpp"] +else: + for extension in args.extension: + assert len(extension) > 0, "empty --extension passed in" + if extension[0] != ".": + extension = "." + extension + extensions.append(extension) +print("extensions=%s" % (",".join(extensions))) +ignore_str = "@ignore" +swap_str = "@swap" +fc_reflect_str = "FC_REFLECT" +fc_reflect_possible_enum_ext = "(?:_ENUM)?" +fc_reflect_derived_ext = "(?:_DERIVED)" + +def debug(debug_str): + if debug_file is not None: + debug_file.write(debug_str + "\n") + +class EmptyScope: + single_comment_pattern = re.compile(r'//.*\n+') + single_comment_ignore_swap_pattern = re.compile(r'//\s*(?:%s|%s)\s' % (ignore_str, swap_str)) + multi_line_comment_pattern = re.compile(r'/\*(.*?)\*/', re.MULTILINE | re.DOTALL) + ignore_swap_pattern = re.compile(r'^\s*(%s|%s)\s+(.*)$' % (ignore_str, swap_str), re.DOTALL) + strip_extra_pattern = re.compile(r'\n\s*\*\s*') + invalid_chars_pattern = re.compile(r'([^\w\s,])') + multi_line_comment_ignore_swap_pattern = re.compile(r'(\w+)(?:\s*,\s*)?') + namespace_str = "namespace" + struct_str = "struct" + class_str = "class" + enum_str = "enum" + any_scope_pattern = re.compile(r'\{', re.DOTALL) + + def __init__(self, name, start, content, parent_scope): + pname = parent_scope.name if parent_scope is not None else "" + debug("EmptyScope.__init__ %s %d - Parent %s" % (name, start, pname)) + self.name = name + self.content = content + self.start = start + self.current = start + 1 + self.parent_scope = parent_scope + self.end = len(content) - 1 if start == 0 else None + self.start_char = "{" + self.end_char = "}" + self.children = {} + self.children_ordered = [] + self.fields = [] + self.usings = {} + self.type = "EmptyScope" + self.inherit = None + + def read(self): + debug("EmptyScope(%s).read - %s" % (self.type, self.name)) + end = len(self.content) - 1 + while self.current < end: + next_scope = self.next_scope() + if next_scope is None: + break + self.add(next_scope) + + if self.end is None: + self.end = self.content.find(self.end_char, self.current, len(self.content)) + pdesc = str(self.parent_scope) if self.parent_scope is not None else "" + assert self.end != -1, "Could not find \"%s\" in \"%s\" - parent scope - %s" % (self.end_char, self.content[self.current:], pdesc) + debug("EmptyScope(%s).read - %s - Done at %s" % (self.type, self.name, self.end)) + + def add(self, child): + debug("EmptyScope.add %s (%s) to %s (%s) - DROP" % (child.name, child.type, self.name, self.type)) + pass + + def find_scope_start(self, content, start, end, find_str): + debug("EmptyScope.find_scope_start") + loc = content.find(find_str, start, end) + if loc == -1: + return loc + else: + return loc + len(find_str) - len(self.start_char) + + def find_possible_end(self): + possible = self.content.find(self.end_char, self.current) + if possible == -1: + possible = len(self.content) - 1 + debug("EmptyScope.find_possible_end current=%s possible end=%s" % (self.current, possible)) + return possible + + def next_scope(self, end = None): + if end is None: + end = self.find_possible_end() + debug("EmptyScope.next_scope current=%s end=%s" % (self.current, end)) + match = EmptyScope.any_scope_pattern.search(self.content[self.current:end]) + if match: + start = self.find_scope_start(self.content, self.current, end, self.start_char) + new_scope = EmptyScope(None, start, self.content, self) + new_scope.read() + self.current = new_scope.end + 1 + return new_scope + + return None + + def find_class(self, scoped_name): + scope_separator = "::" + loc = scoped_name.find(scope_separator) + if loc != -1: + child_name = scoped_name[0:loc] + loc += len(scope_separator) + child_scoped_name = scoped_name[loc:] + if child_name in self.children: + debug("find_class traverse child_name: %s, child_scoped_name: %s" % (child_name, child_scoped_name)) + return self.children[child_name].find_class(child_scoped_name) + elif self.inherit is not None and scoped_name in self.inherit.children: + debug("find_class found scoped_name: %s in inherited: %s" % (scoped_name, self.inherit.name)) + return self.inherit.children[scoped_name].find_class(child_scoped_name) + else: + if scoped_name not in self.children: + inherit_children = ",".join(self.inherit.children) if self.inherit is not None else "no inheritance" + inherit_using = ",".join(self.inherit.usings) if self.inherit is not None else "no inheritance" + inherit = self.inherit.name if self.inherit is not None else None + debug("find_class %s not in children, using: %s, inherit: %s - children: %s, using: %s" % (scoped_name, ",".join(self.usings), inherit, inherit_children, inherit_using)) + + if scoped_name in self.children: + debug("find_class found scoped_name: %s" % (scoped_name)) + return self.children[scoped_name] + elif scoped_name in self.usings: + using = self.usings[scoped_name] + debug("find_class found scoped_name: %s, using: %s" % (scoped_name, using)) + return self.find_class(using) + elif self.inherit is not None and scoped_name in self.inherit.children: + debug("find_class found scoped_name: %s in inherited: %s" % (scoped_name, self.inherit.name)) + return self.inherit.children[scoped_name] + else: + debug("find_class could not find scoped_name: %s, children: %s" % (scoped_name, ",".join(self.children))) + return None + + def __str__(self): + indent = "" + next = self.parent_scope + while next is not None: + indent += " " + next = next.parent_scope + desc = "%s%s scope type=\"%s\"\n%s children={\n" % (indent, self.name, self.type, indent) + for child in self.children_ordered: + desc += str(self.children[child]) + "\n" + desc += indent + " }\n" + desc += indent + " fields={\n" + for field in self.fields: + desc += indent + " " + field + "\n" + desc += indent + " }\n" + desc += indent + " usings={\n" + for using in self.usings: + desc += indent + " " + using + ": " + self.usings[using] + "\n" + desc += indent + " }\n" + return desc + +def create_scope(type, name, inherit, start, content, parent_scope): + debug("create_scope") + if type == EmptyScope.namespace_str: + return Namespace(name, inherit, start, content, parent_scope) + elif type == EmptyScope.class_str or type == EmptyScope.struct_str: + return ClassStruct(name, inherit, start, content, parent_scope, is_enum = False) + elif type == EmptyScope.enum_str: + return ClassStruct(name, inherit, start, content, parent_scope, is_enum = True) + else: + assert False, "Script does not account for type = \"%s\" found in \"%s\"" % (type, content[start:]) + +class ClassStruct(EmptyScope): + #field_pattern = re.compile(r'\n\s*?(?:mutable\s+)?(\w[\w:\d<>]+)\s*(\w+)\s*(?:=\s[^;]+)?;', re.MULTILINE | re.DOTALL) + field_pattern = re.compile(r'\n\s*?(?:mutable\s+)?(\w[\w:\d<>]*)\s+(\w+)\s*(?:=\s[^;]+;|;|=\s*{)', re.MULTILINE | re.DOTALL) + enum_field_pattern = re.compile(r'\n\s*?(\w+)\s*(?:=\s*[^,}\s]+)?\s*(?:,|})', re.MULTILINE | re.DOTALL) + class_pattern = re.compile(r'(%s|%s|%s)\s+(\w+)\s*(:\s*public\s+([^<\s]+)[^{]*)?\s*\{' % (EmptyScope.struct_str, EmptyScope.class_str, EmptyScope.enum_str), re.MULTILINE | re.DOTALL) + cb_obj_pattern = re.compile(r'chainbase::object$') + obj_pattern = re.compile(r'^object$') + using_pattern = re.compile(r'\n\s*?using\s+(\w+)\s*=\s*([\w:]+)(?:<.*>)?;') + + def __init__(self, name, inherit, start, content, parent_scope, is_enum): + debug("ClassStruct.__init__ %s %d" % (name, start)) + EmptyScope.__init__(self, name, start, content, parent_scope) + self.classes = {} + self.pattern = ClassStruct.class_pattern + self.type = "ClassStruct" + self.is_enum = is_enum + self.inherit = None + if inherit is None: + self.ignore_id = False + else: + match = ClassStruct.cb_obj_pattern.search(inherit) + if match is None: + match = ClassStruct.obj_pattern.search(inherit) + + self.ignore_id = True if match else False + next = self.parent_scope + while self.inherit is None and next is not None: + self.inherit = next.find_class(inherit) + next = next.parent_scope + debug("Checking for object, ignore_id: %s, inherit: %s, name: %s" % (self.ignore_id, inherit, name)) + + def add(self, child): + debug("ClassStruct.add %s (%s) to %s (%s)" % (child.name, child.type, self.name, self.type)) + if isinstance(child, ClassStruct): + self.classes[child.name] = child + self.children[child.name] = child + self.children_ordered.append(child.name) + + def add_fields(self, start, end): + loc = start + while loc < end: + debug("ClassStruct.add_fields -{\n%s\n}" % (self.content[loc:end + 1])) + if self.is_enum: + loc = self.add_enum_field(loc, end) + else: + loc = self.add_field(loc, end) + debug("ClassStruct.add_fields done") + + def add_field(self, loc, end): + match = ClassStruct.field_pattern.search(self.content[loc:end + 1]) + if match is None: + return end + field = match.group(2) + self.fields.append(field) + all = match.group(0) + loc = self.content.find(all, loc) + len(all) + debug("ClassStruct.add_field - %s (%d) - %s" % (field, len(self.fields), ClassStruct.field_pattern.pattern)) + return loc + + def add_enum_field(self, loc, end): + match = ClassStruct.enum_field_pattern.search(self.content[loc:end + 1]) + if match is None: + return end + field = match.group(1) + self.fields.append(field) + all = match.group(0) + loc = self.content.find(all, loc) + len(all) + debug("ClassStruct.add_enum_field - %s (%d) - %s" % (field, len(self.fields), ClassStruct.enum_field_pattern.pattern)) + return loc + + def add_usings(self, start, end): + loc = start + while loc < end: + debug("ClassStruct.add_usings -{\n%s\n}" % (self.content[loc:end + 1])) + match = ClassStruct.using_pattern.search(self.content[loc:end]) + if match is None: + break + using = match.group(1) + class_struct = match.group(2) + self.usings[using] = class_struct + all = match.group(0) + loc = self.content.find(all, loc) + len(all) + debug("ClassStruct.add_usings - %s (%d)" % (using, len(self.usings))) + debug("ClassStruct.add_usings done") + + def next_scope(self, end = None): + new_scope = None + if end is None: + end = self.find_possible_end() + debug("ClassStruct.next_scope end=%s on %s\n\npossible scope={\n\"%s\"\n\n\npattern=%s" % (end, self.name, self.content[self.current:end], self.pattern.pattern)) + match = self.pattern.search(self.content[self.current:end]) + start = -1 + search_str = None + type = None + name = None + inherit = None + if match: + debug("ClassStruct.next_scope match on %s" % (self.name)) + search_str = match.group(0) + type = match.group(1) + name = match.group(2) + if len(match.groups()) >= 3: + inherit = match.group(4) + + start = self.find_scope_start(self.content, self.current, end, search_str) + debug("all: %s, type: %s, name: %s, start: %s, inherit: %s" % (search_str, type, name, start, inherit)) + + generic_scope_start = self.find_scope_start(self.content, self.current, end, self.start_char) + if start == -1 and generic_scope_start == -1: + debug("ClassStruct.next_scope end=%s no scopes add_fields and exit" % (end)) + self.add_fields(self.current, end) + return None + + debug("found \"%s\" - \"%s\" - \"%s\" current=%s, start=%s, end=%s, pattern=%s " % (search_str, type, name, self.current, start, end, self.pattern.pattern)) + # determine if there is a non-namespace/non-class/non-struct scope before a namespace/class/struct scope + if start != -1 and (generic_scope_start == -1 or start <= generic_scope_start): + debug("found %s at %d" % (type, start)) + new_scope = create_scope(type, name, inherit, start, self.content, self) + else: + debug("found EmptyScope (%s) at %d, next scope at %s" % (type, generic_scope_start, start)) + contextStart = generic_scope_start - 10 if generic_scope_start >= 10 else 0 + contextEnd = generic_scope_start + 10 if generic_scope_start < len(self.content) - 10 else len(self.content) + context2Start = start - 10 if start >= 10 else 0 + context2End = start + 10 if start < len(self.content) - 10 else len(self.content) + #debug("context=\"%s\"\n next context=\"%s\"" % (self.content[contextStart:contextEnd], self.content[context2Start:context2End])) + new_scope = EmptyScope("", generic_scope_start, self.content, self) + + self.add_fields(self.current, new_scope.start) + self.add_usings(self.current, new_scope.start) + new_scope.read() + self.current = new_scope.end + 1 + + return new_scope + +class Namespace(ClassStruct): + namespace_class_pattern = re.compile(r'(%s|%s|%s|%s)\s+(\w+)\s*(:\s*public\s+([^<\s]+)[^{]*)?\s*\{' % (EmptyScope.namespace_str, EmptyScope.struct_str, EmptyScope.class_str, EmptyScope.enum_str), re.MULTILINE | re.DOTALL) + + def __init__(self, name, inherit, start, content, parent_scope): + debug("Namespace.__init__ %s %d" % (name, start)) + assert inherit is None, "namespace %s should not inherit from %s" % (name, inherit) + ClassStruct.__init__(self, name, None, start, content, parent_scope, is_enum = False) + self.namespaces = {} + self.pattern = Namespace.namespace_class_pattern + self.type = "Namespace" + + def add(self, child): + debug("Namespace.add %s (%s) to %s (%s)" % (child.name, child.type, self.name, self.type)) + if isinstance(child, ClassStruct): + ClassStruct.add(self, child) + return + if isinstance(child, Namespace): + self.namespaces[child.name] = child + self.children[child.name] = child + self.children_ordered.append(child.name) + +class Reflection: + def __init__(self, name): + self.name = name + self.fields = [] + self.ignored = [] + self.swapped = [] + self.absent = [] + +class Reflections: + def __init__(self, content): + self.content = content + self.current = 0 + self.end = len(content) + self.classes = {} + self.classes_ordered = [] + self.with_2_comments = re.compile(r'(//\s*(%s|%s)\s+([^/]*?)\s*\n\s*//\s*(%s|%s)\s+([^/]*?)\s*\n\s*(%s%s\s*\(\s*(\w[^\s<]*))(?:<[^>]*>)?\s*,)' % (ignore_str, swap_str, ignore_str, swap_str, fc_reflect_str, fc_reflect_possible_enum_ext), re.MULTILINE | re.DOTALL) + self.with_comment = re.compile(r'(//\s*(%s|%s)\s+([^/]*?)\s*\n\s*(%s%s\s*\(\s*(\w[^\s<]*))(?:<[^>]*>)?\s*,)' % (ignore_str, swap_str, fc_reflect_str, fc_reflect_possible_enum_ext), re.MULTILINE | re.DOTALL) + self.reflect_pattern = re.compile(r'(\b(%s%s\s*\(\s*(\w[^\s<]*)(?:<[^>]*>)?\s*,)\s*(\(.*?\))\s*\))[^\)]*%s%s\b' % (fc_reflect_str, fc_reflect_possible_enum_ext, fc_reflect_str, fc_reflect_possible_enum_ext), re.MULTILINE | re.DOTALL) + self.field_pattern = re.compile(r'\(([^\)]+)\)', re.MULTILINE | re.DOTALL) + self.ignore_swap_pattern = re.compile(r'\b([\w\d]+)\b', re.MULTILINE | re.DOTALL) + + def read(self): + while self.current < self.end: + match_2_comments = self.with_2_comments.search(self.content[self.current:]) + match_comment = self.with_comment.search(self.content[self.current:]) + match_reflect = self.reflect_pattern.search(self.content[self.current:]) + match_loc = None + if match_2_comments or match_comment: + loc1 = self.content.find(match_2_comments.group(1), self.current) if match_2_comments else self.end + loc2 = self.content.find(match_comment.group(1), self.current) if match_comment else self.end + debug("loc1=%s and loc2=%s" % (loc1, loc2)) + group1 = match_2_comments.group(1) if match_2_comments else "" + group2 = match_comment.group(1) if match_comment else "" + debug("\n ***** group1={\n%s\n}\n\n\n ***** group2={\n%s\n}\n\n\n" % (group1, group2)) + if loc2 < loc1: + debug("loc2 earlier") + match_2_comments = None + match_loc = loc2 + else: + match_loc = loc1 + if match_reflect and match_loc is not None: + debug("match_reflect and one of the other matches") + loc1 = self.content.find(match_reflect.group(1), self.current) + if loc1 < match_loc: + debug("choose the other matches") + match_comment = None + match_2_comments = None + else: + debug("choose comment") + pass + + if match_2_comments: + debug("match_2_comments") + debug("Groups {") + for g in match_2_comments.groups(): + debug(" %s" % g) + debug("}") + ignore_or_swap1 = match_2_comments.group(2) + next_reflect_ignore_swap1 = match_2_comments.group(3) + ignore_or_swap2 = match_2_comments.group(4) + next_reflect_ignore_swap2 = match_2_comments.group(5) + search_string_for_next_reflect_class = match_2_comments.group(6) + next_reflect_class = match_2_comments.group(7) + self.add_ignore_swaps(next_reflect_class, next_reflect_ignore_swap1, ignore_or_swap1) + self.add_ignore_swaps(next_reflect_class, next_reflect_ignore_swap2, ignore_or_swap2) + elif match_comment: + debug("match_comment") + debug("Groups {") + for g in match_comment.groups(): + debug(" %s" % g) + debug("}") + ignore_or_swap = match_comment.group(2) + next_reflect_ignore_swap = match_comment.group(3) + search_string_for_next_reflect_class = match_comment.group(4) + next_reflect_class = match_comment.group(5) + self.add_ignore_swaps(next_reflect_class, next_reflect_ignore_swap, ignore_or_swap) + + if match_reflect: + debug("match_reflect") + debug("Groups {") + for g in match_reflect.groups(): + debug(" %s" % g) + debug("}") + next_reflect = match_reflect.group(2) + next_reflect_class = match_reflect.group(3) + next_reflect_fields = match_reflect.group(4) + self.add_fields(next_reflect, next_reflect_class, next_reflect_fields) + else: + debug("search for next reflect done") + self.current = self.end + break + + def find_or_add(self, reflect_class): + if reflect_class not in self.classes: + debug("find_or_add added \"%s\"" % (reflect_class)) + self.classes[reflect_class] = Reflection(reflect_class) + self.classes_ordered.append(self.classes[reflect_class]) + return self.classes[reflect_class] + + def add_fields(self, next_reflect, next_reflect_class, next_reflect_fields): + old = self.current + self.current = self.content.find(next_reflect, self.current) + len(next_reflect) + debug("all={\n\n%s\n\nclass=\n\n%s\n\nfields=\n\n%s\n\n" % (next_reflect, next_reflect_class, next_reflect_fields)) + fields = re.findall(self.field_pattern, next_reflect_fields) + for field in fields: + self.add_field(next_reflect_class, field) + reflect_class = self.find_or_add(next_reflect_class) + debug("add_fields %s done, fields count=%s, ignored count=%s, swapped count=%s" % (next_reflect_class, len(reflect_class.fields), len(reflect_class.ignored), len(reflect_class.swapped))) + + def add_ignore_swaps(self, next_reflect_class, next_reflect_ignores_swaps, ignore_or_swap): + debug("class=\n\n%s\n\n%s=\n\n%s\n\n" % (next_reflect_class, ignore_or_swap, next_reflect_ignores_swaps)) + end = len(next_reflect_ignores_swaps) + current = 0 + while current < end: + ignore_swap_match = self.ignore_swap_pattern.search(next_reflect_ignores_swaps[current:]) + if ignore_swap_match: + ignore_swap = ignore_swap_match.group(1) + reflect_class = self.find_or_add(next_reflect_class) + if (ignore_or_swap == ignore_str): + assert ignore_swap not in reflect_class.ignored, "Reflection for %s repeats %s \"%s\"" % (next_reflect_class, ignore_or_swap) + assert ignore_swap not in reflect_class.swapped, "Reflection for %s references field \"%s\" in %s and %s " % (next_reflect_class, ignore_swap, ignore_str, swap_str) + reflect_class.ignored.append(ignore_swap) + else: + assert ignore_swap not in reflect_class.swapped, "Reflection for %s repeats %s \"%s\"" % (next_reflect_class, ignore_or_swap) + assert ignore_swap not in reflect_class.ignored, "Reflection for %s references field \"%s\" in %s and %s " % (next_reflect_class, ignore_swap, swap_str, ignore_str) + reflect_class.swapped.append(ignore_swap) + debug("ignore or swap %s --> %s, ignored count=%s, swapped count=%s" % (next_reflect_class, ignore_swap, len(reflect_class.ignored), len(reflect_class.swapped))) + current = next_reflect_ignores_swaps.find(ignore_swap_match.group(0), current) + len(ignore_swap_match.group(0)) + else: + break + + + def add_field(self, reflect_class_name, field): + reflect_class = self.find_or_add(reflect_class_name) + assert field not in reflect_class.fields, "Reflection for %s repeats field \"%s\"" % (reflect_class_name, field) + reflect_class.fields.append(field) + debug("add_field %s --> %s" % (reflect_class_name, field)) + +def replace_multi_line_comment(match): + all=match.group(1) + all=EmptyScope.strip_extra_pattern.sub("", all) + debug("multiline found=%s" % (all)) + match=EmptyScope.ignore_swap_pattern.search(all) + if match: + ignore_or_swap = match.group(1) + all = match.group(2) + debug("multiline %s now=%s" % (ignore_or_swap, all)) + invalid_chars=EmptyScope.invalid_chars_pattern.search(all) + if invalid_chars: + for ic in invalid_chars.groups(): + debug("invalid_char=%s" % (ic)) + debug("WARNING: looks like \"%s\" is intending to %s, but there are invalid characters - \"%s\"" % (all, ignore_or_swap, ",".join(invalid_chars.groups()))) + return "" + groups=re.findall(EmptyScope.multi_line_comment_ignore_swap_pattern, all) + if groups is None: + return "" + rtn_str="// %s " % (ignore_or_swap) + add=False + for group in groups: + debug("group=%s" % (group)) + if group is None: + continue + if add: + rtn_str+=", " + rtn_str+="%s" % (group) + add=True + debug("multiline rtn_str=%s" % (rtn_str)) + return rtn_str + + debug("multiline no match") + return "" + +def replace_line_comment(match): + all=match.group(0) + debug("singleline found=%s" % (all)) + if EmptyScope.single_comment_ignore_swap_pattern.match(all): + return all + else: + return "\n" + +def validate_file(file): + f = open(file, "r") + contents = f.read() + f.close() + contents = "\n" + contents # lazy fix for complex regex + contents = EmptyScope.multi_line_comment_pattern.sub(replace_multi_line_comment, contents) + contents = EmptyScope.single_comment_pattern.sub(replace_line_comment, contents) + found = re.search(fc_reflect_str, contents) + if found is None: + return + print("validate %s" % (file)) + debug("validate %s" % (file)) + global_namespace=Namespace("", None, 0, contents, None) + global_namespace.read() + if args.debug: + _, filename = os.path.split(file) + f = open(temp_dir + "/" + filename + ".struct", "w") + f.write("global_namespace=%s" % (global_namespace)) + f.close() + f = open(temp_dir + "/" + filename + ".stripped", "w") + f.write(contents) + f.close() + reflections=Reflections(contents) + reflections.read() + for reflection in reflections.classes_ordered: + reflection_name = reflection.name + class_struct = global_namespace.find_class(reflection_name) + if class_struct is None: + match=re.search(r'^(.+?)::id_type$', reflection_name) + if match: + parent_class_name = match.group(1) + parent_class = global_namespace.find_class(parent_class_name) + if parent_class.ignore_id: + # this is a chainbase::object, don't need to worry about id_type definition + continue + class_struct_num_fields = len(class_struct.fields) if class_struct is not None else None + debug("reflection_name=%s, class field count=%s, reflection field count=%s, ingore count=%s, swap count=%s" % (reflection_name, class_struct_num_fields, len(reflection.fields), len(reflection.ignored), len(reflection.swapped))) + assert isinstance(class_struct, ClassStruct), "could not find a %s/%s/%s for %s" % (EmptyScope.class_str, EmptyScope.struct_str, EmptyScope.enum_str, reflection_name) + if class_struct.ignore_id: + id_field = "id" + if id_field not in reflection.ignored and id_field not in reflection.fields: + debug("Object ignore_id Adding id to ignored for %s" % (reflection_name)) + reflection.ignored.append(id_field) + else: + debug("Object ignore_id NOT adding id to ignored for %s" % (reflection_name)) + rf_index = 0 + rf_len = len(reflection.fields) + + processed = [] + back_swapped = [] + fwd_swapped = [] + ignored = [] + f_index = 0 + f_len = len(class_struct.fields) + while f_index < f_len: + field = class_struct.fields[f_index] + reflect_field = reflection.fields[rf_index] if rf_index < rf_len else None + processed.append(field) + debug("\nfield=%s reflect_field=%s" % (field, reflect_field)) + #debug("start rf_index=%s, rf_len=%s, f_index=%s, f_len=%s" % (rf_index, rf_len, f_index, f_len)) + if field in reflection.swapped: + debug("field \"%s\" swapped (back)" % (field)) + reflection.swapped.remove(field) + back_swapped.append(field) + assert field in reflection.fields, "Reflection for %s indicates swapping %s but swapped position is not indicated in the reflection fields. Should it be ignored?" % (reflection_name, field) + assert reflect_field != field, "Reflection for %s should not indicate swapping %s since it is in the correct order" % (reflection_name, field) + f_index += 1 + continue + if reflect_field in reflection.swapped: + debug("field \"%s\" swapped (fwd)" % (field)) + reflection.swapped.remove(reflect_field) + fwd_swapped.append(reflect_field) + assert reflect_field in reflection.fields, "Reflection for %s indicates swapping field %s but it doesn't exist in that class/struct so it should be removed" % (reflection_name, reflect_field) + rf_index += 1 + continue + assert reflect_field not in ignored, "Reflection for %s should not indicate %s for %s, it should indicate %s - %s" % (reflection_name, ignore_str, reflect_field, swap_str, ",".join(ignored)) + if field in reflection.ignored: + debug("ignoring: %s" % (field)) + reflection.ignored.remove(field) + ignored.append(field) + assert reflect_field != field, "Reflection for %s should not indicate ignoring %s since it is in the correct order" % (reflection_name, field) + f_index += 1 + continue + debug("ignored=%s, swapped=%s" % (",".join(reflection.ignored),",".join(reflection.swapped))) + if reflect_field is not None and reflect_field in back_swapped: + back_swapped.remove(reflect_field) + rf_index += 1 + elif field in fwd_swapped: + fwd_swapped.remove(field) + f_index += 1 + else: + assert reflect_field == field, "Reflection for %s should have field %s instead of %s or else it should indicate if the field should be ignored (%s) or swapped (%s)" %(reflection_name, field, reflect_field, ignore_str, swap_str) + f_index += 1 + rf_index += 1 + debug("rf_index=%s, rf_len=%s, f_index=%s, f_len=%s" % (rf_index, rf_len, f_index, f_len)) + + assert len(reflection.ignored) == 0, "Reflection for %s has erroneous ignores - \"%s\"" % (reflection_name, ",".join(reflection.ignored)) + unused_reflect_fields = [] + while rf_index < rf_len: + debug("rf_index=%s, rf_len=%s fields=%s" % (rf_index, rf_len, ",".join(reflection.fields))) + reflect_field = reflection.fields[rf_index] + if reflect_field in back_swapped: + back_swapped.remove(reflect_field) + else: + unused_reflect_fields.append(reflect_field) + rf_index += 1 + assert len(unused_reflect_fields) == 0, "Reflection for %s has fields not in defintion for class/struct - \"%s\"" % (reflection_name, ",".join(unused_reflect_fields)) + assert len(reflection.swapped) == 0, "Reflection for %s has erroneous swaps - \"%s\"" % (reflection_name, ",".join(reflection.swapped)) + assert len(back_swapped) == 0, "Reflection for %s indicated swapped fields that were never provided - \"%s\"" % (reflection_name, ",".join(back_swapped)) + assert len(fwd_swapped) == 0, "Reflection for %s indicated and provided swapped fields that are not in the class - \"%s\"" % (reflection_name, ",".join(fwd_swapped)) + + print("%s passed" % (file)) + +success = True + +def walk(current_dir): + result = True + print("Searching for files: %s" % (current_dir)) + for root, dirs, filenames in os.walk(current_dir): + for filename in filenames: + _, extension = os.path.splitext(filename) + if extension not in extensions: + continue + try: + validate_file(root + "/" + filename) + except AssertionError: + _, info, tb = sys.exc_info() + traceback.print_tb(tb) # Fixed format + tb_info = traceback.extract_tb(tb) + filename, line, func, text = tb_info[-1] + + print("An error occurred in %s:%s: %s" % (filename, line, info), file=sys.stderr) + if args.exit_on_error: + exit(1) + result = False + + if not recurse: + break + return result + +for file in args.files: + if os.path.isdir(file): + success &= walk(file) + elif os.path.isfile(file): + try: + validate_file(file) + except AssertionError: + _, info, tb = sys.exc_info() + traceback.print_tb(tb) # Fixed format + tb_info = traceback.extract_tb(tb) + filename, line, func, text = tb_info[-1] + + print("An error occurred in %s:%s: %s" % (filename, line, info), file=sys.stderr) + if args.exit_on_error: + exit(1) + success = False + else: + print("ERROR \"%s\" is neither a directory nor a file" % file) + success = False + +if success: + exit(0) +else: + exit(1) From 4bdcbb5890979de41d2244d2874c0e250f35d17a Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Mon, 3 Dec 2018 08:22:40 -0600 Subject: [PATCH 060/111] Added @ignore comment for field that is left out of reflect definition. GH #3127 --- .../chain/include/eosio/chain/resource_limits_private.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/chain/include/eosio/chain/resource_limits_private.hpp b/libraries/chain/include/eosio/chain/resource_limits_private.hpp index 687a56a4d90..dc5b26008bd 100644 --- a/libraries/chain/include/eosio/chain/resource_limits_private.hpp +++ b/libraries/chain/include/eosio/chain/resource_limits_private.hpp @@ -267,7 +267,8 @@ CHAINBASE_SET_INDEX_TYPE(eosio::chain::resource_limits::resource_limits_state_ob FC_REFLECT(eosio::chain::resource_limits::usage_accumulator, (last_ordinal)(value_ex)(consumed)) +// @ignore pending FC_REFLECT(eosio::chain::resource_limits::resource_limits_object, (owner)(net_weight)(cpu_weight)(ram_bytes)) FC_REFLECT(eosio::chain::resource_limits::resource_usage_object, (owner)(net_usage)(cpu_usage)(ram_usage)) FC_REFLECT(eosio::chain::resource_limits::resource_limits_config_object, (cpu_limit_parameters)(net_limit_parameters)(account_cpu_usage_average_window)(account_net_usage_average_window)) -FC_REFLECT(eosio::chain::resource_limits::resource_limits_state_object, (average_block_net_usage)(average_block_cpu_usage)(pending_net_usage)(pending_cpu_usage)(total_net_weight)(total_cpu_weight)(total_ram_bytes)(virtual_net_limit)(virtual_cpu_limit)) \ No newline at end of file +FC_REFLECT(eosio::chain::resource_limits::resource_limits_state_object, (average_block_net_usage)(average_block_cpu_usage)(pending_net_usage)(pending_cpu_usage)(total_net_weight)(total_cpu_weight)(total_ram_bytes)(virtual_net_limit)(virtual_cpu_limit)) From f8a21273147e56aa452e4b3a8a4427cb3f07efa6 Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Wed, 12 Dec 2018 16:27:10 -0600 Subject: [PATCH 061/111] Fixed pull request comments. --- tools/validate_reflection.py | 111 +++++++++++++++-------------------- 1 file changed, 48 insertions(+), 63 deletions(-) diff --git a/tools/validate_reflection.py b/tools/validate_reflection.py index ac97446f88a..52cae39bc30 100755 --- a/tools/validate_reflection.py +++ b/tools/validate_reflection.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import argparse +from collections import OrderedDict import re import os import sys @@ -19,21 +20,26 @@ # so once it runs into the swapped field, it will remove that field from the order and expect the remaining in # that order, so if the class has field1, field2, field3, and field4, and the reflect macro has the order # field1, field3, field2, then field4, it should indicate swapping field2. This will remove field2 from the -# expected order and the rest will now match. Or else it should indicated swapping field3, since the remaining +# expected order and the rest will now match. Alternatively it should indicate swapping field3, since the remaining # fields will also match the order. But both field2 and field3 should not be indicated. # # # ############################################################### +import atexit +import tempfile -temp_dir = "temp_dir" +@atexit.register +def close_debug_file(): + if debug_file != None: + debug_file.close() parser = argparse.ArgumentParser(add_help=False) parser.add_argument('-?', action='help', default=argparse.SUPPRESS, help=argparse._('show this help message and exit')) -parser.add_argument('-d', '--debug', help="generate debug output into \"./%s\"" % (temp_dir), action='store_true') +parser.add_argument('-d', '--debug', help="generate debug output into a temporary directory", action='store_true') parser.add_argument('-r', '--recurse', help="recurse through an entire directory (if directory provided for \"file\"", action='store_true') parser.add_argument('-x', '--extension', type=str, help="extensions array to allow for directory and recursive search. Defaults to \".hpp\" and \".cpp\".", action='append') parser.add_argument('-e', '--exit-on-error', help="Exit immediately when a validation error is discovered. Default is to run validation on all files and directories provided.", action='store_true') @@ -42,9 +48,9 @@ recurse = args.recurse if args.debug: - if not os.path.exists(temp_dir): - os.mkdir(temp_dir) - debug_file = open(temp_dir + "/validate_reflect.debug", "w") + temp_dir = tempfile.mkdtemp() + print("temporary files writen to %s" % (temp_dir)) + debug_file = open(os.path.join(temp_dir, "validate_reflect.debug"), "w") else: debug_file = None extensions = [] @@ -80,6 +86,8 @@ class EmptyScope: class_str = "class" enum_str = "enum" any_scope_pattern = re.compile(r'\{', re.DOTALL) + start_char = "{" + end_char = "}" def __init__(self, name, start, content, parent_scope): pname = parent_scope.name if parent_scope is not None else "" @@ -90,17 +98,14 @@ def __init__(self, name, start, content, parent_scope): self.current = start + 1 self.parent_scope = parent_scope self.end = len(content) - 1 if start == 0 else None - self.start_char = "{" - self.end_char = "}" self.children = {} self.children_ordered = [] self.fields = [] self.usings = {} - self.type = "EmptyScope" self.inherit = None def read(self): - debug("EmptyScope(%s).read - %s" % (self.type, self.name)) + debug("EmptyScope(%s).read - %s" % (self.__class__.__name__, self.name)) end = len(self.content) - 1 while self.current < end: next_scope = self.next_scope() @@ -109,13 +114,13 @@ def read(self): self.add(next_scope) if self.end is None: - self.end = self.content.find(self.end_char, self.current, len(self.content)) + self.end = self.content.find(EmptyScope.end_char, self.current, len(self.content)) pdesc = str(self.parent_scope) if self.parent_scope is not None else "" - assert self.end != -1, "Could not find \"%s\" in \"%s\" - parent scope - %s" % (self.end_char, self.content[self.current:], pdesc) - debug("EmptyScope(%s).read - %s - Done at %s" % (self.type, self.name, self.end)) + assert self.end != -1, "Could not find \"%s\" in \"%s\" - parent scope - %s" % (EmptyScope.end_char, self.content[self.current:], pdesc) + debug("EmptyScope(%s).read - %s - Done at %s" % (self.__class__.__name__, self.name, self.end)) def add(self, child): - debug("EmptyScope.add %s (%s) to %s (%s) - DROP" % (child.name, child.type, self.name, self.type)) + debug("EmptyScope.add %s (%s) to %s (%s) - DROP" % (child.name, child.__class__.__name__, self.name, self.__class__.__name__)) pass def find_scope_start(self, content, start, end, find_str): @@ -124,12 +129,10 @@ def find_scope_start(self, content, start, end, find_str): if loc == -1: return loc else: - return loc + len(find_str) - len(self.start_char) + return loc + len(find_str) - len(EmptyScope.start_char) def find_possible_end(self): - possible = self.content.find(self.end_char, self.current) - if possible == -1: - possible = len(self.content) - 1 + possible = self.content.find(EmptyScope.end_char, self.current) debug("EmptyScope.find_possible_end current=%s possible end=%s" % (self.current, possible)) return possible @@ -139,7 +142,7 @@ def next_scope(self, end = None): debug("EmptyScope.next_scope current=%s end=%s" % (self.current, end)) match = EmptyScope.any_scope_pattern.search(self.content[self.current:end]) if match: - start = self.find_scope_start(self.content, self.current, end, self.start_char) + start = self.find_scope_start(self.content, self.current, end, EmptyScope.start_char) new_scope = EmptyScope(None, start, self.content, self) new_scope.read() self.current = new_scope.end + 1 @@ -187,7 +190,7 @@ def __str__(self): while next is not None: indent += " " next = next.parent_scope - desc = "%s%s scope type=\"%s\"\n%s children={\n" % (indent, self.name, self.type, indent) + desc = "%s%s scope type=\"%s\"\n%s children={\n" % (indent, self.name, self.__class__.__name__, indent) for child in self.children_ordered: desc += str(self.children[child]) + "\n" desc += indent + " }\n" @@ -213,7 +216,6 @@ def create_scope(type, name, inherit, start, content, parent_scope): assert False, "Script does not account for type = \"%s\" found in \"%s\"" % (type, content[start:]) class ClassStruct(EmptyScope): - #field_pattern = re.compile(r'\n\s*?(?:mutable\s+)?(\w[\w:\d<>]+)\s*(\w+)\s*(?:=\s[^;]+)?;', re.MULTILINE | re.DOTALL) field_pattern = re.compile(r'\n\s*?(?:mutable\s+)?(\w[\w:\d<>]*)\s+(\w+)\s*(?:=\s[^;]+;|;|=\s*{)', re.MULTILINE | re.DOTALL) enum_field_pattern = re.compile(r'\n\s*?(\w+)\s*(?:=\s*[^,}\s]+)?\s*(?:,|})', re.MULTILINE | re.DOTALL) class_pattern = re.compile(r'(%s|%s|%s)\s+(\w+)\s*(:\s*public\s+([^<\s]+)[^{]*)?\s*\{' % (EmptyScope.struct_str, EmptyScope.class_str, EmptyScope.enum_str), re.MULTILINE | re.DOTALL) @@ -226,7 +228,6 @@ def __init__(self, name, inherit, start, content, parent_scope, is_enum): EmptyScope.__init__(self, name, start, content, parent_scope) self.classes = {} self.pattern = ClassStruct.class_pattern - self.type = "ClassStruct" self.is_enum = is_enum self.inherit = None if inherit is None: @@ -244,7 +245,7 @@ def __init__(self, name, inherit, start, content, parent_scope, is_enum): debug("Checking for object, ignore_id: %s, inherit: %s, name: %s" % (self.ignore_id, inherit, name)) def add(self, child): - debug("ClassStruct.add %s (%s) to %s (%s)" % (child.name, child.type, self.name, self.type)) + debug("ClassStruct.add %s (%s) to %s (%s)" % (child.name, child.__class__.__name__, self.name, self.__class__.__name__)) if isinstance(child, ClassStruct): self.classes[child.name] = child self.children[child.name] = child @@ -319,7 +320,7 @@ def next_scope(self, end = None): start = self.find_scope_start(self.content, self.current, end, search_str) debug("all: %s, type: %s, name: %s, start: %s, inherit: %s" % (search_str, type, name, start, inherit)) - generic_scope_start = self.find_scope_start(self.content, self.current, end, self.start_char) + generic_scope_start = self.find_scope_start(self.content, self.current, end, EmptyScope.start_char) if start == -1 and generic_scope_start == -1: debug("ClassStruct.next_scope end=%s no scopes add_fields and exit" % (end)) self.add_fields(self.current, end) @@ -332,11 +333,6 @@ def next_scope(self, end = None): new_scope = create_scope(type, name, inherit, start, self.content, self) else: debug("found EmptyScope (%s) at %d, next scope at %s" % (type, generic_scope_start, start)) - contextStart = generic_scope_start - 10 if generic_scope_start >= 10 else 0 - contextEnd = generic_scope_start + 10 if generic_scope_start < len(self.content) - 10 else len(self.content) - context2Start = start - 10 if start >= 10 else 0 - context2End = start + 10 if start < len(self.content) - 10 else len(self.content) - #debug("context=\"%s\"\n next context=\"%s\"" % (self.content[contextStart:contextEnd], self.content[context2Start:context2End])) new_scope = EmptyScope("", generic_scope_start, self.content, self) self.add_fields(self.current, new_scope.start) @@ -355,10 +351,9 @@ def __init__(self, name, inherit, start, content, parent_scope): ClassStruct.__init__(self, name, None, start, content, parent_scope, is_enum = False) self.namespaces = {} self.pattern = Namespace.namespace_class_pattern - self.type = "Namespace" def add(self, child): - debug("Namespace.add %s (%s) to %s (%s)" % (child.name, child.type, self.name, self.type)) + debug("Namespace.add %s (%s) to %s (%s)" % (child.name, child.__class__.__name__, self.name, self.__class__.__name__)) if isinstance(child, ClassStruct): ClassStruct.add(self, child) return @@ -380,8 +375,7 @@ def __init__(self, content): self.content = content self.current = 0 self.end = len(content) - self.classes = {} - self.classes_ordered = [] + self.classes = OrderedDict() self.with_2_comments = re.compile(r'(//\s*(%s|%s)\s+([^/]*?)\s*\n\s*//\s*(%s|%s)\s+([^/]*?)\s*\n\s*(%s%s\s*\(\s*(\w[^\s<]*))(?:<[^>]*>)?\s*,)' % (ignore_str, swap_str, ignore_str, swap_str, fc_reflect_str, fc_reflect_possible_enum_ext), re.MULTILINE | re.DOTALL) self.with_comment = re.compile(r'(//\s*(%s|%s)\s+([^/]*?)\s*\n\s*(%s%s\s*\(\s*(\w[^\s<]*))(?:<[^>]*>)?\s*,)' % (ignore_str, swap_str, fc_reflect_str, fc_reflect_possible_enum_ext), re.MULTILINE | re.DOTALL) self.reflect_pattern = re.compile(r'(\b(%s%s\s*\(\s*(\w[^\s<]*)(?:<[^>]*>)?\s*,)\s*(\(.*?\))\s*\))[^\)]*%s%s\b' % (fc_reflect_str, fc_reflect_possible_enum_ext, fc_reflect_str, fc_reflect_possible_enum_ext), re.MULTILINE | re.DOTALL) @@ -424,12 +418,13 @@ def read(self): for g in match_2_comments.groups(): debug(" %s" % g) debug("}") - ignore_or_swap1 = match_2_comments.group(2) - next_reflect_ignore_swap1 = match_2_comments.group(3) - ignore_or_swap2 = match_2_comments.group(4) - next_reflect_ignore_swap2 = match_2_comments.group(5) - search_string_for_next_reflect_class = match_2_comments.group(6) - next_reflect_class = match_2_comments.group(7) + assert len(match_2_comments.groups()) == 7, "match_2_comments wrong size due to regex pattern change" + ignore_or_swap1 = match_2_comments[2] + next_reflect_ignore_swap1 = match_2_comments[3] + ignore_or_swap2 = match_2_comments[4] + next_reflect_ignore_swap2 = match_2_comments[5] + search_string_for_next_reflect_class = match_2_comments[6] + next_reflect_class = match_2_comments[7] self.add_ignore_swaps(next_reflect_class, next_reflect_ignore_swap1, ignore_or_swap1) self.add_ignore_swaps(next_reflect_class, next_reflect_ignore_swap2, ignore_or_swap2) elif match_comment: @@ -438,6 +433,8 @@ def read(self): for g in match_comment.groups(): debug(" %s" % g) debug("}") + assert len(match_comment.groups()) == 5, "match_comment too short due to regex pattern change" + # not using array indices here because for some reason the type of match_2_comments and match_comment are different ignore_or_swap = match_comment.group(2) next_reflect_ignore_swap = match_comment.group(3) search_string_for_next_reflect_class = match_comment.group(4) @@ -450,6 +447,7 @@ def read(self): for g in match_reflect.groups(): debug(" %s" % g) debug("}") + assert len(match_reflect.groups()) == 4, "match_reflect too short due to regex pattern change" next_reflect = match_reflect.group(2) next_reflect_class = match_reflect.group(3) next_reflect_fields = match_reflect.group(4) @@ -463,7 +461,6 @@ def find_or_add(self, reflect_class): if reflect_class not in self.classes: debug("find_or_add added \"%s\"" % (reflect_class)) self.classes[reflect_class] = Reflection(reflect_class) - self.classes_ordered.append(self.classes[reflect_class]) return self.classes[reflect_class] def add_fields(self, next_reflect, next_reflect_class, next_reflect_fields): @@ -524,15 +521,7 @@ def replace_multi_line_comment(match): if groups is None: return "" rtn_str="// %s " % (ignore_or_swap) - add=False - for group in groups: - debug("group=%s" % (group)) - if group is None: - continue - if add: - rtn_str+=", " - rtn_str+="%s" % (group) - add=True + rtn_str+=', '.join([group for group in groups if group is not None]) debug("multiline rtn_str=%s" % (rtn_str)) return rtn_str @@ -549,9 +538,8 @@ def replace_line_comment(match): def validate_file(file): f = open(file, "r") - contents = f.read() + contents = "\n" + f.read() # lazy fix for complex regex f.close() - contents = "\n" + contents # lazy fix for complex regex contents = EmptyScope.multi_line_comment_pattern.sub(replace_multi_line_comment, contents) contents = EmptyScope.single_comment_pattern.sub(replace_line_comment, contents) found = re.search(fc_reflect_str, contents) @@ -563,16 +551,14 @@ def validate_file(file): global_namespace.read() if args.debug: _, filename = os.path.split(file) - f = open(temp_dir + "/" + filename + ".struct", "w") - f.write("global_namespace=%s" % (global_namespace)) - f.close() - f = open(temp_dir + "/" + filename + ".stripped", "w") - f.write(contents) - f.close() + with open(os.path.join(temp_dir, filename + ".struct"), "w") as f: + f.write("global_namespace=%s" % (global_namespace)) + with open(os.path.join(temp_dir, filename + ".stripped"), "w") as f: + f.write(contents) reflections=Reflections(contents) reflections.read() - for reflection in reflections.classes_ordered: - reflection_name = reflection.name + for reflection_name in reflections.classes: + reflection = reflections.classes[reflection_name] class_struct = global_namespace.find_class(reflection_name) if class_struct is None: match=re.search(r'^(.+?)::id_type$', reflection_name) @@ -606,7 +592,6 @@ def validate_file(file): reflect_field = reflection.fields[rf_index] if rf_index < rf_len else None processed.append(field) debug("\nfield=%s reflect_field=%s" % (field, reflect_field)) - #debug("start rf_index=%s, rf_len=%s, f_index=%s, f_len=%s" % (rf_index, rf_len, f_index, f_len)) if field in reflection.swapped: debug("field \"%s\" swapped (back)" % (field)) reflection.swapped.remove(field) @@ -622,7 +607,7 @@ def validate_file(file): assert reflect_field in reflection.fields, "Reflection for %s indicates swapping field %s but it doesn't exist in that class/struct so it should be removed" % (reflection_name, reflect_field) rf_index += 1 continue - assert reflect_field not in ignored, "Reflection for %s should not indicate %s for %s, it should indicate %s - %s" % (reflection_name, ignore_str, reflect_field, swap_str, ",".join(ignored)) + assert reflect_field not in ignored, "Reflection for %s should not indicate %s for %s; it should indicate %s - %s" % (reflection_name, ignore_str, reflect_field, swap_str, ",".join(ignored)) if field in reflection.ignored: debug("ignoring: %s" % (field)) reflection.ignored.remove(field) @@ -653,7 +638,7 @@ def validate_file(file): else: unused_reflect_fields.append(reflect_field) rf_index += 1 - assert len(unused_reflect_fields) == 0, "Reflection for %s has fields not in defintion for class/struct - \"%s\"" % (reflection_name, ",".join(unused_reflect_fields)) + assert len(unused_reflect_fields) == 0, "Reflection for %s has fields not in definition for class/struct - \"%s\"" % (reflection_name, ",".join(unused_reflect_fields)) assert len(reflection.swapped) == 0, "Reflection for %s has erroneous swaps - \"%s\"" % (reflection_name, ",".join(reflection.swapped)) assert len(back_swapped) == 0, "Reflection for %s indicated swapped fields that were never provided - \"%s\"" % (reflection_name, ",".join(back_swapped)) assert len(fwd_swapped) == 0, "Reflection for %s indicated and provided swapped fields that are not in the class - \"%s\"" % (reflection_name, ",".join(fwd_swapped)) @@ -671,7 +656,7 @@ def walk(current_dir): if extension not in extensions: continue try: - validate_file(root + "/" + filename) + validate_file(os.path.join(root, filename)) except AssertionError: _, info, tb = sys.exc_info() traceback.print_tb(tb) # Fixed format From f712780acc1b77c0d4441e8592df00fbdf23d097 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Thu, 13 Dec 2018 20:37:20 -0600 Subject: [PATCH 062/111] Peer review changes. Fix move. --- plugins/net_plugin/net_plugin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index c4a5e7ddf76..81213d9d65d 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -578,10 +578,10 @@ namespace eosio { } void operator()( signed_block&& msg ) const { - impl.handle_message( c, std::make_shared( std::forward( msg ))); + impl.handle_message( c, std::make_shared( std::move( msg ) ) ); } void operator()( packed_transaction&& msg ) const { - impl.handle_message( c, std::make_shared( std::forward( msg ))); + impl.handle_message( c, std::make_shared( std::move( msg ) ) ); } template @@ -2738,7 +2738,7 @@ namespace eosio { ( "network-version-match", bpo::value()->default_value(false), "True to require exact match of peer network version.") ( "sync-fetch-span", bpo::value()->default_value(def_sync_fetch_span), "number of blocks to retrieve in a chunk from any individual peer during synchronization") - ( "max-implicit-request", bpo::value()->default_value(def_max_just_send), "maximum sizes of transaction or block messages that are sent without first sending a notice") + ( "max-implicit-request", bpo::value()->default_value(def_max_just_send), "(deprecated) this option is ignored") ( "use-socket-read-watermark", bpo::value()->default_value(false), "Enable expirimental socket read watermark optimization") ( "peer-log-format", bpo::value()->default_value( "[\"${_name}\" ${_ip}:${_port}]" ), "The string used to format peers when logging messages about them. Variables are escaped with ${}.\n" From cb463e53f979f496f3d40fb288b66e6537d86dc7 Mon Sep 17 00:00:00 2001 From: Greg Lee Date: Fri, 14 Dec 2018 00:41:37 -0500 Subject: [PATCH 063/111] Spelling correction --- eosio_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eosio_build.sh b/eosio_build.sh index b1988d74f0c..d1e77b6e85f 100755 --- a/eosio_build.sh +++ b/eosio_build.sh @@ -238,7 +238,7 @@ . "$FILE" - printf "\\n\\n>>>>>>>> ALL dependencies sucessfully found or installed . Installing EOSIO\\n\\n" + printf "\\n\\n>>>>>>>> ALL dependencies successfully found or installed . Installing EOSIO\\n\\n" printf ">>>>>>>> CMAKE_BUILD_TYPE=%s\\n" "${CMAKE_BUILD_TYPE}" printf ">>>>>>>> ENABLE_COVERAGE_TESTING=%s\\n" "${ENABLE_COVERAGE_TESTING}" printf ">>>>>>>> DOXYGEN=%s\\n\\n" "${DOXYGEN}" From e027d0081973e11b634ddbcff201097d4f1c4491 Mon Sep 17 00:00:00 2001 From: Greg Lee Date: Fri, 14 Dec 2018 00:43:38 -0500 Subject: [PATCH 064/111] Spelling correction #2 --- tests/validate-dirty-db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/validate-dirty-db.py b/tests/validate-dirty-db.py index 68a62701dd6..ac7520bc353 100755 --- a/tests/validate-dirty-db.py +++ b/tests/validate-dirty-db.py @@ -91,7 +91,7 @@ def runNodeosAndGetOutput(myTimeout=3): assert(ret) assert(isinstance(ret, tuple)) if not ret[0]: - errorExit("Failed to startup nodeos sucessfully on try number %d" % (i)) + errorExit("Failed to startup nodeos successfully on try number %d" % (i)) assert(ret[1]) assert(isinstance(ret[1], dict)) # pylint: disable=unsubscriptable-object From 2edbf2fb84fe66e052d3ae56806ea3bbaf49a315 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 14 Dec 2018 11:30:25 -0600 Subject: [PATCH 065/111] Remove unused max-implicit-request config --- Docker/config.ini | 3 --- plugins/net_plugin/net_plugin.cpp | 5 ----- 2 files changed, 8 deletions(-) diff --git a/Docker/config.ini b/Docker/config.ini index d9871858f19..3dd9181f359 100644 --- a/Docker/config.ini +++ b/Docker/config.ini @@ -110,9 +110,6 @@ network-version-match = 0 # number of blocks to retrieve in a chunk from any individual peer during synchronization (eosio::net_plugin) sync-fetch-span = 100 -# maximum sizes of transaction or block messages that are sent without first sending a notice (eosio::net_plugin) -max-implicit-request = 1500 - # Enable block production, even if the chain is stale. (eosio::producer_plugin) enable-stale-production = false diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 81213d9d65d..b4decf5ecdc 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -289,7 +289,6 @@ namespace eosio { constexpr auto def_txn_expire_wait = std::chrono::seconds(3); constexpr auto def_resp_expected_wait = std::chrono::seconds(5); constexpr auto def_sync_fetch_span = 100; - constexpr uint32_t def_max_just_send = 1500; // roughly 1 "mtu" constexpr auto message_header_size = 4; @@ -629,8 +628,6 @@ namespace eosio { class dispatch_manager { public: - uint32_t just_send_it_max = 0; - std::multimap received_blocks; std::multimap received_transactions; @@ -2738,7 +2735,6 @@ namespace eosio { ( "network-version-match", bpo::value()->default_value(false), "True to require exact match of peer network version.") ( "sync-fetch-span", bpo::value()->default_value(def_sync_fetch_span), "number of blocks to retrieve in a chunk from any individual peer during synchronization") - ( "max-implicit-request", bpo::value()->default_value(def_max_just_send), "(deprecated) this option is ignored") ( "use-socket-read-watermark", bpo::value()->default_value(false), "Enable expirimental socket read watermark optimization") ( "peer-log-format", bpo::value()->default_value( "[\"${_name}\" ${_ip}:${_port}]" ), "The string used to format peers when logging messages about them. Variables are escaped with ${}.\n" @@ -2772,7 +2768,6 @@ namespace eosio { my->max_cleanup_time_ms = options.at("max-cleanup-time-msec").as(); my->txn_exp_period = def_txn_expire_wait; my->resp_expected_period = def_resp_expected_wait; - my->dispatcher->just_send_it_max = options.at( "max-implicit-request" ).as(); my->max_client_count = options.at( "max-clients" ).as(); my->max_nodes_per_host = options.at( "p2p-max-nodes-per-host" ).as(); my->num_clients = 0; From 3095d85e3f57c25908587c15b0cdd54c2d3fbc66 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 11 Dec 2018 22:18:48 -0600 Subject: [PATCH 066/111] Switch interface from packed_transaction_ptr to transaction_metadata_ptr --- plugins/bnet_plugin/bnet_plugin.cpp | 4 ++- .../include/eosio/chain/plugin_interface.hpp | 6 ++-- plugins/chain_plugin/chain_plugin.cpp | 10 +++--- .../eosio/chain_plugin/chain_plugin.hpp | 2 +- plugins/net_plugin/net_plugin.cpp | 30 +++++++++-------- plugins/producer_plugin/producer_plugin.cpp | 32 +++++++++---------- 6 files changed, 46 insertions(+), 38 deletions(-) diff --git a/plugins/bnet_plugin/bnet_plugin.cpp b/plugins/bnet_plugin/bnet_plugin.cpp index ce0a096b531..9cf267b6f0f 100644 --- a/plugins/bnet_plugin/bnet_plugin.cpp +++ b/plugins/bnet_plugin/bnet_plugin.cpp @@ -1558,6 +1558,8 @@ namespace eosio { if( mark_transaction_known_by_peer( id ) ) return; - app().get_channel().publish(p); + auto ptr = std::make_shared(p); + + app().get_channel().publish(ptr); } } /// namespace eosio diff --git a/plugins/chain_interface/include/eosio/chain/plugin_interface.hpp b/plugins/chain_interface/include/eosio/chain/plugin_interface.hpp index 7303768cab4..5a0c7bc11fd 100644 --- a/plugins/chain_interface/include/eosio/chain/plugin_interface.hpp +++ b/plugins/chain_interface/include/eosio/chain/plugin_interface.hpp @@ -45,19 +45,19 @@ namespace eosio { namespace chain { namespace plugin_interface { namespace incoming { namespace channels { using block = channel_decl; - using transaction = channel_decl; + using transaction = channel_decl; } namespace methods { // synchronously push a block/trx to a single provider using block_sync = method_decl; - using transaction_async = method_decl), first_provider_policy>; + using transaction_async = method_decl), first_provider_policy>; } } namespace compat { namespace channels { - using transaction_ack = channel_decl>; + using transaction_ack = channel_decl>; } } diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index cfe4ea38268..6eeeb5a5082 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -756,10 +756,10 @@ void chain_plugin::accept_block(const signed_block_ptr& block ) { } void chain_plugin::accept_transaction(const chain::packed_transaction& trx, next_function next) { - my->incoming_transaction_async_method(std::make_shared(trx), false, std::forward(next)); + my->incoming_transaction_async_method(std::make_shared(std::make_shared(trx)), false, std::forward(next)); } -void chain_plugin::accept_transaction(const chain::packed_transaction_ptr& trx, next_function next) { +void chain_plugin::accept_transaction(const chain::transaction_metadata_ptr& trx, next_function next) { my->incoming_transaction_async_method(trx, false, std::forward(next)); } @@ -1544,18 +1544,19 @@ void read_write::push_transaction(const read_write::push_transaction_params& par try { auto pretty_input = std::make_shared(); auto resolver = make_resolver(this, abi_serializer_max_time); + transaction_metadata_ptr ptrx; try { abi_serializer::from_variant(params, *pretty_input, resolver, abi_serializer_max_time); + ptrx = std::make_shared( pretty_input ); } EOS_RETHROW_EXCEPTIONS(chain::packed_transaction_type_exception, "Invalid packed transaction") - app().get_method()(pretty_input, true, [this, next](const fc::static_variant& result) -> void{ + app().get_method()(ptrx, true, [this, next](const fc::static_variant& result) -> void{ if (result.contains()) { next(result.get()); } else { auto trx_trace_ptr = result.get(); try { - chain::transaction_id_type id = trx_trace_ptr->id; fc::variant output; try { output = db.to_variant_with_abi( *trx_trace_ptr, abi_serializer_max_time ); @@ -1563,6 +1564,7 @@ void read_write::push_transaction(const read_write::push_transaction_params& par output = *trx_trace_ptr; } + const chain::transaction_id_type& id = trx_trace_ptr->id; next(read_write::push_transaction_results{id, output}); } CATCH_AND_CALL(next); } 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 0f4af5dcd27..cf20781fd44 100644 --- a/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp +++ b/plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp @@ -664,7 +664,7 @@ class chain_plugin : public plugin { void accept_block( const chain::signed_block_ptr& block ); void accept_transaction(const chain::packed_transaction& trx, chain::plugin_interface::next_function next); - void accept_transaction(const chain::packed_transaction_ptr& trx, chain::plugin_interface::next_function next); + void accept_transaction(const chain::transaction_metadata_ptr& trx, chain::plugin_interface::next_function next); bool block_is_on_preferred_chain(const chain::block_id_type& block_id); diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 34a4fd61e47..7f7cd607fad 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -168,7 +168,7 @@ namespace eosio { void send_all( const std::shared_ptr>& send_buffer, VerifierFunc verify ); void accepted_block(const block_state_ptr&); - void transaction_ack(const std::pair&); + void transaction_ack(const std::pair&); bool is_valid( const handshake_message &msg); @@ -631,7 +631,7 @@ namespace eosio { std::multimap received_blocks; std::multimap received_transactions; - void bcast_transaction(const packed_transaction_ptr& trx); + void bcast_transaction(const transaction_metadata_ptr& trx); void rejected_transaction(const transaction_id_type& msg); void bcast_block(const block_state_ptr& bs); void rejected_block(const block_id_type& id); @@ -1596,9 +1596,9 @@ namespace eosio { received_blocks.erase(range.first, range.second); } - void dispatch_manager::bcast_transaction(const packed_transaction_ptr& trx) { + void dispatch_manager::bcast_transaction(const transaction_metadata_ptr& ptrx) { std::set skips; - transaction_id_type id = trx->id(); + const auto& id = ptrx->id; auto range = received_transactions.equal_range(id); for (auto org = range.first; org != range.second; ++org) { @@ -1611,13 +1611,14 @@ namespace eosio { return; } - time_point_sec trx_expiration = trx->expiration(); + time_point_sec trx_expiration = ptrx->packed_trx->expiration(); + const packed_transaction& trx = *ptrx->packed_trx; // this implementation is to avoid copy of packed_transaction to net_message int which = 8; // matches which of net_message for packed_transaction uint32_t which_size = fc::raw::pack_size( unsigned_int( which )); - uint32_t payload_size = which_size + fc::raw::pack_size( *trx ); + uint32_t payload_size = which_size + fc::raw::pack_size( trx ); char* header = reinterpret_cast(&payload_size); size_t header_size = sizeof(payload_size); @@ -1627,7 +1628,7 @@ namespace eosio { fc::datastream ds( buff->data(), buffer_size); ds.write( header, header_size ); fc::raw::pack( ds, unsigned_int( which )); - fc::raw::pack( ds, *trx ); + fc::raw::pack( ds, trx ); node_transaction_state nts = {id, trx_expiration, 0, buff}; my_impl->local_txns.insert(std::move(nts)); @@ -2358,28 +2359,31 @@ namespace eosio { fc_dlog(logger, "got a txn during sync - dropping"); return; } - transaction_id_type tid = trx->id(); + + auto ptrx = std::make_shared( trx ); + const auto& tid = ptrx->id; + c->cancel_wait(); if(local_txns.get().find(tid) != local_txns.end()) { fc_dlog(logger, "got a duplicate transaction - dropping"); return; } dispatcher->recv_transaction(c, tid); - chain_plug->accept_transaction(trx, [c, this, trx](const static_variant& result) { + chain_plug->accept_transaction(ptrx, [c, this, ptrx](const static_variant& result) { if (result.contains()) { peer_dlog(c, "bad packed_transaction : ${m}", ("m",result.get()->what())); } else { auto trace = result.get(); if (!trace->except) { fc_dlog(logger, "chain accepted transaction"); - this->dispatcher->bcast_transaction(trx); + this->dispatcher->bcast_transaction(ptrx); return; } peer_elog(c, "bad packed_transaction : ${m}", ("m",trace->except->what())); } - dispatcher->rejected_transaction(trx->id()); + dispatcher->rejected_transaction(ptrx->id); }); } @@ -2572,8 +2576,8 @@ namespace eosio { dispatcher->bcast_block(block); } - void net_plugin_impl::transaction_ack(const std::pair& results) { - transaction_id_type id = results.second->id(); + void net_plugin_impl::transaction_ack(const std::pair& results) { + const auto& id = results.second->id; if (results.first) { fc_ilog(logger,"signaled NACK, trx-id = ${id} : ${why}",("id", id)("why", results.first->to_detail_string())); dispatcher->rejected_transaction(id); diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index ad80df46cee..1a1d7d0d515 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -343,9 +343,9 @@ class producer_plugin_impl : public std::enable_shared_from_this>> _pending_incoming_transactions; + std::deque>> _pending_incoming_transactions; - void on_incoming_transaction_async(const packed_transaction_ptr& trx, bool persist_until_expired, next_function next) { + void on_incoming_transaction_async(const transaction_metadata_ptr& trx, bool persist_until_expired, next_function next) { chain::controller& chain = chain_plug->chain(); if (!chain.pending_block_state()) { _pending_incoming_transactions.emplace_back(trx, persist_until_expired, next); @@ -357,34 +357,34 @@ class producer_plugin_impl : public std::enable_shared_from_this& response) { next(response); if (response.contains()) { - _transaction_ack_channel.publish(std::pair(response.get(), trx)); + _transaction_ack_channel.publish(std::pair(response.get(), trx)); if (_pending_block_mode == pending_block_mode::producing) { fc_dlog(_trx_trace_log, "[TRX_TRACE] Block ${block_num} for producer ${prod} is REJECTING tx: ${txid} : ${why} ", ("block_num", chain.head_block_num() + 1) ("prod", chain.pending_block_state()->header.producer) - ("txid", trx->id()) + ("txid", trx->id) ("why",response.get()->what())); } else { fc_dlog(_trx_trace_log, "[TRX_TRACE] Speculative execution is REJECTING tx: ${txid} : ${why} ", - ("txid", trx->id()) + ("txid", trx->id) ("why",response.get()->what())); } } else { - _transaction_ack_channel.publish(std::pair(nullptr, trx)); + _transaction_ack_channel.publish(std::pair(nullptr, trx)); if (_pending_block_mode == pending_block_mode::producing) { fc_dlog(_trx_trace_log, "[TRX_TRACE] Block ${block_num} for producer ${prod} is ACCEPTING tx: ${txid}", ("block_num", chain.head_block_num() + 1) ("prod", chain.pending_block_state()->header.producer) - ("txid", trx->id())); + ("txid", trx->id)); } else { fc_dlog(_trx_trace_log, "[TRX_TRACE] Speculative execution is ACCEPTING tx: ${txid}", - ("txid", trx->id())); + ("txid", trx->id)); } } }; - auto id = trx->id(); - if( fc::time_point(trx->expiration()) < block_time ) { + const auto& id = trx->id; + if( fc::time_point(trx->packed_trx->expiration()) < block_time ) { send_response(std::static_pointer_cast(std::make_shared(FC_LOG_MESSAGE(error, "expired transaction ${id}", ("id", id)) ))); return; } @@ -402,7 +402,7 @@ class producer_plugin_impl : public std::enable_shared_from_this(trx), deadline); + auto trace = chain.push_transaction(trx, deadline); if (trace->except) { if (failure_is_subjective(*trace->except, deadline_is_subjective)) { _pending_incoming_transactions.emplace_back(trx, persist_until_expired, next); @@ -410,10 +410,10 @@ class producer_plugin_impl : public std::enable_shared_from_thisheader.producer) - ("txid", trx->id())); + ("txid", trx->id)); } else { fc_dlog(_trx_trace_log, "[TRX_TRACE] Speculative execution COULD NOT FIT tx: ${txid} RETRYING", - ("txid", trx->id())); + ("txid", trx->id)); } } else { auto e_ptr = trace->except->dynamic_copy_exception(); @@ -423,7 +423,7 @@ class producer_plugin_impl : public std::enable_shared_from_thisid(), trx->expiration()}); + _persistent_transactions.insert(transaction_id_with_expiry{trx->id, trx->packed_trx->expiration()}); } send_response(trace); } @@ -682,7 +682,7 @@ void producer_plugin::plugin_initialize(const boost::program_options::variables_ } FC_LOG_AND_DROP(); }); - my->_incoming_transaction_subscription = app().get_channel().subscribe([this](const packed_transaction_ptr& trx){ + my->_incoming_transaction_subscription = app().get_channel().subscribe([this](const transaction_metadata_ptr& trx){ try { my->on_incoming_transaction_async(trx, false, [](const auto&){}); } FC_LOG_AND_DROP(); @@ -692,7 +692,7 @@ void producer_plugin::plugin_initialize(const boost::program_options::variables_ my->on_incoming_block(block); }); - my->_incoming_transaction_async_provider = app().get_method().register_provider([this](const packed_transaction_ptr& trx, bool persist_until_expired, next_function next) -> void { + my->_incoming_transaction_async_provider = app().get_method().register_provider([this](const transaction_metadata_ptr& trx, bool persist_until_expired, next_function next) -> void { return my->on_incoming_transaction_async(trx, persist_until_expired, next ); }); From 49a9c55ef2a1e5c201f523ca66f1e8ce8ebe4f4e Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 12 Dec 2018 07:38:55 -0600 Subject: [PATCH 067/111] Thread pool does not need to be optional --- libraries/chain/controller.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index c7dda941e01..f18b92524f6 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -135,7 +135,7 @@ struct controller_impl { optional subjective_cpu_leeway; bool trusted_producer_light_validation = false; uint32_t snapshot_head_block = 0; - optional thread_pool; + boost::asio::thread_pool thread_pool; typedef pair handler_key; map< account_name, map > apply_handlers; @@ -151,7 +151,7 @@ struct controller_impl { template auto async_thread_pool( F&& f ) { auto task = std::make_shared>( std::forward( f ) ); - boost::asio::post( *thread_pool, [task]() { (*task)(); } ); + boost::asio::post( thread_pool, [task]() { (*task)(); } ); return task->get_future(); } @@ -194,7 +194,8 @@ struct controller_impl { authorization( s, db ), conf( cfg ), chain_id( cfg.genesis.compute_chain_id() ), - read_mode( cfg.read_mode ) + read_mode( cfg.read_mode ), + thread_pool( cfg.thread_pool_size ) { #define SET_APP_HANDLER( receiver, contract, action) \ @@ -349,8 +350,6 @@ struct controller_impl { void init(std::function shutdown, const snapshot_reader_ptr& snapshot) { - thread_pool.emplace( conf.thread_pool_size ); - bool report_integrity_hash = !!snapshot; if (snapshot) { EOS_ASSERT( !head, fork_database_exception, "" ); @@ -418,10 +417,8 @@ struct controller_impl { ~controller_impl() { pending.reset(); - if( thread_pool ) { - thread_pool->join(); - thread_pool->stop(); - } + thread_pool.join(); + thread_pool.stop(); db.flush(); reversible_blocks.flush(); From 4a4a80a12affeebab1f66712d53c1286fd7b9b5a Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 12 Dec 2018 11:55:39 -0600 Subject: [PATCH 068/111] Add transaction_metadata create_signing_keys_future method --- libraries/chain/CMakeLists.txt | 2 +- libraries/chain/controller.cpp | 26 ++++---------- .../chain/include/eosio/chain/controller.hpp | 8 +++-- .../include/eosio/chain/thread_utils.hpp | 24 +++++++++++++ .../eosio/chain/transaction_metadata.hpp | 25 ++++++-------- libraries/chain/transaction_metadata.cpp | 34 +++++++++++++++++++ 6 files changed, 82 insertions(+), 37 deletions(-) create mode 100644 libraries/chain/include/eosio/chain/thread_utils.hpp create mode 100644 libraries/chain/transaction_metadata.cpp diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index ee8fe1ebab2..2c430fecea0 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -46,7 +46,7 @@ add_library( eosio_chain # contracts/chain_initializer.cpp -# transaction_metadata.cpp + transaction_metadata.cpp ${HEADERS} ) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index f18b92524f6..1f777906722 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -17,15 +17,13 @@ #include #include #include +#include #include #include #include #include -#include -#include - namespace eosio { namespace chain { @@ -147,14 +145,6 @@ struct controller_impl { */ map unapplied_transactions; - // async on thread_pool and return future - template - auto async_thread_pool( F&& f ) { - auto task = std::make_shared>( std::forward( f ) ); - boost::asio::post( thread_pool, [task]() { (*task)(); } ); - return task->get_future(); - } - void pop_block() { auto prev = fork_db.get_block( head->header.previous ); EOS_ASSERT( prev, block_validate_exception, "attempt to pop beyond last irreversible block" ); @@ -1202,13 +1192,7 @@ struct controller_impl { auto& pt = receipt.trx.get(); auto mtrx = std::make_shared( std::make_shared( pt ) ); if( !self.skip_auth_check() ) { - std::weak_ptr mtrx_wp = mtrx; - mtrx->signing_keys_future = async_thread_pool( [chain_id = this->chain_id, mtrx_wp]() { - auto mtrx = mtrx_wp.lock(); - return mtrx ? - std::make_pair( chain_id, mtrx->trx.get_signature_keys( chain_id ) ) : - std::make_pair( chain_id, decltype( mtrx->trx.get_signature_keys( chain_id ) ){} ); - } ); + transaction_metadata::create_signing_keys_future( mtrx, thread_pool, chain_id ); } packed_transactions.emplace_back( std::move( mtrx ) ); } @@ -1286,7 +1270,7 @@ struct controller_impl { auto prev = fork_db.get_block( b->previous ); EOS_ASSERT( prev, unlinkable_block_exception, "unlinkable block ${id}", ("id", id)("previous", b->previous) ); - return async_thread_pool( [b, prev]() { + return async_thread_pool( thread_pool, [b, prev]() { const bool skip_validate_signee = false; return std::make_shared( *prev, move( b ), skip_validate_signee ); } ); @@ -1780,6 +1764,10 @@ void controller::abort_block() { my->abort_block(); } +boost::asio::thread_pool& controller::get_thread_pool() { + return my->thread_pool; +} + std::future controller::create_block_state_future( const signed_block_ptr& b ) { return my->create_block_state_future( b ); } diff --git a/libraries/chain/include/eosio/chain/controller.hpp b/libraries/chain/include/eosio/chain/controller.hpp index 7e963cd1028..bb07d223a8e 100644 --- a/libraries/chain/include/eosio/chain/controller.hpp +++ b/libraries/chain/include/eosio/chain/controller.hpp @@ -11,7 +11,9 @@ namespace chainbase { class database; } - +namespace boost { namespace asio { + class thread_pool; +}} namespace eosio { namespace chain { @@ -87,7 +89,7 @@ namespace eosio { namespace chain { incomplete = 3, ///< this is an incomplete block (either being produced by a producer or speculatively produced by a node) }; - controller( const config& cfg ); + explicit controller( const config& cfg ); ~controller(); void add_indices(); @@ -144,6 +146,8 @@ namespace eosio { namespace chain { std::future create_block_state_future( const signed_block_ptr& b ); void push_block( std::future& block_state_future ); + boost::asio::thread_pool& get_thread_pool(); + const chainbase::database& db()const; const fork_database& fork_db()const; diff --git a/libraries/chain/include/eosio/chain/thread_utils.hpp b/libraries/chain/include/eosio/chain/thread_utils.hpp new file mode 100644 index 00000000000..31b32cbd91f --- /dev/null +++ b/libraries/chain/include/eosio/chain/thread_utils.hpp @@ -0,0 +1,24 @@ +/** + * @file + * @copyright defined in eos/LICENSE.txt + */ +#pragma once + +#include +#include +#include +#include + +namespace eosio { namespace chain { + + // async on thread_pool and return future + template + auto async_thread_pool( boost::asio::thread_pool& thread_pool, F&& f ) { + auto task = std::make_shared>( std::forward( f ) ); + boost::asio::post( thread_pool, [task]() { (*task)(); } ); + return task->get_future(); + } + +} } // eosio::chain + + diff --git a/libraries/chain/include/eosio/chain/transaction_metadata.hpp b/libraries/chain/include/eosio/chain/transaction_metadata.hpp index ef50c0c6400..5f2be488dc8 100644 --- a/libraries/chain/include/eosio/chain/transaction_metadata.hpp +++ b/libraries/chain/include/eosio/chain/transaction_metadata.hpp @@ -7,8 +7,14 @@ #include #include +namespace boost { namespace asio { + class thread_pool; +}} + namespace eosio { namespace chain { +class transaction_metadata; +using transaction_metadata_ptr = std::shared_ptr; /** * This data structure should store context-free cached data about a transaction such as * packed/unpacked/compressed and recovered keys @@ -43,23 +49,12 @@ class transaction_metadata { signed_id = digest_type::hash(*packed_trx); } - const flat_set& recover_keys( const chain_id_type& chain_id ) { - // Unlikely for more than one chain_id to be used in one nodeos instance - if( !signing_keys || signing_keys->first != chain_id ) { - if( signing_keys_future.valid() ) { - signing_keys = signing_keys_future.get(); - if( signing_keys->first == chain_id ) { - return signing_keys->second; - } - } - signing_keys = std::make_pair( chain_id, trx.get_signature_keys( chain_id )); - } - return signing_keys->second; - } + const flat_set& recover_keys( const chain_id_type& chain_id ); + + static void create_signing_keys_future( transaction_metadata_ptr& mtrx, + boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id ); uint32_t total_actions()const { return trx.context_free_actions.size() + trx.actions.size(); } }; -using transaction_metadata_ptr = std::shared_ptr; - } } // eosio::chain diff --git a/libraries/chain/transaction_metadata.cpp b/libraries/chain/transaction_metadata.cpp new file mode 100644 index 00000000000..9afc1a01fd0 --- /dev/null +++ b/libraries/chain/transaction_metadata.cpp @@ -0,0 +1,34 @@ +#include +#include +#include + +namespace eosio { namespace chain { + + +const flat_set& transaction_metadata::recover_keys( const chain_id_type& chain_id ) { + // Unlikely for more than one chain_id to be used in one nodeos instance + if( !signing_keys || signing_keys->first != chain_id ) { + if( signing_keys_future.valid() ) { + signing_keys = signing_keys_future.get(); + if( signing_keys->first == chain_id ) { + return signing_keys->second; + } + } + signing_keys = std::make_pair( chain_id, trx.get_signature_keys( chain_id )); + } + return signing_keys->second; +} + +void transaction_metadata::create_signing_keys_future( transaction_metadata_ptr& mtrx, + boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id ) { + std::weak_ptr mtrx_wp = mtrx; + mtrx->signing_keys_future = async_thread_pool( thread_pool, [chain_id, mtrx_wp]() { + auto mtrx = mtrx_wp.lock(); + return mtrx ? + std::make_pair( chain_id, mtrx->trx.get_signature_keys( chain_id ) ) : + std::make_pair( chain_id, decltype( mtrx->trx.get_signature_keys( chain_id ) ){} ); + } ); +} + + +} } // eosio::chain From f71d490b47630740f19be9dc769ae04a296b59e3 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 12 Dec 2018 15:07:18 -0600 Subject: [PATCH 069/111] Start transaction signature earily in thread pool --- .../include/eosio/chain/transaction_metadata.hpp | 2 +- libraries/chain/transaction.cpp | 5 +++-- libraries/chain/transaction_metadata.cpp | 8 +++++++- plugins/producer_plugin/producer_plugin.cpp | 16 ++++++++++++++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/libraries/chain/include/eosio/chain/transaction_metadata.hpp b/libraries/chain/include/eosio/chain/transaction_metadata.hpp index 5f2be488dc8..60f89e2c4fe 100644 --- a/libraries/chain/include/eosio/chain/transaction_metadata.hpp +++ b/libraries/chain/include/eosio/chain/transaction_metadata.hpp @@ -51,7 +51,7 @@ class transaction_metadata { const flat_set& recover_keys( const chain_id_type& chain_id ); - static void create_signing_keys_future( transaction_metadata_ptr& mtrx, + static void create_signing_keys_future( const transaction_metadata_ptr& mtrx, boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id ); uint32_t total_actions()const { return trx.context_free_actions.size() + trx.actions.size(); } diff --git a/libraries/chain/transaction.cpp b/libraries/chain/transaction.cpp index 6e6639bac52..d2528dc21a3 100644 --- a/libraries/chain/transaction.cpp +++ b/libraries/chain/transaction.cpp @@ -95,9 +95,10 @@ flat_set transaction::get_signature_keys( const vector::type::iterator it = recovery_cache.get().find( sig ); - if( it == recovery_cache.get().end() || it->trx_id != id()) { + const auto& tid = id(); + if( it == recovery_cache.get().end() || it->trx_id != tid) { recov = public_key_type( sig, digest ); - recovery_cache.emplace_back(cached_pub_key{id(), recov, sig} ); //could fail on dup signatures; not a problem + recovery_cache.emplace_back(cached_pub_key{tid, recov, sig} ); //could fail on dup signatures; not a problem } else { recov = it->pub_key; } diff --git a/libraries/chain/transaction_metadata.cpp b/libraries/chain/transaction_metadata.cpp index 9afc1a01fd0..068f711f6b0 100644 --- a/libraries/chain/transaction_metadata.cpp +++ b/libraries/chain/transaction_metadata.cpp @@ -19,8 +19,14 @@ const flat_set& transaction_metadata::recover_keys( const chain return signing_keys->second; } -void transaction_metadata::create_signing_keys_future( transaction_metadata_ptr& mtrx, +void transaction_metadata::create_signing_keys_future( const transaction_metadata_ptr& mtrx, boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id ) { + if( mtrx->signing_keys && mtrx->signing_keys->first == chain_id ) + return; + + if( mtrx->signing_keys.valid() ) // already created + return; + std::weak_ptr mtrx_wp = mtrx; mtrx->signing_keys_future = async_thread_pool( thread_pool, [chain_id, mtrx_wp]() { auto mtrx = mtrx_wp.lock(); diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 1a1d7d0d515..d0bda3edf0a 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -346,6 +346,18 @@ class producer_plugin_impl : public std::enable_shared_from_this>> _pending_incoming_transactions; void on_incoming_transaction_async(const transaction_metadata_ptr& trx, bool persist_until_expired, next_function next) { + chain::controller& chain = chain_plug->chain(); + transaction_metadata::create_signing_keys_future( trx, chain.get_thread_pool(), chain.get_chain_id() ); + boost::asio::post( chain.get_thread_pool(), [self = this, trx, persist_until_expired, next]() { + if( trx->signing_keys_future.valid() ) + trx->signing_keys_future.wait(); + app().get_io_service().post( [self, trx, persist_until_expired, next]() { + self->process_incoming_transaction_async( trx, persist_until_expired, next ); + }); + }); + } + + void process_incoming_transaction_async(const transaction_metadata_ptr& trx, bool persist_until_expired, next_function next) { chain::controller& chain = chain_plug->chain(); if (!chain.pending_block_state()) { _pending_incoming_transactions.emplace_back(trx, persist_until_expired, next); @@ -1245,7 +1257,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool _pending_incoming_transactions.pop_front(); --orig_pending_txn_size; _incoming_trx_weight -= 1.0; - on_incoming_transaction_async(std::get<0>(e), std::get<1>(e), std::get<2>(e)); + process_incoming_transaction_async(std::get<0>(e), std::get<1>(e), std::get<2>(e)); } if (block_time <= fc::time_point::now()) { @@ -1308,7 +1320,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool auto e = _pending_incoming_transactions.front(); _pending_incoming_transactions.pop_front(); --orig_pending_txn_size; - on_incoming_transaction_async(std::get<0>(e), std::get<1>(e), std::get<2>(e)); + process_incoming_transaction_async(std::get<0>(e), std::get<1>(e), std::get<2>(e)); if (block_time <= fc::time_point::now()) return start_block_result::exhausted; } } From 96fb1e5f4691013ee6fc310a1e00a0e2888778b6 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Thu, 13 Dec 2018 16:41:54 -0600 Subject: [PATCH 070/111] Refactor packed_transaction for better encapsulation --- .../include/eosio/chain/abi_serializer.hpp | 39 ++++++++--------- .../chain/include/eosio/chain/transaction.hpp | 40 ++++++++++++------ libraries/chain/transaction.cpp | 42 ++++++++++++++----- unittests/misc_tests.cpp | 6 +-- 4 files changed, 81 insertions(+), 46 deletions(-) diff --git a/libraries/chain/include/eosio/chain/abi_serializer.hpp b/libraries/chain/include/eosio/chain/abi_serializer.hpp index 221424e041e..8577c1de972 100644 --- a/libraries/chain/include/eosio/chain/abi_serializer.hpp +++ b/libraries/chain/include/eosio/chain/abi_serializer.hpp @@ -418,11 +418,11 @@ namespace impl { mutable_variant_object mvo; auto trx = ptrx.get_transaction(); mvo("id", trx.id()); - mvo("signatures", ptrx.signatures); - mvo("compression", ptrx.compression); - mvo("packed_context_free_data", ptrx.packed_context_free_data); + mvo("signatures", ptrx.get_signatures()); + mvo("compression", ptrx.get_compression()); + mvo("packed_context_free_data", ptrx.get_packed_context_free_data()); mvo("context_free_data", ptrx.get_context_free_data()); - mvo("packed_trx", ptrx.packed_trx); + mvo("packed_trx", ptrx.get_packed_transaction()); add(mvo, "transaction", trx, resolver, ctx); out(name, std::move(mvo)); @@ -577,32 +577,33 @@ namespace impl { const variant_object& vo = v.get_object(); EOS_ASSERT(vo.contains("signatures"), packed_transaction_type_exception, "Missing signatures"); EOS_ASSERT(vo.contains("compression"), packed_transaction_type_exception, "Missing compression"); - from_variant(vo["signatures"], ptrx.signatures); - from_variant(vo["compression"], ptrx.compression); + std::vector signatures; + packed_transaction::compression_type compression; + from_variant(vo["signatures"], signatures); + from_variant(vo["compression"], compression); - // TODO: Make this nicer eventually. But for now, if it works... good enough. + bytes packed_cfd; if( vo.contains("packed_trx") && vo["packed_trx"].is_string() && !vo["packed_trx"].as_string().empty() ) { - from_variant(vo["packed_trx"], ptrx.packed_trx); - auto trx = ptrx.get_transaction(); // Validates transaction data provided. + bytes packed_trx; + std::vector cfd; + from_variant(vo["packed_trx"], packed_trx); if( vo.contains("packed_context_free_data") && vo["packed_context_free_data"].is_string() && !vo["packed_context_free_data"].as_string().empty() ) { - from_variant(vo["packed_context_free_data"], ptrx.packed_context_free_data ); + from_variant(vo["packed_context_free_data"], packed_cfd ); } else if( vo.contains("context_free_data") ) { - vector context_free_data; - from_variant(vo["context_free_data"], context_free_data); - ptrx.set_transaction(trx, context_free_data, ptrx.compression); + from_variant(vo["context_free_data"], cfd); } + ptrx = packed_transaction( std::move(packed_trx), std::move(signatures), std::move(packed_cfd), std::move(cfd), compression ); } else { EOS_ASSERT(vo.contains("transaction"), packed_transaction_type_exception, "Missing transaction"); - transaction trx; - vector context_free_data; + signed_transaction trx; + trx.signatures = std::move(signatures); extract(vo["transaction"], trx, resolver, ctx); if( vo.contains("packed_context_free_data") && vo["packed_context_free_data"].is_string() && !vo["packed_context_free_data"].as_string().empty() ) { - from_variant(vo["packed_context_free_data"], ptrx.packed_context_free_data ); - context_free_data = ptrx.get_context_free_data(); + from_variant(vo["packed_context_free_data"], packed_cfd ); } else if( vo.contains("context_free_data") ) { - from_variant(vo["context_free_data"], context_free_data); + from_variant(vo["context_free_data"], trx.context_free_data ); } - ptrx.set_transaction(trx, context_free_data, ptrx.compression); + ptrx = packed_transaction( std::move(trx), std::move(packed_cfd), compression ); } } }; diff --git a/libraries/chain/include/eosio/chain/transaction.hpp b/libraries/chain/include/eosio/chain/transaction.hpp index b3fb7c5d7e0..c848490800a 100644 --- a/libraries/chain/include/eosio/chain/transaction.hpp +++ b/libraries/chain/include/eosio/chain/transaction.hpp @@ -108,27 +108,29 @@ namespace eosio { namespace chain { packed_transaction& operator=(packed_transaction&&) = default; explicit packed_transaction(const signed_transaction& t, compression_type _compression = none) - :signatures(t.signatures) + :signatures(t.signatures), compression(_compression) { - set_transaction(t, t.context_free_data, _compression); + set_transaction(t); + set_context_free_data(t.context_free_data); } explicit packed_transaction(signed_transaction&& t, compression_type _compression = none) - :signatures(std::move(t.signatures)) + :signatures(std::move(t.signatures)), compression(_compression) { - set_transaction(t, t.context_free_data, _compression); + set_transaction(t); + set_context_free_data(t.context_free_data); } + // used by abi_serializer + explicit packed_transaction( bytes&& packed_txn, vector&& sigs, + bytes&& packed_cfd, vector&& cfd, compression_type _compression ); + explicit packed_transaction( signed_transaction&& t, bytes&& packed_cfd, compression_type _compression ); + uint32_t get_unprunable_size()const; uint32_t get_prunable_size()const; digest_type packed_digest()const; - vector signatures; - fc::enum_type compression; - bytes packed_context_free_data; - bytes packed_trx; - time_point_sec expiration()const; transaction_id_type id()const; transaction_id_type get_uncached_id()const; // thread safe @@ -136,12 +138,26 @@ namespace eosio { namespace chain { vector get_context_free_data()const; transaction get_transaction()const; signed_transaction get_signed_transaction()const; - void set_transaction(const transaction& t, compression_type _compression = none); - void set_transaction(const transaction& t, const vector& cfd, compression_type _compression = none); + + const vector& get_signatures()const { return signatures; } + const fc::enum_type& get_compression()const { return compression; } + const bytes& get_packed_context_free_data()const { return packed_context_free_data; } + const bytes& get_packed_transaction()const { return packed_trx; } private: - mutable optional unpacked_trx; // <-- intermediate buffer used to retrieve values void local_unpack()const; + void set_transaction(const transaction& t); + void set_context_free_data(const vector& cfd); + + friend struct fc::reflector; + private: + vector signatures; + fc::enum_type compression; + bytes packed_context_free_data; + bytes packed_trx; + + private: + mutable optional unpacked_trx; // <-- intermediate buffer used to retrieve values }; using packed_transaction_ptr = std::shared_ptr; diff --git a/libraries/chain/transaction.cpp b/libraries/chain/transaction.cpp index d2528dc21a3..910651031f8 100644 --- a/libraries/chain/transaction.cpp +++ b/libraries/chain/transaction.cpp @@ -344,10 +344,35 @@ signed_transaction packed_transaction::get_signed_transaction() const } -void packed_transaction::set_transaction(const transaction& t, packed_transaction::compression_type _compression) +packed_transaction::packed_transaction( bytes&& packed_txn, vector&& sigs, + bytes&& packed_cfd, vector&& cfd, compression_type _compression ) +:signatures(std::move(sigs)) +,compression(_compression) +,packed_context_free_data(std::move(packed_cfd)) +,packed_trx(std::move(packed_txn)) +{ + EOS_ASSERT(packed_cfd.empty() || cfd.empty(), tx_decompression_error, "Invalid packed_transaction"); + if( !cfd.empty() ) { + set_context_free_data(cfd); + } +} + +packed_transaction::packed_transaction( signed_transaction&& t, bytes&& packed_cfd, compression_type _compression ) +:signatures(std::move(t.signatures)) +,compression(_compression) +,packed_context_free_data(std::move(packed_cfd)) +{ + set_transaction(t); + // allow passed in packed_cfd to overwrite signed_transaction.context_free_data if provided + if( packed_context_free_data.empty() ) { + set_context_free_data(t.context_free_data); + } +} + +void packed_transaction::set_transaction(const transaction& t) { try { - switch(_compression) { + switch(compression) { case none: packed_trx = pack_transaction(t); break; @@ -357,28 +382,23 @@ void packed_transaction::set_transaction(const transaction& t, packed_transactio default: EOS_THROW(unknown_transaction_compression, "Unknown transaction compression algorithm"); } - } FC_CAPTURE_AND_RETHROW((_compression)(t)) - packed_context_free_data.clear(); - compression = _compression; + } FC_CAPTURE_AND_RETHROW((compression)(t)) } -void packed_transaction::set_transaction(const transaction& t, const vector& cfd, packed_transaction::compression_type _compression) +void packed_transaction::set_context_free_data(const vector& cfd) { try { - switch(_compression) { + switch(compression) { case none: - packed_trx = pack_transaction(t); packed_context_free_data = pack_context_free_data(cfd); break; case zlib: - packed_trx = zlib_compress_transaction(t); packed_context_free_data = zlib_compress_context_free_data(cfd); break; default: EOS_THROW(unknown_transaction_compression, "Unknown transaction compression algorithm"); } - } FC_CAPTURE_AND_RETHROW((_compression)(t)) - compression = _compression; + } FC_CAPTURE_AND_RETHROW((compression)) } diff --git a/unittests/misc_tests.cpp b/unittests/misc_tests.cpp index 1a93b66e97a..14918b6a1f5 100644 --- a/unittests/misc_tests.cpp +++ b/unittests/misc_tests.cpp @@ -590,11 +590,9 @@ BOOST_AUTO_TEST_CASE(transaction_test) { try { BOOST_CHECK_EQUAL(1, trx.signatures.size()); trx.validate(); - packed_transaction pkt; - pkt.set_transaction(trx, packed_transaction::none); + packed_transaction pkt(trx, packed_transaction::none); - packed_transaction pkt2; - pkt2.set_transaction(trx, packed_transaction::zlib); + packed_transaction pkt2(trx, packed_transaction::zlib); BOOST_CHECK_EQUAL(true, trx.expiration == pkt.expiration()); BOOST_CHECK_EQUAL(true, trx.expiration == pkt2.expiration()); From 20ffa70f649b0e2abb2f0b9afec6b076946fa3df Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 12 Dec 2018 11:55:39 -0600 Subject: [PATCH 071/111] Add transaction_metadata create_signing_keys_future method --- libraries/chain/include/eosio/chain/transaction_metadata.hpp | 2 +- libraries/chain/transaction_metadata.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/chain/include/eosio/chain/transaction_metadata.hpp b/libraries/chain/include/eosio/chain/transaction_metadata.hpp index 60f89e2c4fe..5f2be488dc8 100644 --- a/libraries/chain/include/eosio/chain/transaction_metadata.hpp +++ b/libraries/chain/include/eosio/chain/transaction_metadata.hpp @@ -51,7 +51,7 @@ class transaction_metadata { const flat_set& recover_keys( const chain_id_type& chain_id ); - static void create_signing_keys_future( const transaction_metadata_ptr& mtrx, + static void create_signing_keys_future( transaction_metadata_ptr& mtrx, boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id ); uint32_t total_actions()const { return trx.context_free_actions.size() + trx.actions.size(); } diff --git a/libraries/chain/transaction_metadata.cpp b/libraries/chain/transaction_metadata.cpp index 068f711f6b0..c16702c837b 100644 --- a/libraries/chain/transaction_metadata.cpp +++ b/libraries/chain/transaction_metadata.cpp @@ -19,7 +19,7 @@ const flat_set& transaction_metadata::recover_keys( const chain return signing_keys->second; } -void transaction_metadata::create_signing_keys_future( const transaction_metadata_ptr& mtrx, +void transaction_metadata::create_signing_keys_future( transaction_metadata_ptr& mtrx, boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id ) { if( mtrx->signing_keys && mtrx->signing_keys->first == chain_id ) return; From f64da40d800ca37815017b89892efdd75d503acb Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Wed, 12 Dec 2018 15:07:18 -0600 Subject: [PATCH 072/111] Start transaction signature earily in thread pool --- libraries/chain/include/eosio/chain/transaction_metadata.hpp | 2 +- libraries/chain/transaction_metadata.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/chain/include/eosio/chain/transaction_metadata.hpp b/libraries/chain/include/eosio/chain/transaction_metadata.hpp index 5f2be488dc8..60f89e2c4fe 100644 --- a/libraries/chain/include/eosio/chain/transaction_metadata.hpp +++ b/libraries/chain/include/eosio/chain/transaction_metadata.hpp @@ -51,7 +51,7 @@ class transaction_metadata { const flat_set& recover_keys( const chain_id_type& chain_id ); - static void create_signing_keys_future( transaction_metadata_ptr& mtrx, + static void create_signing_keys_future( const transaction_metadata_ptr& mtrx, boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id ); uint32_t total_actions()const { return trx.context_free_actions.size() + trx.actions.size(); } diff --git a/libraries/chain/transaction_metadata.cpp b/libraries/chain/transaction_metadata.cpp index c16702c837b..068f711f6b0 100644 --- a/libraries/chain/transaction_metadata.cpp +++ b/libraries/chain/transaction_metadata.cpp @@ -19,7 +19,7 @@ const flat_set& transaction_metadata::recover_keys( const chain return signing_keys->second; } -void transaction_metadata::create_signing_keys_future( transaction_metadata_ptr& mtrx, +void transaction_metadata::create_signing_keys_future( const transaction_metadata_ptr& mtrx, boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id ) { if( mtrx->signing_keys && mtrx->signing_keys->first == chain_id ) return; From 22ab63cc1d06b73ce7297a714fbb482962a5ef99 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 14 Dec 2018 15:14:28 -0600 Subject: [PATCH 073/111] Update txn_test_gen_plugin to overlap transaction submit @taokayan --- .../txn_test_gen_plugin.cpp | 50 +++++++++++++------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp index 6b4753e9919..fd11b129155 100644 --- a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp +++ b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp @@ -87,19 +87,38 @@ using namespace eosio::chain; api_handle->call_name(vs.at(0).as(), vs.at(1).as(), result_handler); struct txn_test_gen_plugin_impl { - static void push_next_transaction(const std::shared_ptr>& trxs, size_t index, const std::function& next ) { + + uint64_t _total_us = 0; + uint64_t _txcount = 0; + + int _remain = 0; + + void push_next_transaction(const std::shared_ptr>& trxs, size_t index, const std::function& next ) { chain_plugin& cp = app().get_plugin(); - cp.accept_transaction( packed_transaction(trxs->at(index)), [=](const fc::static_variant& result){ - if (result.contains()) { - next(result.get()); - } else { - if (index + 1 < trxs->size()) { - push_next_transaction(trxs, index + 1, next); + + const int overlap = 20; + int end = std::min(index + overlap, trxs->size()); + _remain = end - index; + for (int i = index; i < end; ++i) { + cp.accept_transaction( packed_transaction(trxs->at(i)), [=](const fc::static_variant& result){ + if (result.contains()) { + next(result.get()); } else { - next(nullptr); + if (result.contains() && result.get()->receipt) { + _total_us += result.get()->receipt->cpu_usage_us; + ++_txcount; + } + --_remain; + if (_remain == 0 ) { + if (end < trxs->size()) { + push_next_transaction(trxs, index + overlap, next); + } else { + next(nullptr); + } + } } - } - }); + }); + } } void push_transactions( std::vector&& trxs, const std::function& next ) { @@ -295,13 +314,11 @@ struct txn_test_gen_plugin_impl { try { controller& cc = app().get_plugin().chain(); auto chainid = app().get_plugin().get_chain_id(); - auto abi_serializer_max_time = app().get_plugin().get_abi_serializer_max_time(); - fc::crypto::private_key a_priv_key = fc::crypto::private_key::regenerate(fc::sha256(std::string(64, 'a'))); - fc::crypto::private_key b_priv_key = fc::crypto::private_key::regenerate(fc::sha256(std::string(64, 'b'))); + static fc::crypto::private_key a_priv_key = fc::crypto::private_key::regenerate(fc::sha256(std::string(64, 'a'))); + static fc::crypto::private_key b_priv_key = fc::crypto::private_key::regenerate(fc::sha256(std::string(64, 'b'))); static uint64_t nonce = static_cast(fc::time_point::now().sec_since_epoch()) << 32; - abi_serializer eosio_serializer(cc.db().find(config::system_account_name)->get_abi(), abi_serializer_max_time); uint32_t reference_block_num = cc.last_irreversible_block_num(); if (txn_reference_block_lag >= 0) { @@ -351,6 +368,11 @@ struct txn_test_gen_plugin_impl { timer.cancel(); running = false; ilog("Stopping transaction generation test"); + + if (_txcount) { + ilog("${d} transactions executed, ${t}us / transaction", ("d", _txcount)("t", _total_us / (double)_txcount)); + _txcount = _total_us = 0; + } } boost::asio::high_resolution_timer timer{app().get_io_service()}; From 64537c562671434f120c1091c1921d5751df55aa Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 17 Dec 2018 12:13:17 -0500 Subject: [PATCH 074/111] Remove redundant signing_keys check --- libraries/chain/transaction_metadata.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/libraries/chain/transaction_metadata.cpp b/libraries/chain/transaction_metadata.cpp index 068f711f6b0..95edf0f3f68 100644 --- a/libraries/chain/transaction_metadata.cpp +++ b/libraries/chain/transaction_metadata.cpp @@ -21,9 +21,6 @@ const flat_set& transaction_metadata::recover_keys( const chain void transaction_metadata::create_signing_keys_future( const transaction_metadata_ptr& mtrx, boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id ) { - if( mtrx->signing_keys && mtrx->signing_keys->first == chain_id ) - return; - if( mtrx->signing_keys.valid() ) // already created return; From ca8e5bc30fcfcedfd9cc65e652f2a5a705f7cf37 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 17 Dec 2018 16:23:25 -0500 Subject: [PATCH 075/111] Add deadline to key recovery --- libraries/chain/controller.cpp | 2 +- .../chain/include/eosio/chain/transaction.hpp | 7 ++-- .../eosio/chain/transaction_metadata.hpp | 4 +-- libraries/chain/transaction.cpp | 33 +++++++++---------- libraries/chain/transaction_metadata.cpp | 10 +++--- plugins/mongo_db_plugin/mongo_db_plugin.cpp | 2 +- plugins/producer_plugin/producer_plugin.cpp | 4 ++- tests/wallet_tests.cpp | 2 +- unittests/api_tests.cpp | 8 ++--- 9 files changed, 37 insertions(+), 35 deletions(-) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 1f777906722..461f481a34f 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -1192,7 +1192,7 @@ struct controller_impl { auto& pt = receipt.trx.get(); auto mtrx = std::make_shared( std::make_shared( pt ) ); if( !self.skip_auth_check() ) { - transaction_metadata::create_signing_keys_future( mtrx, thread_pool, chain_id ); + transaction_metadata::create_signing_keys_future( mtrx, thread_pool, chain_id, fc::time_point::maximum() ); } packed_transactions.emplace_back( std::move( mtrx ) ); } diff --git a/libraries/chain/include/eosio/chain/transaction.hpp b/libraries/chain/include/eosio/chain/transaction.hpp index c848490800a..65f3c35ff63 100644 --- a/libraries/chain/include/eosio/chain/transaction.hpp +++ b/libraries/chain/include/eosio/chain/transaction.hpp @@ -60,9 +60,9 @@ namespace eosio { namespace chain { digest_type sig_digest( const chain_id_type& chain_id, const vector& cfd = vector() )const; flat_set get_signature_keys( const vector& signatures, const chain_id_type& chain_id, + fc::time_point deadline, const vector& cfd = vector(), - bool allow_duplicate_keys = false, - bool use_cache = true )const; + bool allow_duplicate_keys = false)const; uint32_t total_actions()const { return context_free_actions.size() + actions.size(); } account_name first_authorizor()const { @@ -92,7 +92,8 @@ namespace eosio { namespace chain { const signature_type& sign(const private_key_type& key, const chain_id_type& chain_id); signature_type sign(const private_key_type& key, const chain_id_type& chain_id)const; - flat_set get_signature_keys( const chain_id_type& chain_id, bool allow_duplicate_keys = false, bool use_cache = true )const; + flat_set get_signature_keys( const chain_id_type& chain_id, fc::time_point deadline, + bool allow_duplicate_keys = false )const; }; struct packed_transaction { diff --git a/libraries/chain/include/eosio/chain/transaction_metadata.hpp b/libraries/chain/include/eosio/chain/transaction_metadata.hpp index 60f89e2c4fe..e3742eb0978 100644 --- a/libraries/chain/include/eosio/chain/transaction_metadata.hpp +++ b/libraries/chain/include/eosio/chain/transaction_metadata.hpp @@ -51,8 +51,8 @@ class transaction_metadata { const flat_set& recover_keys( const chain_id_type& chain_id ); - static void create_signing_keys_future( const transaction_metadata_ptr& mtrx, - boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id ); + static void create_signing_keys_future( const transaction_metadata_ptr& mtrx, boost::asio::thread_pool& thread_pool, + const chain_id_type& chain_id, fc::time_point deadline); uint32_t total_actions()const { return trx.context_free_actions.size() + trx.actions.size(); } }; diff --git a/libraries/chain/transaction.cpp b/libraries/chain/transaction.cpp index 910651031f8..9cdac6f4889 100644 --- a/libraries/chain/transaction.cpp +++ b/libraries/chain/transaction.cpp @@ -82,28 +82,28 @@ digest_type transaction::sig_digest( const chain_id_type& chain_id, const vector } flat_set transaction::get_signature_keys( const vector& signatures, - const chain_id_type& chain_id, const vector& cfd, bool allow_duplicate_keys, bool use_cache )const + const chain_id_type& chain_id, fc::time_point deadline, const vector& cfd, bool allow_duplicate_keys)const { try { using boost::adaptors::transformed; constexpr size_t recovery_cache_size = 1000; static thread_local recovery_cache_type recovery_cache; + fc::time_point start = fc::time_point::now(); const digest_type digest = sig_digest(chain_id, cfd); flat_set recovered_pub_keys; for(const signature_type& sig : signatures) { + auto now = fc::time_point::now(); + EOS_ASSERT( start + now <= deadline, tx_cpu_usage_exceeded, "transaction signature verification executed for too long", + ("now", now)("deadline", deadline)("start", start) ); public_key_type recov; - if( use_cache ) { - recovery_cache_type::index::type::iterator it = recovery_cache.get().find( sig ); - const auto& tid = id(); - if( it == recovery_cache.get().end() || it->trx_id != tid) { - recov = public_key_type( sig, digest ); - recovery_cache.emplace_back(cached_pub_key{tid, recov, sig} ); //could fail on dup signatures; not a problem - } else { - recov = it->pub_key; - } - } else { + recovery_cache_type::index::type::iterator it = recovery_cache.get().find( sig ); + const auto& tid = id(); + if( it == recovery_cache.get().end() || it->trx_id != tid ) { recov = public_key_type( sig, digest ); + recovery_cache.emplace_back( cached_pub_key{tid, recov, sig} ); //could fail on dup signatures; not a problem + } else { + recov = it->pub_key; } bool successful_insertion = false; std::tie(std::ignore, successful_insertion) = recovered_pub_keys.insert(recov); @@ -113,10 +113,8 @@ flat_set transaction::get_signature_keys( const vector recovery_cache_size ) - recovery_cache.erase( recovery_cache.begin() ); - } + while ( recovery_cache.size() > recovery_cache_size ) + recovery_cache.erase( recovery_cache.begin()); return recovered_pub_keys; } FC_CAPTURE_AND_RETHROW() } @@ -131,9 +129,10 @@ signature_type signed_transaction::sign(const private_key_type& key, const chain return key.sign(sig_digest(chain_id, context_free_data)); } -flat_set signed_transaction::get_signature_keys( const chain_id_type& chain_id, bool allow_duplicate_keys, bool use_cache )const +flat_set signed_transaction::get_signature_keys( const chain_id_type& chain_id, fc::time_point deadline, + bool allow_duplicate_keys)const { - return transaction::get_signature_keys(signatures, chain_id, context_free_data, allow_duplicate_keys, use_cache); + return transaction::get_signature_keys(signatures, chain_id, deadline, context_free_data, allow_duplicate_keys); } uint32_t packed_transaction::get_unprunable_size()const { diff --git a/libraries/chain/transaction_metadata.cpp b/libraries/chain/transaction_metadata.cpp index 95edf0f3f68..5e049fdf217 100644 --- a/libraries/chain/transaction_metadata.cpp +++ b/libraries/chain/transaction_metadata.cpp @@ -14,22 +14,22 @@ const flat_set& transaction_metadata::recover_keys( const chain return signing_keys->second; } } - signing_keys = std::make_pair( chain_id, trx.get_signature_keys( chain_id )); + signing_keys = std::make_pair( chain_id, trx.get_signature_keys( chain_id, fc::time_point::maximum() )); } return signing_keys->second; } void transaction_metadata::create_signing_keys_future( const transaction_metadata_ptr& mtrx, - boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id ) { + boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id, fc::time_point deadline ) { if( mtrx->signing_keys.valid() ) // already created return; std::weak_ptr mtrx_wp = mtrx; - mtrx->signing_keys_future = async_thread_pool( thread_pool, [chain_id, mtrx_wp]() { + mtrx->signing_keys_future = async_thread_pool( thread_pool, [deadline, chain_id, mtrx_wp]() { auto mtrx = mtrx_wp.lock(); return mtrx ? - std::make_pair( chain_id, mtrx->trx.get_signature_keys( chain_id ) ) : - std::make_pair( chain_id, decltype( mtrx->trx.get_signature_keys( chain_id ) ){} ); + std::make_pair( chain_id, mtrx->trx.get_signature_keys( chain_id, deadline ) ) : + std::make_pair( chain_id, decltype( mtrx->trx.get_signature_keys( chain_id, deadline ) ){} ); } ); } diff --git a/plugins/mongo_db_plugin/mongo_db_plugin.cpp b/plugins/mongo_db_plugin/mongo_db_plugin.cpp index 3ef0ee252ac..6c7ce0959d7 100644 --- a/plugins/mongo_db_plugin/mongo_db_plugin.cpp +++ b/plugins/mongo_db_plugin/mongo_db_plugin.cpp @@ -761,7 +761,7 @@ void mongo_db_plugin_impl::_process_accepted_transaction( const chain::transacti if( t->signing_keys.valid() ) { signing_keys_json = fc::json::to_string( t->signing_keys->second ); } else { - auto signing_keys = trx.get_signature_keys( *chain_id, false, false ); + auto signing_keys = trx.get_signature_keys( *chain_id, fc::time_point::maximum(), false ); if( !signing_keys.empty() ) { signing_keys_json = fc::json::to_string( signing_keys ); } diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index d0bda3edf0a..320d12b9877 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -347,7 +347,9 @@ class producer_plugin_impl : public std::enable_shared_from_this next) { chain::controller& chain = chain_plug->chain(); - transaction_metadata::create_signing_keys_future( trx, chain.get_thread_pool(), chain.get_chain_id() ); + const auto& cfg = chain.get_global_properties().configuration; + fc::time_point deadline = fc::time_point::now() + fc::time_point( fc::microseconds( cfg.max_transaction_cpu_usage )); + transaction_metadata::create_signing_keys_future( trx, chain.get_thread_pool(), chain.get_chain_id(), deadline ); boost::asio::post( chain.get_thread_pool(), [self = this, trx, persist_until_expired, next]() { if( trx->signing_keys_future.valid() ) trx->signing_keys_future.wait(); diff --git a/tests/wallet_tests.cpp b/tests/wallet_tests.cpp index 0891b030906..e52f5d0a483 100644 --- a/tests/wallet_tests.cpp +++ b/tests/wallet_tests.cpp @@ -173,7 +173,7 @@ BOOST_AUTO_TEST_CASE(wallet_manager_test) pubkeys.emplace(pkey1.get_public_key()); pubkeys.emplace(pkey2.get_public_key()); trx = wm.sign_transaction(trx, pubkeys, chain_id ); - const auto& pks = trx.get_signature_keys(chain_id); + const auto& pks = trx.get_signature_keys(chain_id, fc::time_point::maximum()); BOOST_CHECK_EQUAL(2, pks.size()); BOOST_CHECK(find(pks.cbegin(), pks.cend(), pkey1.get_public_key()) != pks.cend()); BOOST_CHECK(find(pks.cbegin(), pks.cend(), pkey2.get_public_key()) != pks.cend()); diff --git a/unittests/api_tests.cpp b/unittests/api_tests.cpp index 79b4555aa91..3f3468885e9 100644 --- a/unittests/api_tests.cpp +++ b/unittests/api_tests.cpp @@ -149,7 +149,7 @@ transaction_trace_ptr CallAction(TESTER& test, T ac, const vector& test.set_transaction_headers(trx); auto sigs = trx.sign(test.get_private_key(scope[0], "active"), test.control->get_chain_id()); - trx.get_signature_keys(test.control->get_chain_id()); + trx.get_signature_keys(test.control->get_chain_id(), fc::time_point::maximum()); auto res = test.push_transaction(trx); BOOST_CHECK_EQUAL(res->receipt->status, transaction_receipt::executed); test.produce_block(); @@ -173,7 +173,7 @@ transaction_trace_ptr CallFunction(TESTER& test, T ac, const vector& data, test.set_transaction_headers(trx, test.DEFAULT_EXPIRATION_DELTA); auto sigs = trx.sign(test.get_private_key(scope[0], "active"), test.control->get_chain_id()); - trx.get_signature_keys(test.control->get_chain_id() ); + trx.get_signature_keys(test.control->get_chain_id(), fc::time_point::maximum()); auto res = test.push_transaction(trx); BOOST_CHECK_EQUAL(res->receipt->status, transaction_receipt::executed); test.produce_block(); @@ -266,7 +266,7 @@ BOOST_FIXTURE_TEST_CASE(action_receipt_tests, TESTER) { try { trx.actions.push_back(act); this->set_transaction_headers(trx, this->DEFAULT_EXPIRATION_DELTA); trx.sign(this->get_private_key(config::system_account_name, "active"), control->get_chain_id()); - trx.get_signature_keys(control->get_chain_id() ); + trx.get_signature_keys(control->get_chain_id(), fc::time_point::maximum()); auto res = this->push_transaction(trx); BOOST_CHECK_EQUAL(res->receipt->status, transaction_receipt::executed); this->produce_block(); @@ -745,7 +745,7 @@ void call_test(TESTER& test, T ac, uint32_t billed_cpu_time_us , uint32_t max_cp test.set_transaction_headers(trx); //trx.max_cpu_usage_ms = max_cpu_usage_ms; auto sigs = trx.sign(test.get_private_key(N(testapi), "active"), test.control->get_chain_id()); - trx.get_signature_keys(test.control->get_chain_id() ); + trx.get_signature_keys(test.control->get_chain_id(), fc::time_point::maximum()); auto res = test.push_transaction( trx, fc::time_point::now() + fc::milliseconds(max_cpu_usage_ms), billed_cpu_time_us ); BOOST_CHECK_EQUAL(res->receipt->status, transaction_receipt::executed); test.produce_block(); From b8a565952bc426741dea96ce4f3fe84ff384faa9 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 17 Dec 2018 16:38:18 -0500 Subject: [PATCH 076/111] Modify producer_plugin to have its own thead_pool instead of using chain-threads --- plugins/producer_plugin/producer_plugin.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 320d12b9877..2ab341f7114 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -114,6 +114,13 @@ class producer_plugin_impl : public std::enable_shared_from_thisjoin(); + _thread_pool->stop(); + } + } + optional calculate_next_block_time(const account_name& producer_name, const block_timestamp_type& current_block_time) const; void schedule_production_loop(); void produce_block(); @@ -131,6 +138,7 @@ class producer_plugin_impl : public std::enable_shared_from_this _producer_watermarks; pending_block_mode _pending_block_mode; transaction_id_with_expiry_index _persistent_transactions; + fc::optional _thread_pool; int32_t _max_transaction_time_ms; fc::microseconds _max_irreversible_block_age_us; @@ -349,8 +357,8 @@ class producer_plugin_impl : public std::enable_shared_from_thischain(); const auto& cfg = chain.get_global_properties().configuration; fc::time_point deadline = fc::time_point::now() + fc::time_point( fc::microseconds( cfg.max_transaction_cpu_usage )); - transaction_metadata::create_signing_keys_future( trx, chain.get_thread_pool(), chain.get_chain_id(), deadline ); - boost::asio::post( chain.get_thread_pool(), [self = this, trx, persist_until_expired, next]() { + transaction_metadata::create_signing_keys_future( trx, *_thread_pool, chain.get_chain_id(), deadline ); + boost::asio::post( *_thread_pool, [self = this, trx, persist_until_expired, next]() { if( trx->signing_keys_future.valid() ) trx->signing_keys_future.wait(); app().get_io_service().post( [self, trx, persist_until_expired, next]() { @@ -543,6 +551,8 @@ void producer_plugin::set_program_options( "offset of last block producing time in microseconds. Negative number results in blocks to go out sooner, and positive number results in blocks to go out later") ("incoming-defer-ratio", bpo::value()->default_value(1.0), "ratio between incoming transations and deferred transactions when both are exhausted") + ("producer-threads", bpo::value()->default_value(config::default_controller_thread_pool_size), + "Number of worker threads in producer thread pool") ("snapshots-dir", bpo::value()->default_value("snapshots"), "the location of the snapshots directory (absolute path or relative to application data dir)") ; @@ -675,6 +685,11 @@ void producer_plugin::plugin_initialize(const boost::program_options::variables_ my->_incoming_defer_ratio = options.at("incoming-defer-ratio").as(); + auto thread_pool_size = options.at( "producer-threads" ).as(); + EOS_ASSERT( thread_pool_size > 0, plugin_config_exception, + "producer-threads ${num} must be greater than 0", ("num", thread_pool_size)); + my->_thread_pool.emplace( thread_pool_size ); + if( options.count( "snapshots-dir" )) { auto sd = options.at( "snapshots-dir" ).as(); if( sd.is_relative()) { From 957db7f667349ea816d54b0e11107c9d806cd556 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 17 Dec 2018 17:32:31 -0500 Subject: [PATCH 077/111] Move thread_pool join/stop to plugin shutdown so that they are joined before application quit --- libraries/chain/controller.cpp | 3 --- plugins/chain_plugin/chain_plugin.cpp | 2 ++ plugins/producer_plugin/producer_plugin.cpp | 11 ++++------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 461f481a34f..e2fbd402f84 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -407,9 +407,6 @@ struct controller_impl { ~controller_impl() { pending.reset(); - thread_pool.join(); - thread_pool.stop(); - db.flush(); reversible_blocks.flush(); } diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 6eeeb5a5082..0f46927b260 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -738,6 +738,8 @@ void chain_plugin::plugin_shutdown() { my->accepted_transaction_connection.reset(); my->applied_transaction_connection.reset(); my->accepted_confirmation_connection.reset(); + my->chain->get_thread_pool().stop(); + my->chain->get_thread_pool().join(); my->chain.reset(); } diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 2ab341f7114..57423dbb804 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -114,13 +114,6 @@ class producer_plugin_impl : public std::enable_shared_from_thisjoin(); - _thread_pool->stop(); - } - } - optional calculate_next_block_time(const account_name& producer_name, const block_timestamp_type& current_block_time) const; void schedule_production_loop(); void produce_block(); @@ -791,6 +784,10 @@ void producer_plugin::plugin_shutdown() { edump((e.to_detail_string())); } + if( my->_thread_pool ) { + my->_thread_pool->join(); + my->_thread_pool->stop(); + } my->_accepted_block_connection.reset(); my->_irreversible_block_connection.reset(); } From 9270c9cb9a611dd3857b6d09c75b9381e72e6167 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 17 Dec 2018 17:35:50 -0500 Subject: [PATCH 078/111] Fix signature future deadline from starting too early --- libraries/chain/controller.cpp | 2 +- libraries/chain/include/eosio/chain/transaction_metadata.hpp | 2 +- libraries/chain/transaction_metadata.cpp | 5 +++-- plugins/producer_plugin/producer_plugin.cpp | 3 +-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index e2fbd402f84..83eb9a472e0 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -1189,7 +1189,7 @@ struct controller_impl { auto& pt = receipt.trx.get(); auto mtrx = std::make_shared( std::make_shared( pt ) ); if( !self.skip_auth_check() ) { - transaction_metadata::create_signing_keys_future( mtrx, thread_pool, chain_id, fc::time_point::maximum() ); + transaction_metadata::create_signing_keys_future( mtrx, thread_pool, chain_id, microseconds::maximum() ); } packed_transactions.emplace_back( std::move( mtrx ) ); } diff --git a/libraries/chain/include/eosio/chain/transaction_metadata.hpp b/libraries/chain/include/eosio/chain/transaction_metadata.hpp index e3742eb0978..76c55e88635 100644 --- a/libraries/chain/include/eosio/chain/transaction_metadata.hpp +++ b/libraries/chain/include/eosio/chain/transaction_metadata.hpp @@ -52,7 +52,7 @@ class transaction_metadata { const flat_set& recover_keys( const chain_id_type& chain_id ); static void create_signing_keys_future( const transaction_metadata_ptr& mtrx, boost::asio::thread_pool& thread_pool, - const chain_id_type& chain_id, fc::time_point deadline); + const chain_id_type& chain_id, fc::microseconds timelimit ); uint32_t total_actions()const { return trx.context_free_actions.size() + trx.actions.size(); } }; diff --git a/libraries/chain/transaction_metadata.cpp b/libraries/chain/transaction_metadata.cpp index 5e049fdf217..bd95904a0d0 100644 --- a/libraries/chain/transaction_metadata.cpp +++ b/libraries/chain/transaction_metadata.cpp @@ -20,12 +20,13 @@ const flat_set& transaction_metadata::recover_keys( const chain } void transaction_metadata::create_signing_keys_future( const transaction_metadata_ptr& mtrx, - boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id, fc::time_point deadline ) { + boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id, fc::microseconds timelimit ) { if( mtrx->signing_keys.valid() ) // already created return; std::weak_ptr mtrx_wp = mtrx; - mtrx->signing_keys_future = async_thread_pool( thread_pool, [deadline, chain_id, mtrx_wp]() { + mtrx->signing_keys_future = async_thread_pool( thread_pool, [timelimit, chain_id, mtrx_wp]() { + fc::time_point deadline = fc::time_point::now() + timelimit; auto mtrx = mtrx_wp.lock(); return mtrx ? std::make_pair( chain_id, mtrx->trx.get_signature_keys( chain_id, deadline ) ) : diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 57423dbb804..d4a8e877b01 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -349,8 +349,7 @@ class producer_plugin_impl : public std::enable_shared_from_this next) { chain::controller& chain = chain_plug->chain(); const auto& cfg = chain.get_global_properties().configuration; - fc::time_point deadline = fc::time_point::now() + fc::time_point( fc::microseconds( cfg.max_transaction_cpu_usage )); - transaction_metadata::create_signing_keys_future( trx, *_thread_pool, chain.get_chain_id(), deadline ); + transaction_metadata::create_signing_keys_future( trx, *_thread_pool, chain.get_chain_id(), fc::microseconds( cfg.max_transaction_cpu_usage ) ); boost::asio::post( *_thread_pool, [self = this, trx, persist_until_expired, next]() { if( trx->signing_keys_future.valid() ) trx->signing_keys_future.wait(); From 3e733f5711209df5e65536f03bb202be9d2d0b9c Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 17 Dec 2018 18:22:09 -0500 Subject: [PATCH 079/111] Fix overflow of deadline and deadline check --- libraries/chain/transaction.cpp | 6 ++---- libraries/chain/transaction_metadata.cpp | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libraries/chain/transaction.cpp b/libraries/chain/transaction.cpp index 9cdac6f4889..0f6ad026b94 100644 --- a/libraries/chain/transaction.cpp +++ b/libraries/chain/transaction.cpp @@ -88,14 +88,12 @@ flat_set transaction::get_signature_keys( const vector recovered_pub_keys; for(const signature_type& sig : signatures) { - auto now = fc::time_point::now(); - EOS_ASSERT( start + now <= deadline, tx_cpu_usage_exceeded, "transaction signature verification executed for too long", - ("now", now)("deadline", deadline)("start", start) ); + EOS_ASSERT( fc::time_point::now() < deadline, tx_cpu_usage_exceeded, "transaction signature verification executed for too long", + ("now", fc::time_point::now())("deadline", deadline) ); public_key_type recov; recovery_cache_type::index::type::iterator it = recovery_cache.get().find( sig ); const auto& tid = id(); diff --git a/libraries/chain/transaction_metadata.cpp b/libraries/chain/transaction_metadata.cpp index bd95904a0d0..c493a846cd5 100644 --- a/libraries/chain/transaction_metadata.cpp +++ b/libraries/chain/transaction_metadata.cpp @@ -26,7 +26,8 @@ void transaction_metadata::create_signing_keys_future( const transaction_metadat std::weak_ptr mtrx_wp = mtrx; mtrx->signing_keys_future = async_thread_pool( thread_pool, [timelimit, chain_id, mtrx_wp]() { - fc::time_point deadline = fc::time_point::now() + timelimit; + fc::time_point deadline = timelimit == fc::microseconds::maximum() ? + fc::time_point::maximum() : fc::time_point::now() + timelimit; auto mtrx = mtrx_wp.lock(); return mtrx ? std::make_pair( chain_id, mtrx->trx.get_signature_keys( chain_id, deadline ) ) : From 6e9b4419da691028f3e837904f72b3dbf9cfd2e4 Mon Sep 17 00:00:00 2001 From: arhag Date: Mon, 17 Dec 2018 20:30:47 -0500 Subject: [PATCH 080/111] initial setup of billing CPU for signatures recovered earlier --- libraries/chain/controller.cpp | 16 ++++++++++++++-- .../include/eosio/chain/transaction_context.hpp | 1 - libraries/chain/transaction_context.cpp | 1 - 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 83eb9a472e0..fa3ec68cb6c 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -998,7 +998,20 @@ struct controller_impl { transaction_trace_ptr trace; try { - transaction_context trx_context(self, trx->trx, trx->id); + auto start = fc::time_point::now(); + if( !explicit_billed_cpu_time ) { + int64_t cpu_per_signature_us = 10; // TODO: plumb in producer configuration for this value. + auto already_consumed_time = fc::microseconds( cpu_per_signature_us * trx->trx.signatures.size() ); + // Alternatively store actual time to recover keys in transaction_metadata and use that as already_consumed_time (makes more sense if recovery cache was removed). + + if( start.time_since_epoch() < already_consumed_time ) { + start = fc::time_point(); + } else { + start -= already_consumed_time; + } + } + + transaction_context trx_context(self, trx->trx, trx->id, start); if ((bool)subjective_cpu_leeway && pending->_block_status == controller::block_status::incomplete) { trx_context.leeway = *subjective_cpu_leeway; } @@ -1014,7 +1027,6 @@ struct controller_impl { bool skip_recording = replay_head_time && (time_point(trx->trx.expiration) <= *replay_head_time); trx_context.init_for_input_trx( trx->packed_trx->get_unprunable_size(), trx->packed_trx->get_prunable_size(), - trx->trx.signatures.size(), skip_recording); } diff --git a/libraries/chain/include/eosio/chain/transaction_context.hpp b/libraries/chain/include/eosio/chain/transaction_context.hpp index 2e215f00ec2..b0327dafb18 100644 --- a/libraries/chain/include/eosio/chain/transaction_context.hpp +++ b/libraries/chain/include/eosio/chain/transaction_context.hpp @@ -33,7 +33,6 @@ namespace eosio { namespace chain { void init_for_input_trx( uint64_t packed_trx_unprunable_size, uint64_t packed_trx_prunable_size, - uint32_t num_signatures, bool skip_recording); void init_for_deferred_trx( fc::time_point published ); diff --git a/libraries/chain/transaction_context.cpp b/libraries/chain/transaction_context.cpp index 989905ef9a0..d5da8ca279b 100644 --- a/libraries/chain/transaction_context.cpp +++ b/libraries/chain/transaction_context.cpp @@ -284,7 +284,6 @@ namespace bacc = boost::accumulators; void transaction_context::init_for_input_trx( uint64_t packed_trx_unprunable_size, uint64_t packed_trx_prunable_size, - uint32_t num_signatures, bool skip_recording ) { const auto& cfg = control.get_global_properties().configuration; From 66fd77982d64aa2af138c2a3fcf53aebae0e847f Mon Sep 17 00:00:00 2001 From: Necokeine Date: Mon, 17 Dec 2018 12:19:54 +0800 Subject: [PATCH 081/111] Return 400 on get_block with uonexist block number. For issue 6374 --- plugins/http_plugin/http_plugin.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/http_plugin/http_plugin.cpp b/plugins/http_plugin/http_plugin.cpp index d9be006bb45..6226cec8fd0 100644 --- a/plugins/http_plugin/http_plugin.cpp +++ b/plugins/http_plugin/http_plugin.cpp @@ -561,6 +561,9 @@ namespace eosio { try { try { throw; + } catch (chain::unknown_block_exception& e) { + error_results results{400, "Unknown Block", error_results::error_info(e, verbose_http_errors)}; + cb( 400, fc::json::to_string( results )); } catch (chain::unsatisfied_authorization& e) { error_results results{401, "UnAuthorized", error_results::error_info(e, verbose_http_errors)}; cb( 401, fc::json::to_string( results )); From 649289df8e1f19de6a421c04cd545cca5be09279 Mon Sep 17 00:00:00 2001 From: UMU618 Date: Tue, 18 Dec 2018 16:59:18 +0800 Subject: [PATCH 082/111] fix issue 5488 --- plugins/mongo_db_plugin/mongo_db_plugin.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/mongo_db_plugin/mongo_db_plugin.cpp b/plugins/mongo_db_plugin/mongo_db_plugin.cpp index 3ef0ee252ac..444a5b2174a 100644 --- a/plugins/mongo_db_plugin/mongo_db_plugin.cpp +++ b/plugins/mongo_db_plugin/mongo_db_plugin.cpp @@ -570,6 +570,15 @@ void handle_mongo_exception( const std::string& desc, int line_num ) { } } +// custom oid to avoid monotonic throttling +// https://docs.mongodb.com/master/core/bulk-write-operations/#avoid-monotonic-throttling +bsoncxx::oid make_custom_oid() { + bsoncxx::oid x = bsoncxx::oid(); + const char* p = x.bytes(); + std::swap((short&)p[0], (short&)p[10]); + return x; +} + } // anonymous namespace void mongo_db_plugin_impl::purge_abi_cache() { @@ -818,6 +827,9 @@ mongo_db_plugin_impl::add_action_trace( mongocxx::bulk_write& bulk_action_traces auto action_traces_doc = bsoncxx::builder::basic::document{}; const chain::base_action_trace& base = atrace; // without inline action traces + // improve data distributivity when using mongodb sharding + action_traces_doc.append( kvp( "_id", make_custom_oid() ) ); + auto v = to_variant_with_abi( base ); string json = fc::json::to_string( v ); try { From badafc3b2b6895daf22d05a69ef594bbf03db9c2 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 18 Dec 2018 09:25:05 -0500 Subject: [PATCH 083/111] Add action_trace.block_num index. Remove action_trace.trx_id index. --- plugins/mongo_db_plugin/mongo_db_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mongo_db_plugin/mongo_db_plugin.cpp b/plugins/mongo_db_plugin/mongo_db_plugin.cpp index 00ca0b1ed71..60aeeeb6834 100644 --- a/plugins/mongo_db_plugin/mongo_db_plugin.cpp +++ b/plugins/mongo_db_plugin/mongo_db_plugin.cpp @@ -1426,7 +1426,7 @@ void mongo_db_plugin_impl::init() { // action traces indexes auto action_traces = mongo_conn[db_name][action_traces_col]; - action_traces.create_index( bsoncxx::from_json( R"xxx({ "trx_id" : 1 })xxx" )); + action_traces.create_index( bsoncxx::from_json( R"xxx({ "block_num" : 1 })xxx" )); // pub_keys indexes auto pub_keys = mongo_conn[db_name][pub_keys_col]; From 955476d94372ab28485d857f1ab84a6f435e0c8a Mon Sep 17 00:00:00 2001 From: Emory Barlow Date: Tue, 18 Dec 2018 09:51:01 -0500 Subject: [PATCH 084/111] Fix return codes of build scripts so that buildkite can fail properly --- scripts/generate_deb.sh | 3 +++ scripts/generate_package.sh.in | 5 +++++ scripts/generate_rpm.sh | 3 +++ 3 files changed, 11 insertions(+) diff --git a/scripts/generate_deb.sh b/scripts/generate_deb.sh index 5009f7627b3..c4d50132847 100644 --- a/scripts/generate_deb.sh +++ b/scripts/generate_deb.sh @@ -37,5 +37,8 @@ bash generate_tarball.sh ${NAME}.tar.gz tar -xvzf ${NAME}.tar.gz -C ${PROJECT} dpkg-deb --build ${PROJECT} +BUILDSTATUS=$? mv ${PROJECT}.deb ${NAME}.deb rm -r ${PROJECT} + +exit $BUILDSTATUS diff --git a/scripts/generate_package.sh.in b/scripts/generate_package.sh.in index 5d8aedebb70..9c190ed7d87 100644 --- a/scripts/generate_package.sh.in +++ b/scripts/generate_package.sh.in @@ -35,4 +35,9 @@ else echo "Error, unknown package type. Use either ['brew', 'deb', 'rpm']." exit -1 fi + +BUILDSTATUS=$? + rm -r tmp + +exit $BUILDSTATUS diff --git a/scripts/generate_rpm.sh b/scripts/generate_rpm.sh index 35b60a4c816..8d7ebf03caa 100644 --- a/scripts/generate_rpm.sh +++ b/scripts/generate_rpm.sh @@ -47,5 +47,8 @@ ${DESC} %files -f filenames.txt" &> ${PROJECT}.spec rpmbuild -bb ${PROJECT}.spec +BUILDSTATUS=$? mv ~/rpmbuild/RPMS/x86_64 ./ rm -r ${PROJECT} ~/rpmbuild/BUILD/filenames.txt ${PROJECT}.spec + +exit $BUILDSTATUS From 2b6a88a299fa017386e4b2a945c2cf5fa096ff3b Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 18 Dec 2018 11:53:33 -0500 Subject: [PATCH 085/111] Make recovery cache non-thread local and guard by mutex --- libraries/chain/transaction.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/libraries/chain/transaction.cpp b/libraries/chain/transaction.cpp index 0f6ad026b94..5bd5090d114 100644 --- a/libraries/chain/transaction.cpp +++ b/libraries/chain/transaction.cpp @@ -28,6 +28,7 @@ struct cached_pub_key { transaction_id_type trx_id; public_key_type pub_key; signature_type sig; + fc::microseconds cpu_usage; cached_pub_key(const cached_pub_key&) = delete; cached_pub_key() = delete; cached_pub_key& operator=(const cached_pub_key&) = delete; @@ -48,6 +49,8 @@ typedef multi_index_container< > > recovery_cache_type; +static std::mutex cache_mtx; + void transaction_header::set_reference_block( const block_id_type& reference_block ) { ref_block_num = fc::endian_reverse_u32(reference_block._hash[0]); ref_block_prefix = reference_block._hash[1]; @@ -81,38 +84,48 @@ digest_type transaction::sig_digest( const chain_id_type& chain_id, const vector return enc.result(); } + flat_set transaction::get_signature_keys( const vector& signatures, const chain_id_type& chain_id, fc::time_point deadline, const vector& cfd, bool allow_duplicate_keys)const { try { using boost::adaptors::transformed; - constexpr size_t recovery_cache_size = 1000; - static thread_local recovery_cache_type recovery_cache; + constexpr size_t recovery_cache_size = 10000; + static recovery_cache_type recovery_cache; + auto start = fc::time_point::now(); const digest_type digest = sig_digest(chain_id, cfd); + std::unique_lock lock(cache_mtx, std::defer_lock); flat_set recovered_pub_keys; for(const signature_type& sig : signatures) { - EOS_ASSERT( fc::time_point::now() < deadline, tx_cpu_usage_exceeded, "transaction signature verification executed for too long", - ("now", fc::time_point::now())("deadline", deadline) ); + auto now = fc::time_point::now(); + EOS_ASSERT( now < deadline, tx_cpu_usage_exceeded, "transaction signature verification executed for too long", + ("now", now)("deadline", deadline)("start", start) ); public_key_type recov; - recovery_cache_type::index::type::iterator it = recovery_cache.get().find( sig ); const auto& tid = id(); + lock.lock(); + recovery_cache_type::index::type::iterator it = recovery_cache.get().find( sig ); if( it == recovery_cache.get().end() || it->trx_id != tid ) { + lock.unlock(); recov = public_key_type( sig, digest ); - recovery_cache.emplace_back( cached_pub_key{tid, recov, sig} ); //could fail on dup signatures; not a problem + fc::microseconds cpu_usage = fc::time_point::now() - start; + lock.lock(); + recovery_cache.emplace_back( cached_pub_key{tid, recov, sig, cpu_usage} ); //could fail on dup signatures; not a problem } else { recov = it->pub_key; } + lock.unlock(); bool successful_insertion = false; std::tie(std::ignore, successful_insertion) = recovered_pub_keys.insert(recov); EOS_ASSERT( allow_duplicate_keys || successful_insertion, tx_duplicate_sig, "transaction includes more than one signature signed using the same key associated with public key: ${key}", - ("key", recov) - ); + ("key", recov) ); } + lock.lock(); while ( recovery_cache.size() > recovery_cache_size ) recovery_cache.erase( recovery_cache.begin()); + lock.unlock(); return recovered_pub_keys; } FC_CAPTURE_AND_RETHROW() } From 94ad2d1533ed48a5dbfa466504758b24395de7ac Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 18 Dec 2018 14:58:21 -0500 Subject: [PATCH 086/111] Calculate cpu usage of signature recovery --- .../chain/include/eosio/chain/transaction.hpp | 10 ++++--- .../eosio/chain/transaction_metadata.hpp | 4 ++- libraries/chain/transaction.cpp | 20 ++++++++------ libraries/chain/transaction_metadata.cpp | 27 ++++++++++++------- plugins/mongo_db_plugin/mongo_db_plugin.cpp | 7 ++--- tests/wallet_tests.cpp | 3 ++- unittests/api_tests.cpp | 12 ++++++--- 7 files changed, 52 insertions(+), 31 deletions(-) diff --git a/libraries/chain/include/eosio/chain/transaction.hpp b/libraries/chain/include/eosio/chain/transaction.hpp index 65f3c35ff63..0829907c09c 100644 --- a/libraries/chain/include/eosio/chain/transaction.hpp +++ b/libraries/chain/include/eosio/chain/transaction.hpp @@ -58,11 +58,12 @@ namespace eosio { namespace chain { transaction_id_type id()const; digest_type sig_digest( const chain_id_type& chain_id, const vector& cfd = vector() )const; - flat_set get_signature_keys( const vector& signatures, + fc::microseconds get_signature_keys( const vector& signatures, const chain_id_type& chain_id, fc::time_point deadline, - const vector& cfd = vector(), - bool allow_duplicate_keys = false)const; + const vector& cfd, + flat_set& recovered_pub_keys, + bool allow_duplicate_keys = false) const; uint32_t total_actions()const { return context_free_actions.size() + actions.size(); } account_name first_authorizor()const { @@ -92,7 +93,8 @@ namespace eosio { namespace chain { const signature_type& sign(const private_key_type& key, const chain_id_type& chain_id); signature_type sign(const private_key_type& key, const chain_id_type& chain_id)const; - flat_set get_signature_keys( const chain_id_type& chain_id, fc::time_point deadline, + fc::microseconds get_signature_keys( const chain_id_type& chain_id, fc::time_point deadline, + flat_set& recovered_pub_keys, bool allow_duplicate_keys = false )const; }; diff --git a/libraries/chain/include/eosio/chain/transaction_metadata.hpp b/libraries/chain/include/eosio/chain/transaction_metadata.hpp index 76c55e88635..9b9dfd9df77 100644 --- a/libraries/chain/include/eosio/chain/transaction_metadata.hpp +++ b/libraries/chain/include/eosio/chain/transaction_metadata.hpp @@ -25,8 +25,10 @@ class transaction_metadata { transaction_id_type signed_id; signed_transaction trx; packed_transaction_ptr packed_trx; + fc::microseconds sig_cpu_usage; optional>> signing_keys; - std::future>> signing_keys_future; + std::future>> + signing_keys_future; bool accepted = false; bool implicit = false; bool scheduled = false; diff --git a/libraries/chain/transaction.cpp b/libraries/chain/transaction.cpp index 5bd5090d114..f53b140a1ef 100644 --- a/libraries/chain/transaction.cpp +++ b/libraries/chain/transaction.cpp @@ -84,9 +84,9 @@ digest_type transaction::sig_digest( const chain_id_type& chain_id, const vector return enc.result(); } - -flat_set transaction::get_signature_keys( const vector& signatures, - const chain_id_type& chain_id, fc::time_point deadline, const vector& cfd, bool allow_duplicate_keys)const +fc::microseconds transaction::get_signature_keys( const vector& signatures, + const chain_id_type& chain_id, fc::time_point deadline, const vector& cfd, + flat_set& recovered_pub_keys, bool allow_duplicate_keys)const { try { using boost::adaptors::transformed; @@ -96,7 +96,7 @@ flat_set transaction::get_signature_keys( const vector lock(cache_mtx, std::defer_lock); - flat_set recovered_pub_keys; + fc::microseconds sig_cpu_usage; for(const signature_type& sig : signatures) { auto now = fc::time_point::now(); EOS_ASSERT( now < deadline, tx_cpu_usage_exceeded, "transaction signature verification executed for too long", @@ -111,8 +111,10 @@ flat_set transaction::get_signature_keys( const vectorpub_key; + sig_cpu_usage += it->cpu_usage; } lock.unlock(); bool successful_insertion = false; @@ -127,7 +129,7 @@ flat_set transaction::get_signature_keys( const vector signed_transaction::get_signature_keys( const chain_id_type& chain_id, fc::time_point deadline, - bool allow_duplicate_keys)const +fc::microseconds +signed_transaction::get_signature_keys( const chain_id_type& chain_id, fc::time_point deadline, + flat_set& recovered_pub_keys, + bool allow_duplicate_keys)const { - return transaction::get_signature_keys(signatures, chain_id, deadline, context_free_data, allow_duplicate_keys); + return transaction::get_signature_keys(signatures, chain_id, deadline, context_free_data, recovered_pub_keys, allow_duplicate_keys); } uint32_t packed_transaction::get_unprunable_size()const { diff --git a/libraries/chain/transaction_metadata.cpp b/libraries/chain/transaction_metadata.cpp index c493a846cd5..4324612bbdb 100644 --- a/libraries/chain/transaction_metadata.cpp +++ b/libraries/chain/transaction_metadata.cpp @@ -9,29 +9,36 @@ const flat_set& transaction_metadata::recover_keys( const chain // Unlikely for more than one chain_id to be used in one nodeos instance if( !signing_keys || signing_keys->first != chain_id ) { if( signing_keys_future.valid() ) { - signing_keys = signing_keys_future.get(); - if( signing_keys->first == chain_id ) { + std::tuple> sig_keys = signing_keys_future.get(); + if( std::get<0>( sig_keys ) == chain_id ) { + sig_cpu_usage = std::get<1>( sig_keys ); + signing_keys.emplace( std::make_pair( std::get<0>( sig_keys ), std::get<2>( sig_keys ))); return signing_keys->second; } } - signing_keys = std::make_pair( chain_id, trx.get_signature_keys( chain_id, fc::time_point::maximum() )); + flat_set recovered_pub_keys; + sig_cpu_usage = trx.get_signature_keys( chain_id, fc::time_point::maximum(), recovered_pub_keys ); + signing_keys.emplace( chain_id, std::move( recovered_pub_keys )); } return signing_keys->second; } void transaction_metadata::create_signing_keys_future( const transaction_metadata_ptr& mtrx, - boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id, fc::microseconds timelimit ) { + boost::asio::thread_pool& thread_pool, const chain_id_type& chain_id, fc::microseconds time_limit ) { if( mtrx->signing_keys.valid() ) // already created return; std::weak_ptr mtrx_wp = mtrx; - mtrx->signing_keys_future = async_thread_pool( thread_pool, [timelimit, chain_id, mtrx_wp]() { - fc::time_point deadline = timelimit == fc::microseconds::maximum() ? - fc::time_point::maximum() : fc::time_point::now() + timelimit; + mtrx->signing_keys_future = async_thread_pool( thread_pool, [time_limit, chain_id, mtrx_wp]() { + fc::time_point deadline = time_limit == fc::microseconds::maximum() ? + fc::time_point::maximum() : fc::time_point::now() + time_limit; auto mtrx = mtrx_wp.lock(); - return mtrx ? - std::make_pair( chain_id, mtrx->trx.get_signature_keys( chain_id, deadline ) ) : - std::make_pair( chain_id, decltype( mtrx->trx.get_signature_keys( chain_id, deadline ) ){} ); + fc::microseconds cpu_usage; + flat_set recovered_pub_keys; + if( mtrx ) { + mtrx->trx.get_signature_keys( chain_id, deadline, recovered_pub_keys ); + } + return std::make_tuple( chain_id, cpu_usage, recovered_pub_keys); } ); } diff --git a/plugins/mongo_db_plugin/mongo_db_plugin.cpp b/plugins/mongo_db_plugin/mongo_db_plugin.cpp index 6c7ce0959d7..5c70db212c7 100644 --- a/plugins/mongo_db_plugin/mongo_db_plugin.cpp +++ b/plugins/mongo_db_plugin/mongo_db_plugin.cpp @@ -761,9 +761,10 @@ void mongo_db_plugin_impl::_process_accepted_transaction( const chain::transacti if( t->signing_keys.valid() ) { signing_keys_json = fc::json::to_string( t->signing_keys->second ); } else { - auto signing_keys = trx.get_signature_keys( *chain_id, fc::time_point::maximum(), false ); - if( !signing_keys.empty() ) { - signing_keys_json = fc::json::to_string( signing_keys ); + flat_set keys; + trx.get_signature_keys( *chain_id, fc::time_point::maximum(), keys, false ); + if( !keys.empty() ) { + signing_keys_json = fc::json::to_string( keys ); } } diff --git a/tests/wallet_tests.cpp b/tests/wallet_tests.cpp index e52f5d0a483..fd22a95f6da 100644 --- a/tests/wallet_tests.cpp +++ b/tests/wallet_tests.cpp @@ -173,7 +173,8 @@ BOOST_AUTO_TEST_CASE(wallet_manager_test) pubkeys.emplace(pkey1.get_public_key()); pubkeys.emplace(pkey2.get_public_key()); trx = wm.sign_transaction(trx, pubkeys, chain_id ); - const auto& pks = trx.get_signature_keys(chain_id, fc::time_point::maximum()); + flat_set pks; + trx.get_signature_keys(chain_id, fc::time_point::maximum(), pks); BOOST_CHECK_EQUAL(2, pks.size()); BOOST_CHECK(find(pks.cbegin(), pks.cend(), pkey1.get_public_key()) != pks.cend()); BOOST_CHECK(find(pks.cbegin(), pks.cend(), pkey2.get_public_key()) != pks.cend()); diff --git a/unittests/api_tests.cpp b/unittests/api_tests.cpp index 3f3468885e9..e077d2dad08 100644 --- a/unittests/api_tests.cpp +++ b/unittests/api_tests.cpp @@ -149,7 +149,8 @@ transaction_trace_ptr CallAction(TESTER& test, T ac, const vector& test.set_transaction_headers(trx); auto sigs = trx.sign(test.get_private_key(scope[0], "active"), test.control->get_chain_id()); - trx.get_signature_keys(test.control->get_chain_id(), fc::time_point::maximum()); + flat_set keys; + trx.get_signature_keys(test.control->get_chain_id(), fc::time_point::maximum(), keys); auto res = test.push_transaction(trx); BOOST_CHECK_EQUAL(res->receipt->status, transaction_receipt::executed); test.produce_block(); @@ -173,7 +174,8 @@ transaction_trace_ptr CallFunction(TESTER& test, T ac, const vector& data, test.set_transaction_headers(trx, test.DEFAULT_EXPIRATION_DELTA); auto sigs = trx.sign(test.get_private_key(scope[0], "active"), test.control->get_chain_id()); - trx.get_signature_keys(test.control->get_chain_id(), fc::time_point::maximum()); + flat_set keys; + trx.get_signature_keys(test.control->get_chain_id(), fc::time_point::maximum(), keys); auto res = test.push_transaction(trx); BOOST_CHECK_EQUAL(res->receipt->status, transaction_receipt::executed); test.produce_block(); @@ -266,7 +268,8 @@ BOOST_FIXTURE_TEST_CASE(action_receipt_tests, TESTER) { try { trx.actions.push_back(act); this->set_transaction_headers(trx, this->DEFAULT_EXPIRATION_DELTA); trx.sign(this->get_private_key(config::system_account_name, "active"), control->get_chain_id()); - trx.get_signature_keys(control->get_chain_id(), fc::time_point::maximum()); + flat_set keys; + trx.get_signature_keys(control->get_chain_id(), fc::time_point::maximum(), keys); auto res = this->push_transaction(trx); BOOST_CHECK_EQUAL(res->receipt->status, transaction_receipt::executed); this->produce_block(); @@ -745,7 +748,8 @@ void call_test(TESTER& test, T ac, uint32_t billed_cpu_time_us , uint32_t max_cp test.set_transaction_headers(trx); //trx.max_cpu_usage_ms = max_cpu_usage_ms; auto sigs = trx.sign(test.get_private_key(N(testapi), "active"), test.control->get_chain_id()); - trx.get_signature_keys(test.control->get_chain_id(), fc::time_point::maximum()); + flat_set keys; + trx.get_signature_keys(test.control->get_chain_id(), fc::time_point::maximum(), keys); auto res = test.push_transaction( trx, fc::time_point::now() + fc::milliseconds(max_cpu_usage_ms), billed_cpu_time_us ); BOOST_CHECK_EQUAL(res->receipt->status, transaction_receipt::executed); test.produce_block(); From 48bf2d4c63e95dac06d1a4912722a639aba811a0 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 18 Dec 2018 15:32:36 -0500 Subject: [PATCH 087/111] Add signature-cpu-billable-pct option to chain_plugin --- libraries/chain/controller.cpp | 4 +--- libraries/chain/include/eosio/chain/config.hpp | 1 + libraries/chain/include/eosio/chain/controller.hpp | 1 + plugins/chain_plugin/chain_plugin.cpp | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index fa3ec68cb6c..e46f65bf11f 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -1000,9 +1000,7 @@ struct controller_impl { try { auto start = fc::time_point::now(); if( !explicit_billed_cpu_time ) { - int64_t cpu_per_signature_us = 10; // TODO: plumb in producer configuration for this value. - auto already_consumed_time = fc::microseconds( cpu_per_signature_us * trx->trx.signatures.size() ); - // Alternatively store actual time to recover keys in transaction_metadata and use that as already_consumed_time (makes more sense if recovery cache was removed). + fc::microseconds already_consumed_time( EOS_PERCENT(trx->sig_cpu_usage.count(), conf.sig_cpu_bill_pct) ); if( start.time_since_epoch() < already_consumed_time ) { start = fc::time_point(); diff --git a/libraries/chain/include/eosio/chain/config.hpp b/libraries/chain/include/eosio/chain/config.hpp index 307b36aab00..2c208ffd6c0 100644 --- a/libraries/chain/include/eosio/chain/config.hpp +++ b/libraries/chain/include/eosio/chain/config.hpp @@ -79,6 +79,7 @@ const static uint32_t default_max_trx_delay = 45*24*3600; // const static uint32_t default_max_inline_action_size = 4 * 1024; // 4 KB const static uint16_t default_max_inline_action_depth = 4; const static uint16_t default_max_auth_depth = 6; +const static uint32_t default_sig_cpu_bill_pct = 50 * percent_1; // billable percentage of signature recovery const static uint16_t default_controller_thread_pool_size = 2; const static uint32_t min_net_usage_delta_between_base_and_max_for_trx = 10*1024; diff --git a/libraries/chain/include/eosio/chain/controller.hpp b/libraries/chain/include/eosio/chain/controller.hpp index bb07d223a8e..f0d5a53f52d 100644 --- a/libraries/chain/include/eosio/chain/controller.hpp +++ b/libraries/chain/include/eosio/chain/controller.hpp @@ -65,6 +65,7 @@ namespace eosio { namespace chain { uint64_t state_guard_size = chain::config::default_state_guard_size; uint64_t reversible_cache_size = chain::config::default_reversible_cache_size; uint64_t reversible_guard_size = chain::config::default_reversible_guard_size; + uint32_t sig_cpu_bill_pct = chain::config::default_sig_cpu_bill_pct; uint16_t thread_pool_size = chain::config::default_controller_thread_pool_size; bool read_only = false; bool force_all_checks = false; diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 0f46927b260..ffdbdccf7a1 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -218,6 +218,8 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip ("chain-state-db-guard-size-mb", bpo::value()->default_value(config::default_state_guard_size / (1024 * 1024)), "Safely shut down node when free space remaining in the chain state database drops below this size (in MiB).") ("reversible-blocks-db-size-mb", bpo::value()->default_value(config::default_reversible_cache_size / (1024 * 1024)), "Maximum size (in MiB) of the reversible blocks database") ("reversible-blocks-db-guard-size-mb", bpo::value()->default_value(config::default_reversible_guard_size / (1024 * 1024)), "Safely shut down node when free space remaining in the reverseible blocks database drops below this size (in MiB).") + ("signature-cpu-billable-pct", bpo::value()->default_value(config::default_sig_cpu_bill_pct / config::percent_1), + "Percentage of actual signature recovery cpu to bill. Whole number percentages, e.g. 50 for 50%") ("chain-threads", bpo::value()->default_value(config::default_controller_thread_pool_size), "Number of worker threads in controller thread pool") ("contracts-console", bpo::bool_switch()->default_value(false), @@ -426,6 +428,8 @@ void chain_plugin::plugin_initialize(const variables_map& options) { "chain-threads ${num} must be greater than 0", ("num", my->chain_config->thread_pool_size) ); } + my->chain_config->sig_cpu_bill_pct = options.at("signature-cpu-billable-pct").as() * config::percent_1; + if( my->wasm_runtime ) my->chain_config->wasm_runtime = *my->wasm_runtime; From 1ecb7cc59b1d305a6e997f2f5459692523554a35 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 18 Dec 2018 15:39:02 -0500 Subject: [PATCH 088/111] Add missing include of mutex --- libraries/chain/transaction.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/chain/transaction.cpp b/libraries/chain/transaction.cpp index f53b140a1ef..c914aab80fc 100644 --- a/libraries/chain/transaction.cpp +++ b/libraries/chain/transaction.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -49,8 +50,6 @@ typedef multi_index_container< > > recovery_cache_type; -static std::mutex cache_mtx; - void transaction_header::set_reference_block( const block_id_type& reference_block ) { ref_block_num = fc::endian_reverse_u32(reference_block._hash[0]); ref_block_prefix = reference_block._hash[1]; @@ -92,6 +91,8 @@ fc::microseconds transaction::get_signature_keys( const vector& constexpr size_t recovery_cache_size = 10000; static recovery_cache_type recovery_cache; + static std::mutex cache_mtx; + auto start = fc::time_point::now(); const digest_type digest = sig_digest(chain_id, cfd); From 75587d0959a8fadd17f4c8a49b0ac4bab87aa6bf Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 18 Dec 2018 16:10:40 -0500 Subject: [PATCH 089/111] Assert signature-cpu-billable-pct is 0-100 --- plugins/chain_plugin/chain_plugin.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index ffdbdccf7a1..c7863b906d9 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -428,7 +428,10 @@ void chain_plugin::plugin_initialize(const variables_map& options) { "chain-threads ${num} must be greater than 0", ("num", my->chain_config->thread_pool_size) ); } - my->chain_config->sig_cpu_bill_pct = options.at("signature-cpu-billable-pct").as() * config::percent_1; + my->chain_config->sig_cpu_bill_pct = options.at("signature-cpu-billable-pct").as(); + EOS_ASSERT( my->chain_config->sig_cpu_bill_pct >= 0 && my->chain_config->sig_cpu_bill_pct <= 100, plugin_config_exception, + "signature-cpu-billable-pct must be 0 - 100, ${pct}", ("pct", my->chain_config->sig_cpu_bill_pct) ); + my->chain_config->sig_cpu_bill_pct *= config::percent_1; if( my->wasm_runtime ) my->chain_config->wasm_runtime = *my->wasm_runtime; From 21d20a866a52435457c96344832a172f63b6932d Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 18 Dec 2018 16:12:36 -0500 Subject: [PATCH 090/111] Fix capture of cpu_usage. move flat_set into attribute --- libraries/chain/transaction_metadata.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/chain/transaction_metadata.cpp b/libraries/chain/transaction_metadata.cpp index 4324612bbdb..a7ed2935107 100644 --- a/libraries/chain/transaction_metadata.cpp +++ b/libraries/chain/transaction_metadata.cpp @@ -12,7 +12,7 @@ const flat_set& transaction_metadata::recover_keys( const chain std::tuple> sig_keys = signing_keys_future.get(); if( std::get<0>( sig_keys ) == chain_id ) { sig_cpu_usage = std::get<1>( sig_keys ); - signing_keys.emplace( std::make_pair( std::get<0>( sig_keys ), std::get<2>( sig_keys ))); + signing_keys.emplace( std::get<0>( sig_keys ), std::move( std::get<2>( sig_keys ))); return signing_keys->second; } } @@ -36,7 +36,7 @@ void transaction_metadata::create_signing_keys_future( const transaction_metadat fc::microseconds cpu_usage; flat_set recovered_pub_keys; if( mtrx ) { - mtrx->trx.get_signature_keys( chain_id, deadline, recovered_pub_keys ); + cpu_usage = mtrx->trx.get_signature_keys( chain_id, deadline, recovered_pub_keys ); } return std::make_tuple( chain_id, cpu_usage, recovered_pub_keys); } ); From 058d4ac4f8ecc55bb093ed3705a1f79e0bc5b46c Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 18 Dec 2018 16:18:49 -0500 Subject: [PATCH 091/111] clear recovered_pub_keys to preserve previous behaviour --- libraries/chain/transaction.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/chain/transaction.cpp b/libraries/chain/transaction.cpp index c914aab80fc..e53e663ed40 100644 --- a/libraries/chain/transaction.cpp +++ b/libraries/chain/transaction.cpp @@ -94,6 +94,7 @@ fc::microseconds transaction::get_signature_keys( const vector& static std::mutex cache_mtx; auto start = fc::time_point::now(); + recovered_pub_keys.clear(); const digest_type digest = sig_digest(chain_id, cfd); std::unique_lock lock(cache_mtx, std::defer_lock); From 12ac2daef0dfca631ecef26b377f915b7d9ff4c0 Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Tue, 18 Dec 2018 16:21:37 -0500 Subject: [PATCH 092/111] use `assign` instead of `resize`+`memcpy` to update `shared_blob` data Co-Authored-By: Kayan --- libraries/chain/apply_context.cpp | 6 ++---- libraries/chain/eosio_contract.cpp | 17 ++++++++++------- libraries/chain/include/eosio/chain/types.hpp | 14 +++++++++++++- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/libraries/chain/apply_context.cpp b/libraries/chain/apply_context.cpp index bedf5b4d616..1beb647eed6 100644 --- a/libraries/chain/apply_context.cpp +++ b/libraries/chain/apply_context.cpp @@ -521,9 +521,8 @@ int apply_context::db_store_i64( uint64_t code, uint64_t scope, uint64_t table, const auto& obj = db.create( [&]( auto& o ) { o.t_id = tableid; o.primary_key = id; - o.value.resize( buffer_size ); + o.value.assign( buffer, buffer_size ); o.payer = payer; - memcpy( o.value.data(), buffer, buffer_size ); }); db.modify( tab, [&]( auto& t ) { @@ -562,8 +561,7 @@ void apply_context::db_update_i64( int iterator, account_name payer, const char* } db.modify( obj, [&]( auto& o ) { - o.value.resize( buffer_size ); - memcpy( o.value.data(), buffer, buffer_size ); + o.value.assign( buffer, buffer_size ); o.payer = payer; }); } diff --git a/libraries/chain/eosio_contract.cpp b/libraries/chain/eosio_contract.cpp index 8d1a8dc7562..03e0fed7f7f 100644 --- a/libraries/chain/eosio_contract.cpp +++ b/libraries/chain/eosio_contract.cpp @@ -155,10 +155,11 @@ void apply_eosio_setcode(apply_context& context) { // TODO: update setcode message to include the hash, then validate it in validate a.last_code_update = context.control.pending_block_time(); a.code_version = code_id; - a.code.resize( code_size ); - if( code_size > 0 ) - memcpy( a.code.data(), act.code.data(), code_size ); - + if ( code_size > 0 ) { + a.code.assign(act.code.data(), code_size); + } else { + a.code.resize(0); + } }); const auto& account_sequence = db.get(act.account); @@ -185,9 +186,11 @@ void apply_eosio_setabi(apply_context& context) { int64_t new_size = abi_size; db.modify( account, [&]( auto& a ) { - a.abi.resize( abi_size ); - if( abi_size > 0 ) - memcpy( a.abi.data(), act.abi.data(), abi_size ); + if (abi_size > 0) { + a.abi.assign(act.abi.data(), abi_size); + } else { + a.abi.resize(0); + } }); const auto& account_sequence = db.get(act.account); diff --git a/libraries/chain/include/eosio/chain/types.hpp b/libraries/chain/include/eosio/chain/types.hpp index 9319a853258..d5fec0abf97 100644 --- a/libraries/chain/include/eosio/chain/types.hpp +++ b/libraries/chain/include/eosio/chain/types.hpp @@ -103,7 +103,19 @@ namespace eosio { namespace chain { */ class shared_blob : public shared_string { public: - shared_blob() = default; + shared_blob() = delete; + shared_blob(shared_blob&&) = default; + + shared_blob(const shared_blob& s) + :shared_string(s.get_allocator()) + { + assign(s.c_str(), s.size()); + } + + shared_blob &operator=(const shared_blob &s) { + assign(s.c_str(), s.size()); + return *this; + } template shared_blob(InputIterator f, InputIterator l, const allocator_type& a) From 1c8640b1757180fbe9de6df0150cad99fb240a66 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 18 Dec 2018 16:22:03 -0500 Subject: [PATCH 093/111] Add move into tuple creation --- libraries/chain/transaction_metadata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/transaction_metadata.cpp b/libraries/chain/transaction_metadata.cpp index a7ed2935107..5b275baccf9 100644 --- a/libraries/chain/transaction_metadata.cpp +++ b/libraries/chain/transaction_metadata.cpp @@ -38,7 +38,7 @@ void transaction_metadata::create_signing_keys_future( const transaction_metadat if( mtrx ) { cpu_usage = mtrx->trx.get_signature_keys( chain_id, deadline, recovered_pub_keys ); } - return std::make_tuple( chain_id, cpu_usage, recovered_pub_keys); + return std::make_tuple( chain_id, cpu_usage, std::move( recovered_pub_keys )); } ); } From 75c3e972c7ab4bef47121b5b107e95614a6ae725 Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Tue, 18 Dec 2018 17:05:10 -0500 Subject: [PATCH 094/111] bump version to 1.6.0-rc1 --- CMakeLists.txt | 2 +- Docker/README.md | 4 ++-- README.md | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21f5b281904..3c50704c691 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ set( CXX_STANDARD_REQUIRED ON) set(VERSION_MAJOR 1) set(VERSION_MINOR 6) set(VERSION_PATCH 0) -set(VERSION_SUFFIX develop) +set(VERSION_SUFFIX rc1) if(VERSION_SUFFIX) set(VERSION_FULL "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_SUFFIX}") diff --git a/Docker/README.md b/Docker/README.md index 4e22a07e419..2400c54d25f 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -20,10 +20,10 @@ cd eos/Docker docker build . -t eosio/eos ``` -The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.6.0 tag, you could do the following: +The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.6.0-rc1 tag, you could do the following: ```bash -docker build -t eosio/eos:v1.6.0 --build-arg branch=v1.6.0 . +docker build -t eosio/eos:v1.6.0-rc1 --build-arg branch=v1.6.0-rc1 . ``` By default, the symbol in eosio.system is set to SYS. You can override this using the symbol argument while building the docker image. diff --git a/README.md b/README.md index c1ce654c145..a0f62cac74e 100644 --- a/README.md +++ b/README.md @@ -39,13 +39,13 @@ $ brew remove eosio ``` #### Ubuntu 18.04 Debian Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-develop-ubuntu-18.04_amd64.deb -$ sudo apt install ./eosio_1.6.0-develop-ubuntu-18.04_amd64.deb +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-rc1-ubuntu-18.04_amd64.deb +$ sudo apt install ./eosio_1.6.0-rc1-ubuntu-18.04_amd64.deb ``` #### Ubuntu 16.04 Debian Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-develop-ubuntu-16.04_amd64.deb -$ sudo apt install ./eosio_1.6.0-develop-ubuntu-16.04_amd64.deb +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-rc1-ubuntu-16.04_amd64.deb +$ sudo apt install ./eosio_1.6.0-rc1-ubuntu-16.04_amd64.deb ``` #### Debian Package Uninstall ```sh @@ -53,8 +53,8 @@ $ sudo apt remove eosio ``` #### Centos RPM Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-develop.el7.x86_64.rpm -$ sudo yum install ./eosio-1.6.0-develop.el7.x86_64.rpm +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-rc1.el7.x86_64.rpm +$ sudo yum install ./eosio-1.6.0-rc1.el7.x86_64.rpm ``` #### Centos RPM Package Uninstall ```sh @@ -62,8 +62,8 @@ $ sudo yum remove eosio.cdt ``` #### Fedora RPM Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-develop.fc27.x86_64.rpm -$ sudo yum install ./eosio-1.6.0-develop.fc27.x86_64.rpm +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-rc1.fc27.x86_64.rpm +$ sudo yum install ./eosio-1.6.0-rc1.fc27.x86_64.rpm ``` #### Fedora RPM Package Uninstall ```sh From d02741c09f28a23ef3ca627ed21aa61d5a45f7f3 Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Tue, 18 Dec 2018 17:13:26 -0500 Subject: [PATCH 095/111] add explicitly defaulted move semantics --- libraries/chain/include/eosio/chain/types.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/chain/include/eosio/chain/types.hpp b/libraries/chain/include/eosio/chain/types.hpp index d5fec0abf97..21fbf216c43 100644 --- a/libraries/chain/include/eosio/chain/types.hpp +++ b/libraries/chain/include/eosio/chain/types.hpp @@ -112,11 +112,14 @@ namespace eosio { namespace chain { assign(s.c_str(), s.size()); } - shared_blob &operator=(const shared_blob &s) { + + shared_blob& operator=(const shared_blob& s) { assign(s.c_str(), s.size()); return *this; } + shared_blob& operator=(shared_blob&& ) = default; + template shared_blob(InputIterator f, InputIterator l, const allocator_type& a) :shared_string(f,l,a) From f53a7833c4ab8de435295905535222de9fc9092c Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Sat, 15 Dec 2018 09:55:12 -0600 Subject: [PATCH 096/111] Store unpacked_trx as signed_transaction --- .../chain/include/eosio/chain/transaction.hpp | 49 ++++--- libraries/chain/transaction.cpp | 124 +++++++----------- 2 files changed, 79 insertions(+), 94 deletions(-) diff --git a/libraries/chain/include/eosio/chain/transaction.hpp b/libraries/chain/include/eosio/chain/transaction.hpp index 909035d8d1d..5aa49438acf 100644 --- a/libraries/chain/include/eosio/chain/transaction.hpp +++ b/libraries/chain/include/eosio/chain/transaction.hpp @@ -85,8 +85,12 @@ namespace eosio { namespace chain { : transaction(std::move(trx)) , signatures(signatures) , context_free_data(context_free_data) - { - } + {} + signed_transaction( transaction&& trx, const vector& signatures, vector&& context_free_data) + : transaction(std::move(trx)) + , signatures(signatures) + , context_free_data(std::move(context_free_data)) + {} vector signatures; vector context_free_data; ///< for each context-free action, there is an entry here @@ -111,17 +115,17 @@ namespace eosio { namespace chain { packed_transaction& operator=(packed_transaction&&) = default; explicit packed_transaction(const signed_transaction& t, compression_type _compression = none) - :signatures(t.signatures), compression(_compression) + :signatures(t.signatures), compression(_compression), unpacked_trx(t) { - set_transaction(t); - set_context_free_data(t.context_free_data); + set_packed_transaction(unpacked_trx); + set_packed_context_free_data(unpacked_trx.context_free_data); } explicit packed_transaction(signed_transaction&& t, compression_type _compression = none) - :signatures(std::move(t.signatures)), compression(_compression) + :signatures(t.signatures), compression(_compression), unpacked_trx(std::move(t)) { - set_transaction(t); - set_context_free_data(t.context_free_data); + set_packed_transaction(unpacked_trx); + set_packed_context_free_data(unpacked_trx.context_free_data); } // used by abi_serializer @@ -134,25 +138,27 @@ namespace eosio { namespace chain { digest_type packed_digest()const; - time_point_sec expiration()const; - transaction_id_type id()const; - transaction_id_type get_uncached_id()const; // thread safe - bytes get_raw_transaction()const; // thread safe - vector get_context_free_data()const; - transaction get_transaction()const; - signed_transaction get_signed_transaction()const; + transaction_id_type id()const { return unpacked_trx.id(); } + bytes get_raw_transaction()const; + time_point_sec expiration()const { return unpacked_trx.expiration; } + const vector& get_context_free_data()const { return unpacked_trx.context_free_data; } + const transaction& get_transaction()const { return unpacked_trx; } + const signed_transaction& get_signed_transaction()const { return unpacked_trx; } const vector& get_signatures()const { return signatures; } const fc::enum_type& get_compression()const { return compression; } - const bytes& get_packed_context_free_data()const { return packed_context_free_data; } - const bytes& get_packed_transaction()const { return packed_trx; } + const bytes& get_packed_context_free_data()const { return packed_context_free_data; } + const bytes& get_packed_transaction()const { return packed_trx; } private: - void local_unpack()const; - void set_transaction(const transaction& t); - void set_context_free_data(const vector& cfd); + void local_unpack_context_free_data(); + void local_unpack_transaction(vector&& context_free_data); + void set_packed_transaction(const transaction& t); + void set_packed_context_free_data(const vector& cfd); friend struct fc::reflector; + friend struct fc::reflector_verifier_visitor; + void reflector_verify(); private: vector signatures; fc::enum_type compression; @@ -160,7 +166,8 @@ namespace eosio { namespace chain { bytes packed_trx; private: - mutable optional unpacked_trx; // <-- intermediate buffer used to retrieve values + // cache unpacked trx, for thread safety do not modify after construction + signed_transaction unpacked_trx; }; using packed_transaction_ptr = std::shared_ptr; diff --git a/libraries/chain/transaction.cpp b/libraries/chain/transaction.cpp index 3787e48af95..ff3083fef04 100644 --- a/libraries/chain/transaction.cpp +++ b/libraries/chain/transaction.cpp @@ -289,103 +289,81 @@ bytes packed_transaction::get_raw_transaction() const } FC_CAPTURE_AND_RETHROW((compression)(packed_trx)) } -vector packed_transaction::get_context_free_data()const -{ - try { - switch(compression) { - case none: - return unpack_context_free_data(packed_context_free_data); - case zlib: - return zlib_decompress_context_free_data(packed_context_free_data); - default: - EOS_THROW(unknown_transaction_compression, "Unknown transaction compression algorithm"); - } - } FC_CAPTURE_AND_RETHROW((compression)(packed_context_free_data)) -} - -time_point_sec packed_transaction::expiration()const +packed_transaction::packed_transaction( bytes&& packed_txn, vector&& sigs, + bytes&& packed_cfd, vector&& cfd, compression_type _compression ) +:signatures(std::move(sigs)) +,compression(_compression) +,packed_context_free_data(std::move(packed_cfd)) +,packed_trx(std::move(packed_txn)) { - local_unpack(); - return unpacked_trx->expiration; + const bool cfd_empty = cfd.empty(); + EOS_ASSERT( cfd_empty || packed_cfd.empty(), tx_decompression_error, "Invalid packed_transaction" ); + local_unpack_transaction( cfd_empty ? vector() : std::move( cfd ) ); + if( !cfd_empty ) { + set_packed_context_free_data( unpacked_trx.context_free_data ); + } else if( !packed_context_free_data.empty() ) { + local_unpack_context_free_data(); + } } -transaction_id_type packed_transaction::id()const +packed_transaction::packed_transaction( signed_transaction&& t, bytes&& packed_cfd, compression_type _compression ) +:signatures(t.signatures) +,compression(_compression) +,packed_context_free_data(std::move(packed_cfd)) +,unpacked_trx(std::move(t)) { - local_unpack(); - return get_transaction().id(); + EOS_ASSERT( packed_cfd.empty() || unpacked_trx.context_free_data.empty(), tx_decompression_error, "Invalid packed_transaction" ); + set_packed_transaction( unpacked_trx ); + if( !packed_context_free_data.empty() ) { + local_unpack_context_free_data(); + } } -transaction_id_type packed_transaction::get_uncached_id()const +void packed_transaction::reflector_verify() { - const auto raw = get_raw_transaction(); - return fc::raw::unpack( raw ).id(); + // called after construction, but always on the same thread and before packed_transaction passed to any other threads + static_assert(&fc::reflector_verifier_visitor::reflector_verify, "FC with reflector_verify required"); + static_assert(fc::raw::has_feature_reflector_verify_on_unpacked_reflected_types, + "FC unpack needs to call reflector_verify otherwise unpacked_trx will not be initialized"); + EOS_ASSERT( unpacked_trx.expiration == time_point_sec(), tx_decompression_error, "packed_transaction already unpacked" ); + local_unpack_transaction({}); + local_unpack_context_free_data(); } -void packed_transaction::local_unpack()const +void packed_transaction::local_unpack_transaction(vector&& context_free_data) { - if (!unpacked_trx) { - try { - switch(compression) { + try { + switch( compression ) { case none: - unpacked_trx = unpack_transaction(packed_trx); + unpacked_trx = signed_transaction( unpack_transaction( packed_trx ), signatures, std::move(context_free_data) ); break; case zlib: - unpacked_trx = zlib_decompress_transaction(packed_trx); + unpacked_trx = signed_transaction( zlib_decompress_transaction( packed_trx ), signatures, std::move(context_free_data) ); break; default: - EOS_THROW(unknown_transaction_compression, "Unknown transaction compression algorithm"); - } - } FC_CAPTURE_AND_RETHROW((compression)(packed_trx)) - } -} - -transaction packed_transaction::get_transaction()const -{ - local_unpack(); - return transaction(*unpacked_trx); + EOS_THROW( unknown_transaction_compression, "Unknown transaction compression algorithm" ); + } + } FC_CAPTURE_AND_RETHROW( (compression) ) } -signed_transaction packed_transaction::get_signed_transaction() const +void packed_transaction::local_unpack_context_free_data() { try { - switch(compression) { + EOS_ASSERT(unpacked_trx.context_free_data.empty(), tx_decompression_error, "packed_transaction.context_free_data not empty"); + switch( compression ) { case none: - return signed_transaction(get_transaction(), signatures, unpack_context_free_data(packed_context_free_data)); + unpacked_trx.context_free_data = unpack_context_free_data( packed_context_free_data ); + break; case zlib: - return signed_transaction(get_transaction(), signatures, zlib_decompress_context_free_data(packed_context_free_data)); + unpacked_trx.context_free_data = zlib_decompress_context_free_data( packed_context_free_data ); + break; default: - EOS_THROW(unknown_transaction_compression, "Unknown transaction compression algorithm"); + EOS_THROW( unknown_transaction_compression, "Unknown transaction compression algorithm" ); } - } FC_CAPTURE_AND_RETHROW((compression)(packed_trx)(packed_context_free_data)) - -} - -packed_transaction::packed_transaction( bytes&& packed_txn, vector&& sigs, - bytes&& packed_cfd, vector&& cfd, compression_type _compression ) -:signatures(std::move(sigs)) -,compression(_compression) -,packed_context_free_data(std::move(packed_cfd)) -,packed_trx(std::move(packed_txn)) -{ - EOS_ASSERT(packed_cfd.empty() || cfd.empty(), tx_decompression_error, "Invalid packed_transaction"); - if( !cfd.empty() ) { - set_context_free_data(cfd); - } -} - -packed_transaction::packed_transaction( signed_transaction&& t, bytes&& packed_cfd, compression_type _compression ) -:signatures(std::move(t.signatures)) -,compression(_compression) -,packed_context_free_data(std::move(packed_cfd)) -{ - set_transaction(t); - // allow passed in packed_cfd to overwrite signed_transaction.context_free_data if provided - if( packed_context_free_data.empty() ) { - set_context_free_data(t.context_free_data); - } + } FC_CAPTURE_AND_RETHROW( (compression) ) } -void packed_transaction::set_transaction(const transaction& t) +void packed_transaction::set_packed_transaction(const transaction& t) { try { switch(compression) { @@ -401,7 +379,7 @@ void packed_transaction::set_transaction(const transaction& t) } FC_CAPTURE_AND_RETHROW((compression)(t)) } -void packed_transaction::set_context_free_data(const vector& cfd) +void packed_transaction::set_packed_context_free_data(const vector& cfd) { try { switch(compression) { From 2c627f4ac1832738ff20ec7dc67dca6a01617f52 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Sat, 15 Dec 2018 09:55:57 -0600 Subject: [PATCH 097/111] get_uncached_id no longer needed for thread safety --- plugins/bnet_plugin/bnet_plugin.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/plugins/bnet_plugin/bnet_plugin.cpp b/plugins/bnet_plugin/bnet_plugin.cpp index 9cf267b6f0f..4e54df8b605 100644 --- a/plugins/bnet_plugin/bnet_plugin.cpp +++ b/plugins/bnet_plugin/bnet_plugin.cpp @@ -555,8 +555,7 @@ namespace eosio { for( const auto& receipt : s->block->transactions ) { if( receipt.trx.which() == 1 ) { const auto& pt = receipt.trx.get(); - // get id via get_uncached_id() as packed_transaction.id() mutates internal transaction state - const auto& tid = pt.get_uncached_id(); + const auto& tid = pt.id(); auto itr = _transaction_status.find( tid ); if( itr != _transaction_status.end() ) _transaction_status.erase(itr); @@ -1014,8 +1013,7 @@ namespace eosio { for( const auto& receipt : b->transactions ) { if( receipt.trx.which() == 1 ) { const auto& pt = receipt.trx.get(); - // get id via get_uncached_id() as packed_transaction.id() mutates internal transaction state - const auto& id = pt.get_uncached_id(); + const auto& id = pt.id(); mark_transaction_known_by_peer(id); } } @@ -1552,8 +1550,7 @@ namespace eosio { // ilog( "recv trx ${n}", ("n", id) ); if( p->expiration() < fc::time_point::now() ) return; - // get id via get_uncached_id() as packed_transaction.id() mutates internal transaction state - const auto& id = p->get_uncached_id(); + const auto& id = p->id(); if( mark_transaction_known_by_peer( id ) ) return; From 695488a497f09a42a116360f151cde6c3ff5d128 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Sat, 15 Dec 2018 09:56:30 -0600 Subject: [PATCH 098/111] get_raw_transaction no longer needed for thread safety --- plugins/mongo_db_plugin/mongo_db_plugin.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/mongo_db_plugin/mongo_db_plugin.cpp b/plugins/mongo_db_plugin/mongo_db_plugin.cpp index ea39c11f1a8..f377cf50a19 100644 --- a/plugins/mongo_db_plugin/mongo_db_plugin.cpp +++ b/plugins/mongo_db_plugin/mongo_db_plugin.cpp @@ -1095,11 +1095,8 @@ void mongo_db_plugin_impl::_process_irreversible_block(const chain::block_state_ string trx_id_str; if( receipt.trx.contains() ) { const auto& pt = receipt.trx.get(); - // get id via get_raw_transaction() as packed_transaction.id() mutates internal transaction state - const auto& raw = pt.get_raw_transaction(); - const auto& trx = fc::raw::unpack( raw ); - if( !filter_include( trx ) ) continue; - const auto& id = trx.id(); + if( !filter_include( pt.get_signed_transaction() ) ) continue; + const auto& id = pt.id(); trx_id_str = id.str(); } else { const auto& id = receipt.trx.get(); From 4ef352760fa197333538f4e74d26a481d1ea328d Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Sat, 15 Dec 2018 10:49:23 -0600 Subject: [PATCH 099/111] Remove cached signed_transaction since now cached in packed_transaction --- libraries/chain/controller.cpp | 9 +++++---- .../chain/include/eosio/chain/transaction_metadata.hpp | 8 +++----- libraries/chain/transaction_metadata.cpp | 5 +++-- plugins/bnet_plugin/bnet_plugin.cpp | 2 +- plugins/mongo_db_plugin/mongo_db_plugin.cpp | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index e46f65bf11f..98b2065d1e1 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -1009,7 +1009,8 @@ struct controller_impl { } } - transaction_context trx_context(self, trx->trx, trx->id, start); + const signed_transaction& trn = trx->packed_trx->get_signed_transaction(); + transaction_context trx_context(self, trn, trx->id, start); if ((bool)subjective_cpu_leeway && pending->_block_status == controller::block_status::incomplete) { trx_context.leeway = *subjective_cpu_leeway; } @@ -1022,17 +1023,17 @@ struct controller_impl { trx_context.init_for_implicit_trx(); trx_context.enforce_whiteblacklist = false; } else { - bool skip_recording = replay_head_time && (time_point(trx->trx.expiration) <= *replay_head_time); + bool skip_recording = replay_head_time && (time_point(trn.expiration) <= *replay_head_time); trx_context.init_for_input_trx( trx->packed_trx->get_unprunable_size(), trx->packed_trx->get_prunable_size(), skip_recording); } - trx_context.delay = fc::seconds(trx->trx.delay_sec); + trx_context.delay = fc::seconds(trn.delay_sec); if( !self.skip_auth_check() && !trx->implicit ) { authorization.check_authorization( - trx->trx.actions, + trn.actions, trx->recover_keys( chain_id ), {}, trx_context.delay, diff --git a/libraries/chain/include/eosio/chain/transaction_metadata.hpp b/libraries/chain/include/eosio/chain/transaction_metadata.hpp index 1ab184b73b0..6136580fa44 100644 --- a/libraries/chain/include/eosio/chain/transaction_metadata.hpp +++ b/libraries/chain/include/eosio/chain/transaction_metadata.hpp @@ -23,7 +23,6 @@ class transaction_metadata { public: transaction_id_type id; transaction_id_type signed_id; - signed_transaction trx; packed_transaction_ptr packed_trx; fc::microseconds sig_cpu_usage; optional>> signing_keys; @@ -40,13 +39,13 @@ class transaction_metadata { transaction_metadata operator=(transaction_metadata&&) = delete; explicit transaction_metadata( const signed_transaction& t, packed_transaction::compression_type c = packed_transaction::none ) - :id(t.id()), trx(t), packed_trx(std::make_shared(t, c)) { + :id(t.id()), packed_trx(std::make_shared(t, c)) { //raw_packed = fc::raw::pack( static_cast(trx) ); signed_id = digest_type::hash(*packed_trx); } explicit transaction_metadata( const packed_transaction_ptr& ptrx ) - :id(ptrx->id()), trx( ptrx->get_signed_transaction() ), packed_trx(ptrx) { + :id(ptrx->id()), packed_trx(ptrx) { //raw_packed = fc::raw::pack( static_cast(trx) ); signed_id = digest_type::hash(*packed_trx); } @@ -54,9 +53,8 @@ class transaction_metadata { const flat_set& recover_keys( const chain_id_type& chain_id ); static void create_signing_keys_future( const transaction_metadata_ptr& mtrx, boost::asio::thread_pool& thread_pool, - const chain_id_type& chain_id, fc::microseconds timelimit ); + const chain_id_type& chain_id, fc::microseconds time_limit ); - uint32_t total_actions()const { return trx.context_free_actions.size() + trx.actions.size(); } }; } } // eosio::chain diff --git a/libraries/chain/transaction_metadata.cpp b/libraries/chain/transaction_metadata.cpp index 5b275baccf9..2053669c0d7 100644 --- a/libraries/chain/transaction_metadata.cpp +++ b/libraries/chain/transaction_metadata.cpp @@ -17,7 +17,7 @@ const flat_set& transaction_metadata::recover_keys( const chain } } flat_set recovered_pub_keys; - sig_cpu_usage = trx.get_signature_keys( chain_id, fc::time_point::maximum(), recovered_pub_keys ); + sig_cpu_usage = packed_trx->get_signed_transaction().get_signature_keys( chain_id, fc::time_point::maximum(), recovered_pub_keys ); signing_keys.emplace( chain_id, std::move( recovered_pub_keys )); } return signing_keys->second; @@ -36,7 +36,8 @@ void transaction_metadata::create_signing_keys_future( const transaction_metadat fc::microseconds cpu_usage; flat_set recovered_pub_keys; if( mtrx ) { - cpu_usage = mtrx->trx.get_signature_keys( chain_id, deadline, recovered_pub_keys ); + const signed_transaction& trn = mtrx->packed_trx->get_signed_transaction(); + cpu_usage = trn.get_signature_keys( chain_id, deadline, recovered_pub_keys ); } return std::make_tuple( chain_id, cpu_usage, std::move( recovered_pub_keys )); } ); diff --git a/plugins/bnet_plugin/bnet_plugin.cpp b/plugins/bnet_plugin/bnet_plugin.cpp index 4e54df8b605..b25631cbabc 100644 --- a/plugins/bnet_plugin/bnet_plugin.cpp +++ b/plugins/bnet_plugin/bnet_plugin.cpp @@ -441,7 +441,7 @@ namespace eosio { if( itr != _transaction_status.end() ) { if( !itr->known_by_peer() ) { _transaction_status.modify( itr, [&]( auto& stat ) { - stat.expired = std::min( fc::time_point::now() + fc::seconds(5), t->trx.expiration ); + stat.expired = std::min( fc::time_point::now() + fc::seconds(5), t->packed_trx->expiration() ); }); } return; diff --git a/plugins/mongo_db_plugin/mongo_db_plugin.cpp b/plugins/mongo_db_plugin/mongo_db_plugin.cpp index f377cf50a19..70327c3d96b 100644 --- a/plugins/mongo_db_plugin/mongo_db_plugin.cpp +++ b/plugins/mongo_db_plugin/mongo_db_plugin.cpp @@ -734,7 +734,7 @@ void mongo_db_plugin_impl::_process_accepted_transaction( const chain::transacti using bsoncxx::builder::basic::make_array; namespace bbb = bsoncxx::builder::basic; - const auto& trx = t->trx; + const signed_transaction& trx = t->packed_trx->get_signed_transaction(); if( !filter_include( trx ) ) return; From 04e276cc30a53074cbf2fcf25b5d3ff0ca2bc56f Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Sat, 15 Dec 2018 15:38:14 -0600 Subject: [PATCH 100/111] Test should honor existing compression --- unittests/block_tests.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/unittests/block_tests.cpp b/unittests/block_tests.cpp index 1b0ead1c636..045255da6d9 100644 --- a/unittests/block_tests.cpp +++ b/unittests/block_tests.cpp @@ -58,13 +58,14 @@ std::pair corrupt_trx_in_block(validating_te // Make a copy of the valid block and corrupt the transaction auto copy_b = std::make_shared(b->clone()); - auto signed_tx = copy_b->transactions.back().trx.get().get_signed_transaction(); + const auto& packed_trx = copy_b->transactions.back().trx.get(); + auto signed_tx = packed_trx.get_signed_transaction(); // Corrupt one signature signed_tx.signatures.clear(); signed_tx.sign(main.get_private_key(act_name, "active"), main.control->get_chain_id()); // Replace the valid transaction with the invalid transaction - auto invalid_packed_tx = packed_transaction(signed_tx); + auto invalid_packed_tx = packed_transaction(signed_tx, packed_trx.get_compression()); copy_b->transactions.back().trx = invalid_packed_tx; // Re-calculate the transaction merkle From 20e219efea208c4fc35845cefe87318dc4b740d8 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 17 Dec 2018 12:00:37 -0500 Subject: [PATCH 101/111] Cleanup of packed_transaction interface. Fixes for comments on PR #6471 --- .../include/eosio/chain/abi_serializer.hpp | 37 +++++++++------ .../chain/include/eosio/chain/transaction.hpp | 20 ++++----- libraries/chain/transaction.cpp | 45 ++++++++++--------- 3 files changed, 58 insertions(+), 44 deletions(-) diff --git a/libraries/chain/include/eosio/chain/abi_serializer.hpp b/libraries/chain/include/eosio/chain/abi_serializer.hpp index 62a034ca859..75cc8a51ee4 100644 --- a/libraries/chain/include/eosio/chain/abi_serializer.hpp +++ b/libraries/chain/include/eosio/chain/abi_serializer.hpp @@ -583,27 +583,36 @@ namespace impl { from_variant(vo["compression"], compression); bytes packed_cfd; + std::vector cfd; + bool use_packed_cfd = false; + if( vo.contains("packed_context_free_data") && vo["packed_context_free_data"].is_string() && !vo["packed_context_free_data"].as_string().empty() ) { + from_variant(vo["packed_context_free_data"], packed_cfd ); + use_packed_cfd = true; + } else if( vo.contains("context_free_data") ) { + from_variant(vo["context_free_data"], cfd); + } + if( vo.contains("packed_trx") && vo["packed_trx"].is_string() && !vo["packed_trx"].as_string().empty() ) { bytes packed_trx; - std::vector cfd; from_variant(vo["packed_trx"], packed_trx); - if( vo.contains("packed_context_free_data") && vo["packed_context_free_data"].is_string() && !vo["packed_context_free_data"].as_string().empty() ) { - from_variant(vo["packed_context_free_data"], packed_cfd ); - } else if( vo.contains("context_free_data") ) { - from_variant(vo["context_free_data"], cfd); + if( use_packed_cfd ) { + ptrx = packed_transaction( std::move( packed_trx ), std::move( signatures ), std::move( packed_cfd ), compression ); + } else { + ptrx = packed_transaction( std::move( packed_trx ), std::move( signatures ), std::move( cfd ), compression ); } - ptrx = packed_transaction( std::move(packed_trx), std::move(signatures), std::move(packed_cfd), std::move(cfd), compression ); } else { EOS_ASSERT(vo.contains("transaction"), packed_transaction_type_exception, "Missing transaction"); - signed_transaction trx; - trx.signatures = std::move(signatures); - extract(vo["transaction"], trx, resolver, ctx); - if( vo.contains("packed_context_free_data") && vo["packed_context_free_data"].is_string() && !vo["packed_context_free_data"].as_string().empty() ) { - from_variant(vo["packed_context_free_data"], packed_cfd ); - } else if( vo.contains("context_free_data") ) { - from_variant(vo["context_free_data"], trx.context_free_data ); + if( use_packed_cfd ) { + transaction trx; + extract( vo["transaction"], trx, resolver, ctx ); + ptrx = packed_transaction( std::move(trx), std::move(signatures), std::move(packed_cfd), compression ); + } else { + signed_transaction trx; + extract( vo["transaction"], trx, resolver, ctx ); + trx.signatures = std::move( signatures ); + trx.context_free_data = std::move(cfd); + ptrx = packed_transaction( std::move( trx ), compression ); } - ptrx = packed_transaction( std::move(trx), std::move(packed_cfd), compression ); } } }; diff --git a/libraries/chain/include/eosio/chain/transaction.hpp b/libraries/chain/include/eosio/chain/transaction.hpp index 5aa49438acf..60ac50d0413 100644 --- a/libraries/chain/include/eosio/chain/transaction.hpp +++ b/libraries/chain/include/eosio/chain/transaction.hpp @@ -117,21 +117,21 @@ namespace eosio { namespace chain { explicit packed_transaction(const signed_transaction& t, compression_type _compression = none) :signatures(t.signatures), compression(_compression), unpacked_trx(t) { - set_packed_transaction(unpacked_trx); - set_packed_context_free_data(unpacked_trx.context_free_data); + local_pack_transaction(); + local_pack_context_free_data(); } explicit packed_transaction(signed_transaction&& t, compression_type _compression = none) :signatures(t.signatures), compression(_compression), unpacked_trx(std::move(t)) { - set_packed_transaction(unpacked_trx); - set_packed_context_free_data(unpacked_trx.context_free_data); + local_pack_transaction(); + local_pack_context_free_data(); } // used by abi_serializer - explicit packed_transaction( bytes&& packed_txn, vector&& sigs, - bytes&& packed_cfd, vector&& cfd, compression_type _compression ); - explicit packed_transaction( signed_transaction&& t, bytes&& packed_cfd, compression_type _compression ); + packed_transaction( bytes&& packed_txn, vector&& sigs, bytes&& packed_cfd, compression_type _compression ); + packed_transaction( bytes&& packed_txn, vector&& sigs, vector&& cfd, compression_type _compression ); + packed_transaction( transaction&& t, vector&& sigs, bytes&& packed_cfd, compression_type _compression ); uint32_t get_unprunable_size()const; uint32_t get_prunable_size()const; @@ -151,10 +151,10 @@ namespace eosio { namespace chain { const bytes& get_packed_transaction()const { return packed_trx; } private: - void local_unpack_context_free_data(); void local_unpack_transaction(vector&& context_free_data); - void set_packed_transaction(const transaction& t); - void set_packed_context_free_data(const vector& cfd); + void local_unpack_context_free_data(); + void local_pack_transaction(); + void local_pack_context_free_data(); friend struct fc::reflector; friend struct fc::reflector_verifier_visitor; diff --git a/libraries/chain/transaction.cpp b/libraries/chain/transaction.cpp index ff3083fef04..d185e693ed1 100644 --- a/libraries/chain/transaction.cpp +++ b/libraries/chain/transaction.cpp @@ -289,31 +289,36 @@ bytes packed_transaction::get_raw_transaction() const } FC_CAPTURE_AND_RETHROW((compression)(packed_trx)) } -packed_transaction::packed_transaction( bytes&& packed_txn, vector&& sigs, - bytes&& packed_cfd, vector&& cfd, compression_type _compression ) +packed_transaction::packed_transaction( bytes&& packed_txn, vector&& sigs, bytes&& packed_cfd, compression_type _compression ) :signatures(std::move(sigs)) ,compression(_compression) ,packed_context_free_data(std::move(packed_cfd)) ,packed_trx(std::move(packed_txn)) { - const bool cfd_empty = cfd.empty(); - EOS_ASSERT( cfd_empty || packed_cfd.empty(), tx_decompression_error, "Invalid packed_transaction" ); - local_unpack_transaction( cfd_empty ? vector() : std::move( cfd ) ); - if( !cfd_empty ) { - set_packed_context_free_data( unpacked_trx.context_free_data ); - } else if( !packed_context_free_data.empty() ) { + local_unpack_transaction({}); + if( !packed_context_free_data.empty() ) { local_unpack_context_free_data(); } } -packed_transaction::packed_transaction( signed_transaction&& t, bytes&& packed_cfd, compression_type _compression ) -:signatures(t.signatures) +packed_transaction::packed_transaction( bytes&& packed_txn, vector&& sigs, vector&& cfd, compression_type _compression ) +:signatures(std::move(sigs)) +,compression(_compression) +,packed_trx(std::move(packed_txn)) +{ + local_unpack_transaction( std::move( cfd ) ); + if( !unpacked_trx.context_free_data.empty() ) { + local_pack_context_free_data(); + } +} + +packed_transaction::packed_transaction( transaction&& t, vector&& sigs, bytes&& packed_cfd, compression_type _compression ) +:signatures(std::move(sigs)) ,compression(_compression) ,packed_context_free_data(std::move(packed_cfd)) -,unpacked_trx(std::move(t)) +,unpacked_trx(std::move(t), signatures, {}) { - EOS_ASSERT( packed_cfd.empty() || unpacked_trx.context_free_data.empty(), tx_decompression_error, "Invalid packed_transaction" ); - set_packed_transaction( unpacked_trx ); + local_pack_transaction(); if( !packed_context_free_data.empty() ) { local_unpack_context_free_data(); } @@ -363,31 +368,31 @@ void packed_transaction::local_unpack_context_free_data() } FC_CAPTURE_AND_RETHROW( (compression) ) } -void packed_transaction::set_packed_transaction(const transaction& t) +void packed_transaction::local_pack_transaction() { try { switch(compression) { case none: - packed_trx = pack_transaction(t); + packed_trx = pack_transaction(unpacked_trx); break; case zlib: - packed_trx = zlib_compress_transaction(t); + packed_trx = zlib_compress_transaction(unpacked_trx); break; default: EOS_THROW(unknown_transaction_compression, "Unknown transaction compression algorithm"); } - } FC_CAPTURE_AND_RETHROW((compression)(t)) + } FC_CAPTURE_AND_RETHROW((compression)) } -void packed_transaction::set_packed_context_free_data(const vector& cfd) +void packed_transaction::local_pack_context_free_data() { try { switch(compression) { case none: - packed_context_free_data = pack_context_free_data(cfd); + packed_context_free_data = pack_context_free_data(unpacked_trx.context_free_data); break; case zlib: - packed_context_free_data = zlib_compress_context_free_data(cfd); + packed_context_free_data = zlib_compress_context_free_data(unpacked_trx.context_free_data); break; default: EOS_THROW(unknown_transaction_compression, "Unknown transaction compression algorithm"); From b4d08029434d86c9b504e72878b6e5de064f2f44 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 17 Dec 2018 12:02:37 -0500 Subject: [PATCH 102/111] Update to fc with unpack verify --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index a8613d3786c..91a15a59838 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit a8613d3786cddfcc336808d2b9b7df655e6cc6d1 +Subproject commit 91a15a598384e663177323d02b48aa317be70d92 From 81980a836005b9b13aefaf6f4dd1914e248c6fa7 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Mon, 17 Dec 2018 18:13:17 -0500 Subject: [PATCH 103/111] fc renamed reflector_verify to reflector_init --- libraries/chain/chain_id_type.cpp | 2 +- libraries/chain/include/eosio/chain/abi_serializer.hpp | 4 ++-- libraries/chain/include/eosio/chain/asset.hpp | 2 +- libraries/chain/include/eosio/chain/chain_id_type.hpp | 2 +- libraries/chain/include/eosio/chain/symbol.hpp | 2 +- libraries/chain/include/eosio/chain/transaction.hpp | 4 ++-- libraries/chain/transaction.cpp | 8 ++++---- libraries/fc | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libraries/chain/chain_id_type.cpp b/libraries/chain/chain_id_type.cpp index 898b8170d1d..634d4623c98 100644 --- a/libraries/chain/chain_id_type.cpp +++ b/libraries/chain/chain_id_type.cpp @@ -8,7 +8,7 @@ namespace eosio { namespace chain { - void chain_id_type::reflector_verify()const { + void chain_id_type::reflector_init()const { EOS_ASSERT( *reinterpret_cast(this) != fc::sha256(), chain_id_type_exception, "chain_id_type cannot be zero" ); } diff --git a/libraries/chain/include/eosio/chain/abi_serializer.hpp b/libraries/chain/include/eosio/chain/abi_serializer.hpp index 75cc8a51ee4..8f8fca4cdeb 100644 --- a/libraries/chain/include/eosio/chain/abi_serializer.hpp +++ b/libraries/chain/include/eosio/chain/abi_serializer.hpp @@ -625,11 +625,11 @@ namespace impl { * @tparam Reslover - callable with the signature (const name& code_account) -> optional */ template - class abi_from_variant_visitor : reflector_verifier_visitor + class abi_from_variant_visitor : reflector_init_visitor { public: abi_from_variant_visitor( const variant_object& _vo, T& v, Resolver _resolver, abi_traverse_context& _ctx ) - : reflector_verifier_visitor(v) + : reflector_init_visitor(v) ,_vo(_vo) ,_resolver(_resolver) ,_ctx(_ctx) diff --git a/libraries/chain/include/eosio/chain/asset.hpp b/libraries/chain/include/eosio/chain/asset.hpp index a1855619b97..5c9bb9669bc 100644 --- a/libraries/chain/include/eosio/chain/asset.hpp +++ b/libraries/chain/include/eosio/chain/asset.hpp @@ -84,7 +84,7 @@ struct asset friend struct fc::reflector; - void reflector_verify()const { + void reflector_init()const { EOS_ASSERT( is_amount_within_range(), asset_type_exception, "magnitude of asset amount must be less than 2^62" ); EOS_ASSERT( sym.valid(), asset_type_exception, "invalid symbol" ); } diff --git a/libraries/chain/include/eosio/chain/chain_id_type.hpp b/libraries/chain/include/eosio/chain/chain_id_type.hpp index c227bd15d0c..a16fc143ae6 100644 --- a/libraries/chain/include/eosio/chain/chain_id_type.hpp +++ b/libraries/chain/include/eosio/chain/chain_id_type.hpp @@ -34,7 +34,7 @@ namespace chain { return ds; } - void reflector_verify()const; + void reflector_init()const; private: chain_id_type() = default; diff --git a/libraries/chain/include/eosio/chain/symbol.hpp b/libraries/chain/include/eosio/chain/symbol.hpp index f32541ed61c..437b1d36ab7 100644 --- a/libraries/chain/include/eosio/chain/symbol.hpp +++ b/libraries/chain/include/eosio/chain/symbol.hpp @@ -137,7 +137,7 @@ namespace eosio { return ds << s.to_string(); } - void reflector_verify()const { + void reflector_init()const { EOS_ASSERT( decimals() <= max_precision, symbol_type_exception, "precision ${p} should be <= 18", ("p", decimals()) ); EOS_ASSERT( valid_name(name()), symbol_type_exception, "invalid symbol: ${name}", ("name",name())); } diff --git a/libraries/chain/include/eosio/chain/transaction.hpp b/libraries/chain/include/eosio/chain/transaction.hpp index 60ac50d0413..a8b53b98e0d 100644 --- a/libraries/chain/include/eosio/chain/transaction.hpp +++ b/libraries/chain/include/eosio/chain/transaction.hpp @@ -157,8 +157,8 @@ namespace eosio { namespace chain { void local_pack_context_free_data(); friend struct fc::reflector; - friend struct fc::reflector_verifier_visitor; - void reflector_verify(); + friend struct fc::reflector_init_visitor; + void reflector_init(); private: vector signatures; fc::enum_type compression; diff --git a/libraries/chain/transaction.cpp b/libraries/chain/transaction.cpp index d185e693ed1..2724a31b28d 100644 --- a/libraries/chain/transaction.cpp +++ b/libraries/chain/transaction.cpp @@ -324,12 +324,12 @@ packed_transaction::packed_transaction( transaction&& t, vector& } } -void packed_transaction::reflector_verify() +void packed_transaction::reflector_init() { // called after construction, but always on the same thread and before packed_transaction passed to any other threads - static_assert(&fc::reflector_verifier_visitor::reflector_verify, "FC with reflector_verify required"); - static_assert(fc::raw::has_feature_reflector_verify_on_unpacked_reflected_types, - "FC unpack needs to call reflector_verify otherwise unpacked_trx will not be initialized"); + static_assert(&fc::reflector_init_visitor::reflector_init, "FC with reflector_init required"); + static_assert(fc::raw::has_feature_reflector_init_on_unpacked_reflected_types, + "FC unpack needs to call reflector_init otherwise unpacked_trx will not be initialized"); EOS_ASSERT( unpacked_trx.expiration == time_point_sec(), tx_decompression_error, "packed_transaction already unpacked" ); local_unpack_transaction({}); local_unpack_context_free_data(); diff --git a/libraries/fc b/libraries/fc index 91a15a59838..37bd1c82b1a 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 91a15a598384e663177323d02b48aa317be70d92 +Subproject commit 37bd1c82b1ac09cac3ec8508761a4369f73ac19d From 1466c8079547372eb5d2c04bec7c702ee3b08e1a Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Tue, 18 Dec 2018 18:07:16 -0500 Subject: [PATCH 104/111] Update to latest fc with updated verify_init --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 37bd1c82b1a..a6bbb25c3d3 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 37bd1c82b1ac09cac3ec8508761a4369f73ac19d +Subproject commit a6bbb25c3d395b8ccc62314311822db89569eb9d From e9a5ff743770752c771749e585f5bf845afdae16 Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Wed, 2 Jan 2019 16:18:58 -0500 Subject: [PATCH 105/111] bump version to 1.6.0-rc2 --- CMakeLists.txt | 2 +- Docker/README.md | 4 ++-- README.md | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c50704c691..d4e77323b74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ set( CXX_STANDARD_REQUIRED ON) set(VERSION_MAJOR 1) set(VERSION_MINOR 6) set(VERSION_PATCH 0) -set(VERSION_SUFFIX rc1) +set(VERSION_SUFFIX rc2) if(VERSION_SUFFIX) set(VERSION_FULL "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_SUFFIX}") diff --git a/Docker/README.md b/Docker/README.md index 2400c54d25f..b8c73c7fc28 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -20,10 +20,10 @@ cd eos/Docker docker build . -t eosio/eos ``` -The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.6.0-rc1 tag, you could do the following: +The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.6.0-rc2 tag, you could do the following: ```bash -docker build -t eosio/eos:v1.6.0-rc1 --build-arg branch=v1.6.0-rc1 . +docker build -t eosio/eos:v1.6.0-rc2 --build-arg branch=v1.6.0-rc2 . ``` By default, the symbol in eosio.system is set to SYS. You can override this using the symbol argument while building the docker image. diff --git a/README.md b/README.md index a0f62cac74e..9b4d554959a 100644 --- a/README.md +++ b/README.md @@ -39,13 +39,13 @@ $ brew remove eosio ``` #### Ubuntu 18.04 Debian Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-rc1-ubuntu-18.04_amd64.deb -$ sudo apt install ./eosio_1.6.0-rc1-ubuntu-18.04_amd64.deb +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-rc2-ubuntu-18.04_amd64.deb +$ sudo apt install ./eosio_1.6.0-rc2-ubuntu-18.04_amd64.deb ``` #### Ubuntu 16.04 Debian Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-rc1-ubuntu-16.04_amd64.deb -$ sudo apt install ./eosio_1.6.0-rc1-ubuntu-16.04_amd64.deb +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-rc2-ubuntu-16.04_amd64.deb +$ sudo apt install ./eosio_1.6.0-rc2-ubuntu-16.04_amd64.deb ``` #### Debian Package Uninstall ```sh @@ -53,8 +53,8 @@ $ sudo apt remove eosio ``` #### Centos RPM Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-rc1.el7.x86_64.rpm -$ sudo yum install ./eosio-1.6.0-rc1.el7.x86_64.rpm +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-rc2.el7.x86_64.rpm +$ sudo yum install ./eosio-1.6.0-rc2.el7.x86_64.rpm ``` #### Centos RPM Package Uninstall ```sh @@ -62,8 +62,8 @@ $ sudo yum remove eosio.cdt ``` #### Fedora RPM Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-rc1.fc27.x86_64.rpm -$ sudo yum install ./eosio-1.6.0-rc1.fc27.x86_64.rpm +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-rc2.fc27.x86_64.rpm +$ sudo yum install ./eosio-1.6.0-rc2.fc27.x86_64.rpm ``` #### Fedora RPM Package Uninstall ```sh From 839d0dc7a6f49ec9e50a8eb67887a9b2ac9a9a19 Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Wed, 2 Jan 2019 15:29:30 -0500 Subject: [PATCH 106/111] Consolidated Security Fixes for 1.6.0-rc2 - Add missing implementation of dtor, copy ctor, etc for blob_types of fc::variant Co-Authored-By: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index a6bbb25c3d3..b2fa419ddf6 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit a6bbb25c3d395b8ccc62314311822db89569eb9d +Subproject commit b2fa419ddf68c6b5fc902de53cf8e691206cc8f3 From 68bd6609d2d541d3f7582fcacfc775d0c5638ced Mon Sep 17 00:00:00 2001 From: dixia Date: Fri, 4 Jan 2019 14:37:28 +0800 Subject: [PATCH 107/111] update developer portal link update the getting started link to the latest version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b4d554959a..1114685a749 100644 --- a/README.md +++ b/README.md @@ -92,4 +92,4 @@ EOSIO currently supports the following operating systems: ## Getting Started -Instructions detailing the process of getting the software, building it, running a simple test network that produces blocks, account creation and uploading a sample contract to the blockchain can be found in [Getting Started](https://developers.eos.io/eosio-nodeos/docs/overview-1) on the [EOSIO Developer Portal](https://developers.eos.io). +Instructions detailing the process of getting the software, building it, running a simple test network that produces blocks, account creation and uploading a sample contract to the blockchain can be found in [Getting Started](https://developers.eos.io/eosio-home/docs) on the [EOSIO Developer Portal](https://developers.eos.io). From 640c499ab47fc8f525ee48de1e9076e3a562777e Mon Sep 17 00:00:00 2001 From: Robin B Date: Sat, 12 Jan 2019 04:00:18 +0100 Subject: [PATCH 108/111] Use https url for wabt submodule A user agent that doesn't respect hsts could potentially be coerced into downloading malicious sources for wabt via a mitm attack. Prevent this by using a https upstream like the other submodules already do --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 7d0f8a37f7b..205a731ffce 100644 --- a/.gitmodules +++ b/.gitmodules @@ -29,4 +29,4 @@ url = https://github.com/EOSIO/fc [submodule "libraries/wabt"] path = libraries/wabt - url = http://github.com/EOSIO/wabt + url = https://github.com/EOSIO/wabt From 7d8074aa3dd58c3aca2e7fa084b5dc4a8f430e13 Mon Sep 17 00:00:00 2001 From: Jonathan Giszczak Date: Mon, 14 Jan 2019 15:47:09 -0600 Subject: [PATCH 109/111] Add libtinfo5 dependency to deb package. Resolves #6590 Also clean up unused variables and force control directory permissions to comply with Debian specifications regardless of umask. --- scripts/generate_deb.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/scripts/generate_deb.sh b/scripts/generate_deb.sh index c4d50132847..9af16c069f3 100644 --- a/scripts/generate_deb.sh +++ b/scripts/generate_deb.sh @@ -13,19 +13,16 @@ fi NAME="${PROJECT}_${VERSION_NO_SUFFIX}-${RELEASE}_amd64" -DEPS_STR="" -for dep in "${DEPS[@]}"; do - DEPS_STR="${DEPS_STR} Depends: ${dep}" -done mkdir -p ${PROJECT}/DEBIAN -echo "Package: ${PROJECT} +chmod 0755 ${PROJECT}/DEBIAN +echo "Package: ${PROJECT} Version: ${VERSION_NO_SUFFIX}-${RELEASE} Section: devel Priority: optional -Depends: libbz2-dev (>= 1.0), libssl-dev (>= 1.0), libgmp3-dev, build-essential, libicu-dev, zlib1g-dev +Depends: libbz2-dev (>= 1.0), libssl-dev (>= 1.0), libgmp3-dev, build-essential, libicu-dev, zlib1g-dev, libtinfo5 Architecture: amd64 -Homepage: ${URL} -Maintainer: ${EMAIL} +Homepage: ${URL} +Maintainer: ${EMAIL} Description: ${DESC}" &> ${PROJECT}/DEBIAN/control export PREFIX @@ -35,8 +32,8 @@ export SSUBPREFIX bash generate_tarball.sh ${NAME}.tar.gz -tar -xvzf ${NAME}.tar.gz -C ${PROJECT} -dpkg-deb --build ${PROJECT} +tar -xvzf ${NAME}.tar.gz -C ${PROJECT} +dpkg-deb --build ${PROJECT} BUILDSTATUS=$? mv ${PROJECT}.deb ${NAME}.deb rm -r ${PROJECT} From 847e9a083d14067b36d37c866b840ad200c56e17 Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Tue, 15 Jan 2019 14:48:32 -0500 Subject: [PATCH 110/111] Bump version to 1.6.0 --- CMakeLists.txt | 1 - Docker/README.md | 4 ++-- README.md | 16 ++++++++-------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d4e77323b74..fc57979b0e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,6 @@ set( CXX_STANDARD_REQUIRED ON) set(VERSION_MAJOR 1) set(VERSION_MINOR 6) set(VERSION_PATCH 0) -set(VERSION_SUFFIX rc2) if(VERSION_SUFFIX) set(VERSION_FULL "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_SUFFIX}") diff --git a/Docker/README.md b/Docker/README.md index b8c73c7fc28..834f44ac39e 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -20,10 +20,10 @@ cd eos/Docker docker build . -t eosio/eos ``` -The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.6.0-rc2 tag, you could do the following: +The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the 1.6.0 tag, you could do the following: ```bash -docker build -t eosio/eos:v1.6.0-rc2 --build-arg branch=v1.6.0-rc2 . +docker build -t eosio/eos:1.6.0 --build-arg branch=1.6.0 . ``` By default, the symbol in eosio.system is set to SYS. You can override this using the symbol argument while building the docker image. diff --git a/README.md b/README.md index 1114685a749..17dfe24052b 100644 --- a/README.md +++ b/README.md @@ -39,13 +39,13 @@ $ brew remove eosio ``` #### Ubuntu 18.04 Debian Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-rc2-ubuntu-18.04_amd64.deb -$ sudo apt install ./eosio_1.6.0-rc2-ubuntu-18.04_amd64.deb +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-1-ubuntu-18.04_amd64.deb +$ sudo apt install ./eosio_1.6.0-1-ubuntu-18.04_amd64.deb ``` #### Ubuntu 16.04 Debian Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-rc2-ubuntu-16.04_amd64.deb -$ sudo apt install ./eosio_1.6.0-rc2-ubuntu-16.04_amd64.deb +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio_1.6.0-1-ubuntu-16.04_amd64.deb +$ sudo apt install ./eosio_1.6.0-1-ubuntu-16.04_amd64.deb ``` #### Debian Package Uninstall ```sh @@ -53,8 +53,8 @@ $ sudo apt remove eosio ``` #### Centos RPM Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-rc2.el7.x86_64.rpm -$ sudo yum install ./eosio-1.6.0-rc2.el7.x86_64.rpm +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-1.el7.x86_64.rpm +$ sudo yum install ./eosio-1.6.0-1.el7.x86_64.rpm ``` #### Centos RPM Package Uninstall ```sh @@ -62,8 +62,8 @@ $ sudo yum remove eosio.cdt ``` #### Fedora RPM Package Install ```sh -$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-rc2.fc27.x86_64.rpm -$ sudo yum install ./eosio-1.6.0-rc2.fc27.x86_64.rpm +$ wget https://github.com/eosio/eos/releases/download/v1.6.0/eosio-1.6.0-1.fc27.x86_64.rpm +$ sudo yum install ./eosio-1.6.0-1.fc27.x86_64.rpm ``` #### Fedora RPM Package Uninstall ```sh From fe95e039be837f48fac5902bd0052e7e0144d363 Mon Sep 17 00:00:00 2001 From: Bart Wyatt Date: Tue, 15 Jan 2019 13:50:51 -0500 Subject: [PATCH 111/111] Consolidated Security Fixes for 1.6.0 - Force compilation support for c++ exceptions for the wabt submodule - Allow limiting the time a node will spend processing scheduled transactions Co-Authored-By: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Co-Authored-By: Bart Wyatt --- libraries/CMakeLists.txt | 3 +- .../eosio/producer_plugin/producer_plugin.hpp | 1 + plugins/producer_plugin/producer_plugin.cpp | 67 +++++++++++++------ 3 files changed, 50 insertions(+), 21 deletions(-) diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 18013317c57..eeaf5afa771 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -7,8 +7,9 @@ add_subdirectory( appbase ) add_subdirectory( chain ) add_subdirectory( testing ) -#turn these off for now +#turn tools&tests off; not needed for library build set(BUILD_TESTS OFF CACHE BOOL "Build GTest-based tests") set(BUILD_TOOLS OFF CACHE BOOL "Build wabt tools") set(RUN_RE2C OFF CACHE BOOL "Run re2c") +set(WITH_EXCEPTIONS ON CACHE BOOL "Build with exceptions enabled" FORCE) add_subdirectory( wabt ) diff --git a/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp b/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp index 7fc653d2034..c43f0e0f38b 100644 --- a/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp +++ b/plugins/producer_plugin/include/eosio/producer_plugin/producer_plugin.hpp @@ -23,6 +23,7 @@ class producer_plugin : public appbase::plugin { fc::optional max_irreversible_block_age; fc::optional produce_time_offset_us; fc::optional last_block_time_offset_us; + fc::optional max_scheduled_transaction_time_per_block_ms; fc::optional subjective_cpu_leeway_us; fc::optional incoming_defer_ratio; }; diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index 18d7f2b795a..71583aee0c5 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -137,6 +137,7 @@ class producer_plugin_impl : public std::enable_shared_from_this& weak_this, const block_timestamp_type& current_block_time); }; @@ -541,6 +544,8 @@ void producer_plugin::set_program_options( "offset of non last block producing time in microseconds. Negative number results in blocks to go out sooner, and positive number results in blocks to go out later") ("last-block-time-offset-us", boost::program_options::value()->default_value(0), "offset of last block producing time in microseconds. Negative number results in blocks to go out sooner, and positive number results in blocks to go out later") + ("max-scheduled-transaction-time-per-block-ms", boost::program_options::value()->default_value(100), + "Maximum wall-clock time, in milliseconds, spent retiring scheduled transactions in any block before returning to normal transaction processing.") ("incoming-defer-ratio", bpo::value()->default_value(1.0), "ratio between incoming transations and deferred transactions when both are exhausted") ("producer-threads", bpo::value()->default_value(config::default_controller_thread_pool_size), @@ -671,6 +676,8 @@ void producer_plugin::plugin_initialize(const boost::program_options::variables_ my->_last_block_time_offset_us = options.at("last-block-time-offset-us").as(); + my->_max_scheduled_transaction_time_per_block_ms = options.at("max-scheduled-transaction-time-per-block-ms").as(); + my->_max_transaction_time_ms = options.at("max-transaction-time").as(); my->_max_irreversible_block_age_us = fc::seconds(options.at("max-irreversible-block-age").as()); @@ -831,6 +838,10 @@ void producer_plugin::update_runtime_options(const runtime_options& options) { my->_last_block_time_offset_us = *options.last_block_time_offset_us; } + if (options.max_scheduled_transaction_time_per_block_ms) { + my->_max_scheduled_transaction_time_per_block_ms = *options.max_scheduled_transaction_time_per_block_ms; + } + if (options.incoming_defer_ratio) { my->_incoming_defer_ratio = *options.incoming_defer_ratio; } @@ -852,7 +863,8 @@ producer_plugin::runtime_options producer_plugin::get_runtime_options() const { my->_max_transaction_time_ms, my->_max_irreversible_block_age_us.count() < 0 ? -1 : my->_max_irreversible_block_age_us.count() / 1'000'000, my->_produce_time_offset_us, - my->_last_block_time_offset_us + my->_last_block_time_offset_us, + my->_max_scheduled_transaction_time_per_block_ms }; } @@ -1021,6 +1033,11 @@ fc::time_point producer_plugin_impl::calculate_pending_block_time() const { return block_time; } +fc::time_point producer_plugin_impl::calculate_block_deadline( const fc::time_point& block_time ) const { + bool last_block = ((block_timestamp_type(block_time).slot % config::producer_repetitions) == config::producer_repetitions - 1); + return block_time + fc::microseconds(last_block ? _last_block_time_offset_us : _produce_time_offset_us); +} + enum class tx_category { PERSISTED, UNEXPIRED_UNPERSISTED, @@ -1028,7 +1045,7 @@ enum class tx_category { }; -producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool &last_block) { +producer_plugin_impl::start_block_result producer_plugin_impl::start_block() { chain::controller& chain = chain_plug->chain(); if( chain.get_read_mode() == chain::db_read_mode::READ_ONLY ) @@ -1044,7 +1061,6 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool _pending_block_mode = pending_block_mode::producing; // Not our turn - last_block = ((block_timestamp_type(block_time).slot % config::producer_repetitions) == config::producer_repetitions - 1); const auto& scheduled_producer = hbs->get_scheduled_producer(block_time); auto currrent_watermark_itr = _producer_watermarks.find(scheduled_producer.producer_name); auto signature_provider_itr = _signature_providers.find(scheduled_producer.block_signing_key); @@ -1109,6 +1125,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool const auto& pbs = chain.pending_block_state(); if (pbs) { + const fc::time_point preprocess_deadline = calculate_block_deadline(block_time); if (_pending_block_mode == pending_block_mode::producing && pbs->block_signing_key != scheduled_producer.block_signing_key) { elog("Block Signing Key is not expected value, reverting to speculative mode! [expected: \"${expected}\", actual: \"${actual\"", ("expected", scheduled_producer.block_signing_key)("actual", pbs->block_signing_key)); @@ -1191,7 +1208,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool int num_processed = 0; for (const auto& trx: apply_trxs) { - if (block_time <= fc::time_point::now()) exhausted = true; + if (preprocess_deadline <= fc::time_point::now()) exhausted = true; if (exhausted) { break; } @@ -1201,9 +1218,9 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool try { auto deadline = fc::time_point::now() + fc::milliseconds(_max_transaction_time_ms); bool deadline_is_subjective = false; - if (_max_transaction_time_ms < 0 || (_pending_block_mode == pending_block_mode::producing && block_time < deadline)) { + if (_max_transaction_time_ms < 0 || (_pending_block_mode == pending_block_mode::producing && preprocess_deadline < deadline)) { deadline_is_subjective = true; - deadline = block_time; + deadline = preprocess_deadline; } auto trace = chain.push_transaction(trx, deadline); @@ -1256,8 +1273,16 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool int num_failed = 0; int num_processed = 0; + auto scheduled_trx_deadline = preprocess_deadline; + if (_max_scheduled_transaction_time_per_block_ms >= 0) { + scheduled_trx_deadline = std::min( + scheduled_trx_deadline, + fc::time_point::now() + fc::milliseconds(_max_scheduled_transaction_time_per_block_ms) + ); + } + for (const auto& trx : scheduled_trxs) { - if (block_time <= fc::time_point::now()) exhausted = true; + if (scheduled_trx_deadline <= fc::time_point::now()) exhausted = true; if (exhausted) { break; } @@ -1266,6 +1291,8 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool // configurable ratio of incoming txns vs deferred txns while (_incoming_trx_weight >= 1.0 && orig_pending_txn_size && _pending_incoming_transactions.size()) { + if (scheduled_trx_deadline <= fc::time_point::now()) break; + auto e = _pending_incoming_transactions.front(); _pending_incoming_transactions.pop_front(); --orig_pending_txn_size; @@ -1273,7 +1300,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool process_incoming_transaction_async(std::get<0>(e), std::get<1>(e), std::get<2>(e)); } - if (block_time <= fc::time_point::now()) { + if (scheduled_trx_deadline <= fc::time_point::now()) { exhausted = true; break; } @@ -1285,9 +1312,9 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool try { auto deadline = fc::time_point::now() + fc::milliseconds(_max_transaction_time_ms); bool deadline_is_subjective = false; - if (_max_transaction_time_ms < 0 || (_pending_block_mode == pending_block_mode::producing && block_time < deadline)) { + if (_max_transaction_time_ms < 0 || (_pending_block_mode == pending_block_mode::producing && scheduled_trx_deadline < deadline)) { deadline_is_subjective = true; - deadline = block_time; + deadline = scheduled_trx_deadline; } auto trace = chain.push_scheduled_transaction(trx, deadline); @@ -1321,7 +1348,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool } } - if (exhausted || block_time <= fc::time_point::now()) { + if (exhausted || preprocess_deadline <= fc::time_point::now()) { return start_block_result::exhausted; } else { // attempt to apply any pending incoming transactions @@ -1334,7 +1361,7 @@ producer_plugin_impl::start_block_result producer_plugin_impl::start_block(bool _pending_incoming_transactions.pop_front(); --orig_pending_txn_size; process_incoming_transaction_async(std::get<0>(e), std::get<1>(e), std::get<2>(e)); - if (block_time <= fc::time_point::now()) return start_block_result::exhausted; + if (preprocess_deadline <= fc::time_point::now()) return start_block_result::exhausted; } } return start_block_result::succeeded; @@ -1355,8 +1382,7 @@ void producer_plugin_impl::schedule_production_loop() { _timer.cancel(); std::weak_ptr weak_this = shared_from_this(); - bool last_block; - auto result = start_block(last_block); + auto result = start_block(); if (result == start_block_result::failed) { elog("Failed to start a pending block, will try again later"); @@ -1382,11 +1408,12 @@ void producer_plugin_impl::schedule_production_loop() { // we succeeded but block may be exhausted static const boost::posix_time::ptime epoch(boost::gregorian::date(1970, 1, 1)); - if (result == start_block_result::succeeded) { + auto deadline = calculate_block_deadline(chain.pending_block_time()); + + if (deadline > fc::time_point::now()) { // ship this block off no later than its deadline EOS_ASSERT( chain.pending_block_state(), missing_pending_block_state, "producing without pending_block_state, start_block succeeded" ); - auto deadline = chain.pending_block_time().time_since_epoch().count() + (last_block ? _last_block_time_offset_us : _produce_time_offset_us); - _timer.expires_at( epoch + boost::posix_time::microseconds( deadline )); + _timer.expires_at( epoch + boost::posix_time::microseconds( deadline.time_since_epoch().count() )); fc_dlog(_log, "Scheduling Block Production on Normal Block #${num} for ${time}", ("num", chain.pending_block_state()->block_num)("time",deadline)); } else { EOS_ASSERT( chain.pending_block_state(), missing_pending_block_state, "producing without pending_block_state" );