From f1337a320be179ac6467bcb1496b3dd75bbce6aa Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Mon, 7 Oct 2019 15:07:22 -0400 Subject: [PATCH 01/18] Update for modified chainbase --- libraries/chainbase | 2 +- .../state_history_plugin/state_history_serialization.hpp | 2 +- plugins/state_history_plugin/state_history_plugin.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/chainbase b/libraries/chainbase index c6fa8ac0eaf..21e30bef02d 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit c6fa8ac0eaf00dc365b7d2d7c26608273c2cbb0d +Subproject commit 21e30bef02ddd36a8273cb0888fbb84ee8a3d839 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 3f42d0792e9..6e089e66228 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 @@ -405,7 +405,7 @@ datastream& operator<<(datastream& ds, const history_serial_wrappersecond; + parent = &*it; } fc::raw::pack(ds, as_type(parent->name.to_uint64_t())); } else { diff --git a/plugins/state_history_plugin/state_history_plugin.cpp b/plugins/state_history_plugin/state_history_plugin.cpp index 040c4678da9..c24870cd071 100644 --- a/plugins/state_history_plugin/state_history_plugin.cpp +++ b/plugins/state_history_plugin/state_history_plugin.cpp @@ -475,7 +475,7 @@ struct state_history_plugin_impl : std::enable_shared_from_this(); std::map removed_table_id; for (auto& rem : table_id_index.stack().back().removed_values) - removed_table_id[rem.first._id] = &rem.second; + removed_table_id[rem.id._id] = &rem; auto get_table_id = [&](uint64_t tid) -> const table_id_object& { auto obj = table_id_index.find(tid); @@ -511,12 +511,12 @@ struct state_history_plugin_impl : std::enable_shared_from_this Date: Mon, 7 Oct 2019 15:09:31 -0400 Subject: [PATCH 02/18] Updates for cow_string. --- libraries/chain/controller.cpp | 3 +-- libraries/chain/eosio_contract.cpp | 8 ++++---- .../chain/include/eosio/chain/account_object.hpp | 2 +- libraries/chain/include/eosio/chain/authority.hpp | 4 ++-- .../eosio/chain/generated_transaction_object.hpp | 2 +- .../include/eosio/chain/reversible_block_object.hpp | 2 +- libraries/chain/include/eosio/chain/types.hpp | 13 +++---------- libraries/chainbase | 2 +- plugins/history_plugin/history_plugin.cpp | 2 +- 9 files changed, 15 insertions(+), 23 deletions(-) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 3b439379b35..aa45a5db8f7 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -990,8 +990,7 @@ struct controller_impl { if( name == config::system_account_name ) { // The initial eosio ABI value affects consensus; see https://github.com/EOSIO/eos/issues/7794 // TODO: This doesn't charge RAM; a fix requires a consensus upgrade. - a.abi.resize(sizeof(eosio_abi_bin)); - memcpy(a.abi.data(), eosio_abi_bin, sizeof(eosio_abi_bin)); + a.abi.assign(eosio_abi_bin, sizeof(eosio_abi_bin)); } }); db.create([&](auto & a) { diff --git a/libraries/chain/eosio_contract.cpp b/libraries/chain/eosio_contract.cpp index ccb85a82ac2..3465b916005 100644 --- a/libraries/chain/eosio_contract.cpp +++ b/libraries/chain/eosio_contract.cpp @@ -209,11 +209,11 @@ void apply_eosio_setabi(apply_context& context) { int64_t new_size = abi_size; db.modify( account, [&]( auto& a ) { - if (abi_size > 0) { + // if (abi_size > 0) { a.abi.assign(act.abi.data(), abi_size); - } else { - a.abi.resize(0); - } + // } else { + // a.abi.resize(0); + // } }); const auto& account_metadata = db.get(act.account); diff --git a/libraries/chain/include/eosio/chain/account_object.hpp b/libraries/chain/include/eosio/chain/account_object.hpp index 8c8da161a24..e8b79ce2486 100644 --- a/libraries/chain/include/eosio/chain/account_object.hpp +++ b/libraries/chain/include/eosio/chain/account_object.hpp @@ -19,7 +19,7 @@ namespace eosio { namespace chain { void set_abi( const eosio::chain::abi_def& a ) { abi.resize( fc::raw::pack_size( a ) ); - fc::datastream ds( abi.data(), abi.size() ); + fc::datastream ds( const_cast(abi.data()), abi.size() ); fc::raw::pack( ds, a ); } diff --git a/libraries/chain/include/eosio/chain/authority.hpp b/libraries/chain/include/eosio/chain/authority.hpp index 492fd9b404f..60e3532632b 100644 --- a/libraries/chain/include/eosio/chain/authority.hpp +++ b/libraries/chain/include/eosio/chain/authority.hpp @@ -112,7 +112,7 @@ struct shared_key_weight { [&](const fc::crypto::webauthn::public_key& wa) { size_t psz = fc::raw::pack_size(wa); shared_string wa_ss(psz, boost::container::default_init, std::move(allocator)); - fc::datastream ds(wa_ss.data(), wa_ss.size()); + fc::datastream ds(const_cast(wa_ss.data()), wa_ss.size()); fc::raw::pack(ds, wa); return shared_key_weight(std::move(wa_ss), k.weight); @@ -306,4 +306,4 @@ FC_REFLECT(eosio::chain::wait_weight, (wait_sec)(weight) ) FC_REFLECT(eosio::chain::authority, (threshold)(keys)(accounts)(waits) ) FC_REFLECT(eosio::chain::shared_key_weight, (key)(weight) ) FC_REFLECT(eosio::chain::shared_authority, (threshold)(keys)(accounts)(waits) ) -FC_REFLECT(eosio::chain::shared_public_key, (pubkey)) \ No newline at end of file +FC_REFLECT(eosio::chain::shared_public_key, (pubkey)) diff --git a/libraries/chain/include/eosio/chain/generated_transaction_object.hpp b/libraries/chain/include/eosio/chain/generated_transaction_object.hpp index a93e65296e4..ca2f1bc3494 100644 --- a/libraries/chain/include/eosio/chain/generated_transaction_object.hpp +++ b/libraries/chain/include/eosio/chain/generated_transaction_object.hpp @@ -36,7 +36,7 @@ namespace eosio { namespace chain { uint32_t set( const transaction& trx ) { auto trxsize = fc::raw::pack_size( trx ); packed_trx.resize( trxsize ); - fc::datastream ds( packed_trx.data(), trxsize ); + fc::datastream ds( const_cast(packed_trx.data()), trxsize ); fc::raw::pack( ds, trx ); return trxsize; } diff --git a/libraries/chain/include/eosio/chain/reversible_block_object.hpp b/libraries/chain/include/eosio/chain/reversible_block_object.hpp index 690d3c1953c..16bc0f88502 100644 --- a/libraries/chain/include/eosio/chain/reversible_block_object.hpp +++ b/libraries/chain/include/eosio/chain/reversible_block_object.hpp @@ -17,7 +17,7 @@ namespace eosio { namespace chain { void set_block( const signed_block_ptr& b ) { packedblock.resize( fc::raw::pack_size( *b ) ); - fc::datastream ds( packedblock.data(), packedblock.size() ); + fc::datastream ds( const_cast(packedblock.data()), packedblock.size() ); fc::raw::pack( ds, *b ); } diff --git a/libraries/chain/include/eosio/chain/types.hpp b/libraries/chain/include/eosio/chain/types.hpp index 6f259f73b02..3fe85bfc457 100644 --- a/libraries/chain/include/eosio/chain/types.hpp +++ b/libraries/chain/include/eosio/chain/types.hpp @@ -87,7 +87,7 @@ namespace eosio { namespace chain { struct void_t{}; using chainbase::allocator; - using shared_string = boost::interprocess::basic_string, allocator>; + using shared_string = chainbase::shared_string;//boost::interprocess::basic_string, allocator>; template using shared_vector = boost::interprocess::vector>; template @@ -105,17 +105,10 @@ namespace eosio { namespace chain { 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(const shared_blob& s) = default; - shared_blob& operator=(const shared_blob& s) { - assign(s.c_str(), s.size()); - return *this; - } + shared_blob& operator=(const shared_blob& s) = default; shared_blob& operator=(shared_blob&& ) = default; diff --git a/libraries/chainbase b/libraries/chainbase index 21e30bef02d..865dfeaa9a1 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 21e30bef02ddd36a8273cb0888fbb84ee8a3d839 +Subproject commit 865dfeaa9a1034994bd02ef0cc01a2583b232972 diff --git a/plugins/history_plugin/history_plugin.cpp b/plugins/history_plugin/history_plugin.cpp index 4de5d99093e..b9d258347f0 100644 --- a/plugins/history_plugin/history_plugin.cpp +++ b/plugins/history_plugin/history_plugin.cpp @@ -259,7 +259,7 @@ namespace eosio { db.create( [&]( auto& aho ) { auto ps = fc::raw::pack_size( at ); aho.packed_action_trace.resize(ps); - datastream ds( aho.packed_action_trace.data(), ps ); + datastream ds( const_cast(aho.packed_action_trace.data()), ps ); fc::raw::pack( ds, at ); aho.action_sequence_num = at.receipt->global_sequence; aho.block_num = chain.head_block_num() + 1; From 7008ae4d08ebee1ee48dad52157249c45589563d Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Tue, 8 Oct 2019 16:41:38 -0400 Subject: [PATCH 03/18] Update for chainbase changes --- .../eosio/state_history_plugin/state_history_serialization.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 6e089e66228..f2a785b19d2 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 @@ -402,7 +402,8 @@ datastream& operator<<(datastream& ds, const history_serial_wrapper Date: Tue, 8 Oct 2019 17:02:08 -0400 Subject: [PATCH 04/18] Update chainbase --- libraries/chainbase | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chainbase b/libraries/chainbase index 865dfeaa9a1..eaa42dcd1e9 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 865dfeaa9a1034994bd02ef0cc01a2583b232972 +Subproject commit eaa42dcd1e956e9f1700ac4566db55e72b2f26b8 From 59e633ea60c2499a76ca4a9c59855bd1c5a259c3 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Wed, 9 Oct 2019 08:56:57 -0400 Subject: [PATCH 05/18] Update fc --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 52e372f4cab..61785646004 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 52e372f4cabc59d531a2bbf35bebbf244e4d9485 +Subproject commit 61785646004f9e763f656be0516e1a1eb20e6c40 From a4ef2c21c147139c4d465f31a98310e409eb12cd Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Wed, 9 Oct 2019 14:47:37 -0400 Subject: [PATCH 06/18] Update chainbase to fix replay issues. --- libraries/chainbase | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chainbase b/libraries/chainbase index eaa42dcd1e9..c26f2d5a7c9 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit eaa42dcd1e956e9f1700ac4566db55e72b2f26b8 +Subproject commit c26f2d5a7c91677f9e07eb100f04e7b9fb9ae6d9 From d43d43c48be8fabc1a216969ac1e63f87db72d03 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Wed, 9 Oct 2019 17:44:47 -0400 Subject: [PATCH 07/18] Update chainbase to fix memory issues. --- libraries/chainbase | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chainbase b/libraries/chainbase index c26f2d5a7c9..901536252ce 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit c26f2d5a7c91677f9e07eb100f04e7b9fb9ae6d9 +Subproject commit 901536252ce89df283c8ee9c3a8cb68a88bf464e From 970cade550a86406b8bfcb3044f3357d47abad2d Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Tue, 15 Oct 2019 16:36:13 -0400 Subject: [PATCH 08/18] Fix state_history_plugin. --- libraries/chainbase | 2 +- .../state_history_serialization.hpp | 2 +- plugins/state_history_plugin/state_history_plugin.cpp | 11 ++++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/libraries/chainbase b/libraries/chainbase index 901536252ce..4211bcb6292 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 901536252ce89df283c8ee9c3a8cb68a88bf464e +Subproject commit 4211bcb62923da9d8eb8f1133b429d345f83e5ef 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 f2a785b19d2..733d1624536 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 @@ -401,7 +401,7 @@ datastream& operator<<(datastream& ds, const history_serial_wrapper(); const auto* parent = index.find(obj.obj.parent); if (!parent) { - auto& undo = index.stack().back(); + auto undo = index.last_undo_session(); // FIXME: This is inefficient auto it = std::find_if(undo.removed_values.begin(), undo.removed_values.end(), [&](auto& x){ return x.id._id == obj.obj.parent; }); EOS_ASSERT(it != undo.removed_values.end(), eosio::chain::plugin_exception, diff --git a/plugins/state_history_plugin/state_history_plugin.cpp b/plugins/state_history_plugin/state_history_plugin.cpp index c24870cd071..33c117bf1ad 100644 --- a/plugins/state_history_plugin/state_history_plugin.cpp +++ b/plugins/state_history_plugin/state_history_plugin.cpp @@ -474,7 +474,7 @@ struct state_history_plugin_impl : std::enable_shared_from_this(); std::map removed_table_id; - for (auto& rem : table_id_index.stack().back().removed_values) + for (auto& rem : table_id_index.last_undo_session().removed_values) removed_table_id[rem.id._id] = &rem; auto get_table_id = [&](uint64_t tid) -> const table_id_object& { @@ -502,10 +502,8 @@ struct state_history_plugin_impl : std::enable_shared_from_this Date: Wed, 16 Oct 2019 14:41:43 -0400 Subject: [PATCH 09/18] Update chainbase --- libraries/chainbase | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chainbase b/libraries/chainbase index 4211bcb6292..40e59c92c8c 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 4211bcb62923da9d8eb8f1133b429d345f83e5ef +Subproject commit 40e59c92c8c75727bb0a6a6586b0e96704f3a71d From 72fe9d198a6ff2126ad66061433331543f1fbd66 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Fri, 18 Oct 2019 16:37:15 -0400 Subject: [PATCH 10/18] Update chainbase. --- libraries/chainbase | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chainbase b/libraries/chainbase index 40e59c92c8c..8a3bebf35ad 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 40e59c92c8c75727bb0a6a6586b0e96704f3a71d +Subproject commit 8a3bebf35adae6b6c2c041377cca8ea1eb22e2dc From 866efc369616a13a8eb545f53f9f652a52997bb8 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Fri, 25 Oct 2019 16:10:45 -0400 Subject: [PATCH 11/18] Update chainbase --- libraries/chainbase | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chainbase b/libraries/chainbase index 8a3bebf35ad..4095f0c2535 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 8a3bebf35adae6b6c2c041377cca8ea1eb22e2dc +Subproject commit 4095f0c2535e8f0f366b57c6ef2c3e39fbd94bd0 From 33da1c1b10514c7c85a2620678fc9c0a91bad950 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Tue, 29 Oct 2019 17:00:06 -0400 Subject: [PATCH 12/18] Update chainbase and adjust to new string resize api. --- libraries/chain/include/eosio/chain/account_object.hpp | 7 ++++--- .../include/eosio/chain/generated_transaction_object.hpp | 7 ++++--- .../chain/include/eosio/chain/reversible_block_object.hpp | 7 ++++--- libraries/chainbase | 2 +- plugins/history_plugin/history_plugin.cpp | 7 ++++--- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/libraries/chain/include/eosio/chain/account_object.hpp b/libraries/chain/include/eosio/chain/account_object.hpp index e8b79ce2486..d755950c952 100644 --- a/libraries/chain/include/eosio/chain/account_object.hpp +++ b/libraries/chain/include/eosio/chain/account_object.hpp @@ -18,9 +18,10 @@ namespace eosio { namespace chain { shared_blob abi; void set_abi( const eosio::chain::abi_def& a ) { - abi.resize( fc::raw::pack_size( a ) ); - fc::datastream ds( const_cast(abi.data()), abi.size() ); - fc::raw::pack( ds, a ); + abi.resize_and_fill( fc::raw::pack_size( a ), [&a](char* data, std::size_t size) { + fc::datastream ds( const_cast(data), size ); + fc::raw::pack( ds, a ); + }); } eosio::chain::abi_def get_abi()const { diff --git a/libraries/chain/include/eosio/chain/generated_transaction_object.hpp b/libraries/chain/include/eosio/chain/generated_transaction_object.hpp index ca2f1bc3494..8467f0a99b3 100644 --- a/libraries/chain/include/eosio/chain/generated_transaction_object.hpp +++ b/libraries/chain/include/eosio/chain/generated_transaction_object.hpp @@ -35,9 +35,10 @@ namespace eosio { namespace chain { uint32_t set( const transaction& trx ) { auto trxsize = fc::raw::pack_size( trx ); - packed_trx.resize( trxsize ); - fc::datastream ds( const_cast(packed_trx.data()), trxsize ); - fc::raw::pack( ds, trx ); + packed_trx.resize_and_fill( trxsize, [&trx](char* data, std::size_t size) { + fc::datastream ds( data, size ); + fc::raw::pack( ds, trx ); + }); return trxsize; } }; diff --git a/libraries/chain/include/eosio/chain/reversible_block_object.hpp b/libraries/chain/include/eosio/chain/reversible_block_object.hpp index 16bc0f88502..963c2b28fa3 100644 --- a/libraries/chain/include/eosio/chain/reversible_block_object.hpp +++ b/libraries/chain/include/eosio/chain/reversible_block_object.hpp @@ -16,9 +16,10 @@ namespace eosio { namespace chain { shared_string packedblock; void set_block( const signed_block_ptr& b ) { - packedblock.resize( fc::raw::pack_size( *b ) ); - fc::datastream ds( const_cast(packedblock.data()), packedblock.size() ); - fc::raw::pack( ds, *b ); + packedblock.resize_and_fill( fc::raw::pack_size( *b ), [&b](char* data, std::size_t size) { + fc::datastream ds( data, size ); + fc::raw::pack( ds, *b ); + }); } signed_block_ptr get_block()const { diff --git a/libraries/chainbase b/libraries/chainbase index 4095f0c2535..258c6f2bacb 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 4095f0c2535e8f0f366b57c6ef2c3e39fbd94bd0 +Subproject commit 258c6f2bacb59fc16c3de9bb758d87d751472fad diff --git a/plugins/history_plugin/history_plugin.cpp b/plugins/history_plugin/history_plugin.cpp index b9d258347f0..7dfe7e2e6de 100644 --- a/plugins/history_plugin/history_plugin.cpp +++ b/plugins/history_plugin/history_plugin.cpp @@ -258,9 +258,10 @@ namespace eosio { db.create( [&]( auto& aho ) { auto ps = fc::raw::pack_size( at ); - aho.packed_action_trace.resize(ps); - datastream ds( const_cast(aho.packed_action_trace.data()), ps ); - fc::raw::pack( ds, at ); + aho.packed_action_trace.resize_and_fill(ps, [&at](char* data, std::size_t size) { + fc::datastream ds( data, size ); + fc::raw::pack( ds, at ); + }); aho.action_sequence_num = at.receipt->global_sequence; aho.block_num = chain.head_block_num() + 1; aho.block_time = chain.pending_block_time(); From 27238b9aa8adeb52c9af4921182f327bf4c81d1b Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Tue, 29 Oct 2019 17:20:37 -0400 Subject: [PATCH 13/18] Replace c_str with data. --- libraries/chain/whitelisted_intrinsics.cpp | 2 +- libraries/chainbase | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/chain/whitelisted_intrinsics.cpp b/libraries/chain/whitelisted_intrinsics.cpp index cd3974d1ce5..c77144ddd9a 100644 --- a/libraries/chain/whitelisted_intrinsics.cpp +++ b/libraries/chain/whitelisted_intrinsics.cpp @@ -95,7 +95,7 @@ namespace eosio { namespace chain { std::set s; for( const auto& p : whitelisted_intrinsics ) { - s.emplace( p.second.c_str(), p.second.size() ); + s.emplace( p.second.data(), p.second.size() ); } return s; diff --git a/libraries/chainbase b/libraries/chainbase index 258c6f2bacb..37b54ce84b9 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 258c6f2bacb59fc16c3de9bb758d87d751472fad +Subproject commit 37b54ce84b937ebe499b18c05244d8fef651a79a From 0d57164c55a06e390de9a42a6fdde147ac4f208b Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Mon, 4 Nov 2019 10:34:35 -0500 Subject: [PATCH 14/18] Move serialization of shared_cow_string from fc to eos and update chainbase --- libraries/chain/include/eosio/chain/types.hpp | 18 ++++++++++++++++++ libraries/chainbase | 2 +- libraries/fc | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/libraries/chain/include/eosio/chain/types.hpp b/libraries/chain/include/eosio/chain/types.hpp index 3fe85bfc457..1176cc32105 100644 --- a/libraries/chain/include/eosio/chain/types.hpp +++ b/libraries/chain/include/eosio/chain/types.hpp @@ -388,4 +388,22 @@ namespace eosio { namespace chain { } } // eosio::chain +namespace chainbase { + // chainbase::shared_cow_string + template inline DataStream& operator<<( DataStream& s, const chainbase::shared_cow_string& v ) { + FC_ASSERT( v.size() <= MAX_SIZE_OF_BYTE_ARRAYS ); + fc::raw::pack( s, fc::unsigned_int((uint32_t)v.size())); + if( v.size() ) s.write( v.data(), v.size() ); + return s; + } + + template inline DataStream& operator>>( DataStream& s, chainbase::shared_cow_string& v ) { + fc::unsigned_int size; fc::raw::unpack( s, size ); + FC_ASSERT( size.value <= MAX_SIZE_OF_BYTE_ARRAYS ); + FC_ASSERT( v.size() == 0 ); + v.resize_and_fill(size.value, [&s](char* buf, std::size_t sz) { s.read(buf, sz); }); + return s; + } +} + FC_REFLECT_EMPTY( eosio::chain::void_t ) diff --git a/libraries/chainbase b/libraries/chainbase index 37b54ce84b9..547154780c9 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 37b54ce84b937ebe499b18c05244d8fef651a79a +Subproject commit 547154780c9b0a69776908f6edbc03af23d568f6 diff --git a/libraries/fc b/libraries/fc index 61785646004..83984c78336 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 61785646004f9e763f656be0516e1a1eb20e6c40 +Subproject commit 83984c783361fd4867c616c60d99bb236873ba9f From c38ea36be10b2d2d405ba507c938bb8594956add Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Mon, 4 Nov 2019 15:04:48 -0500 Subject: [PATCH 15/18] Cleanup --- libraries/chain/eosio_contract.cpp | 6 +----- .../state_history_plugin/state_history_serialization.hpp | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/libraries/chain/eosio_contract.cpp b/libraries/chain/eosio_contract.cpp index 3465b916005..aab94bd3414 100644 --- a/libraries/chain/eosio_contract.cpp +++ b/libraries/chain/eosio_contract.cpp @@ -209,11 +209,7 @@ void apply_eosio_setabi(apply_context& context) { int64_t new_size = abi_size; db.modify( account, [&]( auto& a ) { - // if (abi_size > 0) { - a.abi.assign(act.abi.data(), abi_size); - // } else { - // a.abi.resize(0); - // } + a.abi.assign(act.abi.data(), abi_size); }); const auto& account_metadata = db.get(act.account); 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 733d1624536..c1fd3f509bc 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 @@ -402,7 +402,6 @@ datastream& operator<<(datastream& ds, const history_serial_wrapper Date: Tue, 5 Nov 2019 17:40:20 -0500 Subject: [PATCH 16/18] Fix const_casts --- libraries/chain/include/eosio/chain/account_object.hpp | 2 +- libraries/chain/include/eosio/chain/authority.hpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/chain/include/eosio/chain/account_object.hpp b/libraries/chain/include/eosio/chain/account_object.hpp index d755950c952..354b67869e7 100644 --- a/libraries/chain/include/eosio/chain/account_object.hpp +++ b/libraries/chain/include/eosio/chain/account_object.hpp @@ -19,7 +19,7 @@ namespace eosio { namespace chain { void set_abi( const eosio::chain::abi_def& a ) { abi.resize_and_fill( fc::raw::pack_size( a ), [&a](char* data, std::size_t size) { - fc::datastream ds( const_cast(data), size ); + fc::datastream ds( data, size ); fc::raw::pack( ds, a ); }); } diff --git a/libraries/chain/include/eosio/chain/authority.hpp b/libraries/chain/include/eosio/chain/authority.hpp index 60e3532632b..7d2a6a3f7bb 100644 --- a/libraries/chain/include/eosio/chain/authority.hpp +++ b/libraries/chain/include/eosio/chain/authority.hpp @@ -111,9 +111,11 @@ struct shared_key_weight { }, [&](const fc::crypto::webauthn::public_key& wa) { size_t psz = fc::raw::pack_size(wa); - shared_string wa_ss(psz, boost::container::default_init, std::move(allocator)); - fc::datastream ds(const_cast(wa_ss.data()), wa_ss.size()); - fc::raw::pack(ds, wa); + shared_string wa_ss(std::move(allocator)); + wa_ss.resize_and_fill( psz, [&wa]( char* data, std::size_t sz ) { + fc::datastream ds(data, sz); + fc::raw::pack(ds, wa); + }); return shared_key_weight(std::move(wa_ss), k.weight); } From 3d481b09f93f1b61749ff310e7e020a4ad0940f2 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Tue, 5 Nov 2019 17:41:05 -0500 Subject: [PATCH 17/18] Remove commented out code. --- libraries/chain/include/eosio/chain/types.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/include/eosio/chain/types.hpp b/libraries/chain/include/eosio/chain/types.hpp index 833dc187a53..47ee1ba4d86 100644 --- a/libraries/chain/include/eosio/chain/types.hpp +++ b/libraries/chain/include/eosio/chain/types.hpp @@ -85,7 +85,7 @@ namespace eosio { namespace chain { struct void_t{}; using chainbase::allocator; - using shared_string = chainbase::shared_string;//boost::interprocess::basic_string, allocator>; + using shared_string = chainbase::shared_string; template using shared_vector = boost::interprocess::vector>; template From 8676444e6efc97b7076ecf9e35f493e0ce36a0af Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Wed, 6 Nov 2019 09:17:29 -0500 Subject: [PATCH 18/18] Update chainbase --- libraries/chainbase | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chainbase b/libraries/chainbase index 547154780c9..100f76d18d6 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 547154780c9b0a69776908f6edbc03af23d568f6 +Subproject commit 100f76d18d69491c17ff6b0eada81c06bdb048e2