From 78a6fa50206633f920e1a5d76ba4605dfe3725d1 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 22 Aug 2018 13:26:57 -0300 Subject: [PATCH 001/172] refactor get_assets to accept id or name --- libraries/app/database_api.cpp | 43 +++++++++++++++---- .../app/include/graphene/app/database_api.hpp | 4 +- libraries/wallet/wallet.cpp | 9 +++- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 77407e1045..f35dda15b0 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -98,7 +98,7 @@ class database_api_impl : public std::enable_shared_from_this vector get_vesting_balances( const std::string account_id_or_name )const; // Assets - vector> get_assets(const vector& asset_ids)const; + vector> get_assets(const vector& asset_names_or_ids)const; vector list_assets(const string& lower_bound_symbol, uint32_t limit)const; vector> lookup_asset_symbols(const vector& symbols_or_ids)const; uint64_t get_asset_count()const; @@ -227,6 +227,31 @@ class database_api_impl : public std::enable_shared_from_this return account; } + const asset_object* get_asset_from_string( const std::string& name_or_id ) const + { + // TODO cache the result to avoid repeatly fetching from db + FC_ASSERT( name_or_id.size() > 0); + const asset_object* asset = nullptr; + if (std::isdigit(name_or_id[0])) + asset = _db.find(fc::variant(name_or_id, 1).as(1)); + else + { + const auto& idx = _db.get_index_type().indices().get(); + auto itr = idx.find(name_or_id); + if (itr != idx.end()) + asset = &*itr; + } + FC_ASSERT( asset, "no such asset" ); + return asset; + } + std::string asset_id_to_string(asset_id_type id) const + { + std::string asset_id = fc::to_string(id.space_id) + + "." + fc::to_string(id.type_id) + + "." + fc::to_string(id.instance.value); + return asset_id; + } + template const std::pair get_order_market( const T& order ) { @@ -1049,16 +1074,18 @@ vector database_api_impl::get_vesting_balances( const st // // ////////////////////////////////////////////////////////////////////// -vector> database_api::get_assets(const vector& asset_ids)const +vector> database_api::get_assets(const vector& asset_names_or_ids)const { - return my->get_assets( asset_ids ); + return my->get_assets( asset_names_or_ids ); } -vector> database_api_impl::get_assets(const vector& asset_ids)const +vector> database_api_impl::get_assets(const vector& asset_names_or_ids)const { - vector> result; result.reserve(asset_ids.size()); - std::transform(asset_ids.begin(), asset_ids.end(), std::back_inserter(result), - [this](asset_id_type id) -> optional { + vector> result; result.reserve(asset_names_or_ids.size()); + std::transform(asset_names_or_ids.begin(), asset_names_or_ids.end(), std::back_inserter(result), + [this](std::string id_or_name) -> optional { + const asset_object* asset = get_asset_from_string(id_or_name); + asset_id_type id = asset->id; if(auto o = _db.find(id)) { subscribe_to_item( id ); @@ -1453,7 +1480,7 @@ vector database_api_impl::get_top_markets(uint32_t limit)const { market_volume mv; mv.time = now; - const auto assets = get_assets( { itr->base, itr->quote } ); + const auto assets = get_assets( { asset_id_to_string(itr->base), asset_id_to_string(itr->quote) } ); mv.base = assets[0]->symbol; mv.quote = assets[1]->symbol; mv.base_volume = uint128_amount_to_string( itr->base_volume, assets[0]->precision ); diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 7102ffe62c..d379dbe722 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -375,12 +375,12 @@ class database_api /** * @brief Get a list of assets by ID - * @param asset_ids IDs of the assets to retrieve + * @param asset_names_or_ids Names or IDs of the assets to retrieve * @return The assets corresponding to the provided IDs * * This function has semantics identical to @ref get_objects */ - vector> get_assets(const vector& asset_ids)const; + vector> get_assets(const vector& asset_names_or_ids)const; /** * @brief Get assets alphabetically by symbol name diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 991d84874c..90d880d111 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -608,9 +608,16 @@ class wallet_api_impl { return get_account(account_name_or_id).get_id(); } + std::string asset_id_to_string(asset_id_type id) const + { + std::string asset_id = fc::to_string(id.space_id) + + "." + fc::to_string(id.type_id) + + "." + fc::to_string(id.instance.value); + return asset_id; + } optional find_asset(asset_id_type id)const { - auto rec = _remote_db->get_assets({id}).front(); + auto rec = _remote_db->get_assets({asset_id_to_string(id)}).front(); return rec; } optional find_asset(string asset_symbol_or_id)const From 8a5fae486b05e048ad1723d9168f70177c01c638 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 22 Aug 2018 17:45:27 -0300 Subject: [PATCH 002/172] change argument name --- libraries/app/database_api.cpp | 12 ++++++------ libraries/app/include/graphene/app/database_api.hpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index f35dda15b0..01035f1aab 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -98,7 +98,7 @@ class database_api_impl : public std::enable_shared_from_this vector get_vesting_balances( const std::string account_id_or_name )const; // Assets - vector> get_assets(const vector& asset_names_or_ids)const; + vector> get_assets(const vector& asset_symbols_or_ids)const; vector list_assets(const string& lower_bound_symbol, uint32_t limit)const; vector> lookup_asset_symbols(const vector& symbols_or_ids)const; uint64_t get_asset_count()const; @@ -1074,15 +1074,15 @@ vector database_api_impl::get_vesting_balances( const st // // ////////////////////////////////////////////////////////////////////// -vector> database_api::get_assets(const vector& asset_names_or_ids)const +vector> database_api::get_assets(const vector& asset_symbols_or_ids)const { - return my->get_assets( asset_names_or_ids ); + return my->get_assets( asset_symbols_or_ids ); } -vector> database_api_impl::get_assets(const vector& asset_names_or_ids)const +vector> database_api_impl::get_assets(const vector& asset_symbols_or_ids)const { - vector> result; result.reserve(asset_names_or_ids.size()); - std::transform(asset_names_or_ids.begin(), asset_names_or_ids.end(), std::back_inserter(result), + vector> result; result.reserve(asset_symbols_or_ids.size()); + std::transform(asset_symbols_or_ids.begin(), asset_symbols_or_ids.end(), std::back_inserter(result), [this](std::string id_or_name) -> optional { const asset_object* asset = get_asset_from_string(id_or_name); asset_id_type id = asset->id; diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index d379dbe722..0c2f62c234 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -375,12 +375,12 @@ class database_api /** * @brief Get a list of assets by ID - * @param asset_names_or_ids Names or IDs of the assets to retrieve + * @param asset_symbols_or_ids Symbol names or IDs of the assets to retrieve * @return The assets corresponding to the provided IDs * * This function has semantics identical to @ref get_objects */ - vector> get_assets(const vector& asset_names_or_ids)const; + vector> get_assets(const vector& asset_symbols_or_ids)const; /** * @brief Get assets alphabetically by symbol name From 90bd42648cf942cffe81bb95be5559e46b8b4deb Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 22 Aug 2018 18:20:40 -0300 Subject: [PATCH 003/172] keep get_assets with vector of ids for internal use --- libraries/app/database_api.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 01035f1aab..4e9f128895 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -244,12 +244,19 @@ class database_api_impl : public std::enable_shared_from_this FC_ASSERT( asset, "no such asset" ); return asset; } - std::string asset_id_to_string(asset_id_type id) const + vector> get_assets(const vector& asset_ids)const { - std::string asset_id = fc::to_string(id.space_id) + - "." + fc::to_string(id.type_id) + - "." + fc::to_string(id.instance.value); - return asset_id; + vector> result; result.reserve(asset_ids.size()); + std::transform(asset_ids.begin(), asset_ids.end(), std::back_inserter(result), + [this](asset_id_type id) -> optional { + if(auto o = _db.find(id)) + { + subscribe_to_item( id ); + return *o; + } + return {}; + }); + return result; } template @@ -1480,7 +1487,7 @@ vector database_api_impl::get_top_markets(uint32_t limit)const { market_volume mv; mv.time = now; - const auto assets = get_assets( { asset_id_to_string(itr->base), asset_id_to_string(itr->quote) } ); + const auto assets = get_assets( { itr->base, itr->quote } ); mv.base = assets[0]->symbol; mv.quote = assets[1]->symbol; mv.base_volume = uint128_amount_to_string( itr->base_volume, assets[0]->precision ); From ee0a8cea82148eed8ebbcff55e2bdf3712d8145c Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 23 Aug 2018 11:07:35 -0300 Subject: [PATCH 004/172] refactor get_limit_orders to accept asset symbol or id --- libraries/app/database_api.cpp | 65 +++++++++++-------- .../app/include/graphene/app/database_api.hpp | 6 +- libraries/wallet/wallet.cpp | 4 +- 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 4e9f128895..965584509e 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -104,7 +104,7 @@ class database_api_impl : public std::enable_shared_from_this uint64_t get_asset_count()const; // Markets / feeds - vector get_limit_orders(asset_id_type a, asset_id_type b, uint32_t limit)const; + vector get_limit_orders(std::string a, std::string b, uint32_t limit)const; vector get_account_limit_orders( const string& account_name_or_id, const string &base, const string "e, uint32_t limit, @@ -258,6 +258,35 @@ class database_api_impl : public std::enable_shared_from_this }); return result; } + vector get_limit_orders(const asset_id_type& a, const asset_id_type& b, const uint32_t& limit)const + { + const auto& limit_order_idx = _db.get_index_type(); + const auto& limit_price_idx = limit_order_idx.indices().get(); + + vector result; + result.reserve(limit*2); + + uint32_t count = 0; + auto limit_itr = limit_price_idx.lower_bound(price::max(a,b)); + auto limit_end = limit_price_idx.upper_bound(price::min(a,b)); + while(limit_itr != limit_end && count < limit) + { + result.push_back(*limit_itr); + ++limit_itr; + ++count; + } + count = 0; + limit_itr = limit_price_idx.lower_bound(price::max(b,a)); + limit_end = limit_price_idx.upper_bound(price::min(b,a)); + while(limit_itr != limit_end && count < limit) + { + result.push_back(*limit_itr); + ++limit_itr; + ++count; + } + + return result; + } template const std::pair get_order_market( const T& order ) @@ -1165,7 +1194,7 @@ vector> database_api_impl::lookup_asset_symbols(const vec // // ////////////////////////////////////////////////////////////////////// -vector database_api::get_limit_orders(asset_id_type a, asset_id_type b, uint32_t limit)const +vector database_api::get_limit_orders(std::string a, std::string b, uint32_t limit)const { return my->get_limit_orders( a, b, limit ); } @@ -1173,33 +1202,17 @@ vector database_api::get_limit_orders(asset_id_type a, asset /** * @return the limit orders for both sides of the book for the two assets specified up to limit number on each side. */ -vector database_api_impl::get_limit_orders(asset_id_type a, asset_id_type b, uint32_t limit)const +vector database_api_impl::get_limit_orders(std::string a, std::string b, uint32_t limit)const { - const auto& limit_order_idx = _db.get_index_type(); - const auto& limit_price_idx = limit_order_idx.indices().get(); + FC_ASSERT( limit <= 100 ); + vector results; + results.reserve(limit*2); - vector result; + const asset_id_type asset_a_id = get_asset_from_string(a)->id; + const asset_id_type asset_b_id = get_asset_from_string(b)->id; - uint32_t count = 0; - auto limit_itr = limit_price_idx.lower_bound(price::max(a,b)); - auto limit_end = limit_price_idx.upper_bound(price::min(a,b)); - while(limit_itr != limit_end && count < limit) - { - result.push_back(*limit_itr); - ++limit_itr; - ++count; - } - count = 0; - limit_itr = limit_price_idx.lower_bound(price::max(b,a)); - limit_end = limit_price_idx.upper_bound(price::min(b,a)); - while(limit_itr != limit_end && count < limit) - { - result.push_back(*limit_itr); - ++limit_itr; - ++count; - } - - return result; + results = get_limit_orders(asset_a_id, asset_b_id, limit); + return results; } vector database_api::get_call_orders(asset_id_type a, uint32_t limit)const diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 0c2f62c234..a6b4bbdcac 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -411,12 +411,12 @@ class database_api /** * @brief Get limit orders in a given market - * @param a ID of asset being sold - * @param b ID of asset being purchased + * @param a Symbol or ID of asset being sold + * @param b Symbol or ID of asset being purchased * @param limit Maximum number of orders to retrieve * @return The limit orders, ordered from least price to greatest */ - vector get_limit_orders(asset_id_type a, asset_id_type b, uint32_t limit)const; + vector get_limit_orders(std::string a, std::string b, uint32_t limit)const; /** * @brief Get call orders in a given asset diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 90d880d111..3fe3b6a3ef 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3098,9 +3098,9 @@ vector wallet_api::get_account_limit_orders( const string& n return my->_remote_db->get_account_limit_orders(name_or_id, base, quote, limit, ostart_id, ostart_price); } -vector wallet_api::get_limit_orders(string a, string b, uint32_t limit)const +vector wallet_api::get_limit_orders(std::string a, std::string b, uint32_t limit)const { - return my->_remote_db->get_limit_orders(get_asset(a).id, get_asset(b).id, limit); + return my->_remote_db->get_limit_orders(a, b, limit); } vector wallet_api::get_call_orders(string a, uint32_t limit)const From 80a562462a9b300eb02e85fdaee82d949b9cc09f Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 23 Aug 2018 17:20:25 -0300 Subject: [PATCH 005/172] apply some changes from @abit review --- libraries/app/database_api.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 965584509e..f0fc2f0aae 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -104,7 +104,7 @@ class database_api_impl : public std::enable_shared_from_this uint64_t get_asset_count()const; // Markets / feeds - vector get_limit_orders(std::string a, std::string b, uint32_t limit)const; + vector get_limit_orders(std::string& a, std::string& b, uint32_t limit)const; vector get_account_limit_orders( const string& account_name_or_id, const string &base, const string "e, uint32_t limit, @@ -258,8 +258,10 @@ class database_api_impl : public std::enable_shared_from_this }); return result; } - vector get_limit_orders(const asset_id_type& a, const asset_id_type& b, const uint32_t& limit)const + vector get_limit_orders(const asset_id_type a, const asset_id_type b, const uint32_t limit)const { + FC_ASSERT( limit <= 300 ); + const auto& limit_order_idx = _db.get_index_type(); const auto& limit_price_idx = limit_order_idx.indices().get(); @@ -1202,17 +1204,14 @@ vector database_api::get_limit_orders(std::string a, std::st /** * @return the limit orders for both sides of the book for the two assets specified up to limit number on each side. */ -vector database_api_impl::get_limit_orders(std::string a, std::string b, uint32_t limit)const +vector database_api_impl::get_limit_orders(std::string& a, std::string& b, uint32_t limit)const { - FC_ASSERT( limit <= 100 ); - vector results; - results.reserve(limit*2); + FC_ASSERT( limit <= 300 ); const asset_id_type asset_a_id = get_asset_from_string(a)->id; const asset_id_type asset_b_id = get_asset_from_string(b)->id; - results = get_limit_orders(asset_a_id, asset_b_id, limit); - return results; + return get_limit_orders(asset_a_id, asset_b_id, limit); } vector database_api::get_call_orders(asset_id_type a, uint32_t limit)const From 482f72c4fc7fb93f0a48ab3c7fc49b3b661bd2c1 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 23 Aug 2018 17:50:17 -0300 Subject: [PATCH 006/172] add const to new reference arguments --- libraries/app/database_api.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index f0fc2f0aae..72e791c759 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -104,7 +104,7 @@ class database_api_impl : public std::enable_shared_from_this uint64_t get_asset_count()const; // Markets / feeds - vector get_limit_orders(std::string& a, std::string& b, uint32_t limit)const; + vector get_limit_orders(const std::string& a, const std::string& b, uint32_t limit)const; vector get_account_limit_orders( const string& account_name_or_id, const string &base, const string "e, uint32_t limit, @@ -1204,7 +1204,7 @@ vector database_api::get_limit_orders(std::string a, std::st /** * @return the limit orders for both sides of the book for the two assets specified up to limit number on each side. */ -vector database_api_impl::get_limit_orders(std::string& a, std::string& b, uint32_t limit)const +vector database_api_impl::get_limit_orders(const std::string& a, const std::string& b, uint32_t limit)const { FC_ASSERT( limit <= 300 ); From b1d6a97f0f497fc6f1d7f046fd1f2e0ee2632930 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 30 Aug 2018 11:22:23 -0300 Subject: [PATCH 007/172] get_call_orders asset symbol or id support --- libraries/app/database_api.cpp | 11 +++++++---- libraries/app/include/graphene/app/database_api.hpp | 4 ++-- libraries/wallet/wallet.cpp | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 72e791c759..90b61e064d 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -110,7 +110,7 @@ class database_api_impl : public std::enable_shared_from_this const string "e, uint32_t limit, optional ostart_id, optional ostart_price ); - vector get_call_orders(asset_id_type a, uint32_t limit)const; + vector get_call_orders(const std::string& a, uint32_t limit)const; vector get_settle_orders(asset_id_type a, uint32_t limit)const; vector get_margin_positions( const std::string account_id_or_name )const; vector get_collateral_bids(const asset_id_type asset, uint32_t limit, uint32_t start)const; @@ -1214,15 +1214,18 @@ vector database_api_impl::get_limit_orders(const std::string return get_limit_orders(asset_a_id, asset_b_id, limit); } -vector database_api::get_call_orders(asset_id_type a, uint32_t limit)const +vector database_api::get_call_orders(const std::string& a, uint32_t limit)const { return my->get_call_orders( a, limit ); } -vector database_api_impl::get_call_orders(asset_id_type a, uint32_t limit)const +vector database_api_impl::get_call_orders(const std::string& a, uint32_t limit)const { + FC_ASSERT( limit <= 300 ); + + const asset_id_type asset_a_id = get_asset_from_string(a)->id; const auto& call_index = _db.get_index_type().indices().get(); - const asset_object& mia = _db.get(a); + const asset_object& mia = _db.get(asset_a_id); price index_price = price::min(mia.bitasset_data(_db).options.short_backing_asset, mia.get_id()); vector< call_order_object> result; diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index a6b4bbdcac..d0e840d648 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -420,11 +420,11 @@ class database_api /** * @brief Get call orders in a given asset - * @param a ID of asset being called + * @param a Symbol or ID of asset being called * @param limit Maximum number of orders to retrieve * @return The call orders, ordered from earliest to be called to latest */ - vector get_call_orders(asset_id_type a, uint32_t limit)const; + vector get_call_orders(const std::string& a, uint32_t limit)const; /** * @brief Get forced settlement orders in a given asset diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 3fe3b6a3ef..95597ae085 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3103,9 +3103,9 @@ vector wallet_api::get_limit_orders(std::string a, std::stri return my->_remote_db->get_limit_orders(a, b, limit); } -vector wallet_api::get_call_orders(string a, uint32_t limit)const +vector wallet_api::get_call_orders(std::string a, uint32_t limit)const { - return my->_remote_db->get_call_orders(get_asset(a).id, limit); + return my->_remote_db->get_call_orders(a, limit); } vector wallet_api::get_settle_orders(string a, uint32_t limit)const From 82c4fb11c9b8bb39791cbccc9613a8b933ca7f42 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 30 Aug 2018 11:51:55 -0300 Subject: [PATCH 008/172] get_settle_orders asset symbol or id support --- libraries/app/database_api.cpp | 11 +++++++---- libraries/app/include/graphene/app/database_api.hpp | 4 ++-- libraries/wallet/wallet.cpp | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 90b61e064d..3cefdee530 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -111,7 +111,7 @@ class database_api_impl : public std::enable_shared_from_this optional ostart_id, optional ostart_price ); vector get_call_orders(const std::string& a, uint32_t limit)const; - vector get_settle_orders(asset_id_type a, uint32_t limit)const; + vector get_settle_orders(const std::string& a, uint32_t limit)const; vector get_margin_positions( const std::string account_id_or_name )const; vector get_collateral_bids(const asset_id_type asset, uint32_t limit, uint32_t start)const; @@ -1239,15 +1239,18 @@ vector database_api_impl::get_call_orders(const std::string& return result; } -vector database_api::get_settle_orders(asset_id_type a, uint32_t limit)const +vector database_api::get_settle_orders(const std::string& a, uint32_t limit)const { return my->get_settle_orders( a, limit ); } -vector database_api_impl::get_settle_orders(asset_id_type a, uint32_t limit)const +vector database_api_impl::get_settle_orders(const std::string& a, uint32_t limit)const { + FC_ASSERT( limit <= 300 ); + + const asset_id_type asset_a_id = get_asset_from_string(a)->id; const auto& settle_index = _db.get_index_type().indices().get(); - const asset_object& mia = _db.get(a); + const asset_object& mia = _db.get(asset_a_id); vector result; auto itr_min = settle_index.lower_bound(mia.get_id()); diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index d0e840d648..9a128f6dba 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -428,11 +428,11 @@ class database_api /** * @brief Get forced settlement orders in a given asset - * @param a ID of asset being settled + * @param a Symbol or ID of asset being settled * @param limit Maximum number of orders to retrieve * @return The settle orders, ordered from earliest settlement date to latest */ - vector get_settle_orders(asset_id_type a, uint32_t limit)const; + vector get_settle_orders(const std::string& a, uint32_t limit)const; /** * @brief Get collateral_bid_objects for a given asset diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 95597ae085..6737407484 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3108,9 +3108,9 @@ vector wallet_api::get_call_orders(std::string a, uint32_t li return my->_remote_db->get_call_orders(a, limit); } -vector wallet_api::get_settle_orders(string a, uint32_t limit)const +vector wallet_api::get_settle_orders(std::string a, uint32_t limit)const { - return my->_remote_db->get_settle_orders(get_asset(a).id, limit); + return my->_remote_db->get_settle_orders(a, limit); } vector wallet_api::get_collateral_bids(string asset, uint32_t limit, uint32_t start)const From fc6cec02b25b19acedd620cbc3eae14c04a8043c Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 30 Aug 2018 12:40:12 -0300 Subject: [PATCH 009/172] get_collateral_bids asset symbol or id support --- libraries/app/database_api.cpp | 9 +++++---- .../app/include/graphene/app/database_api.hpp | 4 ++-- libraries/wallet/wallet.cpp | 4 ++-- tests/tests/swan_tests.cpp | 14 ++++++++------ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 3cefdee530..65ceaf1d3c 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -113,7 +113,7 @@ class database_api_impl : public std::enable_shared_from_this vector get_call_orders(const std::string& a, uint32_t limit)const; vector get_settle_orders(const std::string& a, uint32_t limit)const; vector get_margin_positions( const std::string account_id_or_name )const; - vector get_collateral_bids(const asset_id_type asset, uint32_t limit, uint32_t start)const; + vector get_collateral_bids(const std::string& asset, uint32_t limit, uint32_t start)const; void subscribe_to_market(std::function callback, asset_id_type a, asset_id_type b); void unsubscribe_from_market(asset_id_type a, asset_id_type b); @@ -1287,14 +1287,15 @@ vector database_api_impl::get_margin_positions( const std::st } FC_CAPTURE_AND_RETHROW( (account_id_or_name) ) } -vector database_api::get_collateral_bids(const asset_id_type asset, uint32_t limit, uint32_t start)const +vector database_api::get_collateral_bids(const std::string& asset, uint32_t limit, uint32_t start)const { return my->get_collateral_bids( asset, limit, start ); } -vector database_api_impl::get_collateral_bids(const asset_id_type asset_id, uint32_t limit, uint32_t skip)const +vector database_api_impl::get_collateral_bids(const std::string& asset, uint32_t limit, uint32_t skip)const { try { FC_ASSERT( limit <= 100 ); + const asset_id_type asset_id = get_asset_from_string(asset)->id; const asset_object& swan = asset_id(_db); FC_ASSERT( swan.is_market_issued() ); const asset_bitasset_data_object& bad = swan.bitasset_data(_db); @@ -1311,7 +1312,7 @@ vector database_api_impl::get_collateral_bids(const asset ++start; } return result; -} FC_CAPTURE_AND_RETHROW( (asset_id)(limit)(skip) ) } +} FC_CAPTURE_AND_RETHROW( (asset)(limit)(skip) ) } void database_api::subscribe_to_market(std::function callback, asset_id_type a, asset_id_type b) { diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 9a128f6dba..39a80ad4fe 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -436,12 +436,12 @@ class database_api /** * @brief Get collateral_bid_objects for a given asset - * @param a ID of asset + * @param a Symbol or ID of asset * @param limit Maximum number of objects to retrieve * @param start skip that many results * @return The settle orders, ordered from earliest settlement date to latest */ - vector get_collateral_bids(const asset_id_type asset, uint32_t limit, uint32_t start)const; + vector get_collateral_bids(const std::string& a, uint32_t limit, uint32_t start)const; /** * @return all open margin positions for a given account id or name. diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 6737407484..a2e7384d61 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3113,9 +3113,9 @@ vector wallet_api::get_settle_orders(std::string a, uin return my->_remote_db->get_settle_orders(a, limit); } -vector wallet_api::get_collateral_bids(string asset, uint32_t limit, uint32_t start)const +vector wallet_api::get_collateral_bids(std::string asset, uint32_t limit, uint32_t start)const { - return my->_remote_db->get_collateral_bids(get_asset(asset).id, limit, start); + return my->_remote_db->get_collateral_bids(asset, limit, start); } brain_key_info wallet_api::suggest_brain_key()const diff --git a/tests/tests/swan_tests.cpp b/tests/tests/swan_tests.cpp index f0d7ce9aab..56fe2c1615 100644 --- a/tests/tests/swan_tests.cpp +++ b/tests/tests/swan_tests.cpp @@ -366,14 +366,15 @@ BOOST_AUTO_TEST_CASE( recollateralize ) // check get_collateral_bids graphene::app::database_api db_api(db); - GRAPHENE_REQUIRE_THROW( db_api.get_collateral_bids(back().id, 100, 0), fc::assert_exception ); - vector bids = db_api.get_collateral_bids(_swan, 100, 1); + GRAPHENE_REQUIRE_THROW( db_api.get_collateral_bids(back().symbol, 100, 0), fc::assert_exception ); + auto swan_symbol = _swan(db).symbol; + vector bids = db_api.get_collateral_bids(swan_symbol, 100, 1); BOOST_CHECK_EQUAL( 1, bids.size() ); FC_ASSERT( _borrower2 == bids[0].bidder ); - bids = db_api.get_collateral_bids(_swan, 1, 0); + bids = db_api.get_collateral_bids(swan_symbol, 1, 0); BOOST_CHECK_EQUAL( 1, bids.size() ); FC_ASSERT( _borrower == bids[0].bidder ); - bids = db_api.get_collateral_bids(_swan, 100, 0); + bids = db_api.get_collateral_bids(swan_symbol, 100, 0); BOOST_CHECK_EQUAL( 2, bids.size() ); FC_ASSERT( _borrower == bids[0].bidder ); FC_ASSERT( _borrower2 == bids[1].bidder ); @@ -382,7 +383,7 @@ BOOST_AUTO_TEST_CASE( recollateralize ) // revive wait_for_maintenance(); BOOST_CHECK( !swan().bitasset_data(db).has_settlement() ); - bids = db_api.get_collateral_bids(_swan, 100, 0); + bids = db_api.get_collateral_bids(swan_symbol, 100, 0); BOOST_CHECK( bids.empty() ); } catch( const fc::exception& e) { edump((e.to_detail_string())); @@ -477,7 +478,8 @@ BOOST_AUTO_TEST_CASE( revive_empty_with_bid ) wait_for_maintenance(); BOOST_CHECK( !swan().bitasset_data(db).has_settlement() ); graphene::app::database_api db_api(db); - vector bids = db_api.get_collateral_bids(_swan, 100, 0); + auto swan_symbol = _swan(db).symbol; + vector bids = db_api.get_collateral_bids(swan_symbol, 100, 0); BOOST_CHECK( bids.empty() ); auto& call_idx = db.get_index_type().indices().get(); From ce849a4fea159754e178ee6e022eb15aa9273a2d Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 30 Aug 2018 18:44:53 -0300 Subject: [PATCH 010/172] subscribe_to_market and unsubscribe_from_market asset symbol or id support --- libraries/app/database_api.cpp | 30 +++++++++++-------- .../app/include/graphene/app/database_api.hpp | 12 ++++---- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 65ceaf1d3c..d86710e727 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -115,8 +115,8 @@ class database_api_impl : public std::enable_shared_from_this vector get_margin_positions( const std::string account_id_or_name )const; vector get_collateral_bids(const std::string& asset, uint32_t limit, uint32_t start)const; - void subscribe_to_market(std::function callback, asset_id_type a, asset_id_type b); - void unsubscribe_from_market(asset_id_type a, asset_id_type b); + void subscribe_to_market(std::function callback, const std::string& a, const std::string& b); + void unsubscribe_from_market(const std::string& a, const std::string& b); market_ticker get_ticker( const string& base, const string& quote, bool skip_order_book = false )const; market_volume get_24_volume( const string& base, const string& quote )const; @@ -1314,28 +1314,34 @@ vector database_api_impl::get_collateral_bids(const std:: return result; } FC_CAPTURE_AND_RETHROW( (asset)(limit)(skip) ) } -void database_api::subscribe_to_market(std::function callback, asset_id_type a, asset_id_type b) +void database_api::subscribe_to_market(std::function callback, const std::string& a, const std::string& b) { my->subscribe_to_market( callback, a, b ); } -void database_api_impl::subscribe_to_market(std::function callback, asset_id_type a, asset_id_type b) +void database_api_impl::subscribe_to_market(std::function callback, const std::string& a, const std::string& b) { - if(a > b) std::swap(a,b); - FC_ASSERT(a != b); - _market_subscriptions[ std::make_pair(a,b) ] = callback; + auto asset_a_id = get_asset_from_string(a)->id; + auto asset_b_id = get_asset_from_string(b)->id; + + if(asset_a_id > asset_b_id) std::swap(asset_a_id,asset_b_id); + FC_ASSERT(asset_a_id != asset_b_id); + _market_subscriptions[ std::make_pair(asset_a_id,asset_b_id) ] = callback; } -void database_api::unsubscribe_from_market(asset_id_type a, asset_id_type b) +void database_api::unsubscribe_from_market(const std::string& a, const std::string& b) { my->unsubscribe_from_market( a, b ); } -void database_api_impl::unsubscribe_from_market(asset_id_type a, asset_id_type b) +void database_api_impl::unsubscribe_from_market(const std::string& a, const std::string& b) { - if(a > b) std::swap(a,b); - FC_ASSERT(a != b); - _market_subscriptions.erase(std::make_pair(a,b)); + auto asset_a_id = get_asset_from_string(a)->id; + auto asset_b_id = get_asset_from_string(b)->id; + + if(a > b) std::swap(asset_a_id,asset_b_id); + FC_ASSERT(asset_a_id != asset_b_id); + _market_subscriptions.erase(std::make_pair(asset_a_id,asset_b_id)); } string database_api_impl::price_to_string( const price& _price, const asset_object& _base, const asset_object& _quote ) diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 39a80ad4fe..b92adf3cde 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -451,21 +451,21 @@ class database_api /** * @brief Request notification when the active orders in the market between two assets changes * @param callback Callback method which is called when the market changes - * @param a First asset ID - * @param b Second asset ID + * @param a First asset Symbol or ID + * @param b Second asset Symbol or ID * * Callback will be passed a variant containing a vector>. The vector will * contain, in order, the operations which changed the market, and their results. */ void subscribe_to_market(std::function callback, - asset_id_type a, asset_id_type b); + const std::string& a, const std::string& b); /** * @brief Unsubscribe from updates to a given market - * @param a First asset ID - * @param b Second asset ID + * @param a First asset Symbol ID + * @param b Second asset Symbol ID */ - void unsubscribe_from_market( asset_id_type a, asset_id_type b ); + void unsubscribe_from_market( const std::string& a, const std::string& b ); /** * @brief Returns the ticker for the market assetA:assetB From 9e0fa4fd3795533c3f710489e95cc16f26975569 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 30 Aug 2018 19:40:59 -0300 Subject: [PATCH 011/172] get_requiered_fees asset symbol or id support --- libraries/app/database_api.cpp | 10 +++++----- libraries/app/include/graphene/app/database_api.hpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index d86710e727..a4f89de794 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -155,7 +155,7 @@ class database_api_impl : public std::enable_shared_from_this bool verify_authority( const signed_transaction& trx )const; bool verify_account_authority( const string& account_name_or_id, const flat_set& signers )const; processed_transaction validate_transaction( const signed_transaction& trx )const; - vector< fc::variant > get_required_fees( const vector& ops, asset_id_type id )const; + vector< fc::variant > get_required_fees( const vector& ops, const std::string& asset_id_or_symbol )const; // Proposed transactions vector get_proposed_transactions( const std::string account_id_or_name )const; @@ -2150,9 +2150,9 @@ processed_transaction database_api_impl::validate_transaction( const signed_tran return _db.validate_transaction(trx); } -vector< fc::variant > database_api::get_required_fees( const vector& ops, asset_id_type id )const +vector< fc::variant > database_api::get_required_fees( const vector& ops, const std::string& asset_id_or_symbol )const { - return my->get_required_fees( ops, id ); + return my->get_required_fees( ops, asset_id_or_symbol ); } /** @@ -2211,7 +2211,7 @@ struct get_required_fees_helper uint32_t current_recursion = 0; }; -vector< fc::variant > database_api_impl::get_required_fees( const vector& ops, asset_id_type id )const +vector< fc::variant > database_api_impl::get_required_fees( const vector& ops, const std::string& asset_id_or_symbol )const { vector< operation > _ops = ops; // @@ -2221,7 +2221,7 @@ vector< fc::variant > database_api_impl::get_required_fees( const vector result; result.reserve(ops.size()); - const asset_object& a = id(_db); + const asset_object& a = *get_asset_from_string(asset_id_or_symbol); get_required_fees_helper helper( _db.current_fee_schedule(), a.options.core_exchange_rate, diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index b92adf3cde..7c1d53231d 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -676,7 +676,7 @@ class database_api * For each operation calculate the required fee in the specified asset type. If the asset type does * not have a valid core_exchange_rate */ - vector< fc::variant > get_required_fees( const vector& ops, asset_id_type id )const; + vector< fc::variant > get_required_fees( const vector& ops, const std::string& asset_id_or_symbol )const; /////////////////////////// // Proposed transactions // From 6d274b39007e09ffa25565498f750a85d2729851 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 28 Mar 2016 23:14:52 +0200 Subject: [PATCH 012/172] Ported network mapper from old bitshares --- programs/CMakeLists.txt | 1 + programs/network_mapper/CMakeLists.txt | 3 + programs/network_mapper/network_mapper.cpp | 317 +++++++++++++++++++++ 3 files changed, 321 insertions(+) create mode 100644 programs/network_mapper/CMakeLists.txt create mode 100644 programs/network_mapper/network_mapper.cpp diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index b17a972c96..88894ddf70 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -5,3 +5,4 @@ add_subdirectory( witness_node ) add_subdirectory( delayed_node ) add_subdirectory( js_operation_serializer ) add_subdirectory( size_checker ) +add_subdirectory( network_mapper ) diff --git a/programs/network_mapper/CMakeLists.txt b/programs/network_mapper/CMakeLists.txt new file mode 100644 index 0000000000..7d3326c1eb --- /dev/null +++ b/programs/network_mapper/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable( network_mapper network_mapper.cpp ) +target_link_libraries( network_mapper fc graphene_chain graphene_net ) + diff --git a/programs/network_mapper/network_mapper.cpp b/programs/network_mapper/network_mapper.cpp new file mode 100644 index 0000000000..1f878e262f --- /dev/null +++ b/programs/network_mapper/network_mapper.cpp @@ -0,0 +1,317 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include + +class peer_probe : public graphene::net::peer_connection_delegate +{ +public: + bool _peer_closed_connection; + bool _we_closed_connection; + graphene::net::peer_connection_ptr _connection; + std::vector _peers; + fc::ecc::public_key _node_id; + bool _connection_was_rejected; + bool _done; + fc::promise::ptr _probe_complete_promise; + +public: + peer_probe() : + _peer_closed_connection(false), + _we_closed_connection(false), + _connection(graphene::net::peer_connection::make_shared(this)), + _connection_was_rejected(false), + _done(false), + _probe_complete_promise(fc::promise::ptr(new fc::promise("probe_complete"))) + {} + + void start(const fc::ip::endpoint& endpoint_to_probe, + const fc::ecc::private_key& my_node_id, + const graphene::chain::chain_id_type& chain_id) + { + fc::future connect_task = fc::async([=](){ _connection->connect_to(endpoint_to_probe); }, "connect_task"); + try + { + connect_task.wait(fc::seconds(10)); + } + catch (const fc::timeout_exception&) + { + ilog("timeout connecting to node ${endpoint}", ("endpoint", endpoint_to_probe)); + connect_task.cancel(__FUNCTION__); + throw; + } + + fc::sha256::encoder shared_secret_encoder; + fc::sha512 shared_secret = _connection->get_shared_secret(); + shared_secret_encoder.write(shared_secret.data(), sizeof(shared_secret)); + fc::ecc::compact_signature signature = my_node_id.sign_compact(shared_secret_encoder.result()); + + graphene::net::hello_message hello("network_mapper", + GRAPHENE_NET_PROTOCOL_VERSION, + fc::ip::address(), 0, 0, + my_node_id.get_public_key(), + signature, + chain_id, + fc::variant_object()); + + _connection->send_message(hello); + } + + void on_message(graphene::net::peer_connection* originating_peer, + const graphene::net::message& received_message) override + { + graphene::net::message_hash_type message_hash = received_message.id(); + dlog( "handling message ${type} ${hash} size ${size} from peer ${endpoint}", + ( "type", graphene::net::core_message_type_enum(received_message.msg_type ) )("hash", message_hash )("size", received_message.size )("endpoint", originating_peer->get_remote_endpoint() ) ); + switch ( received_message.msg_type ) + { + case graphene::net::core_message_type_enum::hello_message_type: + on_hello_message( originating_peer, received_message.as() ); + break; + case graphene::net::core_message_type_enum::connection_accepted_message_type: + on_connection_accepted_message( originating_peer, received_message.as() ); + break; + case graphene::net::core_message_type_enum::connection_rejected_message_type: + on_connection_rejected_message( originating_peer, received_message.as() ); + break; + case graphene::net::core_message_type_enum::address_request_message_type: + on_address_request_message( originating_peer, received_message.as() ); + break; + case graphene::net::core_message_type_enum::address_message_type: + on_address_message( originating_peer, received_message.as() ); + break; + case graphene::net::core_message_type_enum::closing_connection_message_type: + on_closing_connection_message( originating_peer, received_message.as() ); + break; + case graphene::net::core_message_type_enum::current_time_request_message_type: + on_current_time_request_message( originating_peer, received_message.as() ); + break; + case graphene::net::core_message_type_enum::current_time_reply_message_type: + on_current_time_reply_message( originating_peer, received_message.as() ); + break; + } + } + + void on_hello_message(graphene::net::peer_connection* originating_peer, + const graphene::net::hello_message& hello_message_received) + { + _node_id = hello_message_received.node_public_key; + if (hello_message_received.user_data.contains("node_id")) + originating_peer->node_id = hello_message_received.user_data["node_id"].as(); + originating_peer->send_message(graphene::net::connection_rejected_message()); + } + + void on_connection_accepted_message(graphene::net::peer_connection* originating_peer, + const graphene::net::connection_accepted_message& connection_accepted_message_received) + { + _connection_was_rejected = false; + originating_peer->send_message(graphene::net::address_request_message()); + } + + void on_connection_rejected_message( graphene::net::peer_connection* originating_peer, + const graphene::net::connection_rejected_message& connection_rejected_message_received ) + { + _connection_was_rejected = true; + originating_peer->send_message(graphene::net::address_request_message()); + } + + void on_address_request_message(graphene::net::peer_connection* originating_peer, + const graphene::net::address_request_message& address_request_message_received) + { + originating_peer->send_message(graphene::net::address_message()); + } + + + void on_address_message(graphene::net::peer_connection* originating_peer, + const graphene::net::address_message& address_message_received) + { + _peers = address_message_received.addresses; + originating_peer->send_message(graphene::net::closing_connection_message("Thanks for the info")); + _we_closed_connection = true; + } + + void on_closing_connection_message(graphene::net::peer_connection* originating_peer, + const graphene::net::closing_connection_message& closing_connection_message_received) + { + if (_we_closed_connection) + _connection->close_connection(); + else + _peer_closed_connection = true; + } + + void on_current_time_request_message(graphene::net::peer_connection* originating_peer, + const graphene::net::current_time_request_message& current_time_request_message_received) + { + } + + void on_current_time_reply_message(graphene::net::peer_connection* originating_peer, + const graphene::net::current_time_reply_message& current_time_reply_message_received) + { + } + + void on_connection_closed(graphene::net::peer_connection* originating_peer) override + { + _done = true; + _probe_complete_promise->set_value(); + } + + graphene::net::message get_message_for_item(const graphene::net::item_id& item) override + { + return graphene::net::item_not_available_message(item); + } + + void wait() + { + _probe_complete_promise->wait(); + } +}; + +static std::vector resolve_endpoints(const std::string& endpoint_string) +{ + std::string::size_type colon_pos = endpoint_string.find(':'); + if (colon_pos == std::string::npos) + FC_THROW("Missing required port number in endpoint string \"${endpoint_string}\"", + ("endpoint_string", endpoint_string)); + std::string port_string = endpoint_string.substr(colon_pos + 1); + uint16_t port = boost::lexical_cast(port_string); + std::string hostname = endpoint_string.substr(0, colon_pos); + return fc::resolve(hostname, port); +} + +int main(int argc, char** argv) +{ + std::queue nodes_to_visit; + std::set nodes_to_visit_set; + std::set nodes_already_visited; + + if ( argc < 3 ) { + std::cerr << "Usage: " << argv[0] << " [ ...]\n"; + exit(1); + } + + graphene::chain::chain_id_type chain_id( argv[1] ); + for ( int i = 2; i < argc; i++ ) { + std::vector addrs = resolve_endpoints( argv[i] ); + for ( auto it = addrs.begin(); it != addrs.end(); it++ ) { + if (nodes_to_visit_set.find(*it) == nodes_to_visit_set.end()) + { + nodes_to_visit.push( *it ); + nodes_to_visit_set.insert( *it ); + } + } + } + + fc::path data_dir = fc::temp_directory_path() / ("network_map_" + (fc::string) chain_id); + fc::create_directories(data_dir); + + fc::ip::endpoint seed_node1 = nodes_to_visit.front(); + + fc::ecc::private_key my_node_id = fc::ecc::private_key::generate(); + std::map address_info_by_node_id; + std::map > connections_by_node_id; + + while (!nodes_to_visit.empty()) + { + graphene::net::address_info this_node_info; + this_node_info.direction = graphene::net::peer_connection_direction::outbound; + this_node_info.firewalled = graphene::net::firewalled_state::not_firewalled; + + this_node_info.remote_endpoint = nodes_to_visit.front();; + nodes_to_visit.pop(); + nodes_to_visit_set.erase(this_node_info.remote_endpoint); + nodes_already_visited.insert(this_node_info.remote_endpoint); + + peer_probe probe; + try + { + probe.start(this_node_info.remote_endpoint, + my_node_id, chain_id); + probe.wait(); + + this_node_info.node_id = probe._node_id; + + connections_by_node_id[this_node_info.node_id] = probe._peers; + if (address_info_by_node_id.find(probe._node_id) == address_info_by_node_id.end()) + address_info_by_node_id[probe._node_id] = this_node_info; + + for (const graphene::net::address_info& info : probe._peers) + { + if (nodes_already_visited.find(info.remote_endpoint) == nodes_already_visited.end() && + info.firewalled == graphene::net::firewalled_state::not_firewalled && + nodes_to_visit_set.find(info.remote_endpoint) == nodes_to_visit_set.end()) + { + nodes_to_visit.push(info.remote_endpoint); + nodes_to_visit_set.insert(info.remote_endpoint); + } + if (address_info_by_node_id.find(info.node_id) == address_info_by_node_id.end()) + address_info_by_node_id[info.node_id] = info; + } + } + catch (const fc::exception&) + { + } + std::cout << "Traversed " << nodes_already_visited.size() << " of " << (nodes_already_visited.size() + nodes_to_visit.size()) << " known nodes\n"; + } + + graphene::net::node_id_t seed_node_id; + std::set non_firewalled_nodes_set; + for (const auto& address_info_for_node : address_info_by_node_id) + { + if (address_info_for_node.second.remote_endpoint == seed_node1) + seed_node_id = address_info_for_node.first; + if (address_info_for_node.second.firewalled == graphene::net::firewalled_state::not_firewalled) + non_firewalled_nodes_set.insert(address_info_for_node.first); + } + std::set seed_node_connections; + for (const graphene::net::address_info& info : connections_by_node_id[seed_node_id]) + seed_node_connections.insert(info.node_id); + std::set seed_node_missing_connections; + std::set_difference(non_firewalled_nodes_set.begin(), non_firewalled_nodes_set.end(), + seed_node_connections.begin(), seed_node_connections.end(), + std::inserter(seed_node_missing_connections, seed_node_missing_connections.end())); + seed_node_missing_connections.erase(seed_node_id); + + std::ofstream dot_stream((data_dir / "network_graph.dot").string().c_str()); + std::map all_known_nodes; + + dot_stream << "graph G {\n"; + dot_stream << " // Total " << address_info_by_node_id.size() << " nodes, firewalled: " << (address_info_by_node_id.size() - non_firewalled_nodes_set.size()) + << ", non-firewalled: " << non_firewalled_nodes_set.size() << "\n"; + dot_stream << " // Seed node is " << (std::string)address_info_by_node_id[seed_node_id].remote_endpoint << " id: " << fc::variant(seed_node_id).as_string() << "\n"; + dot_stream << " // Seed node is connected to " << connections_by_node_id[seed_node_id].size() << " nodes\n"; + dot_stream << " // Seed node is missing connections to " << seed_node_missing_connections.size() << " non-firewalled nodes:\n"; + for (const graphene::net::node_id_t& id : seed_node_missing_connections) + dot_stream << " // " << (std::string)address_info_by_node_id[id].remote_endpoint << "\n"; + + dot_stream << " layout=\"circo\";\n"; + //for (const auto& node_and_connections : connections_by_node_id) + // all_known_nodes[node_and_connections.first] = address_info_by_node_id[node_and_connections.first].remote_endpoint; + + for (const auto& address_info_for_node : address_info_by_node_id) + { + dot_stream << " \"" << fc::variant(address_info_for_node.first).as_string() << "\"[label=\"" << (std::string)address_info_for_node.second.remote_endpoint << "\""; + if (address_info_for_node.second.firewalled != graphene::net::firewalled_state::not_firewalled) + dot_stream << ",shape=rectangle"; + dot_stream << "];\n"; + } + for (auto& node_and_connections : connections_by_node_id) + for (const graphene::net::address_info& this_connection : node_and_connections.second) + dot_stream << " \"" << fc::variant(node_and_connections.first).as_string() << "\" -- \"" << fc::variant(this_connection.node_id).as_string() << "\";\n"; + + dot_stream << "}\n"; + + return 0; +} From 0e412c5c90830b41b428f0ba92f12759c6ef86bf Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 6 Sep 2018 17:09:50 +0200 Subject: [PATCH 013/172] Adapted to lastest fc, ported parallel execution from muse --- programs/network_mapper/network_mapper.cpp | 194 ++++++++++----------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/programs/network_mapper/network_mapper.cpp b/programs/network_mapper/network_mapper.cpp index 1f878e262f..6ff51f7eba 100644 --- a/programs/network_mapper/network_mapper.cpp +++ b/programs/network_mapper/network_mapper.cpp @@ -4,18 +4,15 @@ #include #include #include -#include +#include #include #include #include +#include -#include -#include - +#include #include -#include - class peer_probe : public graphene::net::peer_connection_delegate { public: @@ -24,6 +21,7 @@ class peer_probe : public graphene::net::peer_connection_delegate graphene::net::peer_connection_ptr _connection; std::vector _peers; fc::ecc::public_key _node_id; + fc::ip::endpoint _remote; bool _connection_was_rejected; bool _done; fc::promise::ptr _probe_complete_promise; @@ -42,7 +40,8 @@ class peer_probe : public graphene::net::peer_connection_delegate const fc::ecc::private_key& my_node_id, const graphene::chain::chain_id_type& chain_id) { - fc::future connect_task = fc::async([=](){ _connection->connect_to(endpoint_to_probe); }, "connect_task"); + _remote = endpoint_to_probe; + fc::future connect_task = fc::async([this](){ _connection->connect_to(_remote); }, "connect_task"); try { connect_task.wait(fc::seconds(10)); @@ -60,12 +59,12 @@ class peer_probe : public graphene::net::peer_connection_delegate fc::ecc::compact_signature signature = my_node_id.sign_compact(shared_secret_encoder.result()); graphene::net::hello_message hello("network_mapper", - GRAPHENE_NET_PROTOCOL_VERSION, - fc::ip::address(), 0, 0, - my_node_id.get_public_key(), - signature, - chain_id, - fc::variant_object()); + GRAPHENE_NET_PROTOCOL_VERSION, + fc::ip::address(), 0, 0, + my_node_id.get_public_key(), + signature, + chain_id, + fc::variant_object()); _connection->send_message(hello); } @@ -96,11 +95,7 @@ class peer_probe : public graphene::net::peer_connection_delegate case graphene::net::core_message_type_enum::closing_connection_message_type: on_closing_connection_message( originating_peer, received_message.as() ); break; - case graphene::net::core_message_type_enum::current_time_request_message_type: - on_current_time_request_message( originating_peer, received_message.as() ); - break; - case graphene::net::core_message_type_enum::current_time_reply_message_type: - on_current_time_reply_message( originating_peer, received_message.as() ); + default: break; } } @@ -110,7 +105,7 @@ class peer_probe : public graphene::net::peer_connection_delegate { _node_id = hello_message_received.node_public_key; if (hello_message_received.user_data.contains("node_id")) - originating_peer->node_id = hello_message_received.user_data["node_id"].as(); + originating_peer->node_id = hello_message_received.user_data["node_id"].as( 1 ); originating_peer->send_message(graphene::net::connection_rejected_message()); } @@ -152,16 +147,6 @@ class peer_probe : public graphene::net::peer_connection_delegate _peer_closed_connection = true; } - void on_current_time_request_message(graphene::net::peer_connection* originating_peer, - const graphene::net::current_time_request_message& current_time_request_message_received) - { - } - - void on_current_time_reply_message(graphene::net::peer_connection* originating_peer, - const graphene::net::current_time_reply_message& current_time_reply_message_received) - { - } - void on_connection_closed(graphene::net::peer_connection* originating_peer) override { _done = true; @@ -173,24 +158,12 @@ class peer_probe : public graphene::net::peer_connection_delegate return graphene::net::item_not_available_message(item); } - void wait() + void wait( const fc::microseconds& timeout_us ) { - _probe_complete_promise->wait(); + _probe_complete_promise->wait( timeout_us ); } }; -static std::vector resolve_endpoints(const std::string& endpoint_string) -{ - std::string::size_type colon_pos = endpoint_string.find(':'); - if (colon_pos == std::string::npos) - FC_THROW("Missing required port number in endpoint string \"${endpoint_string}\"", - ("endpoint_string", endpoint_string)); - std::string port_string = endpoint_string.substr(colon_pos + 1); - uint16_t port = boost::lexical_cast(port_string); - std::string hostname = endpoint_string.substr(0, colon_pos); - return fc::resolve(hostname, port); -} - int main(int argc, char** argv) { std::queue nodes_to_visit; @@ -198,20 +171,22 @@ int main(int argc, char** argv) std::set nodes_already_visited; if ( argc < 3 ) { - std::cerr << "Usage: " << argv[0] << " [ ...]\n"; - exit(1); + std::cerr << "Usage: " << argv[0] << " [ ...]\n"; + exit(1); } - graphene::chain::chain_id_type chain_id( argv[1] ); - for ( int i = 2; i < argc; i++ ) { - std::vector addrs = resolve_endpoints( argv[i] ); - for ( auto it = addrs.begin(); it != addrs.end(); it++ ) { - if (nodes_to_visit_set.find(*it) == nodes_to_visit_set.end()) - { - nodes_to_visit.push( *it ); - nodes_to_visit_set.insert( *it ); - } - } + const graphene::chain::chain_id_type chain_id( argv[1] ); + for ( int i = 2; i < argc; i++ ) + { + std::string ep(argv[i]); + uint16_t port; + auto pos = ep.find(':'); + if (pos > 0) + port = boost::lexical_cast( ep.substr( pos+1, ep.size() ) ); + else + port = 1776; + for (const auto& addr : fc::resolve( ep.substr( 0, pos > 0 ? pos : ep.size() ), port )) + nodes_to_visit.push( addr ); } fc::path data_dir = fc::temp_directory_path() / ("network_map_" + (fc::string) chain_id); @@ -222,48 +197,76 @@ int main(int argc, char** argv) fc::ecc::private_key my_node_id = fc::ecc::private_key::generate(); std::map address_info_by_node_id; std::map > connections_by_node_id; + std::vector> probes; - while (!nodes_to_visit.empty()) + while (!nodes_to_visit.empty() || !probes.empty()) { - graphene::net::address_info this_node_info; - this_node_info.direction = graphene::net::peer_connection_direction::outbound; - this_node_info.firewalled = graphene::net::firewalled_state::not_firewalled; - - this_node_info.remote_endpoint = nodes_to_visit.front();; - nodes_to_visit.pop(); - nodes_to_visit_set.erase(this_node_info.remote_endpoint); - nodes_already_visited.insert(this_node_info.remote_endpoint); - - peer_probe probe; - try + while (!nodes_to_visit.empty()) { - probe.start(this_node_info.remote_endpoint, - my_node_id, chain_id); - probe.wait(); - - this_node_info.node_id = probe._node_id; - - connections_by_node_id[this_node_info.node_id] = probe._peers; - if (address_info_by_node_id.find(probe._node_id) == address_info_by_node_id.end()) - address_info_by_node_id[probe._node_id] = this_node_info; - - for (const graphene::net::address_info& info : probe._peers) - { - if (nodes_already_visited.find(info.remote_endpoint) == nodes_already_visited.end() && - info.firewalled == graphene::net::firewalled_state::not_firewalled && - nodes_to_visit_set.find(info.remote_endpoint) == nodes_to_visit_set.end()) - { - nodes_to_visit.push(info.remote_endpoint); - nodes_to_visit_set.insert(info.remote_endpoint); - } - if (address_info_by_node_id.find(info.node_id) == address_info_by_node_id.end()) - address_info_by_node_id[info.node_id] = info; - } + fc::ip::endpoint remote = nodes_to_visit.front(); + nodes_to_visit.pop(); + nodes_to_visit_set.erase( remote ); + nodes_already_visited.insert( remote ); + + try + { + std::shared_ptr probe(new peer_probe()); + probe->start(remote, my_node_id, chain_id); + probes.push_back( probe ); + } + catch (const fc::exception&) + { + std::cerr << "Failed to connect " << fc::string(remote) << " - skipping!" << std::endl; + } } - catch (const fc::exception&) + + if (!probes.empty()) { + try { + probes[0]->wait( fc::microseconds(10000) ); + } catch ( fc::timeout_exception& e ) { /* ignore */ } + + std::vector> running; + for ( auto& probe : probes ) { + if (probe->_probe_complete_promise->error()) + { + std::cerr << fc::string(probe->_remote) << " ran into an error!\n"; + continue; + } + if (!probe->_probe_complete_promise->ready()) + { + running.push_back( probe ); + continue; + } + + graphene::net::address_info this_node_info; + this_node_info.direction = graphene::net::peer_connection_direction::outbound; + this_node_info.firewalled = graphene::net::firewalled_state::not_firewalled; + this_node_info.remote_endpoint = probe->_remote; + this_node_info.node_id = probe->_node_id; + + connections_by_node_id[this_node_info.node_id] = probe->_peers; + if (address_info_by_node_id.find(probe->_node_id) == address_info_by_node_id.end()) + address_info_by_node_id[probe->_node_id] = this_node_info; + + for (const graphene::net::address_info& info : probe->_peers) + { + if (nodes_already_visited.find(info.remote_endpoint) == nodes_already_visited.end() && + info.firewalled == graphene::net::firewalled_state::not_firewalled && + nodes_to_visit_set.find(info.remote_endpoint) == nodes_to_visit_set.end()) + { + nodes_to_visit.push(info.remote_endpoint); + nodes_to_visit_set.insert(info.remote_endpoint); + } + if (address_info_by_node_id.find(info.node_id) == address_info_by_node_id.end()) + address_info_by_node_id[info.node_id] = info; + } + } + probes = std::move( running ); + std::cout << address_info_by_node_id.size() << " checked, " + << probes.size() << " active, " + << nodes_to_visit.size() << " to do\n"; } - std::cout << "Traversed " << nodes_already_visited.size() << " of " << (nodes_already_visited.size() + nodes_to_visit.size()) << " known nodes\n"; } graphene::net::node_id_t seed_node_id; @@ -285,31 +288,28 @@ int main(int argc, char** argv) seed_node_missing_connections.erase(seed_node_id); std::ofstream dot_stream((data_dir / "network_graph.dot").string().c_str()); - std::map all_known_nodes; dot_stream << "graph G {\n"; dot_stream << " // Total " << address_info_by_node_id.size() << " nodes, firewalled: " << (address_info_by_node_id.size() - non_firewalled_nodes_set.size()) << ", non-firewalled: " << non_firewalled_nodes_set.size() << "\n"; - dot_stream << " // Seed node is " << (std::string)address_info_by_node_id[seed_node_id].remote_endpoint << " id: " << fc::variant(seed_node_id).as_string() << "\n"; + dot_stream << " // Seed node is " << (std::string)address_info_by_node_id[seed_node_id].remote_endpoint << " id: " << fc::variant( seed_node_id, 1 ).as_string() << "\n"; dot_stream << " // Seed node is connected to " << connections_by_node_id[seed_node_id].size() << " nodes\n"; dot_stream << " // Seed node is missing connections to " << seed_node_missing_connections.size() << " non-firewalled nodes:\n"; for (const graphene::net::node_id_t& id : seed_node_missing_connections) dot_stream << " // " << (std::string)address_info_by_node_id[id].remote_endpoint << "\n"; dot_stream << " layout=\"circo\";\n"; - //for (const auto& node_and_connections : connections_by_node_id) - // all_known_nodes[node_and_connections.first] = address_info_by_node_id[node_and_connections.first].remote_endpoint; for (const auto& address_info_for_node : address_info_by_node_id) { - dot_stream << " \"" << fc::variant(address_info_for_node.first).as_string() << "\"[label=\"" << (std::string)address_info_for_node.second.remote_endpoint << "\""; + dot_stream << " \"" << fc::variant( address_info_for_node.first, 1 ).as_string() << "\"[label=\"" << (std::string)address_info_for_node.second.remote_endpoint << "\""; if (address_info_for_node.second.firewalled != graphene::net::firewalled_state::not_firewalled) dot_stream << ",shape=rectangle"; dot_stream << "];\n"; } for (auto& node_and_connections : connections_by_node_id) for (const graphene::net::address_info& this_connection : node_and_connections.second) - dot_stream << " \"" << fc::variant(node_and_connections.first).as_string() << "\" -- \"" << fc::variant(this_connection.node_id).as_string() << "\";\n"; + dot_stream << " \"" << fc::variant( node_and_connections.first, 2 ).as_string() << "\" -- \"" << fc::variant( this_connection.node_id, 1 ).as_string() << "\";\n"; dot_stream << "}\n"; From 7d44c3abb3621b1237254ad887bb09d74d62f8ab Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 16 Oct 2018 11:06:54 -0500 Subject: [PATCH 014/172] initial fix for verify_account_authority --- libraries/app/database_api.cpp | 34 +++++++++++++------ .../app/include/graphene/app/database_api.hpp | 7 ++-- tests/tests/wallet_tests.cpp | 19 +++++++++++ 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 77407e1045..d2ec51c2b4 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -167,7 +167,7 @@ class database_api_impl : public std::enable_shared_from_this vector get_withdraw_permissions_by_giver(const std::string account_id_or_name, withdraw_permission_id_type start, uint32_t limit)const; vector get_withdraw_permissions_by_recipient(const std::string account_id_or_name, withdraw_permission_id_type start, uint32_t limit)const; - //private: + // private: static string price_to_string( const price& _price, const asset_object& _base, const asset_object& _quote ); template @@ -272,7 +272,9 @@ class database_api_impl : public std::enable_shared_from_this map< pair, std::function > _market_subscriptions; graphene::chain::database& _db; const application_options* _app_options = nullptr; - + private: + bool public_key_found(const flat_set& to_be_found, + const vector& collection_to_search)const; }; ////////////////////////////////////////////////////////////////////// @@ -2068,17 +2070,29 @@ bool database_api::verify_account_authority( const string& account_name_or_id, c return my->verify_account_authority( account_name_or_id, signers ); } -bool database_api_impl::verify_account_authority( const string& account_name_or_id, const flat_set& keys )const +bool database_api_impl::public_key_found(const flat_set& to_be_found, + const vector& collection_to_search) const { - const account_object* account = get_account_from_string(account_name_or_id); + for (public_key_type from_collection : collection_to_search) + { + for(public_key_type passed_in : to_be_found ) + { + if (passed_in == from_collection) + { + return true; + } + } + } + return false; +} - /// reuse trx.verify_authority by creating a dummy transfer - signed_transaction trx; - transfer_operation op; - op.from = account->id; - trx.operations.emplace_back(op); +bool database_api_impl::verify_account_authority( const string& account_name_or_id, + const flat_set& keys )const +{ + const account_object* account = get_account_from_string(account_name_or_id); - return verify_authority( trx ); + return public_key_found(keys, account->active.get_keys()) + && public_key_found(keys, account->owner.get_keys()); } processed_transaction database_api::validate_transaction( const signed_transaction& trx )const diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 7102ffe62c..1e4e296d2b 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -663,9 +663,12 @@ class database_api bool verify_authority( const signed_transaction& trx )const; /** - * @return true if the signers have enough authority to authorize an account + * @brief Verify that the public keys have enough authority to authorize a transaction + * @param account_name_or_id the account to check + * @param signers the public keys + * @return true if the passed in keys have enough authority to authorize a transaction */ - bool verify_account_authority( const string& account_name_or_id, const flat_set& signers )const; + bool verify_account_authority( const string& account_name_or_id, const flat_set& signers )const; /** * Validates a transaction against the current state without broadcasting it on the network. diff --git a/tests/tests/wallet_tests.cpp b/tests/tests/wallet_tests.cpp index 554b729703..c95e39d741 100644 --- a/tests/tests/wallet_tests.cpp +++ b/tests/tests/wallet_tests.cpp @@ -76,4 +76,23 @@ BOOST_FIXTURE_TEST_SUITE(wallet_tests, database_fixture) } FC_LOG_AND_RETHROW() } + BOOST_AUTO_TEST_CASE(verify_account_authority) { + try { + + ACTORS( (nathan) ); + graphene::app::database_api db_api(db); + + // good keys + flat_set public_keys; + public_keys.emplace(nathan_public_key); + BOOST_CHECK(db_api.verify_account_authority( "nathan", public_keys)); + + // bad keys + flat_set bad_public_keys; + bad_public_keys.emplace(public_key_type("BTS6MkMxwBjFWmcDjXRoJ4mW9Hd4LCSPwtv9tKG1qYW5Kgu4AhoZy")); + BOOST_CHECK(!db_api.verify_account_authority( "nathan", bad_public_keys)); + + } FC_LOG_AND_RETHROW() + } + BOOST_AUTO_TEST_SUITE_END() From 7dc0de7f9c494e842fe504149ba7abb1c8d3b90d Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Fri, 19 Oct 2018 15:59:44 +0300 Subject: [PATCH 015/172] Capture Ctrl+C in cli_wallet when not in daemon mode #1193 --- programs/cli_wallet/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 7a50d86cbe..88c027a20e 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -279,6 +279,17 @@ int main( int argc, char** argv ) { wallet_cli->register_api( wapi ); wallet_cli->start(); + + fc::set_signal_handler([](int signal) { + ilog( "Captured SIGINT not in daemon mode" ); + fclose(stdin); + }, SIGINT); + + fc::set_signal_handler([](int signal) { + ilog( "Captured SIGTERM not in daemon mode" ); + fclose(stdin); + }, SIGTERM); + wallet_cli->wait(); } else @@ -288,6 +299,10 @@ int main( int argc, char** argv ) exit_promise->set_value(signal); }, SIGINT); + fc::set_signal_handler([&exit_promise](int signal) { + exit_promise->set_value(signal); + }, SIGTERM); + ilog( "Entering Daemon Mode, ^C to exit" ); exit_promise->wait(); } From 824ed4f2cc5eddee2af8361be8ee8c626739af7d Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 19 Oct 2018 16:09:31 -0500 Subject: [PATCH 016/172] improved way to verify account and keys --- libraries/app/database_api.cpp | 36 ++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index d2ec51c2b4..fb240c4316 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -2070,29 +2070,27 @@ bool database_api::verify_account_authority( const string& account_name_or_id, c return my->verify_account_authority( account_name_or_id, signers ); } -bool database_api_impl::public_key_found(const flat_set& to_be_found, - const vector& collection_to_search) const -{ - for (public_key_type from_collection : collection_to_search) - { - for(public_key_type passed_in : to_be_found ) - { - if (passed_in == from_collection) - { - return true; - } - } - } - return false; -} - bool database_api_impl::verify_account_authority( const string& account_name_or_id, const flat_set& keys )const { - const account_object* account = get_account_from_string(account_name_or_id); + // create a dummy transfer + transfer_operation op; + op.from = get_account_from_string(account_name_or_id)->id; + std::vector ops; + ops.emplace_back(op); + + try + { + graphene::chain::verify_authority(ops, keys, + [this]( account_id_type id ){ return &id(_db).active; }, + [this]( account_id_type id ){ return &id(_db).owner; } ); + } + catch (fc::exception& ex) + { + return false; + } - return public_key_found(keys, account->active.get_keys()) - && public_key_found(keys, account->owner.get_keys()); + return true; } processed_transaction database_api::validate_transaction( const signed_transaction& trx )const From 48fa40023a57496fb438a0f5f640d0ec06c969c9 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 19 Oct 2018 16:13:44 -0500 Subject: [PATCH 017/172] Removed unneeded method definition --- libraries/app/database_api.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index fb240c4316..acb90c8af5 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -167,7 +167,7 @@ class database_api_impl : public std::enable_shared_from_this vector get_withdraw_permissions_by_giver(const std::string account_id_or_name, withdraw_permission_id_type start, uint32_t limit)const; vector get_withdraw_permissions_by_recipient(const std::string account_id_or_name, withdraw_permission_id_type start, uint32_t limit)const; - // private: + //private: static string price_to_string( const price& _price, const asset_object& _base, const asset_object& _quote ); template @@ -272,9 +272,6 @@ class database_api_impl : public std::enable_shared_from_this map< pair, std::function > _market_subscriptions; graphene::chain::database& _db; const application_options* _app_options = nullptr; - private: - bool public_key_found(const flat_set& to_be_found, - const vector& collection_to_search)const; }; ////////////////////////////////////////////////////////////////////// From c2b63f561bb1e54703c75053f56cbbcc8c304d86 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 22 Oct 2018 20:10:59 -0500 Subject: [PATCH 018/172] Added multiple signatures to test --- tests/tests/wallet_tests.cpp | 55 ++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/tests/tests/wallet_tests.cpp b/tests/tests/wallet_tests.cpp index c95e39d741..7311a43ce3 100644 --- a/tests/tests/wallet_tests.cpp +++ b/tests/tests/wallet_tests.cpp @@ -26,6 +26,7 @@ #include #include +#include #include @@ -45,7 +46,7 @@ BOOST_FIXTURE_TEST_SUITE(wallet_tests, database_fixture) /*** * Act */ - int nbr_keys_desired = 3; + unsigned int nbr_keys_desired = 3; vector derived_keys = graphene::wallet::utility::derive_owner_keys_from_brain_key("SOME WORDS GO HERE", nbr_keys_desired); @@ -70,7 +71,7 @@ BOOST_FIXTURE_TEST_SUITE(wallet_tests, database_fixture) string expected_prefix = GRAPHENE_ADDRESS_PREFIX; for (auto info : derived_keys) { string description = (string) info.pub_key; - BOOST_CHECK_EQUAL(0, description.find(expected_prefix)); + BOOST_CHECK_EQUAL(0u, description.find(expected_prefix)); } } FC_LOG_AND_RETHROW() @@ -95,4 +96,54 @@ BOOST_FIXTURE_TEST_SUITE(wallet_tests, database_fixture) } FC_LOG_AND_RETHROW() } +BOOST_AUTO_TEST_CASE( any_two_of_three ) +{ + try { + fc::ecc::private_key nathan_key1 = fc::ecc::private_key::regenerate(fc::digest("key1")); + fc::ecc::private_key nathan_key2 = fc::ecc::private_key::regenerate(fc::digest("key2")); + fc::ecc::private_key nathan_key3 = fc::ecc::private_key::regenerate(fc::digest("key3")); + const account_object& nathan = create_account("nathan", nathan_key1.get_public_key() ); + fund(nathan); + graphene::app::database_api db_api(db); + + try { + account_update_operation op; + op.account = nathan.id; + op.active = authority(2, public_key_type(nathan_key1.get_public_key()), 1, public_key_type(nathan_key2.get_public_key()), 1, public_key_type(nathan_key3.get_public_key()), 1); + op.owner = *op.active; + trx.operations.push_back(op); + sign(trx, nathan_key1); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); + trx.clear(); + } FC_CAPTURE_AND_RETHROW ((nathan.active)) + + // two keys should work + { + flat_set public_keys; + public_keys.emplace(nathan_key1.get_public_key()); + public_keys.emplace(nathan_key2.get_public_key()); + BOOST_CHECK(db_api.verify_account_authority("nathan", public_keys)); + } + + // the other two keys should work + { + flat_set public_keys; + public_keys.emplace(nathan_key2.get_public_key()); + public_keys.emplace(nathan_key3.get_public_key()); + BOOST_CHECK(db_api.verify_account_authority("nathan", public_keys)); + } + + // just one key should not work + { + flat_set public_keys; + public_keys.emplace(nathan_key1.get_public_key()); + BOOST_CHECK(!db_api.verify_account_authority("nathan", public_keys)); + } + } catch (fc::exception& e) { + edump((e.to_detail_string())); + throw; + } +} + BOOST_AUTO_TEST_SUITE_END() + From 5db31f5e8f2d27427825d28fb68d3763d295f572 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 23 Oct 2018 05:06:58 -0500 Subject: [PATCH 019/172] shorten line length --- tests/tests/wallet_tests.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/tests/wallet_tests.cpp b/tests/tests/wallet_tests.cpp index 7311a43ce3..4e91969e10 100644 --- a/tests/tests/wallet_tests.cpp +++ b/tests/tests/wallet_tests.cpp @@ -109,7 +109,8 @@ BOOST_AUTO_TEST_CASE( any_two_of_three ) try { account_update_operation op; op.account = nathan.id; - op.active = authority(2, public_key_type(nathan_key1.get_public_key()), 1, public_key_type(nathan_key2.get_public_key()), 1, public_key_type(nathan_key3.get_public_key()), 1); + op.active = authority(2, public_key_type(nathan_key1.get_public_key()), 1, + public_key_type(nathan_key2.get_public_key()), 1, public_key_type(nathan_key3.get_public_key()), 1); op.owner = *op.active; trx.operations.push_back(op); sign(trx, nathan_key1); From 7e4e033039bc52a339370954a68d4082a0cd5929 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 23 Oct 2018 12:47:26 -0500 Subject: [PATCH 020/172] add test for multisig --- tests/tests/wallet_tests.cpp | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/tests/wallet_tests.cpp b/tests/tests/wallet_tests.cpp index 4e91969e10..766435e974 100644 --- a/tests/tests/wallet_tests.cpp +++ b/tests/tests/wallet_tests.cpp @@ -146,5 +146,47 @@ BOOST_AUTO_TEST_CASE( any_two_of_three ) } } +BOOST_AUTO_TEST_CASE( verify_authority_multiple_accounts ) +{ + try { + fc::ecc::private_key nathan_key = fc::ecc::private_key::regenerate(fc::digest("key1")); + fc::ecc::private_key alice_key = fc::ecc::private_key::regenerate(fc::digest("key2")); + fc::ecc::private_key bob_key = fc::ecc::private_key::regenerate(fc::digest("key3")); + + const account_object& nathan = create_account("nathan", nathan_key.get_public_key() ); + fund(nathan); + + create_account("alice", alice_key.get_public_key() ); + create_account("bob", bob_key.get_public_key() ); + + graphene::app::database_api db_api(db); + + try { + account_update_operation op; + op.account = nathan.id; + op.active = authority(3, public_key_type(nathan_key.get_public_key()), 1, + public_key_type(alice_key.get_public_key()), 1, public_key_type(bob_key.get_public_key()), 1); + op.owner = *op.active; + trx.operations.push_back(op); + sign(trx, nathan_key); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); + trx.clear(); + } FC_CAPTURE_AND_RETHROW ((nathan.active)) + + // requires 3 signatures + { + flat_set public_keys; + public_keys.emplace(nathan_key.get_public_key()); + public_keys.emplace(alice_key.get_public_key()); + public_keys.emplace(bob_key.get_public_key()); + BOOST_CHECK(db_api.verify_account_authority("nathan", public_keys)); + } + + } catch (fc::exception& e) { + edump((e.to_detail_string())); + throw; + } +} + BOOST_AUTO_TEST_SUITE_END() From e03d32914540a8e82fca37504f82aa3715c9d647 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 23 Oct 2018 13:21:38 -0500 Subject: [PATCH 021/172] improved multisig test --- tests/tests/wallet_tests.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/tests/tests/wallet_tests.cpp b/tests/tests/wallet_tests.cpp index 766435e974..569c090ba8 100644 --- a/tests/tests/wallet_tests.cpp +++ b/tests/tests/wallet_tests.cpp @@ -149,26 +149,18 @@ BOOST_AUTO_TEST_CASE( any_two_of_three ) BOOST_AUTO_TEST_CASE( verify_authority_multiple_accounts ) { try { - fc::ecc::private_key nathan_key = fc::ecc::private_key::regenerate(fc::digest("key1")); - fc::ecc::private_key alice_key = fc::ecc::private_key::regenerate(fc::digest("key2")); - fc::ecc::private_key bob_key = fc::ecc::private_key::regenerate(fc::digest("key3")); - - const account_object& nathan = create_account("nathan", nathan_key.get_public_key() ); - fund(nathan); - - create_account("alice", alice_key.get_public_key() ); - create_account("bob", bob_key.get_public_key() ); + ACTORS( (nathan) (alice) (bob) ); graphene::app::database_api db_api(db); try { account_update_operation op; op.account = nathan.id; - op.active = authority(3, public_key_type(nathan_key.get_public_key()), 1, - public_key_type(alice_key.get_public_key()), 1, public_key_type(bob_key.get_public_key()), 1); + op.active = authority(3, nathan_public_key, 1, + alice.id, 1, bob.id, 1); op.owner = *op.active; trx.operations.push_back(op); - sign(trx, nathan_key); + sign(trx, nathan_private_key); PUSH_TX( db, trx, database::skip_transaction_dupe_check ); trx.clear(); } FC_CAPTURE_AND_RETHROW ((nathan.active)) @@ -176,12 +168,19 @@ BOOST_AUTO_TEST_CASE( verify_authority_multiple_accounts ) // requires 3 signatures { flat_set public_keys; - public_keys.emplace(nathan_key.get_public_key()); - public_keys.emplace(alice_key.get_public_key()); - public_keys.emplace(bob_key.get_public_key()); + public_keys.emplace(nathan_public_key); + public_keys.emplace(alice_public_key); + public_keys.emplace(bob_public_key); BOOST_CHECK(db_api.verify_account_authority("nathan", public_keys)); } + // only 2 signatures given + { + flat_set public_keys; + public_keys.emplace(nathan_public_key); + public_keys.emplace(bob_public_key); + BOOST_CHECK(!db_api.verify_account_authority("nathan", public_keys)); + } } catch (fc::exception& e) { edump((e.to_detail_string())); throw; From 673ac2b86574f39fbe420c71c5829c15ef9664a6 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 23 Oct 2018 13:49:54 -0500 Subject: [PATCH 022/172] fix short line --- tests/tests/wallet_tests.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/tests/wallet_tests.cpp b/tests/tests/wallet_tests.cpp index 569c090ba8..02babadb9c 100644 --- a/tests/tests/wallet_tests.cpp +++ b/tests/tests/wallet_tests.cpp @@ -156,8 +156,7 @@ BOOST_AUTO_TEST_CASE( verify_authority_multiple_accounts ) try { account_update_operation op; op.account = nathan.id; - op.active = authority(3, nathan_public_key, 1, - alice.id, 1, bob.id, 1); + op.active = authority(3, nathan_public_key, 1, alice.id, 1, bob.id, 1); op.owner = *op.active; trx.operations.push_back(op); sign(trx, nathan_private_key); From f523ad6eb9c535ad04cb0cfeec96b26f575847e2 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 23 Oct 2018 14:51:27 -0500 Subject: [PATCH 023/172] moved tests, fixed comments --- .../app/include/graphene/app/database_api.hpp | 4 +- tests/tests/database_api_tests.cpp | 110 +++++++++++++++++ tests/tests/wallet_tests.cpp | 111 +----------------- 3 files changed, 113 insertions(+), 112 deletions(-) diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 1e4e296d2b..65de6e2ff6 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -663,10 +663,10 @@ class database_api bool verify_authority( const signed_transaction& trx )const; /** - * @brief Verify that the public keys have enough authority to authorize a transaction + * @brief Verify that the public keys have enough authority to approve an operation * @param account_name_or_id the account to check * @param signers the public keys - * @return true if the passed in keys have enough authority to authorize a transaction + * @return true if the passed in keys have enough authority to approve an operation */ bool verify_account_authority( const string& account_name_or_id, const flat_set& signers )const; diff --git a/tests/tests/database_api_tests.cpp b/tests/tests/database_api_tests.cpp index 2577f57710..1eeb177b42 100644 --- a/tests/tests/database_api_tests.cpp +++ b/tests/tests/database_api_tests.cpp @@ -831,4 +831,114 @@ BOOST_AUTO_TEST_CASE( get_transaction_hex ) } FC_LOG_AND_RETHROW() } +BOOST_AUTO_TEST_CASE(verify_account_authority) +{ + try { + + ACTORS( (nathan) ); + graphene::app::database_api db_api(db); + + // good keys + flat_set public_keys; + public_keys.emplace(nathan_public_key); + BOOST_CHECK(db_api.verify_account_authority( "nathan", public_keys)); + + // bad keys + flat_set bad_public_keys; + bad_public_keys.emplace(public_key_type("BTS6MkMxwBjFWmcDjXRoJ4mW9Hd4LCSPwtv9tKG1qYW5Kgu4AhoZy")); + BOOST_CHECK(!db_api.verify_account_authority( "nathan", bad_public_keys)); + + } FC_LOG_AND_RETHROW() +} + +BOOST_AUTO_TEST_CASE( any_two_of_three ) +{ + try { + fc::ecc::private_key nathan_key1 = fc::ecc::private_key::regenerate(fc::digest("key1")); + fc::ecc::private_key nathan_key2 = fc::ecc::private_key::regenerate(fc::digest("key2")); + fc::ecc::private_key nathan_key3 = fc::ecc::private_key::regenerate(fc::digest("key3")); + const account_object& nathan = create_account("nathan", nathan_key1.get_public_key() ); + fund(nathan); + graphene::app::database_api db_api(db); + + try { + account_update_operation op; + op.account = nathan.id; + op.active = authority(2, public_key_type(nathan_key1.get_public_key()), 1, + public_key_type(nathan_key2.get_public_key()), 1, public_key_type(nathan_key3.get_public_key()), 1); + op.owner = *op.active; + trx.operations.push_back(op); + sign(trx, nathan_key1); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); + trx.clear(); + } FC_CAPTURE_AND_RETHROW ((nathan.active)) + + // two keys should work + { + flat_set public_keys; + public_keys.emplace(nathan_key1.get_public_key()); + public_keys.emplace(nathan_key2.get_public_key()); + BOOST_CHECK(db_api.verify_account_authority("nathan", public_keys)); + } + + // the other two keys should work + { + flat_set public_keys; + public_keys.emplace(nathan_key2.get_public_key()); + public_keys.emplace(nathan_key3.get_public_key()); + BOOST_CHECK(db_api.verify_account_authority("nathan", public_keys)); + } + + // just one key should not work + { + flat_set public_keys; + public_keys.emplace(nathan_key1.get_public_key()); + BOOST_CHECK(!db_api.verify_account_authority("nathan", public_keys)); + } + } catch (fc::exception& e) { + edump((e.to_detail_string())); + throw; + } +} + +BOOST_AUTO_TEST_CASE( verify_authority_multiple_accounts ) +{ + try { + ACTORS( (nathan) (alice) (bob) ); + + graphene::app::database_api db_api(db); + + try { + account_update_operation op; + op.account = nathan.id; + op.active = authority(3, nathan_public_key, 1, alice.id, 1, bob.id, 1); + op.owner = *op.active; + trx.operations.push_back(op); + sign(trx, nathan_private_key); + PUSH_TX( db, trx, database::skip_transaction_dupe_check ); + trx.clear(); + } FC_CAPTURE_AND_RETHROW ((nathan.active)) + + // requires 3 signatures + { + flat_set public_keys; + public_keys.emplace(nathan_public_key); + public_keys.emplace(alice_public_key); + public_keys.emplace(bob_public_key); + BOOST_CHECK(db_api.verify_account_authority("nathan", public_keys)); + } + + // only 2 signatures given + { + flat_set public_keys; + public_keys.emplace(nathan_public_key); + public_keys.emplace(bob_public_key); + BOOST_CHECK(!db_api.verify_account_authority("nathan", public_keys)); + } + } catch (fc::exception& e) { + edump((e.to_detail_string())); + throw; + } +} + BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/tests/wallet_tests.cpp b/tests/tests/wallet_tests.cpp index 02babadb9c..8601f747d5 100644 --- a/tests/tests/wallet_tests.cpp +++ b/tests/tests/wallet_tests.cpp @@ -76,115 +76,6 @@ BOOST_FIXTURE_TEST_SUITE(wallet_tests, database_fixture) } FC_LOG_AND_RETHROW() } - - BOOST_AUTO_TEST_CASE(verify_account_authority) { - try { - - ACTORS( (nathan) ); - graphene::app::database_api db_api(db); - - // good keys - flat_set public_keys; - public_keys.emplace(nathan_public_key); - BOOST_CHECK(db_api.verify_account_authority( "nathan", public_keys)); - - // bad keys - flat_set bad_public_keys; - bad_public_keys.emplace(public_key_type("BTS6MkMxwBjFWmcDjXRoJ4mW9Hd4LCSPwtv9tKG1qYW5Kgu4AhoZy")); - BOOST_CHECK(!db_api.verify_account_authority( "nathan", bad_public_keys)); - - } FC_LOG_AND_RETHROW() - } - -BOOST_AUTO_TEST_CASE( any_two_of_three ) -{ - try { - fc::ecc::private_key nathan_key1 = fc::ecc::private_key::regenerate(fc::digest("key1")); - fc::ecc::private_key nathan_key2 = fc::ecc::private_key::regenerate(fc::digest("key2")); - fc::ecc::private_key nathan_key3 = fc::ecc::private_key::regenerate(fc::digest("key3")); - const account_object& nathan = create_account("nathan", nathan_key1.get_public_key() ); - fund(nathan); - graphene::app::database_api db_api(db); - - try { - account_update_operation op; - op.account = nathan.id; - op.active = authority(2, public_key_type(nathan_key1.get_public_key()), 1, - public_key_type(nathan_key2.get_public_key()), 1, public_key_type(nathan_key3.get_public_key()), 1); - op.owner = *op.active; - trx.operations.push_back(op); - sign(trx, nathan_key1); - PUSH_TX( db, trx, database::skip_transaction_dupe_check ); - trx.clear(); - } FC_CAPTURE_AND_RETHROW ((nathan.active)) - - // two keys should work - { - flat_set public_keys; - public_keys.emplace(nathan_key1.get_public_key()); - public_keys.emplace(nathan_key2.get_public_key()); - BOOST_CHECK(db_api.verify_account_authority("nathan", public_keys)); - } - - // the other two keys should work - { - flat_set public_keys; - public_keys.emplace(nathan_key2.get_public_key()); - public_keys.emplace(nathan_key3.get_public_key()); - BOOST_CHECK(db_api.verify_account_authority("nathan", public_keys)); - } - - // just one key should not work - { - flat_set public_keys; - public_keys.emplace(nathan_key1.get_public_key()); - BOOST_CHECK(!db_api.verify_account_authority("nathan", public_keys)); - } - } catch (fc::exception& e) { - edump((e.to_detail_string())); - throw; - } -} - -BOOST_AUTO_TEST_CASE( verify_authority_multiple_accounts ) -{ - try { - ACTORS( (nathan) (alice) (bob) ); - - graphene::app::database_api db_api(db); - - try { - account_update_operation op; - op.account = nathan.id; - op.active = authority(3, nathan_public_key, 1, alice.id, 1, bob.id, 1); - op.owner = *op.active; - trx.operations.push_back(op); - sign(trx, nathan_private_key); - PUSH_TX( db, trx, database::skip_transaction_dupe_check ); - trx.clear(); - } FC_CAPTURE_AND_RETHROW ((nathan.active)) - - // requires 3 signatures - { - flat_set public_keys; - public_keys.emplace(nathan_public_key); - public_keys.emplace(alice_public_key); - public_keys.emplace(bob_public_key); - BOOST_CHECK(db_api.verify_account_authority("nathan", public_keys)); - } - - // only 2 signatures given - { - flat_set public_keys; - public_keys.emplace(nathan_public_key); - public_keys.emplace(bob_public_key); - BOOST_CHECK(!db_api.verify_account_authority("nathan", public_keys)); - } - } catch (fc::exception& e) { - edump((e.to_detail_string())); - throw; - } -} - + BOOST_AUTO_TEST_SUITE_END() From b0783108b72f8c784ff90c8a6101afc9ada0874f Mon Sep 17 00:00:00 2001 From: John Jones Date: Wed, 24 Oct 2018 07:12:00 -0500 Subject: [PATCH 024/172] clarify comment --- libraries/app/include/graphene/app/database_api.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 65de6e2ff6..9a546eef42 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -663,10 +663,10 @@ class database_api bool verify_authority( const signed_transaction& trx )const; /** - * @brief Verify that the public keys have enough authority to approve an operation + * @brief Verify that the public keys have enough authority to approve an operation for this account * @param account_name_or_id the account to check * @param signers the public keys - * @return true if the passed in keys have enough authority to approve an operation + * @return true if the passed in keys have enough authority to approve an operation for this account */ bool verify_account_authority( const string& account_name_or_id, const flat_set& signers )const; From c293b4058ca03fbc0db01cf984cc9240a348d4f0 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 26 Oct 2018 18:54:31 -0300 Subject: [PATCH 025/172] bump fc and fix node --- libraries/fc | 2 +- libraries/net/node.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/fc b/libraries/fc index a1d84f22c0..8b6a2dd450 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit a1d84f22c07a2875e21a1bab051851f6809a188b +Subproject commit 8b6a2dd450e2c683f234fc8e7af7c8aff5d89607 diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index b2eb5185cb..612529f93c 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -317,7 +317,7 @@ namespace graphene { namespace net { namespace detail { _maximum_blocks_per_peer_during_syncing(GRAPHENE_NET_MAX_BLOCKS_PER_PEER_DURING_SYNCING) { _rate_limiter.set_actual_rate_time_constant(fc::seconds(2)); - fc::rand_pseudo_bytes(&_node_id.data[0], (int)_node_id.size()); + fc::rand_bytes(&_node_id.data[0], (int)_node_id.size()); } node_impl::~node_impl() From 3fb6c44d9e7f951102b222f4678bfe1ce54e6b41 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Sun, 28 Oct 2018 11:05:30 -0300 Subject: [PATCH 026/172] try to fix dockercloud --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index fa58c2da1b..363460d2c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,6 +38,7 @@ RUN \ git submodule update --init --recursive && \ cmake \ -DCMAKE_BUILD_TYPE=Release \ + -DGRAPHENE_DISABLE_UNITY_BUILD=ON \ . && \ make witness_node cli_wallet && \ install -s programs/witness_node/witness_node programs/cli_wallet/cli_wallet /usr/local/bin && \ From 3e1de10ddafe1c4ec5c4da50ec7ccb417de38ebc Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Sun, 28 Oct 2018 12:05:17 -0300 Subject: [PATCH 027/172] remove DGRAPHENE_DISABLE_UNITY_BUILD from cmake command in dockerfile as it will not fix the dockercloud issue. --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 363460d2c5..fa58c2da1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,7 +38,6 @@ RUN \ git submodule update --init --recursive && \ cmake \ -DCMAKE_BUILD_TYPE=Release \ - -DGRAPHENE_DISABLE_UNITY_BUILD=ON \ . && \ make witness_node cli_wallet && \ install -s programs/witness_node/witness_node programs/cli_wallet/cli_wallet /usr/local/bin && \ From ca884e2b9f079cece2912c722a5a60106fbd1d0c Mon Sep 17 00:00:00 2001 From: Haruka Ma Date: Tue, 30 Oct 2018 12:28:35 +0900 Subject: [PATCH 028/172] Change description of delayed_node option --- libraries/plugins/delayed_node/delayed_node_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/plugins/delayed_node/delayed_node_plugin.cpp b/libraries/plugins/delayed_node/delayed_node_plugin.cpp index 24a46cc066..f780d8b496 100644 --- a/libraries/plugins/delayed_node/delayed_node_plugin.cpp +++ b/libraries/plugins/delayed_node/delayed_node_plugin.cpp @@ -58,7 +58,7 @@ delayed_node_plugin::~delayed_node_plugin() void delayed_node_plugin::plugin_set_program_options(bpo::options_description& cli, bpo::options_description& cfg) { cli.add_options() - ("trusted-node", boost::program_options::value(), "RPC endpoint of a trusted validating node (required)") + ("trusted-node", boost::program_options::value(), "RPC endpoint of a trusted validating node (required for delayed_node)") ; cfg.add(cli); } From 5f699b41806283a9dd11ee9d6f1390a4b2e842e7 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 31 Oct 2018 14:20:45 +0100 Subject: [PATCH 029/172] Fix: waiting for a promise with a timeout can lead to the promise erroring out --- programs/network_mapper/network_mapper.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/programs/network_mapper/network_mapper.cpp b/programs/network_mapper/network_mapper.cpp index 6ff51f7eba..6fef314254 100644 --- a/programs/network_mapper/network_mapper.cpp +++ b/programs/network_mapper/network_mapper.cpp @@ -212,7 +212,7 @@ int main(int argc, char** argv) { std::shared_ptr probe(new peer_probe()); probe->start(remote, my_node_id, chain_id); - probes.push_back( probe ); + probes.emplace_back( std::move( probe ) ); } catch (const fc::exception&) { @@ -222,10 +222,7 @@ int main(int argc, char** argv) if (!probes.empty()) { - try { - probes[0]->wait( fc::microseconds(10000) ); - } catch ( fc::timeout_exception& e ) { /* ignore */ } - + fc::yield(); std::vector> running; for ( auto& probe : probes ) { if (probe->_probe_complete_promise->error()) From 9237a716d744472ee19bf17017489574c1dce575 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 5 Nov 2018 16:27:42 +0100 Subject: [PATCH 030/172] Bump fc after re-improving compile time resource usage --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 8b6a2dd450..12e4962891 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 8b6a2dd450e2c683f234fc8e7af7c8aff5d89607 +Subproject commit 12e4962891b3f1e23bcd49867bd5a9146c3db03e From 55aa07ee538b1b68255a740aea68d792a5723da2 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 7 Nov 2018 14:26:21 +0100 Subject: [PATCH 031/172] Skip tests if compile time is too long --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9e21993904..dc295168fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,8 +34,9 @@ script: - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON . - 'which build-wrapper-linux-x86-64 && build-wrapper-linux-x86-64 --out-dir bw-output make -j 2 cli_wallet witness_node chain_test cli_test || make -j 2 cli_wallet witness_node chain_test cli_test' - set -o pipefail + - '[ $((`date +%s` - `cat _start_time`)) -gt $((42 * 60)) ] && touch _empty_cache' - '[ -r _empty_cache ] || tests/chain_test 2>&1 | cat' - '[ -r _empty_cache ] || tests/cli_test 2>&1 | cat' - 'find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d | while read d; do gcov -o "$d" "${d/CMakeFiles*.dir//}"/*.cpp; done >/dev/null' - - '( [ -r _empty_cache -o $((`date +%s` - `cat _start_time`)) -gt $((42 * 60)) ] && echo "WARNING! Skipping sonar scanner due to time constraints!" ) || ( which sonar-scanner && sonar-scanner || true )' - - '[ ! -r _empty_cache ] || ( echo "Please restart with populated cache" && false )' + - '( [ -r _empty_cache ] || ( which sonar-scanner && sonar-scanner || true )' + - '[ ! -r _empty_cache ] || ( echo "WARNING! Skipped some tests due to compile time! Please restart with populated cache." && false )' From 1695076f5040618005e4d6788e9de8d2cf88a28d Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 7 Nov 2018 16:13:41 +0100 Subject: [PATCH 032/172] Bump fc again for fc#88 --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 12e4962891..9cce60c917 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 12e4962891b3f1e23bcd49867bd5a9146c3db03e +Subproject commit 9cce60c91773ad99cfdfa42c5e86ba6ceb3f3ee9 From 3aa689ea60a951896e45ce40fdd7689fef4c6027 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 7 Nov 2018 16:14:22 +0100 Subject: [PATCH 033/172] Fixed travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dc295168fd..236fa6ef78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,9 +34,9 @@ script: - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON . - 'which build-wrapper-linux-x86-64 && build-wrapper-linux-x86-64 --out-dir bw-output make -j 2 cli_wallet witness_node chain_test cli_test || make -j 2 cli_wallet witness_node chain_test cli_test' - set -o pipefail - - '[ $((`date +%s` - `cat _start_time`)) -gt $((42 * 60)) ] && touch _empty_cache' + - '[ $((`date +%s` - `cat _start_time`)) -gt $((42 * 60)) ] && touch _empty_cache || true' - '[ -r _empty_cache ] || tests/chain_test 2>&1 | cat' - '[ -r _empty_cache ] || tests/cli_test 2>&1 | cat' - 'find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d | while read d; do gcov -o "$d" "${d/CMakeFiles*.dir//}"/*.cpp; done >/dev/null' - - '( [ -r _empty_cache ] || ( which sonar-scanner && sonar-scanner || true )' + - '[ -r _empty_cache ] || ( which sonar-scanner && sonar-scanner || true )' - '[ ! -r _empty_cache ] || ( echo "WARNING! Skipped some tests due to compile time! Please restart with populated cache." && false )' From 15e903717fdad07eba083dd8505a2f2d5f7926ca Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 9 Nov 2018 16:20:59 -0300 Subject: [PATCH 034/172] refactor es_objects to use templates --- libraries/plugins/es_objects/es_objects.cpp | 194 +++--------------- .../graphene/es_objects/es_objects.hpp | 157 +++++--------- 2 files changed, 82 insertions(+), 269 deletions(-) diff --git a/libraries/plugins/es_objects/es_objects.cpp b/libraries/plugins/es_objects/es_objects.cpp index d0c35010ce..0cd4bc256d 100644 --- a/libraries/plugins/es_objects/es_objects.cpp +++ b/libraries/plugins/es_objects/es_objects.cpp @@ -30,10 +30,12 @@ #include #include #include +#include +#include +#include #include - namespace graphene { namespace es_objects { namespace detail @@ -72,12 +74,8 @@ class es_objects_plugin_impl fc::time_point_sec block_time; private: - void prepare_proposal(const proposal_object& proposal_object); - void prepare_account(const account_object& account_object); - void prepare_asset(const asset_object& asset_object); - void prepare_balance(const account_balance_object& account_balance_object); - void prepare_limit(const limit_order_object& limit_object); - void prepare_bitasset(const asset_bitasset_data_object& bitasset_object); + template + void prepareTemplate(T blockchain_object, string index_name); }; bool es_objects_plugin_impl::index_database( const vector& ids, std::string action) @@ -102,7 +100,7 @@ bool es_objects_plugin_impl::index_database( const vector& ids, if(action == "delete") remove_from_database(p->id, "proposal"); else - prepare_proposal(*p); + prepareTemplate(*p, "proposal"); } } else if(value.is() && _es_objects_accounts) { @@ -112,7 +110,7 @@ bool es_objects_plugin_impl::index_database( const vector& ids, if(action == "delete") remove_from_database(a->id, "account"); else - prepare_account(*a); + prepareTemplate(*a, "account"); } } else if(value.is() && _es_objects_assets) { @@ -122,7 +120,7 @@ bool es_objects_plugin_impl::index_database( const vector& ids, if(action == "delete") remove_from_database(a->id, "asset"); else - prepare_asset(*a); + prepareTemplate(*a, "asset"); } } else if(value.is() && _es_objects_balances) { @@ -132,7 +130,7 @@ bool es_objects_plugin_impl::index_database( const vector& ids, if(action == "delete") remove_from_database(b->id, "balance"); else - prepare_balance(*b); + prepareTemplate(*b, "balance"); } } else if(value.is() && _es_objects_limit_orders) { @@ -142,7 +140,7 @@ bool es_objects_plugin_impl::index_database( const vector& ids, if(action == "delete") remove_from_database(l->id, "limitorder"); else - prepare_limit(*l); + prepareTemplate(*l, "limitorder"); } } else if(value.is() && _es_objects_asset_bitasset) { @@ -152,7 +150,7 @@ bool es_objects_plugin_impl::index_database( const vector& ids, if(action == "delete") remove_from_database(ba->id, "bitasset"); else - prepare_bitasset(*ba); + prepareTemplate(*ba, "bitasset"); } } } @@ -190,181 +188,39 @@ void es_objects_plugin_impl::remove_from_database( object_id_type id, std::strin } } -void es_objects_plugin_impl::prepare_proposal(const proposal_object& proposal_object) -{ - proposal_struct prop; - prop.object_id = proposal_object.id; - prop.block_time = block_time; - prop.block_number = block_number; - prop.expiration_time = proposal_object.expiration_time; - prop.review_period_time = proposal_object.review_period_time; - prop.proposed_transaction = fc::json::to_string(proposal_object.proposed_transaction); - prop.required_owner_approvals = fc::json::to_string(proposal_object.required_owner_approvals); - prop.available_owner_approvals = fc::json::to_string(proposal_object.available_owner_approvals); - prop.required_active_approvals = fc::json::to_string(proposal_object.required_active_approvals); - prop.available_key_approvals = fc::json::to_string(proposal_object.available_key_approvals); - prop.proposer = proposal_object.proposer; - - std::string data = fc::json::to_string(prop); - - fc::mutable_variant_object bulk_header; - bulk_header["_index"] = _es_objects_index_prefix + "proposal"; - bulk_header["_type"] = "data"; - if(_es_objects_keep_only_current) - { - bulk_header["_id"] = string(prop.object_id); - } - - prepare = graphene::utilities::createBulk(bulk_header, std::move(data)); - std::move(prepare.begin(), prepare.end(), std::back_inserter(bulk)); - prepare.clear(); -} - -void es_objects_plugin_impl::prepare_account(const account_object& account_object) -{ - account_struct acct; - acct.object_id = account_object.id; - acct.block_time = block_time; - acct.block_number = block_number; - acct.membership_expiration_date = account_object.membership_expiration_date; - acct.registrar = account_object.registrar; - acct.referrer = account_object.referrer; - acct.lifetime_referrer = account_object.lifetime_referrer; - acct.network_fee_percentage = account_object.network_fee_percentage; - acct.lifetime_referrer_fee_percentage = account_object.lifetime_referrer_fee_percentage; - acct.referrer_rewards_percentage = account_object.referrer_rewards_percentage; - acct.name = account_object.name; - acct.owner_account_auths = fc::json::to_string(account_object.owner.account_auths); - acct.owner_key_auths = fc::json::to_string(account_object.owner.key_auths); - acct.owner_address_auths = fc::json::to_string(account_object.owner.address_auths); - acct.active_account_auths = fc::json::to_string(account_object.active.account_auths); - acct.active_key_auths = fc::json::to_string(account_object.active.key_auths); - acct.active_address_auths = fc::json::to_string(account_object.active.address_auths); - acct.voting_account = account_object.options.voting_account; - acct.votes = fc::json::to_string(account_object.options.votes); - - std::string data = fc::json::to_string(acct); - - fc::mutable_variant_object bulk_header; - bulk_header["_index"] = _es_objects_index_prefix + "account"; - bulk_header["_type"] = "data"; - if(_es_objects_keep_only_current) - { - bulk_header["_id"] = string(acct.object_id); - } - - prepare = graphene::utilities::createBulk(bulk_header, std::move(data)); - std::move(prepare.begin(), prepare.end(), std::back_inserter(bulk)); - prepare.clear(); -} - -void es_objects_plugin_impl::prepare_asset(const asset_object& asset_object) +template +void es_objects_plugin_impl::prepareTemplate(T blockchain_object, string index_name) { - asset_struct asset; - asset.object_id = asset_object.id; - asset.block_time = block_time; - asset.block_number = block_number; - asset.symbol = asset_object.symbol; - asset.issuer = asset_object.issuer; - asset.is_market_issued = asset_object.is_market_issued(); - asset.dynamic_asset_data_id = asset_object.dynamic_asset_data_id; - asset.bitasset_data_id = asset_object.bitasset_data_id; - - std::string data = fc::json::to_string(asset); - fc::mutable_variant_object bulk_header; - bulk_header["_index"] = _es_objects_index_prefix + "asset"; + bulk_header["_index"] = _es_objects_index_prefix + index_name; bulk_header["_type"] = "data"; if(_es_objects_keep_only_current) { - bulk_header["_id"] = string(asset.object_id); + bulk_header["_id"] = string(blockchain_object.id); } - prepare = graphene::utilities::createBulk(bulk_header, std::move(data)); - std::move(prepare.begin(), prepare.end(), std::back_inserter(bulk)); - prepare.clear(); -} + auto blockchain_object_string = fc::json::to_string(blockchain_object, fc::json::legacy_generator); -void es_objects_plugin_impl::prepare_balance(const account_balance_object& account_balance_object) -{ - balance_struct balance; - balance.object_id = account_balance_object.id; - balance.block_time = block_time; - balance.block_number = block_number; - balance.owner = account_balance_object.owner; - balance.asset_type = account_balance_object.asset_type; - balance.balance = account_balance_object.balance; - balance.maintenance_flag = account_balance_object.maintenance_flag; + variant j = fc::json::from_string(blockchain_object_string); - std::string data = fc::json::to_string(balance); + fc::mutable_variant_object o; - fc::mutable_variant_object bulk_header; - bulk_header["_index"] = _es_objects_index_prefix + "balance"; - bulk_header["_type"] = "data"; - if(_es_objects_keep_only_current) - { - bulk_header["_id"] = string(balance.object_id); - } + adaptor_struct adaptor; + auto adapted = adaptor.adapt(j.get_object()); - prepare = graphene::utilities::createBulk(bulk_header, std::move(data)); - std::move(prepare.begin(), prepare.end(), std::back_inserter(bulk)); - prepare.clear(); -} + fc::from_variant(adapted, o, FC_PACK_MAX_DEPTH); -void es_objects_plugin_impl::prepare_limit(const limit_order_object& limit_object) -{ - limit_order_struct limit; - limit.object_id = limit_object.id; - limit.block_time = block_time; - limit.block_number = block_number; - limit.expiration = limit_object.expiration; - limit.seller = limit_object.seller; - limit.for_sale = limit_object.for_sale; - limit.sell_price = limit_object.sell_price; - limit.deferred_fee = limit_object.deferred_fee; - - std::string data = fc::json::to_string(limit); + o["object_id"] = string(blockchain_object.id); + o["block_time"] = block_time; + o["block_number"] = block_number; - fc::mutable_variant_object bulk_header; - bulk_header["_index"] = _es_objects_index_prefix + "limitorder"; - bulk_header["_type"] = "data"; - if(_es_objects_keep_only_current) - { - bulk_header["_id"] = string(limit.object_id); - } + string data = fc::json::to_string(o, fc::json::legacy_generator); prepare = graphene::utilities::createBulk(bulk_header, std::move(data)); std::move(prepare.begin(), prepare.end(), std::back_inserter(bulk)); prepare.clear(); } -void es_objects_plugin_impl::prepare_bitasset(const asset_bitasset_data_object& bitasset_object) -{ - if(!bitasset_object.is_prediction_market) { - - bitasset_struct bitasset; - bitasset.object_id = bitasset_object.id; - bitasset.block_time = block_time; - bitasset.block_number = block_number; - bitasset.current_feed = fc::json::to_string(bitasset_object.current_feed); - bitasset.current_feed_publication_time = bitasset_object.current_feed_publication_time; - - std::string data = fc::json::to_string(bitasset); - - fc::mutable_variant_object bulk_header; - bulk_header["_index"] = _es_objects_index_prefix + "bitasset"; - bulk_header["_type"] = "data"; - if(_es_objects_keep_only_current) - { - bulk_header["_id"] = string(bitasset.object_id); - } - - prepare = graphene::utilities::createBulk(bulk_header, std::move(data)); - std::move(prepare.begin(), prepare.end(), std::back_inserter(bulk)); - prepare.clear(); - } -} - es_objects_plugin_impl::~es_objects_plugin_impl() { return; diff --git a/libraries/plugins/es_objects/include/graphene/es_objects/es_objects.hpp b/libraries/plugins/es_objects/include/graphene/es_objects/es_objects.hpp index 54ecbdc90d..a66e299551 100644 --- a/libraries/plugins/es_objects/include/graphene/es_objects/es_objects.hpp +++ b/libraries/plugins/es_objects/include/graphene/es_objects/es_objects.hpp @@ -30,7 +30,6 @@ namespace graphene { namespace es_objects { using namespace chain; - namespace detail { class es_objects_plugin_impl; @@ -54,105 +53,63 @@ class es_objects_plugin : public graphene::app::plugin std::unique_ptr my; }; -struct proposal_struct { - object_id_type object_id; - fc::time_point_sec block_time; - uint32_t block_number; - time_point_sec expiration_time; - optional review_period_time; - string proposed_transaction; - string required_active_approvals; - string available_active_approvals; - string required_owner_approvals; - string available_owner_approvals; - string available_key_approvals; - account_id_type proposer; -}; -struct account_struct { - object_id_type object_id; - fc::time_point_sec block_time; - uint32_t block_number; - time_point_sec membership_expiration_date; - account_id_type registrar; - account_id_type referrer; - account_id_type lifetime_referrer; - uint16_t network_fee_percentage; - uint16_t lifetime_referrer_fee_percentage; - uint16_t referrer_rewards_percentage; - string name; - string owner_account_auths; - string owner_key_auths; - string owner_address_auths; - string active_account_auths; - string active_key_auths; - string active_address_auths; - account_id_type voting_account; - string votes; -}; -struct asset_struct { - object_id_type object_id; - fc::time_point_sec block_time; - uint32_t block_number; - string symbol; - account_id_type issuer; - bool is_market_issued; - asset_dynamic_data_id_type dynamic_asset_data_id; - optional bitasset_data_id; -}; -struct balance_struct { - object_id_type object_id; - fc::time_point_sec block_time; - uint32_t block_number; - account_id_type owner; - asset_id_type asset_type; - share_type balance; - bool maintenance_flag; -}; -struct limit_order_struct { - object_id_type object_id; - fc::time_point_sec block_time; - uint32_t block_number; - time_point_sec expiration; - account_id_type seller; - share_type for_sale; - price sell_price; - share_type deferred_fee; -}; -struct bitasset_struct { - object_id_type object_id; - fc::time_point_sec block_time; - uint32_t block_number; - string current_feed; - time_point_sec current_feed_publication_time; - time_point_sec feed_expiration_time; +struct adaptor_struct { + variant adapt(const variant_object &obj) { + fc::mutable_variant_object o(obj); + vector keys_to_rename; + for (auto i = o.begin(); i != o.end(); ++i) { + auto &element = (*i).value(); + if (element.is_object()) { + const string &name = (*i).key(); + auto &vo = element.get_object(); + if (vo.contains(name.c_str())) + keys_to_rename.emplace_back(name); + element = adapt(vo); + } else if (element.is_array()) + adapt(element.get_array()); + } + for (const auto &i : keys_to_rename) { + string new_name = i + "_"; + o[new_name] = variant(o[i]); + o.erase(i); + } + if (o.find("owner") != o.end() && o["owner"].is_string()) + { + o["owner_"] = o["owner"].as_string(); + o.erase("owner"); + } + if (o.find("active_special_authority") != o.end()) + { + o["active_special_authority"] = fc::json::to_string(o["active_special_authority"]); + } + if (o.find("owner_special_authority") != o.end()) + { + o["owner_special_authority"] = fc::json::to_string(o["owner_special_authority"]); + } + if (o.find("feeds") != o.end()) + { + o["feeds"] = fc::json::to_string(o["feeds"]); + } + if (o.find("operations") != o.end()) + { + o["operations"] = fc::json::to_string(o["operations"]); + } + + variant v; + fc::to_variant(o, v, FC_PACK_MAX_DEPTH); + return v; + } + + void adapt(fc::variants &v) { + for (auto &array_element : v) { + if (array_element.is_object()) + array_element = adapt(array_element.get_object()); + else if (array_element.is_array()) + adapt(array_element.get_array()); + else + array_element = array_element.as_string(); + } + } }; } } //graphene::es_objects - -FC_REFLECT( - graphene::es_objects::proposal_struct, - (object_id)(block_time)(block_number)(expiration_time)(review_period_time)(proposed_transaction)(required_active_approvals) - (available_active_approvals)(required_owner_approvals)(available_owner_approvals)(available_key_approvals)(proposer) -) -FC_REFLECT( - graphene::es_objects::account_struct, - (object_id)(block_time)(block_number)(membership_expiration_date)(registrar)(referrer)(lifetime_referrer) - (network_fee_percentage)(lifetime_referrer_fee_percentage)(referrer_rewards_percentage)(name)(owner_account_auths) - (owner_key_auths)(owner_address_auths)(active_account_auths)(active_key_auths)(active_address_auths)(voting_account)(votes) -) -FC_REFLECT( - graphene::es_objects::asset_struct, - (object_id)(block_time)(block_number)(symbol)(issuer)(is_market_issued)(dynamic_asset_data_id)(bitasset_data_id) -) -FC_REFLECT( - graphene::es_objects::balance_struct, - (object_id)(block_time)(block_number)(owner)(asset_type)(balance)(maintenance_flag) -) -FC_REFLECT( - graphene::es_objects::limit_order_struct, - (object_id)(block_time)(block_number)(expiration)(seller)(for_sale)(sell_price)(deferred_fee) -) -FC_REFLECT( - graphene::es_objects::bitasset_struct, - (object_id)(block_time)(block_number)(current_feed)(current_feed_publication_time) -) \ No newline at end of file From 0abcff9fb8b6d7e369e61bd09557ca3bd1ae2d51 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 7 Nov 2018 08:05:21 -0600 Subject: [PATCH 035/172] Allow required plugins As far as I can tell, there was no way previously for an application to register a plugin and ensure that plugin got loaded -- it would be necessary to manually edit the config and specify the plugin be loaded. This is suboptimal; if third party code wishes to track third party extensions on the blockchain, the correct way to do this is with a plugin, and this third party build should be able to load these required plugins regardless of whether the config lists them or not. This commit adds a boolean parameter to application::register_plugin which defaults to false for backwards compatibility; however, if set to true, the plugin will automatically be enabled when the app initializes. --- .../app/include/graphene/app/application.hpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 4892bb9a27..bea72bf8ed 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -48,18 +48,17 @@ namespace graphene { namespace app { application(); ~application(); - void set_program_options( boost::program_options::options_description& command_line_options, - boost::program_options::options_description& configuration_file_options )const; - void initialize(const fc::path& data_dir, const boost::program_options::variables_map&options); - void initialize_plugins( const boost::program_options::variables_map& options ); + void set_program_options(boost::program_options::options_description& command_line_options, + boost::program_options::options_description& configuration_file_options)const; + void initialize(const fc::path& data_dir, const boost::program_options::variables_map& options); + void initialize_plugins(const boost::program_options::variables_map& options); void startup(); void shutdown(); void startup_plugins(); void shutdown_plugins(); template - std::shared_ptr register_plugin() - { + std::shared_ptr register_plugin(bool auto_load = false) { auto plug = std::make_shared(); plug->plugin_set_app(this); @@ -72,6 +71,10 @@ namespace graphene { namespace app { _cfg_options.add(plugin_cfg_options); add_available_plugin( plug ); + + if (auto_load) + enable_plugin(plug->plugin_name()); + return plug; } std::shared_ptr get_plugin( const string& name )const; From b5362ceddb5d6d793a5ff943e4b8a9e180cb7f60 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 7 Nov 2018 20:28:09 -0600 Subject: [PATCH 036/172] Clean up plugin loader That code was nasty and... kinda wrong. So fix it up all shiny-like. But I also removed the super annoying default "wanted" plugins list, which only causes problems for third parties like me, and in general is just poor form. In my opinion, 5220425d433c1ce7af4f3b243655d74afa6c4e7a provides a much cleaner way to do this, in a way that is friendly rather than hostile to third parties. Would Be Nice: A generalized plugin conflict system added at the abstract_plugin level, so, for example, the elasticsearch plugin can conflict account_history and we deal with this in a general fashion rather than having this dirty special case check here. --- libraries/app/application.cpp | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index b77da4b711..98d187763a 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -1007,31 +1007,17 @@ void application::initialize(const fc::path& data_dir, const boost::program_opti fc::asio::default_io_service_scope::set_num_threads(num_threads); } - std::vector wanted; - if( options.count("plugins") ) - { - boost::split(wanted, options.at("plugins").as(), [](char c){return c == ' ';}); - } - else - { - wanted.push_back("witness"); - wanted.push_back("account_history"); - wanted.push_back("market_history"); - wanted.push_back("grouped_orders"); - } - int es_ah_conflict_counter = 0; - for (auto& it : wanted) - { - if(it == "account_history") - ++es_ah_conflict_counter; - if(it == "elasticsearch") - ++es_ah_conflict_counter; + if (options.count("plugins")) { + std::set plugins; + boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); - if(es_ah_conflict_counter > 1) { - elog("Can't start program with elasticsearch and account_history plugin at the same time"); - std::exit(EXIT_FAILURE); - } - if (!it.empty()) enable_plugin(it); + FC_ASSERT(!(plugins.count("account_history") && plugins.count("elasticsearch")), + "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin"); + + std::for_each(plugins.begin(), plugins.end(), [this](const string& plug) mutable { + if (!plug.empty()) + enable_plugin(plug); + }); } } From 86fb00648019cbd87fa9c07694c4c1b623010a3f Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Thu, 1 Nov 2018 19:06:11 -0600 Subject: [PATCH 037/172] Fix warning Potential optimization: don't move a temporary as this prevents copy elision --- libraries/app/database_api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index acb90c8af5..6e05f5fd0d 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -2448,7 +2448,7 @@ void database_api_impl::on_applied_block() } if( market.valid() && _market_subscriptions.count(*market) ) // FIXME this may cause fill_order_operation be pushed before order creation - subscribed_markets_ops[*market].emplace_back( std::move( std::make_pair( op.op, op.result ) ) ); + subscribed_markets_ops[*market].emplace_back(std::make_pair(op.op, op.result)); } /// we need to ensure the database_api is not deleted for the life of the async operation auto capture_this = shared_from_this(); From 3d24032ade2c3e72250877669eb0158c89027fa9 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 26 Oct 2018 17:13:08 -0500 Subject: [PATCH 038/172] Fix build errors - Add missing FC_REFLECT_TYPENAME on account operation extentions - Replace deprecated call to fc::rand_pseudo_bytes with fc::rand_bytes. --- libraries/chain/include/graphene/chain/protocol/account.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/chain/include/graphene/chain/protocol/account.hpp b/libraries/chain/include/graphene/chain/protocol/account.hpp index f6178d3e24..f2be53837b 100644 --- a/libraries/chain/include/graphene/chain/protocol/account.hpp +++ b/libraries/chain/include/graphene/chain/protocol/account.hpp @@ -274,6 +274,7 @@ FC_REFLECT_ENUM( graphene::chain::account_whitelist_operation::account_listing, (no_listing)(white_listed)(black_listed)(white_and_black_listed)) FC_REFLECT(graphene::chain::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options) ) +FC_REFLECT_TYPENAME(graphene::chain::extension) FC_REFLECT( graphene::chain::account_create_operation, (fee)(registrar) (referrer)(referrer_percent) @@ -281,6 +282,7 @@ FC_REFLECT( graphene::chain::account_create_operation, ) FC_REFLECT(graphene::chain::account_update_operation::ext, (null_ext)(owner_special_authority)(active_special_authority) ) +FC_REFLECT_TYPENAME(graphene::chain::extension) FC_REFLECT( graphene::chain::account_update_operation, (fee)(account)(owner)(active)(new_options)(extensions) ) From 9952121981381d5bc62abd87192b94d01d61a708 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 7 Nov 2018 12:09:01 -0600 Subject: [PATCH 039/172] Include smart_ref_impl from fork_database.cpp Required for build on some configurations --- libraries/chain/fork_database.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/chain/fork_database.cpp b/libraries/chain/fork_database.cpp index 39e9d3b83f..b94a2cdc29 100644 --- a/libraries/chain/fork_database.cpp +++ b/libraries/chain/fork_database.cpp @@ -24,6 +24,8 @@ #include #include +#include + namespace graphene { namespace chain { fork_database::fork_database() { From 6225ee42f6ea847c7370f7e407c0f15c09ee464e Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sat, 10 Nov 2018 16:18:24 -0300 Subject: [PATCH 040/172] remove not needed include --- libraries/plugins/es_objects/es_objects.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libraries/plugins/es_objects/es_objects.cpp b/libraries/plugins/es_objects/es_objects.cpp index 0cd4bc256d..766b7ce886 100644 --- a/libraries/plugins/es_objects/es_objects.cpp +++ b/libraries/plugins/es_objects/es_objects.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include @@ -74,8 +73,8 @@ class es_objects_plugin_impl fc::time_point_sec block_time; private: - template - void prepareTemplate(T blockchain_object, string index_name); + template + void prepareTemplate(T blockchain_object, string index_name); }; bool es_objects_plugin_impl::index_database( const vector& ids, std::string action) From 81c276921a8ffef9923b73b47d9f85a4cab69e5c Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sat, 10 Nov 2018 16:40:39 -0300 Subject: [PATCH 041/172] change variable name --- libraries/plugins/es_objects/es_objects.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libraries/plugins/es_objects/es_objects.cpp b/libraries/plugins/es_objects/es_objects.cpp index 766b7ce886..01ec4722a6 100644 --- a/libraries/plugins/es_objects/es_objects.cpp +++ b/libraries/plugins/es_objects/es_objects.cpp @@ -199,16 +199,13 @@ void es_objects_plugin_impl::prepareTemplate(T blockchain_object, string index_n } auto blockchain_object_string = fc::json::to_string(blockchain_object, fc::json::legacy_generator); - - variant j = fc::json::from_string(blockchain_object_string); - + variant blockchain_object_variant = fc::json::from_string(blockchain_object_string); fc::mutable_variant_object o; adaptor_struct adaptor; - auto adapted = adaptor.adapt(j.get_object()); + auto adapted = adaptor.adapt(blockchain_object_variant.get_object()); fc::from_variant(adapted, o, FC_PACK_MAX_DEPTH); - o["object_id"] = string(blockchain_object.id); o["block_time"] = block_time; o["block_number"] = block_number; From f5031bde96c5f3e20fc71c1d34a519bb417e850d Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 15 Nov 2018 17:54:24 -0300 Subject: [PATCH 042/172] move plugins option to witness_node executable --- libraries/app/application.cpp | 14 --------- .../app/include/graphene/app/application.hpp | 3 +- programs/witness_node/main.cpp | 31 +++++++++++++++++-- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 98d187763a..62748a7bcb 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -947,7 +947,6 @@ void application::set_program_options(boost::program_options::options_descriptio ("genesis-json", bpo::value(), "File to read Genesis State from") ("dbg-init-key", bpo::value(), "Block signing key to use for init witnesses, overrides genesis file") ("api-access", bpo::value(), "JSON file specifying API permissions") - ("plugins", bpo::value(), "Space-separated list of plugins to activate") ("io-threads", bpo::value()->implicit_value(0), "Number of IO threads, default to 0 for auto-configuration") ("enable-subscribe-to-all", bpo::value()->implicit_value(true), "Whether allow API clients to subscribe to universal object creation and removal events") @@ -1006,19 +1005,6 @@ void application::initialize(const fc::path& data_dir, const boost::program_opti const uint16_t num_threads = options["io-threads"].as(); fc::asio::default_io_service_scope::set_num_threads(num_threads); } - - if (options.count("plugins")) { - std::set plugins; - boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); - - FC_ASSERT(!(plugins.count("account_history") && plugins.count("elasticsearch")), - "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin"); - - std::for_each(plugins.begin(), plugins.end(), [this](const string& plug) mutable { - if (!plug.empty()) - enable_plugin(plug); - }); - } } void application::startup() diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index bea72bf8ed..66a73f3999 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -101,8 +101,9 @@ namespace graphene { namespace app { const application_options& get_options(); - private: void enable_plugin( const string& name ); + + private: void add_available_plugin( std::shared_ptr p ); std::shared_ptr my; diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 07c17a9010..3141c0957a 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -66,7 +67,7 @@ int main(int argc, char** argv) { ("help,h", "Print this help message and exit.") ("data-dir,d", bpo::value()->default_value("witness_node_data_dir"), "Directory containing databases, configuration file, etc.") ("version,v", "Display version information") - ; + ("plugins", bpo::value(), "Space-separated list of plugins to activate"); bpo::variables_map options; @@ -90,10 +91,34 @@ int main(int argc, char** argv) { } catch (const boost::program_options::error& e) { - std::cerr << "Error parsing command line: " << e.what() << "\n"; - return 1; + std::cerr << "Error parsing command line: " << e.what() << "\n"; + return 1; } + if (options.count("plugins")) { + + std::set plugins; + boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); + + if(plugins.count("account_history") && plugins.count("elasticsearch")) { + std::cerr << "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin\n"; + return 1; + } + + std::for_each(plugins.begin(), plugins.end(), [node](const std::string& plug) mutable { + if (!plug.empty()) { + node->enable_plugin(plug); + } + }); + } + else { + node->enable_plugin("witness"); + node->enable_plugin("account_history"); + node->enable_plugin("market_history"); + node->enable_plugin("grouped_orders"); + } + + if( options.count("help") ) { std::cout << app_options << "\n"; From adef6a2984c13ce882261036a01ba610fe11ff1d Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 15 Nov 2018 18:54:02 -0300 Subject: [PATCH 043/172] fix cli wallet test --- tests/cli/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 393dce4d83..16b29e125d 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -114,10 +114,10 @@ int get_available_port() std::shared_ptr start_application(fc::temp_directory& app_dir, int& server_port_number) { std::shared_ptr app1(new graphene::app::application{}); - app1->register_plugin(); - app1->register_plugin< graphene::market_history::market_history_plugin >(); - app1->register_plugin< graphene::witness_plugin::witness_plugin >(); - app1->register_plugin< graphene::grouped_orders::grouped_orders_plugin>(); + app1->register_plugin(true); + app1->register_plugin< graphene::market_history::market_history_plugin >(true); + app1->register_plugin< graphene::witness_plugin::witness_plugin >(true); + app1->register_plugin< graphene::grouped_orders::grouped_orders_plugin>(true); app1->startup_plugins(); boost::program_options::variables_map cfg; #ifdef _WIN32 From 9647ad117b297aad4885565d4dedf9393a0f9917 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 15 Nov 2018 19:28:56 -0300 Subject: [PATCH 044/172] remove double space line --- programs/witness_node/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 3141c0957a..05679766b6 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -117,8 +117,7 @@ int main(int argc, char** argv) { node->enable_plugin("market_history"); node->enable_plugin("grouped_orders"); } - - + if( options.count("help") ) { std::cout << app_options << "\n"; From ce35a798669660fa1515f536a9e9b319eae47d48 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sat, 17 Nov 2018 19:02:57 -0300 Subject: [PATCH 045/172] add default plugin values to option --- programs/witness_node/main.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 05679766b6..f0fd5da66a 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -65,9 +65,11 @@ int main(int argc, char** argv) { bpo::options_description cfg_options("Graphene Witness Node"); app_options.add_options() ("help,h", "Print this help message and exit.") - ("data-dir,d", bpo::value()->default_value("witness_node_data_dir"), "Directory containing databases, configuration file, etc.") + ("data-dir,d", bpo::value()->default_value("witness_node_data_dir"), + "Directory containing databases, configuration file, etc.") ("version,v", "Display version information") - ("plugins", bpo::value(), "Space-separated list of plugins to activate"); + ("plugins", bpo::value()->default_value("witness account_history market_history grouped_orders"), + "Space-separated list of plugins to activate"); bpo::variables_map options; @@ -111,12 +113,6 @@ int main(int argc, char** argv) { } }); } - else { - node->enable_plugin("witness"); - node->enable_plugin("account_history"); - node->enable_plugin("market_history"); - node->enable_plugin("grouped_orders"); - } if( options.count("help") ) { From 58ad814bc74992153e668ed6911c72f4a214d700 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sun, 18 Nov 2018 11:05:18 -0300 Subject: [PATCH 046/172] remove not needed check --- programs/witness_node/main.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index f0fd5da66a..336639b1ba 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -97,22 +97,19 @@ int main(int argc, char** argv) { return 1; } - if (options.count("plugins")) { + std::set plugins; + boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); - std::set plugins; - boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); + if(plugins.count("account_history") && plugins.count("elasticsearch")) { + std::cerr << "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin\n"; + return 1; + } - if(plugins.count("account_history") && plugins.count("elasticsearch")) { - std::cerr << "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin\n"; - return 1; + std::for_each(plugins.begin(), plugins.end(), [node](const std::string& plug) mutable { + if (!plug.empty()) { + node->enable_plugin(plug); } - - std::for_each(plugins.begin(), plugins.end(), [node](const std::string& plug) mutable { - if (!plug.empty()) { - node->enable_plugin(plug); - } - }); - } + }); if( options.count("help") ) { From 5d1c15cdd7faa955463902ea1348ba302eb65681 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sun, 25 Nov 2018 21:13:09 -0300 Subject: [PATCH 047/172] add last_vote_time --- libraries/chain/account_evaluator.cpp | 12 +- .../include/graphene/chain/account_object.hpp | 3 + tests/tests/voting_tests.cpp | 125 ++++++++++++++++++ 3 files changed, 137 insertions(+), 3 deletions(-) diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index d550007c76..1ef78dd48c 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -57,7 +57,7 @@ void verify_authority_accounts( const database& db, const authority& a ) } } -void verify_account_votes( const database& db, const account_options& options ) +void verify_account_votes( database& db, const account_options& options, const account_id_type account = account_id_type(0)) { // ensure account's votes satisfy requirements // NB only the part of vote checking that requires chain state is here, @@ -117,9 +117,15 @@ void verify_account_votes( const database& db, const account_options& options ) } } } + if(account != account_id_type(0) && + (options.votes != account(db).options.votes || options.voting_account != account(db).options.voting_account)) { + auto &stats_obj = db.get_account_stats_by_owner(account); + db.modify(stats_obj, [&](account_statistics_object &obj) { + obj.last_vote_time = db.head_block_time(); + }); + } } - void_result account_create_evaluator::do_evaluate( const account_create_operation& op ) { try { database& d = db(); @@ -306,7 +312,7 @@ void_result account_update_evaluator::do_evaluate( const account_update_operatio acnt = &o.account(d); if( o.new_options.valid() ) - verify_account_votes( d, *o.new_options ); + verify_account_votes(d, *o.new_options, o.account); return void_result(); } FC_CAPTURE_AND_RETHROW( (o) ) } diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index cae9d35984..8e9297a52d 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -70,6 +70,8 @@ namespace graphene { namespace chain { bool is_voting = false; ///< redundately store whether this account is voting for better maintenance performance + time_point_sec last_vote_time; // add last time voted + /// Whether this account owns some CORE asset and is voting inline bool has_some_core_voting() const { @@ -453,6 +455,7 @@ FC_REFLECT_DERIVED( graphene::chain::account_statistics_object, (core_in_balance) (has_cashback_vb) (is_voting) + (last_vote_time) (lifetime_fees_paid) (pending_fees)(pending_vested_fees) ) diff --git a/tests/tests/voting_tests.cpp b/tests/tests/voting_tests.cpp index 34f39e48c1..b4af210637 100644 --- a/tests/tests/voting_tests.cpp +++ b/tests/tests/voting_tests.cpp @@ -414,5 +414,130 @@ BOOST_AUTO_TEST_CASE(invalid_voting_account) } FC_LOG_AND_RETHROW() } +BOOST_AUTO_TEST_CASE(last_voting_date) +{ + try + { + ACTORS((alice)); + + transfer(committee_account, alice_id, asset(100)); + + // we are going to vote for this witness + auto witness1 = witness_id_type(1)(db); + + auto stats_obj = db.get_account_stats_by_owner(alice_id); + BOOST_CHECK_EQUAL(stats_obj.last_vote_time.sec_since_epoch(), 0); + + // alice votes + graphene::chain::account_update_operation op; + op.account = alice_id; + op.new_options = alice.options; + op.new_options->votes.insert(witness1.vote_id); + trx.operations.push_back(op); + sign(trx, alice_private_key); + PUSH_TX( db, trx, ~0 ); + + auto now = db.head_block_time().sec_since_epoch(); + + // last_vote_time is updated for alice + stats_obj = db.get_account_stats_by_owner(alice_id); + BOOST_CHECK_EQUAL(stats_obj.last_vote_time.sec_since_epoch(), now); + + } FC_LOG_AND_RETHROW() +} +BOOST_AUTO_TEST_CASE(last_voting_date_proxy) +{ + try + { + ACTORS((alice)(proxy)(bob)); + + transfer(committee_account, alice_id, asset(100)); + transfer(committee_account, bob_id, asset(200)); + transfer(committee_account, proxy_id, asset(300)); + + generate_block(); + + // witness to vote for + auto witness1 = witness_id_type(1)(db); + + // alice changes proxy, this is voting activity + { + graphene::chain::account_update_operation op; + op.account = alice_id; + op.new_options = alice_id(db).options; + op.new_options->voting_account = proxy_id; + trx.operations.push_back(op); + sign(trx, alice_private_key); + PUSH_TX( db, trx, ~0 ); + } + // alice last_vote_time is updated + auto alice_stats_obj = db.get_account_stats_by_owner(alice_id); + auto now = db.head_block_time().sec_since_epoch(); + BOOST_CHECK_EQUAL(alice_stats_obj.last_vote_time.sec_since_epoch(), now); + + generate_block(); + + // alice update account but no proxy or voting changes are done + { + graphene::chain::account_update_operation op; + op.account = alice_id; + op.new_options = alice_id(db).options; + trx.operations.push_back(op); + sign(trx, alice_private_key); + set_expiration( db, trx ); + PUSH_TX( db, trx, ~0 ); + } + // last_vote_time is not updated + now = db.head_block_time().sec_since_epoch(); + alice_stats_obj = db.get_account_stats_by_owner(alice_id); + BOOST_CHECK(alice_stats_obj.last_vote_time.sec_since_epoch() != now); + + generate_block(); + + // bob votes + { + graphene::chain::account_update_operation op; + op.account = bob_id; + op.new_options = bob_id(db).options; + op.new_options->votes.insert(witness1.vote_id); + trx.operations.push_back(op); + sign(trx, bob_private_key); + set_expiration( db, trx ); + PUSH_TX(db, trx, ~0); + } + + // last_vote_time for bob is updated as he voted + now = db.head_block_time().sec_since_epoch(); + auto bob_stats_obj = db.get_account_stats_by_owner(bob_id); + BOOST_CHECK_EQUAL(bob_stats_obj.last_vote_time.sec_since_epoch(), now); + + generate_block(); + + // proxy votes + { + graphene::chain::account_update_operation op; + op.account = proxy_id; + op.new_options = proxy_id(db).options; + op.new_options->votes.insert(witness1.vote_id); + trx.operations.push_back(op); + sign(trx, proxy_private_key); + PUSH_TX(db, trx, ~0); + } + + // proxy just voted so the last_vote_time is updated + now = db.head_block_time().sec_since_epoch(); + auto proxy_stats_obj = db.get_account_stats_by_owner(proxy_id); + BOOST_CHECK_EQUAL(proxy_stats_obj.last_vote_time.sec_since_epoch(), now); + + // alice haves proxy, proxy votes but last_vote_time is not updated for alice + alice_stats_obj = db.get_account_stats_by_owner(alice_id); + BOOST_CHECK(alice_stats_obj.last_vote_time.sec_since_epoch() != now); + + // bob haves nothing to do with proxy so last_vote_time is not updated + bob_stats_obj = db.get_account_stats_by_owner(bob_id); + BOOST_CHECK(bob_stats_obj.last_vote_time.sec_since_epoch() != now); + + } FC_LOG_AND_RETHROW() +} BOOST_AUTO_TEST_SUITE_END() From 5909b13da4820bab475b25ecb908b0f44bdaee5d Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 28 Nov 2018 20:17:20 -0300 Subject: [PATCH 048/172] add option elasticsearch-start-es-after-block --- .../plugins/elasticsearch/elasticsearch_plugin.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp index dcffaea5f9..bfde1e02e8 100644 --- a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp +++ b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp @@ -59,6 +59,7 @@ class elasticsearch_plugin_impl std::string _elasticsearch_basic_auth = ""; std::string _elasticsearch_index_prefix = "bitshares-"; bool _elasticsearch_operation_object = false; + uint32_t _elasticsearch_start_es_after_block = 0; // disabled CURL *curl; // curl handler vector bulk_lines; // vector of op lines vector prepare; @@ -428,6 +429,7 @@ void elasticsearch_plugin::plugin_set_program_options( ("elasticsearch-basic-auth", boost::program_options::value(), "Pass basic auth to elasticsearch database('')") ("elasticsearch-index-prefix", boost::program_options::value(), "Add a prefix to the index(bitshares-)") ("elasticsearch-operation-object", boost::program_options::value(), "Save operation as object(false)") + ("elasticsearch-start-es-after-block", boost::program_options::value(), "Start doing ES job after block(0)") ; cfg.add(cli); } @@ -435,11 +437,14 @@ void elasticsearch_plugin::plugin_set_program_options( void elasticsearch_plugin::plugin_initialize(const boost::program_options::variables_map& options) { database().applied_block.connect( [&]( const signed_block& b) { - if(!my->update_account_histories(b)) - { - FC_THROW_EXCEPTION(graphene::chain::plugin_exception, "Error populating ES database, we are going to keep trying."); + if(my->_elasticsearch_start_es_after_block == 0 || b.block_num() > my->_elasticsearch_start_es_after_block) { + if (!my->update_account_histories(b)) { + FC_THROW_EXCEPTION(graphene::chain::plugin_exception, + "Error populating ES database, we are going to keep trying."); + } } } ); + my->_oho_index = database().add_index< primary_index< operation_history_index > >(); database().add_index< primary_index< account_transaction_history_index > >(); @@ -464,6 +469,9 @@ void elasticsearch_plugin::plugin_initialize(const boost::program_options::varia if (options.count("elasticsearch-operation-object")) { my->_elasticsearch_operation_object = options["elasticsearch-operation-object"].as(); } + if (options.count("elasticsearch-start-es-after-block")) { + my->_elasticsearch_start_es_after_block = options["elasticsearch-start-es-after-block"].as(); + } } void elasticsearch_plugin::plugin_startup() From ee4cc4b96ca278e2b8ed28fe5b52cecd9119f755 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 28 Nov 2018 20:50:05 -0300 Subject: [PATCH 049/172] move start_es_after_block check more deeper --- .../elasticsearch/elasticsearch_plugin.cpp | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp index bfde1e02e8..6af2df19ac 100644 --- a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp +++ b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp @@ -75,7 +75,7 @@ class elasticsearch_plugin_impl std::string index_name; bool is_sync = false; private: - bool add_elasticsearch( const account_id_type account_id, const optional& oho ); + bool add_elasticsearch( const account_id_type account_id, const optional& oho, const uint32_t block_number ); const account_transaction_history_object& addNewEntry(const account_statistics_object& stats_obj, const account_id_type& account_id, const optional & oho); @@ -164,7 +164,7 @@ bool elasticsearch_plugin_impl::update_account_histories( const signed_block& b for( auto& account_id : impacted ) { - if(!add_elasticsearch( account_id, oho )) + if(!add_elasticsearch( account_id, oho, b.block_num() )) return false; } } @@ -277,13 +277,16 @@ void elasticsearch_plugin_impl::doVisitor(const optional & oho) + const optional & oho, + const uint32_t block_number) { const auto &stats_obj = getStatsObject(account_id); const auto &ath = addNewEntry(stats_obj, account_id, oho); growStats(stats_obj, ath); - createBulkLine(ath); - prepareBulk(ath.id); + if(_elasticsearch_start_es_after_block == 0 || block_number > _elasticsearch_start_es_after_block) { + createBulkLine(ath); + prepareBulk(ath.id); + } cleanObjects(ath.id, account_id); if (curl && bulk_lines.size() >= limit_documents) { // we are in bulk time, ready to add data to elasticsearech @@ -437,12 +440,8 @@ void elasticsearch_plugin::plugin_set_program_options( void elasticsearch_plugin::plugin_initialize(const boost::program_options::variables_map& options) { database().applied_block.connect( [&]( const signed_block& b) { - if(my->_elasticsearch_start_es_after_block == 0 || b.block_num() > my->_elasticsearch_start_es_after_block) { - if (!my->update_account_histories(b)) { - FC_THROW_EXCEPTION(graphene::chain::plugin_exception, - "Error populating ES database, we are going to keep trying."); - } - } + if (!my->update_account_histories(b)) + FC_THROW_EXCEPTION(graphene::chain::plugin_exception, "Error populating ES database, we are going to keep trying."); } ); my->_oho_index = database().add_index< primary_index< operation_history_index > >(); From 7089d2a95b76e0263ce1c34700db2c084ab1395b Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 30 Nov 2018 16:35:40 -0300 Subject: [PATCH 050/172] fix delayed node --- programs/delayed_node/main.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index 0ba1e6944d..137ae22627 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -60,7 +60,7 @@ fc::optional load_logging_config_from_ini_file(const fc::pat int main(int argc, char** argv) { try { - app::application node; + app::application* node = new app::application(); bpo::options_description app_options("Graphene Delayed Node"); bpo::options_description cfg_options("Graphene Delayed Node"); app_options.add_options() @@ -70,14 +70,14 @@ int main(int argc, char** argv) { bpo::variables_map options; - auto delayed_plug = node.register_plugin(); - auto history_plug = node.register_plugin(); - auto market_history_plug = node.register_plugin(); + auto delayed_plug = node->register_plugin(); + auto history_plug = node->register_plugin(); + auto market_history_plug = node->register_plugin(); try { bpo::options_description cli, cfg; - node.set_program_options(cli, cfg); + node->set_program_options(cli, cfg); app_options.add(cli); cfg_options.add(cfg); bpo::store(bpo::parse_command_line(argc, argv, app_options), options); @@ -88,6 +88,13 @@ int main(int argc, char** argv) { return 1; } + std::set plugins = {"delayed_node", "account_history", "market_history"}; + std::for_each(plugins.begin(), plugins.end(), [node](const std::string& plug) mutable { + if (!plug.empty()) { + node->enable_plugin(plug); + } + }); + if( options.count("help") ) { std::cout << app_options << "\n"; @@ -160,26 +167,24 @@ int main(int argc, char** argv) { elog("Error parsing configuration file: ${e}", ("e", e.what())); return 1; } - if( !options.count("plugins") ) - options.insert( std::make_pair( "plugins", bpo::variable_value(std::string("delayed_node account_history market_history"), true) ) ); - node.initialize(data_dir, options); - node.initialize_plugins( options ); + node->initialize(data_dir, options); + node->initialize_plugins( options ); - node.startup(); - node.startup_plugins(); + node->startup(); + node->startup_plugins(); fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); fc::set_signal_handler([&exit_promise](int signal) { exit_promise->set_value(signal); }, SIGINT); - ilog("Started delayed node on a chain with ${h} blocks.", ("h", node.chain_database()->head_block_num())); - ilog("Chain ID is ${id}", ("id", node.chain_database()->get_chain_id()) ); + ilog("Started delayed node on a chain with ${h} blocks.", ("h", node->chain_database()->head_block_num())); + ilog("Chain ID is ${id}", ("id", node->chain_database()->get_chain_id()) ); int signal = exit_promise->wait(); ilog("Exiting from signal ${n}", ("n", signal)); - node.shutdown_plugins(); + node->shutdown_plugins(); return 0; } catch( const fc::exception& e ) { elog("Exiting with error:\n${e}", ("e", e.to_detail_string())); From 5e24f652b9e81a8289bdc3c9a99e111e92518ada Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 30 Nov 2018 19:18:39 -0300 Subject: [PATCH 051/172] change last_vote_time to do_apply --- libraries/chain/account_evaluator.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index 1ef78dd48c..23891ef555 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -57,7 +57,7 @@ void verify_authority_accounts( const database& db, const authority& a ) } } -void verify_account_votes( database& db, const account_options& options, const account_id_type account = account_id_type(0)) +void verify_account_votes( const database& db, const account_options& options) { // ensure account's votes satisfy requirements // NB only the part of vote checking that requires chain state is here, @@ -117,13 +117,6 @@ void verify_account_votes( database& db, const account_options& options, const a } } } - if(account != account_id_type(0) && - (options.votes != account(db).options.votes || options.voting_account != account(db).options.voting_account)) { - auto &stats_obj = db.get_account_stats_by_owner(account); - db.modify(stats_obj, [&](account_statistics_object &obj) { - obj.last_vote_time = db.head_block_time(); - }); - } } void_result account_create_evaluator::do_evaluate( const account_create_operation& op ) @@ -312,7 +305,7 @@ void_result account_update_evaluator::do_evaluate( const account_update_operatio acnt = &o.account(d); if( o.new_options.valid() ) - verify_account_votes(d, *o.new_options, o.account); + verify_account_votes(d, *o.new_options); return void_result(); } FC_CAPTURE_AND_RETHROW( (o) ) } @@ -324,11 +317,16 @@ void_result account_update_evaluator::do_apply( const account_update_operation& bool sa_before = acnt->has_special_authority(); // update account statistics - if( o.new_options.valid() && o.new_options->is_voting() != acnt->options.is_voting() ) + if( o.new_options.valid() ) { - d.modify( acnt->statistics( d ), []( account_statistics_object& aso ) + d.modify( acnt->statistics( d ), [&]( account_statistics_object& aso ) { - aso.is_voting = !aso.is_voting; + if(o.new_options->is_voting() != acnt->options.is_voting()) + aso.is_voting = !aso.is_voting; + + if((o.new_options->votes != acnt->options.votes || + o.new_options->voting_account != acnt->options.voting_account)) + aso.last_vote_time = d.head_block_time(); } ); } From 5688e7b0fa7fc9d4f594e8ec6929c9c0dc8cbb57 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 30 Nov 2018 19:22:02 -0300 Subject: [PATCH 052/172] minor spacing changes --- libraries/chain/account_evaluator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index 23891ef555..086953dcfb 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -57,7 +57,7 @@ void verify_authority_accounts( const database& db, const authority& a ) } } -void verify_account_votes( const database& db, const account_options& options) +void verify_account_votes( const database& db, const account_options& options ) { // ensure account's votes satisfy requirements // NB only the part of vote checking that requires chain state is here, @@ -305,7 +305,7 @@ void_result account_update_evaluator::do_evaluate( const account_update_operatio acnt = &o.account(d); if( o.new_options.valid() ) - verify_account_votes(d, *o.new_options); + verify_account_votes( d, *o.new_options ); return void_result(); } FC_CAPTURE_AND_RETHROW( (o) ) } From d8323d4c9d36b7c4651e0e2462ad9fdf451fd812 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 2 Dec 2018 10:38:47 +0100 Subject: [PATCH 053/172] Introduced direct_index --- libraries/db/include/graphene/db/index.hpp | 108 ++++++++++++++++++++- 1 file changed, 105 insertions(+), 3 deletions(-) diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index bcf9b24f13..fd2923f599 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -190,6 +190,95 @@ namespace graphene { namespace db { object_database& _db; }; + /** @class direct_index + * @brief A secondary index that tracks objects in vectors indexed by object + * id. It is meant for fully (or almost fully) populated indexes only (will + * fail when loading an object_database with large gaps). + */ + template + class direct_index : public secondary_index + { + static_assert( chunkbits < 64, "Do you really want arrays with more than 2^63 elements???" ); + + private: + static const size_t MAX_HOLE = 100; + static const size_t _mask = ((1 << chunkbits) - 1); + size_t next = 0; + vector< vector< const Object* > > content; + + public: + direct_index() { + FC_ASSERT( (1ULL << chunkbits) > MAX_HOLE, "Small chunkbits is inefficient." ); + } + + virtual ~direct_index(){} + + virtual void object_inserted( const object& obj ) + { + uint64_t instance = obj.id.instance(); + if( instance == next ) + { + if( !(next & _mask) ) + { + content.resize((next >> chunkbits) + 1); + content[next >> chunkbits].reserve( 1 << chunkbits ); + } + next++; + } + else if( instance < next ) + FC_ASSERT( !content[instance >> chunkbits][instance & _mask], "Overwriting insert at {id}!", ("id",obj.id) ); + else // instance > next, allow small "holes" + { + FC_ASSERT( instance <= next + MAX_HOLE, "Out-of-order insert: {id} > {next}!", ("id",obj.id)("next",next) ); + if( !(next & _mask) || (next & (~_mask)) != (instance & (~_mask)) ) + { + content.resize((instance >> chunkbits) + 1); + content[instance >> chunkbits].reserve( 1 << chunkbits ); + } + while( next <= instance ) + { + content[next >> chunkbits][next & _mask] = nullptr; + next++; + } + } + FC_ASSERT( nullptr != dynamic_cast(&obj), "Wrong object type!" ); + content[instance >> chunkbits][instance & _mask] = static_cast( &obj ); + } + + virtual void object_removed( const object& obj ) + { + FC_ASSERT( nullptr != dynamic_cast(&obj), "Wrong object type!" ); + uint64_t instance = obj.id.instance(); + FC_ASSERT( instance < next, "Removing out-of-range object: {id} > {next}!", ("id",obj.id)("next",next) ); + FC_ASSERT( content[instance >> chunkbits][instance & _mask], "Removing non-existent object {id}!", ("id",obj.id) ); + content[instance >> chunkbits][instance & _mask] = nullptr; + } + + template< typename object_id > + const Object* find( const object_id& id )const + { + static_assert( object_id::space_id == Object::space_id, "Space ID mismatch!" ); + static_assert( object_id::type_id == Object::type_id, "Type_ID mismatch!" ); + if( id.instance >= next ) return nullptr; + return content[id.instance >> chunkbits][id.instance & _mask]; + }; + + template< typename object_id > + const Object& get( const object_id& id )const + { + const Object* ptr = find( id ); + FC_ASSERT( ptr != nullptr, "Object not found!" ); + return *ptr; + }; + + const Object* find( const object_id_type& id )const + { + FC_ASSERT( id.space() == Object::space_id, "Space ID mismatch!" ); + FC_ASSERT( id.type() == Object::type_id, "Type_ID mismatch!" ); + if( id.instance() >= next ) return nullptr; + return content[id.instance() >> chunkbits][id.instance() & ((1 << chunkbits) - 1)]; + }; + }; /** * @class primary_index @@ -198,14 +287,18 @@ namespace graphene { namespace db { * * @see http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */ - template + template class primary_index : public DerivedIndex, public base_primary_index { public: typedef typename DerivedIndex::object_type object_type; primary_index( object_database& db ) - :base_primary_index(db),_next_id(object_type::space_id,object_type::type_id,0) {} + :base_primary_index(db),_next_id(object_type::space_id,object_type::type_id,0) + { + if( DirectBits > 0 ) + _direct_by_id = add_secondary_index< direct_index< object_type, DirectBits > >(); + } virtual uint8_t object_space_id()const override { return object_type::space_id; } @@ -217,6 +310,14 @@ namespace graphene { namespace db { virtual void use_next_id()override { ++_next_id.number; } virtual void set_next_id( object_id_type id )override { _next_id = id; } + /** @return the object with id or nullptr if not found */ + virtual const object* find( object_id_type id )const override + { + if( DirectBits > 0 ) + return _direct_by_id->find( id ); + return DerivedIndex::find( id ); + } + fc::sha256 get_object_version()const { std::string desc = "1.0";//get_type_description(); @@ -329,7 +430,8 @@ namespace graphene { namespace db { } private: - object_id_type _next_id; + object_id_type _next_id; + const direct_index< object_type, DirectBits >* _direct_by_id = nullptr; }; } } // graphene::db From 6d79167a570e9e73d6adc3c4524296e96b8ec3a8 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 2 Dec 2018 10:45:43 +0100 Subject: [PATCH 054/172] Use new derived_index for some --- libraries/chain/db_init.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 34d16f4b82..c87d9ec6a6 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -182,15 +182,15 @@ void database::initialize_indexes() _undo_db.set_max_size( GRAPHENE_MIN_UNDO_HISTORY ); //Protocol object indexes - add_index< primary_index >(); + add_index< primary_index >(); // 8192 assets per chunk add_index< primary_index >(); - auto acnt_index = add_index< primary_index >(); + auto acnt_index = add_index< primary_index >(); // ~1 million accounts per chunk acnt_index->add_secondary_index(); acnt_index->add_secondary_index(); - add_index< primary_index >(); - add_index< primary_index >(); + add_index< primary_index >(); // 256 members per chunk + add_index< primary_index >(); // 1024 witnesses per chunk add_index< primary_index >(); add_index< primary_index >(); @@ -206,10 +206,10 @@ void database::initialize_indexes() //Implementation object indexes add_index< primary_index >(); add_index< primary_index >(); - add_index< primary_index >(); + add_index< primary_index >(); // 8192 add_index< primary_index> >(); add_index< primary_index> >(); - add_index< primary_index >(); + add_index< primary_index >(); // 1 Mi add_index< primary_index> >(); add_index< primary_index> >(); add_index< primary_index > >(); From c367219cbad3c264a9d0c92abeaeb967dd6e133d Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 2 Dec 2018 10:46:12 +0100 Subject: [PATCH 055/172] Fixed casts --- libraries/app/database_api.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 6e05f5fd0d..9316cfa4b6 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -547,6 +547,10 @@ vector> database_api::get_key_references( vector> database_api_impl::get_key_references( vector keys )const { + const auto& idx = _db.get_index_type(); + const auto& aidx = dynamic_cast(idx); + const auto& refs = aidx.get_secondary_index(); + vector< vector > final_result; final_result.reserve(keys.size()); @@ -566,10 +570,6 @@ vector> database_api_impl::get_key_references( vector(); - const auto& aidx = dynamic_cast&>(idx); - const auto& refs = aidx.get_secondary_index(); - auto itr = refs.account_to_key_memberships.find(key); vector result; for( auto& a : {a1,a2,a3,a4,a5} ) @@ -585,6 +585,7 @@ vector> database_api_impl::get_key_references( vectorsecond.size() ); @@ -620,7 +621,7 @@ bool database_api_impl::is_public_key_registered(string public_key) const return false; } const auto& idx = _db.get_index_type(); - const auto& aidx = dynamic_cast&>(idx); + const auto& aidx = dynamic_cast(idx); const auto& refs = aidx.get_secondary_index(); auto itr = refs.account_to_key_memberships.find(key); bool is_known = itr != refs.account_to_key_memberships.end(); @@ -755,6 +756,10 @@ std::map database_api::get_full_accounts( const vector database_api_impl::get_full_accounts( const vector& names_or_ids, bool subscribe) { + const auto& proposal_idx = _db.get_index_type(); + const auto& pidx = dynamic_cast(proposal_idx); + const auto& proposals_by_account = pidx.get_secondary_index(); + std::map results; for (const std::string& account_name_or_id : names_or_ids) @@ -784,9 +789,6 @@ std::map database_api_impl::get_full_accounts( const acnt.cashback_balance = account->cashback_balance(_db); } // Add the account's proposals - const auto& proposal_idx = _db.get_index_type(); - const auto& pidx = dynamic_cast&>(proposal_idx); - const auto& proposals_by_account = pidx.get_secondary_index(); auto required_approvals_itr = proposals_by_account._account_to_proposals.find( account->id ); if( required_approvals_itr != proposals_by_account._account_to_proposals.end() ) { @@ -869,7 +871,7 @@ vector database_api::get_account_references( const std::string vector database_api_impl::get_account_references( const std::string account_id_or_name )const { const auto& idx = _db.get_index_type(); - const auto& aidx = dynamic_cast&>(idx); + const auto& aidx = dynamic_cast(idx); const auto& refs = aidx.get_secondary_index(); const account_id_type account_id = get_account_from_string(account_id_or_name)->id; auto itr = refs.account_to_account_memberships.find(account_id); From bcbf5d3c13c6277f83112754d4826f790179c035 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 2 Dec 2018 10:47:14 +0100 Subject: [PATCH 056/172] Fixed wrong reserve() calls --- libraries/app/database_api.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 6e05f5fd0d..ba77512d52 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -577,7 +577,7 @@ vector> database_api_impl::get_key_references( vectorsecond.size() ); + result.reserve( result.size() + itr->second.size() ); for( auto item : itr->second ) { result.push_back(item); @@ -587,7 +587,7 @@ vector> database_api_impl::get_key_references( vectorsecond.size() ); + result.reserve( result.size() + itr->second.size() ); for( auto item : itr->second ) result.push_back(item); } final_result.emplace_back( std::move(result) ); From 59db3f56d239cdc57c7df67f0ed5bb6fe9f4a8c2 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 2 Dec 2018 15:13:35 +0100 Subject: [PATCH 057/172] Do not ignore exceptions while reading object_database --- libraries/db/include/graphene/db/index.hpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index bcf9b24f13..f98412d45b 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -234,14 +234,12 @@ namespace graphene { namespace db { fc::raw::unpack(ds, _next_id); fc::raw::unpack(ds, open_ver); FC_ASSERT( open_ver == get_object_version(), "Incompatible Version, the serialization of objects in this index has changed" ); - try { - vector tmp; - while( true ) - { - fc::raw::unpack( ds, tmp ); - load( tmp ); - } - } catch ( const fc::exception& ){} + vector tmp; + while( ds.remaining() > 0 ) + { + fc::raw::unpack( ds, tmp ); + load( tmp ); + } } virtual void save( const path& db ) override From 1dd719f94ddadcbf13486494d8c2eb1b8eb8d566 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 5 Dec 2018 10:02:21 -0300 Subject: [PATCH 058/172] use auto load plugins in delayed node --- programs/delayed_node/main.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index 137ae22627..311911adcb 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -70,9 +70,9 @@ int main(int argc, char** argv) { bpo::variables_map options; - auto delayed_plug = node->register_plugin(); - auto history_plug = node->register_plugin(); - auto market_history_plug = node->register_plugin(); + auto delayed_plug = node->register_plugin(true); + auto history_plug = node->register_plugin(true); + auto market_history_plug = node->register_plugin(true); try { @@ -88,13 +88,6 @@ int main(int argc, char** argv) { return 1; } - std::set plugins = {"delayed_node", "account_history", "market_history"}; - std::for_each(plugins.begin(), plugins.end(), [node](const std::string& plug) mutable { - if (!plug.empty()) { - node->enable_plugin(plug); - } - }); - if( options.count("help") ) { std::cout << app_options << "\n"; From 8999eacf934eb85e1ed9923fdcffa42d365a16e5 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 8 Oct 2018 17:19:31 +0200 Subject: [PATCH 059/172] Removed unused _unlinked_index --- libraries/chain/fork_database.cpp | 70 +++---------------- .../include/graphene/chain/fork_database.hpp | 3 - 2 files changed, 11 insertions(+), 62 deletions(-) diff --git a/libraries/chain/fork_database.cpp b/libraries/chain/fork_database.cpp index b94a2cdc29..a9b4a95fad 100644 --- a/libraries/chain/fork_database.cpp +++ b/libraries/chain/fork_database.cpp @@ -52,7 +52,7 @@ void fork_database::start_block(signed_block b) } /** - * Pushes the block into the fork database and caches it if it doesn't link + * Pushes the block into the fork database * */ shared_ptr fork_database::push_block(const signed_block& b) @@ -66,7 +66,6 @@ shared_ptr fork_database::push_block(const signed_block& b) wlog( "Pushing block to fork database that failed to link: ${id}, ${num}", ("id",b.id())("num",b.block_num()) ); wlog( "Head: ${num}, ${id}", ("num",_head->data.block_num())("id",_head->data.id()) ); throw; - _unlinked_index.insert( item ); } return _head; } @@ -94,35 +93,10 @@ void fork_database::_push_block(const item_ptr& item) { _head = item; uint32_t min_num = _head->num - std::min( _max_size, _head->num ); -// ilog( "min block in fork DB ${n}, max_size: ${m}", ("n",min_num)("m",_max_size) ); auto& num_idx = _index.get(); while( num_idx.size() && (*num_idx.begin())->num < min_num ) num_idx.erase( num_idx.begin() ); - - _unlinked_index.get().erase(_head->num - _max_size); } - //_push_next( item ); -} - -/** - * Iterate through the unlinked cache and insert anything that - * links to the newly inserted item. This will start a recursive - * set of calls performing a depth-first insertion of pending blocks as - * _push_next(..) calls _push_block(...) which will in turn call _push_next - */ -void fork_database::_push_next( const item_ptr& new_item ) -{ - auto& prev_idx = _unlinked_index.get(); - - auto itr = prev_idx.find( new_item->id ); - while( itr != prev_idx.end() ) - { - auto tmp = *itr; - prev_idx.erase( itr ); - _push_block( tmp ); - - itr = prev_idx.find( new_item->id ); - } } void fork_database::set_max_size( uint32_t s ) @@ -130,29 +104,15 @@ void fork_database::set_max_size( uint32_t s ) _max_size = s; if( !_head ) return; - { /// index - auto& by_num_idx = _index.get(); - auto itr = by_num_idx.begin(); - while( itr != by_num_idx.end() ) - { - if( (*itr)->num < std::max(int64_t(0),int64_t(_head->num) - _max_size) ) - by_num_idx.erase(itr); - else - break; - itr = by_num_idx.begin(); - } - } - { /// unlinked_index - auto& by_num_idx = _unlinked_index.get(); - auto itr = by_num_idx.begin(); - while( itr != by_num_idx.end() ) - { - if( (*itr)->num < std::max(int64_t(0),int64_t(_head->num) - _max_size) ) - by_num_idx.erase(itr); - else - break; - itr = by_num_idx.begin(); - } + auto& by_num_idx = _index.get(); + auto itr = by_num_idx.begin(); + while( itr != by_num_idx.end() ) + { + if( (*itr)->num < std::max(int64_t(0),int64_t(_head->num) - _max_size) ) + by_num_idx.erase(itr); + else + break; + itr = by_num_idx.begin(); } } @@ -160,11 +120,7 @@ bool fork_database::is_known_block(const block_id_type& id)const { auto& index = _index.get(); auto itr = index.find(id); - if( itr != index.end() ) - return true; - auto& unlinked_index = _unlinked_index.get(); - auto unlinked_itr = unlinked_index.find(id); - return unlinked_itr != unlinked_index.end(); + return itr != index.end(); } item_ptr fork_database::fetch_block(const block_id_type& id)const @@ -173,10 +129,6 @@ item_ptr fork_database::fetch_block(const block_id_type& id)const auto itr = index.find(id); if( itr != index.end() ) return *itr; - auto& unlinked_index = _unlinked_index.get(); - auto unlinked_itr = unlinked_index.find(id); - if( unlinked_itr != unlinked_index.end() ) - return *unlinked_itr; return item_ptr(); } diff --git a/libraries/chain/include/graphene/chain/fork_database.hpp b/libraries/chain/include/graphene/chain/fork_database.hpp index be3991ed80..363a21f2ce 100644 --- a/libraries/chain/include/graphene/chain/fork_database.hpp +++ b/libraries/chain/include/graphene/chain/fork_database.hpp @@ -93,12 +93,10 @@ namespace graphene { namespace chain { struct block_id; struct block_num; - struct by_previous; typedef multi_index_container< item_ptr, indexed_by< hashed_unique, member, std::hash>, - hashed_non_unique, const_mem_fun, std::hash>, ordered_non_unique, member> > > fork_multi_index_type; @@ -112,7 +110,6 @@ namespace graphene { namespace chain { uint32_t _max_size = 1024; - fork_multi_index_type _unlinked_index; fork_multi_index_type _index; shared_ptr _head; }; From 684998432f41ed1dc4fb03df67fc9103a7800bf5 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 8 Oct 2018 21:02:18 +0200 Subject: [PATCH 060/172] Fixed fork_db handling in pop_block --- libraries/chain/db_block.cpp | 18 ++++++++++-------- libraries/chain/fork_database.cpp | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index efc5562a89..d6d083a967 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -465,15 +465,17 @@ signed_block database::_generate_block( void database::pop_block() { try { _pending_tx_session.reset(); - auto head_id = head_block_id(); - optional head_block = fetch_block_by_id( head_id ); - GRAPHENE_ASSERT( head_block.valid(), pop_empty_chain, "there are no blocks to pop" ); - - _fork_db.pop_block(); + auto fork_db_head = _fork_db.head(); + FC_ASSERT( fork_db_head, "Trying to pop() from empty fork database!?" ); + if( fork_db_head->id == head_block_id() ) + _fork_db.pop_block(); + else + { + fork_db_head = _fork_db.fetch_block( head_block_id() ); + FC_ASSERT( fork_db_head, "Trying to pop() block that's not in fork database!?" ); + } pop_undo(); - - _popped_tx.insert( _popped_tx.begin(), head_block->transactions.begin(), head_block->transactions.end() ); - + _popped_tx.insert( _popped_tx.begin(), fork_db_head->data.transactions.begin(), fork_db_head->data.transactions.end() ); } FC_CAPTURE_AND_RETHROW() } void database::clear_pending() diff --git a/libraries/chain/fork_database.cpp b/libraries/chain/fork_database.cpp index a9b4a95fad..71da27629b 100644 --- a/libraries/chain/fork_database.cpp +++ b/libraries/chain/fork_database.cpp @@ -41,7 +41,7 @@ void fork_database::pop_block() FC_ASSERT( _head, "no block to pop" ); auto prev = _head->prev.lock(); FC_ASSERT( prev, "popping block would leave head block null" ); - _head = prev; + _head = prev; } void fork_database::start_block(signed_block b) From 73d8b08504f53f71b80b4e4b676d4fa3459f6406 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 7 Oct 2018 14:31:50 +0200 Subject: [PATCH 061/172] Added --revalidate-blockchain --- libraries/app/application.cpp | 10 +++++++--- libraries/chain/db_management.cpp | 2 ++ libraries/chain/include/graphene/chain/database.hpp | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index b77da4b711..d1dd2d903e 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -394,9 +394,12 @@ void application_impl::startup() _chain_db->enable_standby_votes_tracking( _options->at("enable-standby-votes-tracking").as() ); } - if( _options->count("replay-blockchain") ) + if( _options->count("replay-blockchain") || _options->count("revalidate-blockchain") ) _chain_db->wipe( _data_dir / "blockchain", false ); + if( _options->count("revalidate-blockchain") ) + _chain_db->_replay_with_validation = true; + try { _chain_db->open( _data_dir / "blockchain", initial_state, GRAPHENE_CURRENT_DB_VERSION ); @@ -961,9 +964,10 @@ void application::set_program_options(boost::program_options::options_descriptio "Path to create a Genesis State at. If a well-formed JSON file exists at the path, it will be parsed and any " "missing fields in a Genesis State will be added, and any unknown fields will be removed. If no file or an " "invalid file is found, it will be replaced with an example Genesis State.") - ("replay-blockchain", "Rebuild object graph by replaying all blocks") + ("replay-blockchain", "Rebuild object graph by replaying all blocks without validatino") + ("revalidate-blockchain", "Rebuild object graph by replaying all blocks with full validation") ("resync-blockchain", "Delete all blocks and re-sync with network from scratch") - ("force-validate", "Force validation of all transactions") + ("force-validate", "Force validation of all transactions during normal operation") ("genesis-timestamp", bpo::value(), "Replace timestamp from genesis.json with current time plus this many seconds (experts only!)") ; diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index 6f627adb55..13dca0fdb7 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -82,6 +82,8 @@ void database::reindex( fc::path data_dir ) skip_tapos_check | skip_witness_schedule_check | skip_authority_check; + if( _replay_with_validation ) + skip = 0; size_t total_processed_block_size; size_t total_block_size = _block_id_to_block.total_block_size(); diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index f0fb8e11c6..c73a0756a9 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -437,6 +437,10 @@ namespace graphene { namespace chain { void apply_block( const signed_block& next_block, uint32_t skip = skip_nothing ); processed_transaction apply_transaction( const signed_transaction& trx, uint32_t skip = skip_nothing ); operation_result apply_operation( transaction_evaluation_state& eval_state, const operation& op ); + + /** Set to true before open() to force full revalidation during replay */ + bool _replay_with_validation = false; + private: void _apply_block( const signed_block& next_block ); processed_transaction _apply_transaction( const signed_transaction& trx ); From 34baaed45a4c3535fd5e23b7aaa8bbf3ada3ef0c Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 11 Oct 2018 17:56:26 +0200 Subject: [PATCH 062/172] Use externally provided skip flags for replay --- libraries/app/application.cpp | 19 +++++++++++++++---- libraries/chain/db_management.cpp | 11 +---------- .../chain/include/graphene/chain/database.hpp | 3 --- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index d1dd2d903e..0c27120efd 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -397,12 +398,22 @@ void application_impl::startup() if( _options->count("replay-blockchain") || _options->count("revalidate-blockchain") ) _chain_db->wipe( _data_dir / "blockchain", false ); - if( _options->count("revalidate-blockchain") ) - _chain_db->_replay_with_validation = true; - try { - _chain_db->open( _data_dir / "blockchain", initial_state, GRAPHENE_CURRENT_DB_VERSION ); + // these flags are used in open() only, i. e. during replay + uint32_t skip = graphene::chain::database::skip_witness_signature | + graphene::chain::database::skip_block_size_check | + graphene::chain::database::skip_merkle_check | + graphene::chain::database::skip_transaction_signatures | + graphene::chain::database::skip_transaction_dupe_check | + graphene::chain::database::skip_tapos_check | + graphene::chain::database::skip_witness_schedule_check | + graphene::chain::database::skip_authority_check; + if( _options->count("revalidate-blockchain") ) // see also handle_block() + skip = _options->count("force-validate") ? 0 : graphene::chain::database::skip_transaction_signatures; + graphene::chain::detail::with_skip_flags( *_chain_db, skip, [this,&initial_state] () { + _chain_db->open( _data_dir / "blockchain", initial_state, GRAPHENE_CURRENT_DB_VERSION ); + }); } catch( const fc::exception& e ) { diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index 13dca0fdb7..a86978dc4b 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -74,16 +74,7 @@ void database::reindex( fc::path data_dir ) else _undo_db.disable(); - uint32_t skip = skip_witness_signature | - skip_block_size_check | - skip_merkle_check | - skip_transaction_signatures | - skip_transaction_dupe_check | - skip_tapos_check | - skip_witness_schedule_check | - skip_authority_check; - if( _replay_with_validation ) - skip = 0; + uint32_t skip = node_properties().skip_flags; size_t total_processed_block_size; size_t total_block_size = _block_id_to_block.total_block_size(); diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index c73a0756a9..4fdc984ef0 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -438,9 +438,6 @@ namespace graphene { namespace chain { processed_transaction apply_transaction( const signed_transaction& trx, uint32_t skip = skip_nothing ); operation_result apply_operation( transaction_evaluation_state& eval_state, const operation& op ); - /** Set to true before open() to force full revalidation during replay */ - bool _replay_with_validation = false; - private: void _apply_block( const signed_block& next_block ); processed_transaction _apply_transaction( const signed_transaction& trx ); From bd8ed044a53c69c2b3326c683b8681806f035059 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 11 Oct 2018 21:18:34 +0200 Subject: [PATCH 063/172] Removed skip_authority flag because its used interchangably with skip_transaction_signatures --- libraries/app/application.cpp | 3 +-- libraries/chain/db_block.cpp | 2 +- libraries/chain/db_init.cpp | 2 +- .../chain/include/graphene/chain/database.hpp | 2 +- tests/tests/authority_tests.cpp | 8 ++++---- tests/tests/bitasset_tests.cpp | 2 -- tests/tests/block_tests.cpp | 19 ++++++++----------- tests/tests/fee_tests.cpp | 5 ----- tests/tests/operation_tests.cpp | 6 +++--- tests/tests/operation_tests2.cpp | 6 +----- tests/tests/uia_tests.cpp | 4 ++-- 11 files changed, 22 insertions(+), 37 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 0c27120efd..eead708ba2 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -407,8 +407,7 @@ void application_impl::startup() graphene::chain::database::skip_transaction_signatures | graphene::chain::database::skip_transaction_dupe_check | graphene::chain::database::skip_tapos_check | - graphene::chain::database::skip_witness_schedule_check | - graphene::chain::database::skip_authority_check; + graphene::chain::database::skip_witness_schedule_check; if( _options->count("revalidate-blockchain") ) // see also handle_block() skip = _options->count("force-validate") ? 0 : graphene::chain::database::skip_transaction_signatures; graphene::chain::detail::with_skip_flags( *_chain_db, skip, [this,&initial_state] () { diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index d6d083a967..8c2395ef20 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -638,7 +638,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx const chain_parameters& chain_parameters = get_global_properties().parameters; eval_state._trx = &trx; - if( !(skip & (skip_transaction_signatures | skip_authority_check) ) ) + if( !(skip & skip_transaction_signatures) ) { auto get_active = [&]( account_id_type id ) { return &id(*this).active; }; auto get_owner = [&]( account_id_type id ) { return &id(*this).owner; }; diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 34d16f4b82..4ca2231571 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -235,7 +235,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) _undo_db.disable(); struct auth_inhibitor { auth_inhibitor(database& db) : db(db), old_flags(db.node_properties().skip_flags) - { db.node_properties().skip_flags |= skip_authority_check; } + { db.node_properties().skip_flags |= skip_transaction_signatures; } ~auth_inhibitor() { db.node_properties().skip_flags = old_flags; } private: diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index 4fdc984ef0..3b50f1fdb1 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -69,7 +69,7 @@ namespace graphene { namespace chain { skip_fork_db = 1 << 3, ///< used while reindexing skip_block_size_check = 1 << 4, ///< used when applying locally generated transactions skip_tapos_check = 1 << 5, ///< used while reindexing -- note this skips expiration check as well - skip_authority_check = 1 << 6, ///< used while reindexing -- disables any checking of authority on transactions + // skip_authority_check = 1 << 6, ///< removed because effectively identical to skip_transaction_signatures skip_merkle_check = 1 << 7, ///< used while reindexing skip_assert_evaluation = 1 << 8, ///< used while reindexing skip_undo_history_check = 1 << 9, ///< used while reindexing diff --git a/tests/tests/authority_tests.cpp b/tests/tests/authority_tests.cpp index 813cff42d4..0e160c2fd6 100644 --- a/tests/tests/authority_tests.cpp +++ b/tests/tests/authority_tests.cpp @@ -1169,7 +1169,7 @@ BOOST_FIXTURE_TEST_CASE( get_required_signatures_test, database_fixture ) op.owner = auth; tx.operations.push_back( op ); set_expiration( db, tx ); - PUSH_TX( db, tx, database::skip_transaction_signatures | database::skip_authority_check ); + PUSH_TX( db, tx, database::skip_transaction_signatures ); } ; auto get_active = [&]( @@ -1283,7 +1283,7 @@ BOOST_FIXTURE_TEST_CASE( nonminimal_sig_test, database_fixture ) op.owner = auth; tx.operations.push_back( op ); set_expiration( db, tx ); - PUSH_TX( db, tx, database::skip_transaction_signatures | database::skip_authority_check ); + PUSH_TX( db, tx, database::skip_transaction_signatures ); } ; auto get_active = [&]( @@ -1370,7 +1370,7 @@ BOOST_FIXTURE_TEST_CASE( parent_owner_test, database_fixture ) op.owner = owner; tx.operations.push_back( op ); set_expiration( db, tx ); - PUSH_TX( db, tx, database::skip_transaction_signatures | database::skip_authority_check ); + PUSH_TX( db, tx, database::skip_transaction_signatures ); } ; auto set_auth = [&]( @@ -1462,7 +1462,7 @@ BOOST_FIXTURE_TEST_CASE( missing_owner_auth_test, database_fixture ) op.owner = owner; tx.operations.push_back( op ); set_expiration( db, tx ); - PUSH_TX( db, tx, database::skip_transaction_signatures | database::skip_authority_check ); + PUSH_TX( db, tx, database::skip_transaction_signatures ); } ; auto get_active = [&]( diff --git a/tests/tests/bitasset_tests.cpp b/tests/tests/bitasset_tests.cpp index 9e9a2814ed..4fc6097650 100644 --- a/tests/tests/bitasset_tests.cpp +++ b/tests/tests/bitasset_tests.cpp @@ -448,7 +448,6 @@ BOOST_AUTO_TEST_CASE( hf_890_test ) | database::skip_transaction_dupe_check | database::skip_block_size_check | database::skip_tapos_check - | database::skip_authority_check | database::skip_merkle_check ; generate_blocks(HARDFORK_615_TIME, true, skip); // get around Graphene issue #615 feed expiration bug @@ -918,7 +917,6 @@ BOOST_AUTO_TEST_CASE( hf_935_test ) | database::skip_transaction_dupe_check | database::skip_block_size_check | database::skip_tapos_check - | database::skip_authority_check | database::skip_merkle_check ; generate_blocks( HARDFORK_615_TIME, true, skip ); // get around Graphene issue #615 feed expiration bug diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index e71642726b..14e0295ca6 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -687,7 +687,7 @@ BOOST_AUTO_TEST_CASE( duplicate_transactions ) db2.open(dir2.path(), make_genesis, "TEST"); BOOST_CHECK( db1.get_chain_id() == db2.get_chain_id() ); - auto skip_sigs = database::skip_transaction_signatures | database::skip_authority_check; + auto skip_sigs = database::skip_transaction_signatures; auto init_account_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("null_key")) ); public_key_type init_account_pub_key = init_account_priv_key.get_public_key(); @@ -766,11 +766,11 @@ BOOST_AUTO_TEST_CASE( tapos ) trx.operations.push_back(t); trx.sign( init_account_priv_key, db1.get_chain_id() ); //relative_expiration is 1, but ref block is 2 blocks old, so this should fail. - GRAPHENE_REQUIRE_THROW(PUSH_TX( db1, trx, database::skip_transaction_signatures | database::skip_authority_check ), fc::exception); + GRAPHENE_REQUIRE_THROW(PUSH_TX( db1, trx, database::skip_transaction_signatures ), fc::exception); set_expiration( db1, trx ); trx.clear_signatures(); trx.sign( init_account_priv_key, db1.get_chain_id() ); - db1.push_transaction(trx, database::skip_transaction_signatures | database::skip_authority_check); + PUSH_TX( db1, trx, database::skip_transaction_signatures ); } catch (fc::exception& e) { edump((e.to_detail_string())); throw; @@ -1056,7 +1056,6 @@ BOOST_FIXTURE_TEST_CASE( pop_block_twice, database_fixture ) uint32_t skip_flags = ( database::skip_witness_signature | database::skip_transaction_signatures - | database::skip_authority_check ); const asset_object& core = asset_id_type()(db); @@ -1231,8 +1230,8 @@ BOOST_FIXTURE_TEST_CASE( transaction_invalidated_in_cache, database_fixture ) }; // tx's created by ACTORS() have bogus authority, so we need to - // skip_authority_check in the block where they're included - signed_block b1 = generate_block(db, database::skip_authority_check); + // skip_transaction_signatures in the block where they're included + signed_block b1 = generate_block(db, database::skip_transaction_signatures); fc::temp_directory data_dir2( graphene::utilities::temp_directory_path() ); @@ -1244,7 +1243,7 @@ BOOST_FIXTURE_TEST_CASE( transaction_invalidated_in_cache, database_fixture ) { optional< signed_block > b = db.fetch_block_by_number( db2.head_block_num()+1 ); db2.push_block(*b, database::skip_witness_signature - |database::skip_authority_check ); + |database::skip_transaction_signatures ); } BOOST_CHECK( db2.get( alice_id ).name == "alice" ); BOOST_CHECK( db2.get( bob_id ).name == "bob" ); @@ -1253,7 +1252,7 @@ BOOST_FIXTURE_TEST_CASE( transaction_invalidated_in_cache, database_fixture ) transfer( account_id_type(), alice_id, asset( 1000 ) ); transfer( account_id_type(), bob_id, asset( 1000 ) ); // need to skip authority check here as well for same reason as above - db2.push_block(generate_block(db, database::skip_authority_check), database::skip_authority_check); + db2.push_block(generate_block(db, database::skip_transaction_signatures), database::skip_transaction_signatures); BOOST_CHECK_EQUAL(db.get_balance(alice_id, asset_id_type()).amount.value, 1000); BOOST_CHECK_EQUAL(db.get_balance( bob_id, asset_id_type()).amount.value, 1000); @@ -1478,7 +1477,6 @@ BOOST_FIXTURE_TEST_CASE( update_account_keys, database_fixture ) database::skip_transaction_dupe_check | database::skip_witness_signature | database::skip_transaction_signatures - | database::skip_authority_check ; // Sam is the creator of accounts @@ -1606,8 +1604,7 @@ BOOST_FIXTURE_TEST_CASE( update_account_keys, database_fixture ) processed_transaction ptx_create = db.push_transaction( trx, database::skip_transaction_dupe_check | - database::skip_transaction_signatures | - database::skip_authority_check + database::skip_transaction_signatures ); account_id_type alice_account_id = ptx_create.operation_results[0] diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index 503c9ebc6e..587814815c 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -759,7 +759,6 @@ BOOST_AUTO_TEST_CASE( fee_refund_test ) | database::skip_transaction_dupe_check | database::skip_block_size_check | database::skip_tapos_check - | database::skip_authority_check | database::skip_merkle_check ; @@ -897,7 +896,6 @@ BOOST_AUTO_TEST_CASE( non_core_fee_refund_test ) | database::skip_transaction_dupe_check | database::skip_block_size_check | database::skip_tapos_check - | database::skip_authority_check | database::skip_merkle_check ; @@ -1284,7 +1282,6 @@ BOOST_AUTO_TEST_CASE( hf445_fee_refund_cross_test ) | database::skip_transaction_dupe_check | database::skip_block_size_check | database::skip_tapos_check - | database::skip_authority_check | database::skip_merkle_check ; @@ -1791,7 +1788,6 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_test ) | database::skip_transaction_dupe_check | database::skip_block_size_check | database::skip_tapos_check - | database::skip_authority_check | database::skip_merkle_check ; @@ -2349,7 +2345,6 @@ BOOST_AUTO_TEST_CASE( bsip26_fee_refund_cross_test ) | database::skip_transaction_dupe_check | database::skip_block_size_check | database::skip_tapos_check - | database::skip_authority_check | database::skip_merkle_check ; diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index 5e4168562d..b00745ff06 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -1940,7 +1940,7 @@ BOOST_AUTO_TEST_CASE( reserve_asset_test ) transaction tx; tx.operations.push_back( op ); set_expiration( db, tx ); - db.push_transaction( tx, database::skip_authority_check | database::skip_tapos_check | database::skip_transaction_signatures ); + PUSH_TX( db, tx, database::skip_tapos_check | database::skip_transaction_signatures ); } ; auto _issue_uia = [&]( const account_object& recipient, asset amount ) @@ -1952,7 +1952,7 @@ BOOST_AUTO_TEST_CASE( reserve_asset_test ) transaction tx; tx.operations.push_back( op ); set_expiration( db, tx ); - db.push_transaction( tx, database::skip_authority_check | database::skip_tapos_check | database::skip_transaction_signatures ); + PUSH_TX( db, tx, database::skip_tapos_check | database::skip_transaction_signatures ); } ; int64_t init_balance = 10000; @@ -2043,7 +2043,7 @@ BOOST_AUTO_TEST_CASE( cover_with_collateral_test ) transaction tx; tx.operations.push_back( op ); set_expiration( db, tx ); - db.push_transaction( tx, database::skip_authority_check | database::skip_tapos_check | database::skip_transaction_signatures ); + PUSH_TX( db, tx, database::skip_tapos_check | database::skip_transaction_signatures ); } ; // margin call requirement: 1.75x diff --git a/tests/tests/operation_tests2.cpp b/tests/tests/operation_tests2.cpp index 5a876d9418..e0d027da1c 100644 --- a/tests/tests/operation_tests2.cpp +++ b/tests/tests/operation_tests2.cpp @@ -565,7 +565,6 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_whitelist_asset_test ) | database::skip_transaction_dupe_check | database::skip_block_size_check | database::skip_tapos_check - | database::skip_authority_check | database::skip_merkle_check ; @@ -1052,7 +1051,6 @@ BOOST_AUTO_TEST_CASE( witness_create ) | database::skip_transaction_dupe_check | database::skip_block_size_check | database::skip_tapos_check - | database::skip_authority_check | database::skip_merkle_check ; generate_block(skip); @@ -1238,7 +1236,6 @@ BOOST_AUTO_TEST_CASE( global_settle_test ) | database::skip_transaction_dupe_check | database::skip_block_size_check | database::skip_tapos_check - | database::skip_authority_check | database::skip_merkle_check ; @@ -1616,7 +1613,6 @@ BOOST_AUTO_TEST_CASE( force_settle_test ) | database::skip_transaction_dupe_check | database::skip_block_size_check | database::skip_tapos_check - | database::skip_authority_check | database::skip_merkle_check ; @@ -2058,7 +2054,7 @@ BOOST_AUTO_TEST_CASE(zero_second_vbo) transaction tx; tx.operations.push_back( op ); set_expiration( db, tx ); - db.push_transaction( tx, database::skip_authority_check | database::skip_tapos_check | database::skip_transaction_signatures ); + PUSH_TX( db, tx, database::skip_tapos_check | database::skip_transaction_signatures ); } enable_fees(); upgrade_to_lifetime_member(alice_id); diff --git a/tests/tests/uia_tests.cpp b/tests/tests/uia_tests.cpp index 7b44ef4c04..56b2116a44 100644 --- a/tests/tests/uia_tests.cpp +++ b/tests/tests/uia_tests.cpp @@ -377,7 +377,7 @@ BOOST_AUTO_TEST_CASE( transfer_restricted_test ) transaction tx; tx.operations.push_back( op ); set_expiration( db, tx ); - PUSH_TX( db, tx, database::skip_authority_check | database::skip_tapos_check | database::skip_transaction_signatures ); + PUSH_TX( db, tx, database::skip_tapos_check | database::skip_transaction_signatures ); } ; const asset_object& uia = create_user_issued_asset( "TXRX", sam, transfer_restricted ); @@ -396,7 +396,7 @@ BOOST_AUTO_TEST_CASE( transfer_restricted_test ) transaction tx; tx.operations.push_back( op ); set_expiration( db, tx ); - PUSH_TX( db, tx, database::skip_authority_check | database::skip_tapos_check | database::skip_transaction_signatures ); + PUSH_TX( db, tx, database::skip_tapos_check | database::skip_transaction_signatures ); } ; BOOST_TEST_MESSAGE( "Enable transfer_restricted, send fails" ); From 56dfa9c35abf85f97caf4d71b80a336c69ff6c20 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 11 Oct 2018 21:20:47 +0200 Subject: [PATCH 064/172] Removed unused skip_validate flag introduced in #dca5c95 2016-01-04 --- libraries/chain/db_block.cpp | 3 +-- libraries/chain/include/graphene/chain/database.hpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 8c2395ef20..9b85dad148 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -623,8 +623,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx { try { uint32_t skip = get_node_properties().skip_flags; - if( true || !(skip&skip_validate) ) /* issue #505 explains why this skip_flag is disabled */ - trx.validate(); + trx.validate(); auto& trx_idx = get_mutable_index_type(); const chain_id_type& chain_id = get_chain_id(); diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index 3b50f1fdb1..c7d35cc13f 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -73,8 +73,7 @@ namespace graphene { namespace chain { skip_merkle_check = 1 << 7, ///< used while reindexing skip_assert_evaluation = 1 << 8, ///< used while reindexing skip_undo_history_check = 1 << 9, ///< used while reindexing - skip_witness_schedule_check = 1 << 10, ///< used while reindexing - skip_validate = 1 << 11 ///< used prior to checkpoint, skips validate() call on transaction + skip_witness_schedule_check = 1 << 10 ///< used while reindexing }; /** From 1a78e1b2be2982b5138df6b18965a79c747dd10b Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 11 Oct 2018 22:07:43 +0200 Subject: [PATCH 065/172] Add warning when revalidating with checkpoints --- libraries/app/application.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index eead708ba2..057e6368de 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -409,7 +409,11 @@ void application_impl::startup() graphene::chain::database::skip_tapos_check | graphene::chain::database::skip_witness_schedule_check; if( _options->count("revalidate-blockchain") ) // see also handle_block() + { + if( !loaded_checkpoints.empty() ) + wlog( "Warning - revalidate will not validate before last checkpoint" ); skip = _options->count("force-validate") ? 0 : graphene::chain::database::skip_transaction_signatures; + } graphene::chain::detail::with_skip_flags( *_chain_db, skip, [this,&initial_state] () { _chain_db->open( _data_dir / "blockchain", initial_state, GRAPHENE_CURRENT_DB_VERSION ); }); From cf2d6e7b29977e29988f01e6dfcd49fd412a22d1 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Fri, 12 Oct 2018 18:00:43 +0200 Subject: [PATCH 066/172] Make distinction between skip_flag cases clearer --- libraries/app/application.cpp | 22 ++++++++++++------- .../graphene/debug_witness/debug_witness.hpp | 2 +- .../include/graphene/witness/witness.hpp | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 057e6368de..3858c1871c 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -401,19 +401,25 @@ void application_impl::startup() try { // these flags are used in open() only, i. e. during replay - uint32_t skip = graphene::chain::database::skip_witness_signature | - graphene::chain::database::skip_block_size_check | - graphene::chain::database::skip_merkle_check | - graphene::chain::database::skip_transaction_signatures | - graphene::chain::database::skip_transaction_dupe_check | - graphene::chain::database::skip_tapos_check | - graphene::chain::database::skip_witness_schedule_check; + uint32_t skip; if( _options->count("revalidate-blockchain") ) // see also handle_block() { if( !loaded_checkpoints.empty() ) wlog( "Warning - revalidate will not validate before last checkpoint" ); - skip = _options->count("force-validate") ? 0 : graphene::chain::database::skip_transaction_signatures; + if( _options->count("force-validate") ) + skip = graphene::chain::database::skip_nothing; + else + skip = graphene::chain::database::skip_transaction_signatures; } + else // no revalidate, skip most checks + skip = graphene::chain::database::skip_witness_signature | + graphene::chain::database::skip_block_size_check | + graphene::chain::database::skip_merkle_check | + graphene::chain::database::skip_transaction_signatures | + graphene::chain::database::skip_transaction_dupe_check | + graphene::chain::database::skip_tapos_check | + graphene::chain::database::skip_witness_schedule_check; + graphene::chain::detail::with_skip_flags( *_chain_db, skip, [this,&initial_state] () { _chain_db->open( _data_dir / "blockchain", initial_state, GRAPHENE_CURRENT_DB_VERSION ); }); diff --git a/libraries/plugins/debug_witness/include/graphene/debug_witness/debug_witness.hpp b/libraries/plugins/debug_witness/include/graphene/debug_witness/debug_witness.hpp index 907d26ae9a..22c71236b5 100644 --- a/libraries/plugins/debug_witness/include/graphene/debug_witness/debug_witness.hpp +++ b/libraries/plugins/debug_witness/include/graphene/debug_witness/debug_witness.hpp @@ -58,7 +58,7 @@ class debug_witness_plugin : public graphene::app::plugin { boost::program_options::variables_map _options; - std::map _private_keys; + std::map _private_keys; std::shared_ptr< std::ofstream > _json_object_stream; boost::signals2::scoped_connection _applied_block_conn; diff --git a/libraries/plugins/witness/include/graphene/witness/witness.hpp b/libraries/plugins/witness/include/graphene/witness/witness.hpp index 9292b55e9f..0d2eab27ac 100644 --- a/libraries/plugins/witness/include/graphene/witness/witness.hpp +++ b/libraries/plugins/witness/include/graphene/witness/witness.hpp @@ -81,7 +81,7 @@ class witness_plugin : public graphene::app::plugin { uint32_t _required_witness_participation = 33 * GRAPHENE_1_PERCENT; uint32_t _production_skip_flags = graphene::chain::database::skip_nothing; - std::map _private_keys; + std::map _private_keys; std::set _witnesses; fc::future _block_production_task; From d644f200af36b33a3aa95acc4211acb2acc4861b Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Fri, 26 Oct 2018 15:56:13 +0200 Subject: [PATCH 067/172] Prove that irrelevant signature detection depends on sorting order --- tests/tests/authority_tests.cpp | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/tests/authority_tests.cpp b/tests/tests/authority_tests.cpp index 0e160c2fd6..310a992060 100644 --- a/tests/tests/authority_tests.cpp +++ b/tests/tests/authority_tests.cpp @@ -1677,4 +1677,42 @@ BOOST_AUTO_TEST_CASE( issue_214 ) BOOST_CHECK_EQUAL( top.amount.amount.value, get_balance( bob_id, top.amount.asset_id ) ); } FC_LOG_AND_RETHROW() } +BOOST_AUTO_TEST_CASE( irrelevant_signatures ) +{ try { + ACTORS( (alice)(bob) ); + fund( alice ); + + // PK: BTS4vsFgTXJcGQMKCFayF2hrNRfYcKjNZ6Mzk8aw9M4zuWfscPhzE, A: BTSGfxPKKLj6tdTUB7i3mHsd2m7QvPLPy2YA + const fc::ecc::private_key test2 = fc::ecc::private_key::regenerate( fc::sha256::hash( std::string( "test-2" ) ) ); + const public_key_type test2_pub( test2.get_public_key() ); + + // PK: BTS7FXC7S9UH7HEH8QiuJ8Xv1NRJJZd1GomALLm9ffjtH95Tb2ZQB, A: BTSBajRqmdrXqmDpZhJ8sgkGagdeXneHFVeM + const fc::ecc::private_key test3 = fc::ecc::private_key::regenerate( fc::sha256::hash( std::string( "test-3" ) ) ); + const public_key_type test3_pub( test3.get_public_key() ); + + BOOST_REQUIRE( test2_pub.key_data < test3_pub.key_data ); + BOOST_REQUIRE( address( test3_pub ) < address( test2_pub ) ); + + account_update_operation auo; + auo.account = alice_id; + auo.active = authority( 2, test2_pub, 2, test3_pub, 1 ); + + trx.clear(); + set_expiration( db, trx ); + trx.operations.push_back( auo ); + sign( trx, alice_private_key ); + PUSH_TX( db, trx ); + trx.clear(); + + transfer_operation to; + to.amount = asset( 1 ); + to.from = alice_id; + to.to = bob_id; + trx.operations.push_back( to ); + sign( trx, test2 ); + sign( trx, test3 ); + PUSH_TX( db, trx ); + +} FC_LOG_AND_RETHROW() } + BOOST_AUTO_TEST_SUITE_END() From 0c4c13364bb6a29fd06a254c9f9e9d1071412f07 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 25 Oct 2018 17:43:49 +0200 Subject: [PATCH 068/172] Fixed typo --- libraries/app/application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 3858c1871c..882f8f7a8f 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -984,7 +984,7 @@ void application::set_program_options(boost::program_options::options_descriptio "Path to create a Genesis State at. If a well-formed JSON file exists at the path, it will be parsed and any " "missing fields in a Genesis State will be added, and any unknown fields will be removed. If no file or an " "invalid file is found, it will be replaced with an example Genesis State.") - ("replay-blockchain", "Rebuild object graph by replaying all blocks without validatino") + ("replay-blockchain", "Rebuild object graph by replaying all blocks without validation") ("revalidate-blockchain", "Rebuild object graph by replaying all blocks with full validation") ("resync-blockchain", "Delete all blocks and re-sync with network from scratch") ("force-validate", "Force validation of all transactions during normal operation") From e5ba271c264c2c4173e12f37db9d0def1e068ab8 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 27 Sep 2018 20:24:30 +0200 Subject: [PATCH 069/172] Parallelize loading/saving object_database --- libraries/db/object_database.cpp | 17 +++++++++++++++-- libraries/fc | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libraries/db/object_database.cpp b/libraries/db/object_database.cpp index fdde0fed6b..5b026c08cf 100644 --- a/libraries/db/object_database.cpp +++ b/libraries/db/object_database.cpp @@ -25,6 +25,7 @@ #include #include +#include #include namespace graphene { namespace db { @@ -72,14 +73,20 @@ void object_database::flush() { // ilog("Save object_database in ${d}", ("d", _data_dir)); fc::create_directories( _data_dir / "object_database.tmp" / "lock" ); + std::vector> tasks; + tasks.reserve(200); for( uint32_t space = 0; space < _index.size(); ++space ) { fc::create_directories( _data_dir / "object_database.tmp" / fc::to_string(space) ); const auto types = _index[space].size(); for( uint32_t type = 0; type < types; ++type ) if( _index[space][type] ) - _index[space][type]->save( _data_dir / "object_database.tmp" / fc::to_string(space)/fc::to_string(type) ); + tasks.push_back( fc::do_parallel( [this,space,type] () { + _index[space][type]->save( _data_dir / "object_database.tmp" / fc::to_string(space)/fc::to_string(type) ); + } ) ); } + for( auto& task : tasks ) + task.wait(); fc::remove_all( _data_dir / "object_database.tmp" / "lock" ); if( fc::exists( _data_dir / "object_database" ) ) fc::rename( _data_dir / "object_database", _data_dir / "object_database.old" ); @@ -103,11 +110,17 @@ void object_database::open(const fc::path& data_dir) wlog("Ignoring locked object_database"); return; } + std::vector> tasks; + tasks.reserve(200); ilog("Opening object database from ${d} ...", ("d", data_dir)); for( uint32_t space = 0; space < _index.size(); ++space ) for( uint32_t type = 0; type < _index[space].size(); ++type ) if( _index[space][type] ) - _index[space][type]->open( _data_dir / "object_database" / fc::to_string(space)/fc::to_string(type) ); + tasks.push_back( fc::do_parallel( [this,space,type] () { + _index[space][type]->open( _data_dir / "object_database" / fc::to_string(space)/fc::to_string(type) ); + } ) ); + for( auto& task : tasks ) + task.wait(); ilog( "Done opening object database." ); } FC_CAPTURE_AND_RETHROW( (data_dir) ) } diff --git a/libraries/fc b/libraries/fc index 9cce60c917..0468884ea6 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 9cce60c91773ad99cfdfa42c5e86ba6ceb3f3ee9 +Subproject commit 0468884ea675afe3a16ffc61371672fecf6e7dde From 033ddea8cdab350cbfed6f87de86dfb59dd4d959 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 4 Oct 2018 16:43:26 +0200 Subject: [PATCH 070/172] Introduce precomputable_transaction, and clearable_block in tests --- .../graphene/chain/protocol/transaction.hpp | 47 ++++++++++++++----- libraries/chain/protocol/transaction.cpp | 46 ++++++++++++------ tests/common/database_fixture.cpp | 7 +++ tests/common/database_fixture.hpp | 5 ++ tests/tests/authority_tests.cpp | 1 - tests/tests/basic_tests.cpp | 11 ++++- tests/tests/block_tests.cpp | 4 +- 7 files changed, 91 insertions(+), 30 deletions(-) diff --git a/libraries/chain/include/graphene/chain/protocol/transaction.hpp b/libraries/chain/include/graphene/chain/protocol/transaction.hpp index 95c3996135..2f67d5dd60 100644 --- a/libraries/chain/include/graphene/chain/protocol/transaction.hpp +++ b/libraries/chain/include/graphene/chain/protocol/transaction.hpp @@ -85,9 +85,9 @@ namespace graphene { namespace chain { extensions_type extensions; /// Calculate the digest for a transaction - digest_type digest()const; - transaction_id_type id()const; - void validate() const; + digest_type digest()const; + virtual const transaction_id_type& id()const; + virtual void validate() const; /// Calculate the digest used for signature validation digest_type sig_digest( const chain_id_type& chain_id )const; @@ -113,6 +113,10 @@ namespace graphene { namespace chain { } void get_required_authorities( flat_set& active, flat_set& owner, vector& other )const; + + protected: + digest_type sig_digest( const chain_id_type& chain_id )const; + mutable transaction_id_type _tx_id_buffer; }; /** @@ -176,7 +180,7 @@ namespace graphene { namespace chain { * otherwise, the @ref chain_id parameter will be ignored, and * @ref signees will be returned directly. */ - const flat_set& get_signature_keys( const chain_id_type& chain_id )const; + virtual const flat_set& get_signature_keys( const chain_id_type& chain_id )const; /** Signatures */ vector signatures; @@ -184,11 +188,31 @@ namespace graphene { namespace chain { /** Public keys extracted from signatures */ mutable flat_set signees; - /// Removes all operations, signatures and signees - void clear() { operations.clear(); signatures.clear(); signees.clear(); } + /// Removes all operations and signatures + void clear() { operations.clear(); signatures.clear(); } + + /// Removes all signatures + void clear_signatures() { signatures.clear(); } + protected: + /** Public keys extracted from signatures */ + mutable flat_set _signees; + }; + + /** This represents a signed transaction that will never have its operations, + * signatures etc. modified again, after initial creation. It is therefore + * safe to cache results from various calls. + */ + class precomputable_transaction : public signed_transaction { + public: + precomputable_transaction() {} + precomputable_transaction( const signed_transaction& tx ) : signed_transaction(tx) {}; + precomputable_transaction( signed_transaction&& tx ) : signed_transaction( std::move(tx) ) {}; - /// Removes all signatures and signees - void clear_signatures() { signatures.clear(); signees.clear(); } + virtual const transaction_id_type& id()const; + virtual void validate() const; + virtual const flat_set& get_signature_keys( const chain_id_type& chain_id )const; + protected: + mutable bool _validated = false; }; void verify_authority( const vector& ops, const flat_set& sigs, @@ -212,10 +236,10 @@ namespace graphene { namespace chain { * If an operation did not create any new object IDs then 0 * should be returned. */ - struct processed_transaction : public signed_transaction + struct processed_transaction : public precomputable_transaction { processed_transaction( const signed_transaction& trx = signed_transaction() ) - : signed_transaction(trx){} + : precomputable_transaction(trx){} vector operation_results; @@ -229,4 +253,5 @@ namespace graphene { namespace chain { FC_REFLECT( graphene::chain::transaction, (ref_block_num)(ref_block_prefix)(expiration)(operations)(extensions) ) // Note: not reflecting signees field for backward compatibility; in addition, it should not be in p2p messages FC_REFLECT_DERIVED( graphene::chain::signed_transaction, (graphene::chain::transaction), (signatures) ) -FC_REFLECT_DERIVED( graphene::chain::processed_transaction, (graphene::chain::signed_transaction), (operation_results) ) +FC_REFLECT_DERIVED( graphene::chain::precomputable_transaction, (graphene::chain::signed_transaction), ) +FC_REFLECT_DERIVED( graphene::chain::processed_transaction, (graphene::chain::precomputable_transaction), (operation_results) ) diff --git a/libraries/chain/protocol/transaction.cpp b/libraries/chain/protocol/transaction.cpp index 4bb7ce8378..04e3cb4914 100644 --- a/libraries/chain/protocol/transaction.cpp +++ b/libraries/chain/protocol/transaction.cpp @@ -60,19 +60,17 @@ void transaction::validate() const operation_validate(op); } -graphene::chain::transaction_id_type graphene::chain::transaction::id() const +const graphene::chain::transaction_id_type& graphene::chain::transaction::id() const { auto h = digest(); - transaction_id_type result; - memcpy(result._hash, h._hash, std::min(sizeof(result), sizeof(h))); - return result; + memcpy(_tx_id_buffer._hash, h._hash, std::min(sizeof(_tx_id_buffer), sizeof(h))); + return _tx_id_buffer; } const signature_type& graphene::chain::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id) { digest_type h = sig_digest( chain_id ); signatures.push_back(key.sign_compact(h)); - signees.clear(); // Clear signees since it may be inconsistent after added a new signature return signatures.back(); } @@ -307,20 +305,17 @@ const flat_set& signed_transaction::get_signature_keys( const c { try { // Strictly we should check whether the given chain ID is same as the one used to initialize the `signees` field. // However, we don't pass in another chain ID so far, for better performance, we skip the check. - if( signees.empty() && !signatures.empty() ) + auto d = sig_digest( chain_id ); + flat_set result; + for( const auto& sig : signatures ) { - auto d = sig_digest( chain_id ); - flat_set result; - for( const auto& sig : signatures ) - { - GRAPHENE_ASSERT( - result.insert( fc::ecc::public_key(sig,d) ).second, + GRAPHENE_ASSERT( + result.insert( fc::ecc::public_key(sig,d) ).second, tx_duplicate_sig, "Duplicate Signature detected" ); - } - signees = std::move( result ); } - return signees; + _signees = std::move( result ); + return _signees; } FC_CAPTURE_AND_RETHROW() } @@ -386,6 +381,27 @@ set signed_transaction::minimize_required_signatures( return set( result.begin(), result.end() ); } +const transaction_id_type& precomputable_transaction::id()const +{ + if( !_tx_id_buffer._hash[0] ) + transaction::id(); + return _tx_id_buffer; +} + +void precomputable_transaction::validate() const +{ + if( _validated ) return; + transaction::validate(); + _validated = true; +} + +const flat_set& precomputable_transaction::get_signature_keys( const chain_id_type& chain_id )const +{ + if( _signees.empty() ) + signed_transaction::get_signature_keys( chain_id ); + return _signees; +} + void signed_transaction::verify_authority( const chain_id_type& chain_id, const std::function& get_active, diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 534c03de33..2e05f71017 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -55,6 +55,13 @@ namespace graphene { namespace chain { using std::cout; using std::cerr; +void clearable_block::clear() +{ + _calculated_merkle_root = checksum_type(); + _signee = fc::ecc::public_key(); + _block_id = block_id_type(); +} + database_fixture::database_fixture() : app(), db( *app.chain_database() ) { diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index 78f7b65d19..72744ff7e5 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -170,6 +170,11 @@ extern uint32_t GRAPHENE_TESTING_GENESIS_TIMESTAMP; namespace graphene { namespace chain { +class clearable_block : public signed_block { +public: + void clear(); +}; + struct database_fixture { // the reason we use an app is to exercise the indexes of built-in // plugins diff --git a/tests/tests/authority_tests.cpp b/tests/tests/authority_tests.cpp index 310a992060..573d609edf 100644 --- a/tests/tests/authority_tests.cpp +++ b/tests/tests/authority_tests.cpp @@ -1057,7 +1057,6 @@ BOOST_FIXTURE_TEST_CASE( bogus_signature, database_fixture ) PUSH_TX( db, trx, skip ); trx.operations.push_back( xfer_op ); - trx.signees.clear(); // signees should be invalidated BOOST_TEST_MESSAGE( "Invalidating Alices Signature" ); // Alice's signature is now invalid GRAPHENE_REQUIRE_THROW( PUSH_TX( db, trx, skip ), fc::exception ); diff --git a/tests/tests/basic_tests.cpp b/tests/tests/basic_tests.cpp index 2157dde75a..97d03ed41b 100644 --- a/tests/tests/basic_tests.cpp +++ b/tests/tests/basic_tests.cpp @@ -408,7 +408,7 @@ BOOST_AUTO_TEST_CASE( scaled_precision ) BOOST_AUTO_TEST_CASE( merkle_root ) { - signed_block block; + clearable_block block; vector tx; vector t; const uint32_t num_tx = 10; @@ -444,6 +444,7 @@ BOOST_AUTO_TEST_CASE( merkle_root ) dA = d(t[0], t[1]); block.transactions.push_back( tx[1] ); + block.clear(); BOOST_CHECK( block.calculate_merkle_root() == c(dA) ); /* @@ -458,6 +459,7 @@ BOOST_AUTO_TEST_CASE( merkle_root ) dI = d(dA, dB); block.transactions.push_back( tx[2] ); + block.clear(); BOOST_CHECK( block.calculate_merkle_root() == c(dI) ); /* @@ -472,6 +474,7 @@ BOOST_AUTO_TEST_CASE( merkle_root ) dI = d(dA, dB); block.transactions.push_back( tx[3] ); + block.clear(); BOOST_CHECK( block.calculate_merkle_root() == c(dI) ); /* @@ -489,6 +492,7 @@ BOOST_AUTO_TEST_CASE( merkle_root ) dM = d(dI, dJ); block.transactions.push_back( tx[4] ); + block.clear(); BOOST_CHECK( block.calculate_merkle_root() == c(dM) ); /* @@ -506,6 +510,7 @@ BOOST_AUTO_TEST_CASE( merkle_root ) dM = d(dI, dJ); block.transactions.push_back( tx[5] ); + block.clear(); BOOST_CHECK( block.calculate_merkle_root() == c(dM) ); /* @@ -523,6 +528,7 @@ BOOST_AUTO_TEST_CASE( merkle_root ) dM = d(dI, dJ); block.transactions.push_back( tx[6] ); + block.clear(); BOOST_CHECK( block.calculate_merkle_root() == c(dM) ); /* @@ -540,6 +546,7 @@ BOOST_AUTO_TEST_CASE( merkle_root ) dM = d(dI, dJ); block.transactions.push_back( tx[7] ); + block.clear(); BOOST_CHECK( block.calculate_merkle_root() == c(dM) ); /* @@ -560,6 +567,7 @@ BOOST_AUTO_TEST_CASE( merkle_root ) dO = d(dM, dN); block.transactions.push_back( tx[8] ); + block.clear(); BOOST_CHECK( block.calculate_merkle_root() == c(dO) ); /* @@ -580,6 +588,7 @@ BOOST_AUTO_TEST_CASE( merkle_root ) dO = d(dM, dN); block.transactions.push_back( tx[9] ); + block.clear(); BOOST_CHECK( block.calculate_merkle_root() == c(dO) ); } diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index 14e0295ca6..1890dc38b8 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -80,11 +80,12 @@ BOOST_AUTO_TEST_CASE( block_database_test ) FC_ASSERT( !bdb.is_open() ); bdb.open( data_dir.path() ); - signed_block b; + clearable_block b; for( uint32_t i = 0; i < 5; ++i ) { if( i > 0 ) b.previous = b.id(); b.witness = witness_id_type(i+1); + b.clear(); bdb.store( b.id(), b ); auto fetch = bdb.fetch_by_number( b.block_num() ); @@ -976,7 +977,6 @@ BOOST_FIXTURE_TEST_CASE( double_sign_check, database_fixture ) BOOST_TEST_MESSAGE( "Verify that signing once with the proper key passes" ); trx.signatures.pop_back(); - trx.signees.clear(); // signees should be invalidated db.push_transaction(trx, 0); } FC_LOG_AND_RETHROW() } From d2d8b29c097071b15ee311bf675512d589651b1b Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 27 Sep 2018 22:09:44 +0200 Subject: [PATCH 071/172] Preprocess blocks + transactions in parallel, working version --- libraries/app/api.cpp | 13 ++- libraries/app/application.cpp | 19 ++-- libraries/app/application_impl.hxx | 4 + libraries/app/include/graphene/app/api.hpp | 6 +- libraries/chain/db_block.cpp | 71 ++++++++++++ libraries/chain/db_management.cpp | 107 +++++++++++------- .../chain/include/graphene/chain/database.hpp | 24 ++++ .../include/graphene/chain/protocol/base.hpp | 3 + .../include/graphene/chain/protocol/block.hpp | 20 +++- .../graphene/chain/protocol/transaction.hpp | 14 +-- libraries/chain/protocol/block.cpp | 64 ++++++----- libraries/chain/protocol/operations.cpp | 6 + libraries/chain/protocol/transaction.cpp | 2 +- .../include/graphene/net/core_messages.hpp | 4 +- .../delayed_node/delayed_node_plugin.cpp | 1 + 15 files changed, 253 insertions(+), 105 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index dbe6043e50..f3cffa70ff 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -159,18 +159,18 @@ namespace graphene { namespace app { } } - void network_broadcast_api::broadcast_transaction(const signed_transaction& trx) + void network_broadcast_api::broadcast_transaction(const precomputable_transaction& trx) { - trx.validate(); + _app.chain_database()->precompute_parallel( trx ).wait(); _app.chain_database()->push_transaction(trx); if( _app.p2p_node() != nullptr ) _app.p2p_node()->broadcast_transaction(trx); } - fc::variant network_broadcast_api::broadcast_transaction_synchronous(const signed_transaction& trx) + fc::variant network_broadcast_api::broadcast_transaction_synchronous(const precomputable_transaction& trx) { fc::promise::ptr prom( new fc::promise() ); - broadcast_transaction_with_callback( [=]( const fc::variant& v ){ + broadcast_transaction_with_callback( [prom]( const fc::variant& v ){ prom->set_value(v); }, trx ); @@ -179,14 +179,15 @@ namespace graphene { namespace app { void network_broadcast_api::broadcast_block( const signed_block& b ) { + _app.chain_database()->precompute_parallel( b ).wait(); _app.chain_database()->push_block(b); if( _app.p2p_node() != nullptr ) _app.p2p_node()->broadcast( net::block_message( b )); } - void network_broadcast_api::broadcast_transaction_with_callback(confirmation_callback cb, const signed_transaction& trx) + void network_broadcast_api::broadcast_transaction_with_callback(confirmation_callback cb, const precomputable_transaction& trx) { - trx.validate(); + _app.chain_database()->precompute_parallel( trx ).wait(); _callbacks[trx.id()] = cb; _app.chain_database()->push_transaction(trx); if( _app.p2p_node() != nullptr ) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 882f8f7a8f..cc7828034f 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -540,13 +540,17 @@ bool application_impl::handle_block(const graphene::net::block_message& blk_msg, FC_ASSERT( (latency.count()/1000) > -5000, "Rejecting block with timestamp in the future" ); try { - // TODO: in the case where this block is valid but on a fork that's too old for us to switch to, - // you can help the network code out by throwing a block_older_than_undo_history exception. - // when the net code sees that, it will stop trying to push blocks from that chain, but - // leave that peer connected so that they can get sync blocks from us - bool result = _chain_db->push_block( blk_msg.block, - (_is_block_producer | _force_validate) ? - database::skip_nothing : database::skip_transaction_signatures ); + const uint32_t skip = (_is_block_producer | _force_validate) ? + database::skip_nothing : database::skip_transaction_signatures; + bool result = valve.do_serial( [this,&blk_msg,skip] () { + _chain_db->precompute_parallel( blk_msg.block, skip ).wait(); + }, [this,&blk_msg,skip] () { + // TODO: in the case where this block is valid but on a fork that's too old for us to switch to, + // you can help the network code out by throwing a block_older_than_undo_history exception. + // when the net code sees that, it will stop trying to push blocks from that chain, but + // leave that peer connected so that they can get sync blocks from us + return _chain_db->push_block( blk_msg.block, skip ); + }); // the block was accepted, so we now know all of the transactions contained in the block if (!sync_mode) @@ -596,6 +600,7 @@ void application_impl::handle_transaction(const graphene::net::trx_message& tran trx_count = 0; } + _chain_db->precompute_parallel( transaction_message.trx ).wait(); _chain_db->push_transaction( transaction_message.trx ); } FC_CAPTURE_AND_RETHROW( (transaction_message) ) } diff --git a/libraries/app/application_impl.hxx b/libraries/app/application_impl.hxx index 5b0c543728..9f601bce79 100644 --- a/libraries/app/application_impl.hxx +++ b/libraries/app/application_impl.hxx @@ -1,6 +1,8 @@ #pragma once #include +#include + #include #include #include @@ -194,6 +196,8 @@ class application_impl : public net::node_delegate std::map> _available_plugins; bool _is_finished_syncing = false; + private: + fc::serial_valve valve; }; }}} // namespace graphene namespace app namespace detail diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index aea35be08b..af34bbaf73 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -266,19 +266,19 @@ namespace graphene { namespace app { * The transaction will be checked for validity in the local database prior to broadcasting. If it fails to * apply locally, an error will be thrown and the transaction will not be broadcast. */ - void broadcast_transaction(const signed_transaction& trx); + void broadcast_transaction(const precomputable_transaction& trx); /** this version of broadcast transaction registers a callback method that will be called when the transaction is * included into a block. The callback method includes the transaction id, block number, and transaction number in the * block. */ - void broadcast_transaction_with_callback( confirmation_callback cb, const signed_transaction& trx); + void broadcast_transaction_with_callback( confirmation_callback cb, const precomputable_transaction& trx); /** this version of broadcast transaction registers a callback method that will be called when the transaction is * included into a block. The callback method includes the transaction id, block number, and transaction number in the * block. */ - fc::variant broadcast_transaction_synchronous(const signed_transaction& trx); + fc::variant broadcast_transaction_synchronous(const precomputable_transaction& trx); /** * @brief Broadcast a signed block to the network diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 9b85dad148..296d88e649 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -37,6 +37,7 @@ #include #include +#include #include namespace graphene { namespace chain { @@ -751,4 +752,74 @@ bool database::before_last_checkpoint()const return (_checkpoints.size() > 0) && (_checkpoints.rbegin()->first >= head_block_num()); } + +static const uint32_t skip_expensive = database::skip_transaction_signatures | database::skip_witness_signature + | database::skip_merkle_check | database::skip_transaction_dupe_check; + +template +void database::_precompute_parallel( const Trx* trx, const size_t count, const uint32_t skip )const +{ + for( size_t i = 0; i < count; ++i, ++trx ) + { + trx->validate(); // TODO - parallelize wrt confidential operations + if( !(skip&skip_transaction_dupe_check) ) + trx->id(); + if( !(skip&skip_transaction_signatures) ) + trx->get_signature_keys( get_chain_id() ); + } +} + +void database::_precompute_parallel( const signed_block& block, const uint32_t skip )const +{ try { + const bool cheap = (skip & skip_expensive) == skip_expensive; + std::vector> workers; + if( !block.transactions.empty() ) + { + if( cheap ) + _precompute_parallel( &block.transactions[0], block.transactions.size(), skip ); + else + { + uint32_t chunks = fc::asio::default_io_service_scope::get_num_threads(); + if( !chunks ) return; + uint32_t chunk_size = block.transactions.size() / chunks; + if( chunks * chunk_size < block.transactions.size() ) + chunk_size++; + workers.reserve( chunks + 1 ); + for( size_t base = 0; base < block.transactions.size(); base += chunk_size ) + workers.push_back( fc::do_parallel( [this,&block,base,chunk_size,skip] () { + _precompute_parallel( &block.transactions[base], + base + chunk_size < block.transactions.size() ? chunk_size : block.transactions.size() - base, + skip ); + }) ); + } + } + + if( !(skip&skip_witness_signature) ) + workers.push_back( fc::do_parallel( [&block] () { block.signee(); } ) ); + if( !(skip&skip_merkle_check) ) + block.calculate_merkle_root(); + block.id(); + for( auto& worker : workers ) + worker.wait(); +} FC_LOG_AND_RETHROW() } + +fc::future database::precompute_parallel( const signed_block& block, const uint32_t skip )const +{ + if( block.transactions.empty() || (skip & skip_expensive) == skip_expensive ) + { + _precompute_parallel( block, skip ); + return fc::future< void >( fc::promise< void >::ptr( new fc::promise< void >( true ) ) ); + } + return fc::do_parallel([this,&block,skip] () { + _precompute_parallel( block, skip ); + }); +} + +fc::future database::precompute_parallel( const precomputable_transaction& trx )const +{ + return fc::do_parallel([this,&trx] () { + _precompute_parallel( &trx, 1, skip_nothing ); + }); +} + } } diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index a86978dc4b..9167768f48 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -35,6 +35,8 @@ #include #include #include +#include +#include namespace graphene { namespace chain { @@ -76,59 +78,76 @@ void database::reindex( fc::path data_dir ) uint32_t skip = node_properties().skip_flags; - size_t total_processed_block_size; size_t total_block_size = _block_id_to_block.total_block_size(); const auto& gpo = get_global_properties(); - for( uint32_t i = head_block_num() + 1; i <= last_block_num; ++i ) + std::queue< std::tuple< size_t, signed_block, fc::future< void > > > blocks; + uint32_t next_block_num = head_block_num() + 1; + uint32_t i = next_block_num; + while( next_block_num <= last_block_num || !blocks.empty() ) { - if( i % 10000 == 0 ) + if( next_block_num <= last_block_num && blocks.size() < 20 ) { - total_processed_block_size = _block_id_to_block.blocks_current_position(); - - ilog( - " [by size: ${size}% ${processed} of ${total}] [by num: ${num}% ${i} of ${last}]", - ("size", double(total_processed_block_size) / total_block_size * 100) - ("processed", total_processed_block_size) - ("total", total_block_size) - ("num", double(i*100)/last_block_num) - ("i", i) - ("last", last_block_num) - ); - } - if( i == flush_point ) - { - ilog( "Writing database to disk at block ${i}", ("i",i) ); - flush(); - ilog( "Done" ); - } - if( head_block_time() >= last_block->timestamp - gpo.parameters.maximum_time_until_expiration ) - skip &= ~skip_transaction_dupe_check; - fc::optional< signed_block > block = _block_id_to_block.fetch_by_number(i); - if( !block.valid() ) - { - wlog( "Reindexing terminated due to gap: Block ${i} does not exist!", ("i", i) ); - uint32_t dropped_count = 0; - while( true ) + const size_t processed_block_size = _block_id_to_block.blocks_current_position(); + fc::optional< signed_block > block = _block_id_to_block.fetch_by_number( next_block_num++ ); + if( block.valid() ) { - fc::optional< block_id_type > last_id = _block_id_to_block.last_id(); - // this can trigger if we attempt to e.g. read a file that has block #2 but no block #1 - if( !last_id.valid() ) - break; - // we've caught up to the gap - if( block_header::num_from_id( *last_id ) <= i ) - break; - _block_id_to_block.remove( *last_id ); - dropped_count++; + if( block->timestamp >= last_block->timestamp - gpo.parameters.maximum_time_until_expiration ) + skip &= ~skip_transaction_dupe_check; + blocks.emplace( processed_block_size, std::move(*block), fc::future() ); + std::get<2>(blocks.back()) = precompute_parallel( std::get<1>(blocks.back()), skip ); + } + else + { + wlog( "Reindexing terminated due to gap: Block ${i} does not exist!", ("i", i) ); + uint32_t dropped_count = 0; + while( true ) + { + fc::optional< block_id_type > last_id = _block_id_to_block.last_id(); + // this can trigger if we attempt to e.g. read a file that has block #2 but no block #1 + if( !last_id.valid() ) + break; + // we've caught up to the gap + if( block_header::num_from_id( *last_id ) <= i ) + break; + _block_id_to_block.remove( *last_id ); + dropped_count++; + } + wlog( "Dropped ${n} blocks from after the gap", ("n", dropped_count) ); + next_block_num = last_block_num + 1; // don't load more blocks } - wlog( "Dropped ${n} blocks from after the gap", ("n", dropped_count) ); - break; } - if( i < undo_point ) - apply_block( *block, skip ); else { - _undo_db.enable(); - push_block( *block, skip ); + std::get<2>(blocks.front()).wait(); + const signed_block& block = std::get<1>(blocks.front()); + + if( i % 10000 == 0 ) + { + ilog( + " [by size: ${size}% ${processed} of ${total}] [by num: ${num}% ${i} of ${last}]", + ("size", double(std::get<0>(blocks.front())) / total_block_size * 100) + ("processed", std::get<0>(blocks.front())) + ("total", total_block_size) + ("num", double(i*100)/last_block_num) + ("i", i) + ("last", last_block_num) + ); + } + if( i == flush_point ) + { + ilog( "Writing database to disk at block ${i}", ("i",i) ); + flush(); + ilog( "Done" ); + } + if( i < undo_point ) + apply_block( block, skip ); + else + { + _undo_db.enable(); + push_block( block, skip ); + } + blocks.pop(); + i++; } } _undo_db.enable(); diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index c7d35cc13f..db2f38e5de 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -415,6 +415,30 @@ namespace graphene { namespace chain { /// Enable or disable tracking of votes of standby witnesses and committee members inline void enable_standby_votes_tracking(bool enable) { _track_standby_votes = enable; } + /** Precomputes digests, signatures and operation validations depending + * on skip flags. "Expensive" computations may be done in a parallel + * thread. + * + * @param block the block to preprocess + * @param skip indicates which computations can be skipped + * @return a future that will resolve to the input block with + * precomputations applied + */ + fc::future precompute_parallel( const signed_block& block, const uint32_t skip = skip_nothing )const; + + /** Precomputes digests, signatures and operation validations. + * "Expensive" computations may be done in a parallel thread. + * + * @param trx the transaction to preprocess + * @return a future that will resolve to the input transaction with + * precomputations applied + */ + fc::future precompute_parallel( const precomputable_transaction& trx )const; + private: + template + void _precompute_parallel( const Trx* trx, const size_t count, const uint32_t skip )const; + void _precompute_parallel( const signed_block& block, const uint32_t skip )const; + protected: //Mark pop_undo() as protected -- we do not want outside calling pop_undo(); it should call pop_block() instead void pop_undo() { object_database::pop_undo(); } diff --git a/libraries/chain/include/graphene/chain/protocol/base.hpp b/libraries/chain/include/graphene/chain/protocol/base.hpp index 52240b934a..73209a1861 100644 --- a/libraries/chain/include/graphene/chain/protocol/base.hpp +++ b/libraries/chain/include/graphene/chain/protocol/base.hpp @@ -27,6 +27,8 @@ #include #include +#include + namespace graphene { namespace chain { /** @@ -94,6 +96,7 @@ namespace graphene { namespace chain { void get_required_active_authorities( flat_set& )const{} void get_required_owner_authorities( flat_set& )const{} void validate()const{} + fc::optional< fc::future > validate_parallel( uint32_t skip )const; static uint64_t calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte ); }; diff --git a/libraries/chain/include/graphene/chain/protocol/block.hpp b/libraries/chain/include/graphene/chain/protocol/block.hpp index 98e627c928..aa8c46052f 100644 --- a/libraries/chain/include/graphene/chain/protocol/block.hpp +++ b/libraries/chain/include/graphene/chain/protocol/block.hpp @@ -26,8 +26,9 @@ namespace graphene { namespace chain { - struct block_header + class block_header { + public: digest_type digest()const; block_id_type previous; uint32_t block_num()const { return num_from_id(previous) + 1; } @@ -41,20 +42,27 @@ namespace graphene { namespace chain { static uint32_t num_from_id(const block_id_type& id); }; - struct signed_block_header : public block_header + class signed_block_header : public block_header { - block_id_type id()const; - fc::ecc::public_key signee()const; + public: + const block_id_type& id()const; + const fc::ecc::public_key& signee()const; void sign( const fc::ecc::private_key& signer ); bool validate_signee( const fc::ecc::public_key& expected_signee )const; signature_type witness_signature; + protected: + mutable fc::ecc::public_key _signee; + mutable block_id_type _block_id; }; - struct signed_block : public signed_block_header + class signed_block : public signed_block_header { - checksum_type calculate_merkle_root()const; + public: + const checksum_type& calculate_merkle_root()const; vector transactions; + protected: + mutable checksum_type _calculated_merkle_root; }; } } // graphene::chain diff --git a/libraries/chain/include/graphene/chain/protocol/transaction.hpp b/libraries/chain/include/graphene/chain/protocol/transaction.hpp index 2f67d5dd60..02f00799c6 100644 --- a/libraries/chain/include/graphene/chain/protocol/transaction.hpp +++ b/libraries/chain/include/graphene/chain/protocol/transaction.hpp @@ -62,8 +62,9 @@ namespace graphene { namespace chain { /** * @brief groups operations that should be applied atomically */ - struct transaction + class transaction { + public: /** * Least significant 16 bits from the reference block number. If @ref relative_expiration is zero, this field * must be zero as well. @@ -89,7 +90,6 @@ namespace graphene { namespace chain { virtual const transaction_id_type& id()const; virtual void validate() const; /// Calculate the digest used for signature validation - digest_type sig_digest( const chain_id_type& chain_id )const; void set_expiration( fc::time_point_sec expiration_time ); void set_reference_block( const block_id_type& reference_block ); @@ -122,8 +122,9 @@ namespace graphene { namespace chain { /** * @brief adds a signature to a transaction */ - struct signed_transaction : public transaction + class signed_transaction : public transaction { + public: signed_transaction( const transaction& trx = transaction() ) : transaction(trx){} @@ -185,13 +186,10 @@ namespace graphene { namespace chain { /** Signatures */ vector signatures; - /** Public keys extracted from signatures */ - mutable flat_set signees; - - /// Removes all operations and signatures + /** Removes all operations and signatures */ void clear() { operations.clear(); signatures.clear(); } - /// Removes all signatures + /** Removes all signatures */ void clear_signatures() { signatures.clear(); } protected: /** Public keys extracted from signatures */ diff --git a/libraries/chain/protocol/block.cpp b/libraries/chain/protocol/block.cpp index d32365dd08..9fdf4707eb 100644 --- a/libraries/chain/protocol/block.cpp +++ b/libraries/chain/protocol/block.cpp @@ -37,19 +37,23 @@ namespace graphene { namespace chain { return fc::endian_reverse_u32(id._hash[0]); } - block_id_type signed_block_header::id()const + const block_id_type& signed_block_header::id()const { - auto tmp = fc::sha224::hash( *this ); - tmp._hash[0] = fc::endian_reverse_u32(block_num()); // store the block num in the ID, 160 bits is plenty for the hash - static_assert( sizeof(tmp._hash[0]) == 4, "should be 4 bytes" ); - block_id_type result; - memcpy(result._hash, tmp._hash, std::min(sizeof(result), sizeof(tmp))); - return result; + if( !_block_id._hash[0] ) + { + auto tmp = fc::sha224::hash( *this ); + tmp._hash[0] = fc::endian_reverse_u32(block_num()); // store the block num in the ID, 160 bits is plenty for the hash + static_assert( sizeof(tmp._hash[0]) == 4, "should be 4 bytes" ); + memcpy(_block_id._hash, tmp._hash, std::min(sizeof(_block_id), sizeof(tmp))); + } + return _block_id; } - fc::ecc::public_key signed_block_header::signee()const + const fc::ecc::public_key& signed_block_header::signee()const { - return fc::ecc::public_key( witness_signature, digest(), true/*enforce canonical*/ ); + if( !_signee.valid() ) + _signee = fc::ecc::public_key( witness_signature, digest(), true/*enforce canonical*/ ); + return _signee; } void signed_block_header::sign( const fc::ecc::private_key& signer ) @@ -62,31 +66,35 @@ namespace graphene { namespace chain { return signee() == expected_signee; } - checksum_type signed_block::calculate_merkle_root()const + const checksum_type& signed_block::calculate_merkle_root()const { + static const checksum_type empty_checksum; if( transactions.size() == 0 ) - return checksum_type(); - - vector ids; - ids.resize( transactions.size() ); - for( uint32_t i = 0; i < transactions.size(); ++i ) - ids[i] = transactions[i].merkle_digest(); + return empty_checksum; - vector::size_type current_number_of_hashes = ids.size(); - while( current_number_of_hashes > 1 ) + if( !_calculated_merkle_root._hash[0] ) { - // hash ID's in pairs - uint32_t i_max = current_number_of_hashes - (current_number_of_hashes&1); - uint32_t k = 0; + vector ids; + ids.resize( transactions.size() ); + for( uint32_t i = 0; i < transactions.size(); ++i ) + ids[i] = transactions[i].merkle_digest(); - for( uint32_t i = 0; i < i_max; i += 2 ) - ids[k++] = digest_type::hash( std::make_pair( ids[i], ids[i+1] ) ); + vector::size_type current_number_of_hashes = ids.size(); + while( current_number_of_hashes > 1 ) + { + // hash ID's in pairs + uint32_t i_max = current_number_of_hashes - (current_number_of_hashes&1); + uint32_t k = 0; - if( current_number_of_hashes&1 ) - ids[k++] = ids[i_max]; - current_number_of_hashes = k; + for( uint32_t i = 0; i < i_max; i += 2 ) + ids[k++] = digest_type::hash( std::make_pair( ids[i], ids[i+1] ) ); + + if( current_number_of_hashes&1 ) + ids[k++] = ids[i_max]; + current_number_of_hashes = k; + } + _calculated_merkle_root = checksum_type::hash( ids[0] ); } - return checksum_type::hash( ids[0] ); + return _calculated_merkle_root; } - } } diff --git a/libraries/chain/protocol/operations.cpp b/libraries/chain/protocol/operations.cpp index 40a37eba3a..48a65f6fed 100644 --- a/libraries/chain/protocol/operations.cpp +++ b/libraries/chain/protocol/operations.cpp @@ -32,6 +32,12 @@ uint64_t base_operation::calculate_data_fee( uint64_t bytes, uint64_t price_per_ return result.to_uint64(); } +fc::optional< fc::future > base_operation::validate_parallel( uint32_t skip )const +{ + validate(); + return fc::optional< fc::future >(); +} + void balance_claim_operation::validate()const { FC_ASSERT( fee == asset() ); diff --git a/libraries/chain/protocol/transaction.cpp b/libraries/chain/protocol/transaction.cpp index 04e3cb4914..c1dd817693 100644 --- a/libraries/chain/protocol/transaction.cpp +++ b/libraries/chain/protocol/transaction.cpp @@ -60,7 +60,7 @@ void transaction::validate() const operation_validate(op); } -const graphene::chain::transaction_id_type& graphene::chain::transaction::id() const +const transaction_id_type& transaction::id() const { auto h = digest(); memcpy(_tx_id_buffer._hash, h._hash, std::min(sizeof(_tx_id_buffer), sizeof(h))); diff --git a/libraries/net/include/graphene/net/core_messages.hpp b/libraries/net/include/graphene/net/core_messages.hpp index 8af0c3443c..76f74bd253 100644 --- a/libraries/net/include/graphene/net/core_messages.hpp +++ b/libraries/net/include/graphene/net/core_messages.hpp @@ -95,9 +95,9 @@ namespace graphene { namespace net { { static const core_message_type_enum type; - signed_transaction trx; + graphene::chain::precomputable_transaction trx; trx_message() {} - trx_message(signed_transaction transaction) : + trx_message(graphene::chain::signed_transaction transaction) : trx(std::move(transaction)) {} }; diff --git a/libraries/plugins/delayed_node/delayed_node_plugin.cpp b/libraries/plugins/delayed_node/delayed_node_plugin.cpp index 24a46cc066..dd1d4705e6 100644 --- a/libraries/plugins/delayed_node/delayed_node_plugin.cpp +++ b/libraries/plugins/delayed_node/delayed_node_plugin.cpp @@ -105,6 +105,7 @@ void delayed_node_plugin::sync_with_trusted_node() fc::optional block = my->database_api->get_block( db.head_block_num()+1 ); FC_ASSERT(block, "Trusted node claims it has blocks it doesn't actually have."); ilog("Pushing block #${n}", ("n", block->block_num())); + db.precompute_parallel( *block, graphene::chain::database::skip_nothing ).wait(); db.push_block(*block); synced_blocks++; } From 9946bdefd093499684deb77ba01992e261c661da Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Fri, 5 Oct 2018 17:53:40 +0200 Subject: [PATCH 072/172] Get rid of possibly uninitialized local variable --- libraries/chain/db_block.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 296d88e649..4873c65ed5 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -628,12 +628,8 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx auto& trx_idx = get_mutable_index_type(); const chain_id_type& chain_id = get_chain_id(); - transaction_id_type trx_id; if( !(skip & skip_transaction_dupe_check) ) - { - trx_id = trx.id(); - FC_ASSERT( trx_idx.indices().get().find(trx_id) == trx_idx.indices().get().end() ); - } + FC_ASSERT( trx_idx.indices().get().find(trx.id()) == trx_idx.indices().get().end() ); transaction_evaluation_state eval_state(this); const chain_parameters& chain_parameters = get_global_properties().parameters; eval_state._trx = &trx; @@ -667,8 +663,8 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx //Insert transaction into unique transactions database. if( !(skip & skip_transaction_dupe_check) ) { - create([&trx_id,&trx](transaction_object& transaction) { - transaction.trx_id = trx_id; + create([&trx](transaction_object& transaction) { + transaction.trx_id = trx.id(); transaction.trx = trx; }); } From cb2244f3db24f23770e888657b8cb084da2d99c2 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 8 Oct 2018 16:36:04 +0200 Subject: [PATCH 073/172] Changed push_transaction to accept precomputable_transaction instead of signed_transaction --- libraries/chain/db_block.cpp | 4 +- .../chain/include/graphene/chain/database.hpp | 6 +- .../chain/include/graphene/chain/db_with.hpp | 14 +---- tests/app/main.cpp | 2 +- tests/common/database_fixture.cpp | 57 ++++++++++--------- tests/tests/authority_tests.cpp | 2 +- tests/tests/block_tests.cpp | 26 ++++----- tests/tests/confidential_tests.cpp | 8 +-- tests/tests/operation_tests.cpp | 6 +- tests/tests/operation_tests2.cpp | 36 ++++++------ 10 files changed, 78 insertions(+), 83 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 4873c65ed5..ada5167ba2 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -228,7 +228,7 @@ bool database::_push_block(const signed_block& new_block) * queues full as well, it will be kept in the queue to be propagated later when a new block flushes out the pending * queues. */ -processed_transaction database::push_transaction( const signed_transaction& trx, uint32_t skip ) +processed_transaction database::push_transaction( const precomputable_transaction& trx, uint32_t skip ) { try { processed_transaction result; detail::with_skip_flags( *this, skip, [&]() @@ -238,7 +238,7 @@ processed_transaction database::push_transaction( const signed_transaction& trx, return result; } FC_CAPTURE_AND_RETHROW( (trx) ) } -processed_transaction database::_push_transaction( const signed_transaction& trx ) +processed_transaction database::_push_transaction( const precomputable_transaction& trx ) { // If this is the first transaction pushed after applying a block, start a new undo session. // This allows us to quickly rewind to the clean state of the head block, in case a new block arrives. diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index db2f38e5de..bf2795ea1f 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -135,9 +135,9 @@ namespace graphene { namespace chain { bool before_last_checkpoint()const; bool push_block( const signed_block& b, uint32_t skip = skip_nothing ); - processed_transaction push_transaction( const signed_transaction& trx, uint32_t skip = skip_nothing ); + processed_transaction push_transaction( const precomputable_transaction& trx, uint32_t skip = skip_nothing ); bool _push_block( const signed_block& b ); - processed_transaction _push_transaction( const signed_transaction& trx ); + processed_transaction _push_transaction( const precomputable_transaction& trx ); ///@throws fc::exception if the proposed transaction fails to apply. processed_transaction push_proposal( const proposal_object& proposal ); @@ -406,7 +406,7 @@ namespace graphene { namespace chain { /** when popping a block, the transactions that were removed get cached here so they * can be reapplied at the proper time */ - std::deque< signed_transaction > _popped_tx; + std::deque< precomputable_transaction > _popped_tx; /** * @} diff --git a/libraries/chain/include/graphene/chain/db_with.hpp b/libraries/chain/include/graphene/chain/db_with.hpp index de93bb15f5..7ae189216f 100644 --- a/libraries/chain/include/graphene/chain/db_with.hpp +++ b/libraries/chain/include/graphene/chain/db_with.hpp @@ -80,11 +80,9 @@ struct pending_transactions_restorer { try { if( !_db.is_known_transaction( tx.id() ) ) { - // since push_transaction() takes a signed_transaction, - // the operation_results field will be ignored. _db._push_transaction( tx ); } - } catch ( const fc::exception& ) { + } catch ( const fc::exception& ) { // ignore invalid transactions } } _db._popped_tx.clear(); @@ -93,17 +91,11 @@ struct pending_transactions_restorer try { if( !_db.is_known_transaction( tx.id() ) ) { - // since push_transaction() takes a signed_transaction, - // the operation_results field will be ignored. _db._push_transaction( tx ); } } - catch( const fc::exception& e ) - { - /* - wlog( "Pending transaction became invalid after switching to block ${b} ${t}", ("b", _db.head_block_id())("t",_db.head_block_time()) ); - wlog( "The invalid pending transaction caused exception ${e}", ("e", e.to_detail_string() ) ); - */ + catch( const fc::exception& ) + { // ignore invalid transactions } } } diff --git a/tests/app/main.cpp b/tests/app/main.cpp index 848d60d664..b68cdf78a0 100644 --- a/tests/app/main.cpp +++ b/tests/app/main.cpp @@ -267,7 +267,7 @@ BOOST_AUTO_TEST_CASE( two_node_network ) BOOST_CHECK_EQUAL( db2->get_balance( GRAPHENE_NULL_ACCOUNT, asset_id_type() ).amount.value, 0 ); BOOST_TEST_MESSAGE( "Creating transfer tx" ); - graphene::chain::signed_transaction trx; + graphene::chain::precomputable_transaction trx; { account_id_type nathan_id = db2->get_index_type().indices().get().find( "nathan" )->id; fc::ecc::private_key nathan_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan"))); diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 2e05f71017..874e2f8241 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -234,7 +235,7 @@ void database_fixture::verify_asset_supplies( const database& db ) BOOST_CHECK(core_asset_data.fee_pool == 0); const auto& statistics_index = db.get_index_type().indices(); - const auto& balance_index = db.get_index_type().indices(); + const auto& acct_balance_index = db.get_index_type().indices(); const auto& settle_index = db.get_index_type().indices(); const auto& bids = db.get_index_type().indices(); map total_balances; @@ -242,7 +243,7 @@ void database_fixture::verify_asset_supplies( const database& db ) share_type core_in_orders; share_type reported_core_in_orders; - for( const account_balance_object& b : balance_index ) + for( const account_balance_object& b : acct_balance_index ) total_balances[b.asset_type] += b.balance; for( const force_settlement_object& s : settle_index ) total_balances[s.balance.asset_id] += s.balance.amount; @@ -284,6 +285,8 @@ void database_fixture::verify_asset_supplies( const database& db ) total_balances[ vbo.balance.asset_id ] += vbo.balance.amount; for( const fba_accumulator_object& fba : db.get_index_type< simple_index< fba_accumulator_object > >() ) total_balances[ asset_id_type() ] += fba.accumulated_fba_fees; + for( const balance_object& bo : db.get_index_type< balance_index >().indices() ) + total_balances[ bo.balance.asset_id ] += bo.balance.amount; total_balances[asset_id_type()] += db.get_dynamic_global_properties().witness_budget; @@ -460,7 +463,7 @@ const asset_object& database_fixture::create_bitasset( creator.bitasset_opts->short_backing_asset = backing_asset; trx.operations.push_back(std::move(creator)); trx.validate(); - processed_transaction ptx = db.push_transaction(trx, ~0); + processed_transaction ptx = PUSH_TX(db, trx, ~0); trx.operations.clear(); return db.get(ptx.operation_results[0].get()); } FC_CAPTURE_AND_RETHROW( (name)(flags) ) } @@ -491,7 +494,7 @@ const asset_object& database_fixture::create_prediction_market( creator.is_prediction_market = true; trx.operations.push_back(std::move(creator)); trx.validate(); - processed_transaction ptx = db.push_transaction(trx, ~0); + processed_transaction ptx = PUSH_TX(db, trx, ~0); trx.operations.clear(); return db.get(ptx.operation_results[0].get()); } FC_CAPTURE_AND_RETHROW( (name)(flags) ) } @@ -511,7 +514,7 @@ const asset_object& database_fixture::create_user_issued_asset( const string& na creator.common_options.issuer_permissions = charge_market_fee; trx.operations.push_back(std::move(creator)); trx.validate(); - processed_transaction ptx = db.push_transaction(trx, ~0); + processed_transaction ptx = PUSH_TX(db, trx, ~0); trx.operations.clear(); return db.get(ptx.operation_results[0].get()); } @@ -533,7 +536,7 @@ const asset_object& database_fixture::create_user_issued_asset( const string& na trx.operations.push_back(std::move(creator)); set_expiration( db, trx ); trx.validate(); - processed_transaction ptx = db.push_transaction(trx, ~0); + processed_transaction ptx = PUSH_TX(db, trx, ~0); trx.operations.clear(); return db.get(ptx.operation_results[0].get()); } @@ -546,7 +549,7 @@ void database_fixture::issue_uia( const account_object& recipient, asset amount op.asset_to_issue = amount; op.issue_to_account = recipient.id; trx.operations.push_back(op); - db.push_transaction( trx, ~0 ); + PUSH_TX( db, trx, ~0 ); trx.operations.clear(); } @@ -592,7 +595,7 @@ const account_object& database_fixture::create_account( { trx.operations.push_back(make_account(name, key)); trx.validate(); - processed_transaction ptx = db.push_transaction(trx, ~0); + processed_transaction ptx = PUSH_TX(db, trx, ~0); auto& result = db.get(ptx.operation_results[0].get()); trx.operations.clear(); return result; @@ -611,7 +614,7 @@ const account_object& database_fixture::create_account( trx.operations.resize(1); trx.operations.back() = (make_account(name, registrar, referrer, referrer_percent, key)); trx.validate(); - auto r = db.push_transaction(trx, ~0); + auto r = PUSH_TX(db, trx, ~0); const auto& result = db.get(r.operation_results[0].get()); trx.operations.clear(); return result; @@ -643,7 +646,7 @@ const account_object& database_fixture::create_account( trx.validate(); - processed_transaction ptx = db.push_transaction(trx, ~0); + processed_transaction ptx = PUSH_TX(db, trx, ~0); const account_object& result = db.get(ptx.operation_results[0].get()); trx.operations.clear(); return result; @@ -657,7 +660,7 @@ const committee_member_object& database_fixture::create_committee_member( const op.committee_member_account = owner.id; trx.operations.push_back(op); trx.validate(); - processed_transaction ptx = db.push_transaction(trx, ~0); + processed_transaction ptx = PUSH_TX(db, trx, ~0); trx.operations.clear(); return db.get(ptx.operation_results[0].get()); } @@ -678,7 +681,7 @@ const witness_object& database_fixture::create_witness( const account_object& ow op.block_signing_key = signing_private_key.get_public_key(); trx.operations.push_back(op); trx.validate(); - processed_transaction ptx = db.push_transaction(trx, skip_flags ); + processed_transaction ptx = PUSH_TX(db, trx, skip_flags ); trx.clear(); return db.get(ptx.operation_results[0].get()); } FC_CAPTURE_AND_RETHROW() } @@ -693,7 +696,7 @@ const worker_object& database_fixture::create_worker( const account_id_type owne op.work_end_date = op.work_begin_date + duration; trx.operations.push_back(op); trx.validate(); - processed_transaction ptx = db.push_transaction(trx, ~0); + processed_transaction ptx = PUSH_TX(db, trx, ~0); trx.clear(); return db.get(ptx.operation_results[0].get()); } FC_CAPTURE_AND_RETHROW() } @@ -738,7 +741,7 @@ const limit_order_object* database_fixture::create_sell_order( const account_obj trx.operations.push_back(buy_order); for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op, fee_core_exchange_rate); trx.validate(); - auto processed = db.push_transaction(trx, ~0); + auto processed = PUSH_TX(db, trx, ~0); trx.operations.clear(); verify_asset_supplies(db); return db.find( processed.operation_results[0].get() ); @@ -752,7 +755,7 @@ asset database_fixture::cancel_limit_order( const limit_order_object& order ) trx.operations.push_back(cancel_order); for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op); trx.validate(); - auto processed = db.push_transaction(trx, ~0); + auto processed = PUSH_TX(db, trx, ~0); trx.operations.clear(); verify_asset_supplies(db); return processed.operation_results[0].get(); @@ -788,7 +791,7 @@ void database_fixture::transfer( for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op); } trx.validate(); - db.push_transaction(trx, ~0); + PUSH_TX(db, trx, ~0); verify_asset_supplies(db); trx.operations.clear(); } FC_CAPTURE_AND_RETHROW( (from.id)(to.id)(amount)(fee) ) @@ -806,7 +809,7 @@ void database_fixture::update_feed_producers( const asset_object& mia, flat_set< for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op); trx.validate(); - db.push_transaction(trx, ~0); + PUSH_TX(db, trx, ~0); trx.operations.clear(); verify_asset_supplies(db); } FC_CAPTURE_AND_RETHROW( (mia)(producers) ) } @@ -826,7 +829,7 @@ void database_fixture::publish_feed( const asset_object& mia, const account_obje for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op); trx.validate(); - db.push_transaction(trx, ~0); + PUSH_TX(db, trx, ~0); trx.operations.clear(); verify_asset_supplies(db); } @@ -874,7 +877,7 @@ void database_fixture::force_global_settle( const asset_object& what, const pric trx.operations.push_back(sop); for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op); trx.validate(); - db.push_transaction(trx, ~0); + PUSH_TX(db, trx, ~0); trx.operations.clear(); verify_asset_supplies(db); } FC_CAPTURE_AND_RETHROW( (what)(p) ) } @@ -889,7 +892,7 @@ operation_result database_fixture::force_settle( const account_object& who, asse trx.operations.push_back(sop); for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op); trx.validate(); - processed_transaction ptx = db.push_transaction(trx, ~0); + processed_transaction ptx = PUSH_TX(db, trx, ~0); const operation_result& op_result = ptx.operation_results.front(); trx.operations.clear(); verify_asset_supplies(db); @@ -909,7 +912,7 @@ const call_order_object* database_fixture::borrow( const account_object& who, as trx.operations.push_back(update); for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op); trx.validate(); - db.push_transaction(trx, ~0); + PUSH_TX(db, trx, ~0); trx.operations.clear(); verify_asset_supplies(db); @@ -934,7 +937,7 @@ void database_fixture::cover(const account_object& who, asset what, asset collat trx.operations.push_back(update); for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op); trx.validate(); - db.push_transaction(trx, ~0); + PUSH_TX(db, trx, ~0); trx.operations.clear(); verify_asset_supplies(db); } FC_CAPTURE_AND_RETHROW( (who.name)(what)(collateral)(target_cr) ) } @@ -950,7 +953,7 @@ void database_fixture::bid_collateral(const account_object& who, const asset& to trx.operations.push_back(bid); for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op); trx.validate(); - db.push_transaction(trx, ~0); + PUSH_TX(db, trx, ~0); trx.operations.clear(); verify_asset_supplies(db); } FC_CAPTURE_AND_RETHROW( (who.name)(to_bid)(to_cover) ) } @@ -966,7 +969,7 @@ void database_fixture::fund_fee_pool( const account_object& from, const asset_ob for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op); trx.validate(); set_expiration( db, trx ); - db.push_transaction(trx, ~0); + PUSH_TX(db, trx, ~0); trx.operations.clear(); verify_asset_supplies(db); } @@ -993,7 +996,7 @@ void database_fixture::upgrade_to_lifetime_member( const account_object& account op.upgrade_to_lifetime_member = true; op.fee = db.get_global_properties().parameters.current_fees->calculate_fee(op); trx.operations = {op}; - db.push_transaction(trx, ~0); + PUSH_TX(db, trx, ~0); FC_ASSERT( op.account_to_upgrade(db).is_lifetime_member() ); trx.clear(); verify_asset_supplies(db); @@ -1013,7 +1016,7 @@ void database_fixture::upgrade_to_annual_member(const account_object& account) op.account_to_upgrade = account.get_id(); op.fee = db.get_global_properties().parameters.current_fees->calculate_fee(op); trx.operations = {op}; - db.push_transaction(trx, ~0); + PUSH_TX(db, trx, ~0); FC_ASSERT( op.account_to_upgrade(db).is_member(db.head_block_time()) ); trx.clear(); verify_asset_supplies(db); @@ -1180,7 +1183,7 @@ bool _push_block( database& db, const signed_block& b, uint32_t skip_flags /* = processed_transaction _push_transaction( database& db, const signed_transaction& tx, uint32_t skip_flags /* = 0 */ ) { try { - auto pt = db.push_transaction( tx, skip_flags ); + auto pt = db.push_transaction( precomputable_transaction(tx), skip_flags ); database_fixture::verify_asset_supplies(db); return pt; } FC_CAPTURE_AND_RETHROW((tx)) } diff --git a/tests/tests/authority_tests.cpp b/tests/tests/authority_tests.cpp index 573d609edf..37bfb8f7cf 100644 --- a/tests/tests/authority_tests.cpp +++ b/tests/tests/authority_tests.cpp @@ -498,7 +498,7 @@ BOOST_AUTO_TEST_CASE( committee_authority ) */ trx.operations.push_back(uop); sign( trx, committee_key ); - db.push_transaction(trx); + PUSH_TX(db, trx); BOOST_CHECK_EQUAL(get_balance(nathan, asset_id_type()(db)), 0); BOOST_CHECK(db.get(prop.id).is_authorized_to_execute(db)); diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index 1890dc38b8..837a1d9bb2 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -602,11 +602,11 @@ BOOST_AUTO_TEST_CASE( undo_pending ) t.to = nathan_id; t.amount = asset(5000); trx.operations.push_back(t); - db.push_transaction(trx, ~0); + PUSH_TX(db, trx, ~0); trx.clear(); set_expiration( db, trx ); trx.operations.push_back(t); - db.push_transaction(trx, ~0); + PUSH_TX(db, trx, ~0); BOOST_CHECK(db.get_balance(nathan_id, asset_id_type()).amount == 10000); db.clear_pending(); @@ -757,7 +757,7 @@ BOOST_AUTO_TEST_CASE( tapos ) cop.active = cop.owner; trx.operations.push_back(cop); trx.sign( init_account_priv_key, db1.get_chain_id() ); - db1.push_transaction(trx); + PUSH_TX(db1, trx); b = db1.generate_block(db1.get_slot_time(1), db1.get_scheduled_witness(1), init_account_priv_key, database::skip_nothing); trx.clear(); @@ -952,7 +952,7 @@ BOOST_FIXTURE_TEST_CASE( double_sign_check, database_fixture ) for( auto& op : trx.operations ) db.current_fee_schedule().set_fee(op); trx.validate(); - db.push_transaction(trx, ~0); + PUSH_TX(db, trx, ~0); trx.operations.clear(); t.from = bob.id; @@ -963,21 +963,21 @@ BOOST_FIXTURE_TEST_CASE( double_sign_check, database_fixture ) trx.validate(); BOOST_TEST_MESSAGE( "Verify that not-signing causes an exception" ); - GRAPHENE_REQUIRE_THROW( db.push_transaction(trx, 0), fc::exception ); + GRAPHENE_REQUIRE_THROW( PUSH_TX(db, trx, 0), fc::exception ); BOOST_TEST_MESSAGE( "Verify that double-signing causes an exception" ); sign( trx, bob_private_key ); sign( trx, bob_private_key ); - GRAPHENE_REQUIRE_THROW( db.push_transaction(trx, 0), tx_duplicate_sig ); + GRAPHENE_REQUIRE_THROW( PUSH_TX(db, trx, 0), tx_duplicate_sig ); BOOST_TEST_MESSAGE( "Verify that signing with an extra, unused key fails" ); trx.signatures.pop_back(); sign( trx, generate_private_key("bogus" )); - GRAPHENE_REQUIRE_THROW( db.push_transaction(trx, 0), tx_irrelevant_sig ); + GRAPHENE_REQUIRE_THROW( PUSH_TX(db, trx, 0), tx_irrelevant_sig ); BOOST_TEST_MESSAGE( "Verify that signing once with the proper key passes" ); trx.signatures.pop_back(); - db.push_transaction(trx, 0); + PUSH_TX(db, trx, 0); } FC_LOG_AND_RETHROW() } @@ -998,7 +998,7 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture ) uop.new_parameters.block_interval = 1; cop.proposed_ops.emplace_back(uop); trx.operations.push_back(cop); - db.push_transaction(trx); + PUSH_TX(db, trx); } BOOST_TEST_MESSAGE( "Updating proposal by signing with the committee_member private key" ); { @@ -1019,7 +1019,7 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture ) sign( trx, get_account("init6" ).active.get_keys().front(),init_account_priv_key); sign( trx, get_account("init7" ).active.get_keys().front(),init_account_priv_key); */ - db.push_transaction(trx); + PUSH_TX(db, trx); BOOST_CHECK(proposal_id_type()(db).is_authorized_to_execute(db)); } BOOST_TEST_MESSAGE( "Verifying that the interval didn't change immediately" ); @@ -1602,7 +1602,7 @@ BOOST_FIXTURE_TEST_CASE( update_account_keys, database_fixture ) trx.operations.push_back( create_op ); // trx.sign( sam_key ); - processed_transaction ptx_create = db.push_transaction( trx, + processed_transaction ptx_create = PUSH_TX( db, trx, database::skip_transaction_dupe_check | database::skip_transaction_signatures ); @@ -1639,11 +1639,11 @@ BOOST_FIXTURE_TEST_CASE( update_account_keys, database_fixture ) sign( trx, *owner_privkey[i] ); if( i < int(create_op.owner.weight_threshold-1) ) { - GRAPHENE_REQUIRE_THROW(db.push_transaction(trx), fc::exception); + GRAPHENE_REQUIRE_THROW(PUSH_TX(db, trx), fc::exception); } else { - db.push_transaction( trx, + PUSH_TX( db, trx, database::skip_transaction_dupe_check | database::skip_transaction_signatures ); } diff --git a/tests/tests/confidential_tests.cpp b/tests/tests/confidential_tests.cpp index bef651db5c..b5046dcdfe 100644 --- a/tests/tests/confidential_tests.cpp +++ b/tests/tests/confidential_tests.cpp @@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE( confidential_test ) trx.operations = {to_blind}; sign( trx, dan_private_key ); - db.push_transaction(trx); + PUSH_TX(db, trx); trx.clear_signatures(); BOOST_TEST_MESSAGE( "Transfering from blind to blind with change address" ); @@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE( confidential_test ) blind_tr.validate(); trx.operations = {blind_tr}; sign( trx, owner2_key ); - db.push_transaction(trx); + PUSH_TX(db, trx); BOOST_TEST_MESSAGE( "Attempting to double spend the same commitments" ); blind_tr.fee = core.amount(11); @@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE( confidential_test ) out4.range_proof = fc::ecc::range_proof_sign( 0, out3.commitment, InB1, nonce1, 0, 0, 750-300-11 ); blind_tr.outputs = {out4,out3}; trx.operations = {blind_tr}; - BOOST_REQUIRE_THROW( db.push_transaction(trx, ~0), graphene::chain::blind_transfer_unknown_commitment ); + BOOST_REQUIRE_THROW( PUSH_TX(db, trx, ~0), graphene::chain::blind_transfer_unknown_commitment ); BOOST_TEST_MESSAGE( "Transfering from blind to nathan public" ); @@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE( confidential_test ) from_blind.inputs.push_back( {out4.commitment, out4.owner} ); trx.operations = {from_blind}; trx.clear_signatures(); - db.push_transaction(trx); + PUSH_TX(db, trx); BOOST_REQUIRE_EQUAL( get_balance( nathan, core ), 750-300-10-10 ); diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index b00745ff06..398eb42b11 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -303,7 +303,7 @@ BOOST_AUTO_TEST_CASE( asset_settle_cancel_operation_test_after_hf588 ) pcop.proposed_ops.emplace_back(ascop); trx.operations.push_back(pcop); - BOOST_CHECK_EXCEPTION(db.push_transaction(trx), fc::assert_exception, + BOOST_CHECK_EXCEPTION(PUSH_TX(db, trx), fc::assert_exception, [](fc::assert_exception const &e) -> bool { std::cout << e.to_string() << std::endl; if (e.to_string().find("Virtual operation") != std::string::npos) @@ -333,7 +333,7 @@ BOOST_AUTO_TEST_CASE( asset_settle_cancel_operation_test_after_hf588 ) trx.operations.push_back(pcop); - BOOST_CHECK_EXCEPTION(db.push_transaction(trx), fc::assert_exception, + BOOST_CHECK_EXCEPTION(PUSH_TX(db, trx), fc::assert_exception, [](fc::assert_exception const &e) -> bool { std::cout << e.to_string() << std::endl; if (e.to_string().find("Virtual operation") != std::string::npos) @@ -656,7 +656,7 @@ BOOST_AUTO_TEST_CASE( call_order_update_target_cr_hardfork_time_test ) tx.operations.push_back( prop ); db.current_fee_schedule().set_fee( tx.operations.back() ); set_expiration( db, tx ); - db.push_transaction( tx, ~0 ); + PUSH_TX( db, tx, ~0 ); }; BOOST_TEST_MESSAGE( "bob tries to propose a proposal with target_cr set, " diff --git a/tests/tests/operation_tests2.cpp b/tests/tests/operation_tests2.cpp index e0d027da1c..15df1b2ece 100644 --- a/tests/tests/operation_tests2.cpp +++ b/tests/tests/operation_tests2.cpp @@ -139,7 +139,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_create_before_hardfork_23 ) trx.operations.back() = op; } sign( trx, nathan_private_key ); - db.push_transaction( trx ); + PUSH_TX( db, trx ); trx.clear(); } FC_LOG_AND_RETHROW() } @@ -184,7 +184,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_create_after_hardfork_23 ) trx.operations.back() = op; } sign( trx, nathan_private_key ); - db.push_transaction( trx ); + PUSH_TX( db, trx ); trx.clear(); } FC_LOG_AND_RETHROW() } @@ -1027,7 +1027,7 @@ BOOST_AUTO_TEST_CASE( feed_limit_test ) op.issuer = bit_usd.issuer; trx.operations = {op}; sign( trx, nathan_private_key ); - db.push_transaction(trx); + PUSH_TX(db, trx); BOOST_TEST_MESSAGE("Checking current_feed is null"); BOOST_CHECK(bitasset.current_feed.settlement_price.is_null()); @@ -1037,7 +1037,7 @@ BOOST_AUTO_TEST_CASE( feed_limit_test ) trx.clear(); trx.operations = {op}; sign( trx, nathan_private_key ); - db.push_transaction(trx); + PUSH_TX(db, trx); BOOST_TEST_MESSAGE("Checking current_feed is not null"); BOOST_CHECK(!bitasset.current_feed.settlement_price.is_null()); @@ -1907,13 +1907,13 @@ BOOST_AUTO_TEST_CASE( balance_object_test ) trx.operations = {op}; _sign( trx, n_key ); // Fail because I'm claiming from an address which hasn't signed - GRAPHENE_CHECK_THROW(db.push_transaction(trx), tx_missing_other_auth); + GRAPHENE_CHECK_THROW(PUSH_TX(db, trx), tx_missing_other_auth); trx.clear(); op.balance_to_claim = balance_id_type(); op.balance_owner_key = n_key.get_public_key(); trx.operations = {op}; _sign( trx, n_key ); - db.push_transaction(trx); + PUSH_TX(db, trx); // Not using fixture's get_balance() here because it uses fixture's db, not my override BOOST_CHECK_EQUAL(db.get_balance(op.deposit_to_account, asset_id_type()).amount.value, 1); @@ -1941,7 +1941,7 @@ BOOST_AUTO_TEST_CASE( balance_object_test ) _sign( trx, n_key ); _sign( trx, v1_key ); // Attempting to claim 1 from a balance with 0 available - GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_invalid_claim_amount); + GRAPHENE_CHECK_THROW(PUSH_TX(db, trx), balance_claim_invalid_claim_amount); op.balance_to_claim = vesting_balance_2.id; op.total_claimed.amount = 151; @@ -1951,7 +1951,7 @@ BOOST_AUTO_TEST_CASE( balance_object_test ) _sign( trx, n_key ); _sign( trx, v2_key ); // Attempting to claim 151 from a balance with 150 available - GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_invalid_claim_amount); + GRAPHENE_CHECK_THROW(PUSH_TX(db, trx), balance_claim_invalid_claim_amount); op.balance_to_claim = vesting_balance_2.id; op.total_claimed.amount = 100; @@ -1960,7 +1960,7 @@ BOOST_AUTO_TEST_CASE( balance_object_test ) trx.clear_signatures(); _sign( trx, n_key ); _sign( trx, v2_key ); - db.push_transaction(trx); + PUSH_TX(db, trx); BOOST_CHECK_EQUAL(db.get_balance(op.deposit_to_account, asset_id_type()).amount.value, 101); BOOST_CHECK_EQUAL(vesting_balance_2.balance.amount.value, 300); @@ -1970,7 +1970,7 @@ BOOST_AUTO_TEST_CASE( balance_object_test ) _sign( trx, n_key ); _sign( trx, v2_key ); // Attempting to claim twice within a day - GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_claimed_too_often); + GRAPHENE_CHECK_THROW(PUSH_TX(db, trx), balance_claim_claimed_too_often); db.generate_block(db.get_slot_time(1), db.get_scheduled_witness(1), init_account_priv_key, skip_flags); slot = db.get_slot_at_time(vesting_balance_1.vesting_policy->begin_timestamp + 60); @@ -1984,7 +1984,7 @@ BOOST_AUTO_TEST_CASE( balance_object_test ) trx.clear_signatures(); _sign( trx, n_key ); _sign( trx, v1_key ); - db.push_transaction(trx); + PUSH_TX(db, trx); BOOST_CHECK(db.find_object(op.balance_to_claim) == nullptr); BOOST_CHECK_EQUAL(db.get_balance(op.deposit_to_account, asset_id_type()).amount.value, 601); @@ -1996,7 +1996,7 @@ BOOST_AUTO_TEST_CASE( balance_object_test ) _sign( trx, n_key ); _sign( trx, v2_key ); // Attempting to claim twice within a day - GRAPHENE_CHECK_THROW(db.push_transaction(trx), balance_claim_claimed_too_often); + GRAPHENE_CHECK_THROW(PUSH_TX(db, trx), balance_claim_claimed_too_often); db.generate_block(db.get_slot_time(1), db.get_scheduled_witness(1), init_account_priv_key, skip_flags); slot = db.get_slot_at_time(db.head_block_time() + fc::days(1)); @@ -2008,7 +2008,7 @@ BOOST_AUTO_TEST_CASE( balance_object_test ) trx.clear_signatures(); _sign( trx, n_key ); _sign( trx, v2_key ); - db.push_transaction(trx); + PUSH_TX(db, trx); BOOST_CHECK(db.find_object(op.balance_to_claim) == nullptr); BOOST_CHECK_EQUAL(db.get_balance(op.deposit_to_account, asset_id_type()).amount.value, 901); } FC_LOG_AND_RETHROW() } @@ -2028,7 +2028,7 @@ BOOST_AUTO_TEST_CASE(transfer_with_memo) { op.memo->set_message(alice_private_key, bob_public_key, "Dear Bob,\n\nMoney!\n\nLove, Alice"); trx.operations = {op}; trx.sign(alice_private_key, db.get_chain_id()); - db.push_transaction(trx); + PUSH_TX(db, trx); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 500); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 500); @@ -2429,18 +2429,18 @@ BOOST_AUTO_TEST_CASE( buyback ) sign( tx, philbin_private_key ); // Alice and Philbin signed, but asset issuer is invalid - GRAPHENE_CHECK_THROW( db.push_transaction(tx), account_create_buyback_incorrect_issuer ); + GRAPHENE_CHECK_THROW( PUSH_TX(db, tx), account_create_buyback_incorrect_issuer ); tx.clear_signatures(); tx.operations.back().get< account_create_operation >().extensions.value.buyback_options->asset_to_buy_issuer = izzy_id; sign( tx, philbin_private_key ); // Izzy didn't sign - GRAPHENE_CHECK_THROW( db.push_transaction(tx), tx_missing_active_auth ); + GRAPHENE_CHECK_THROW( PUSH_TX(db, tx), tx_missing_active_auth ); sign( tx, izzy_private_key ); // OK - processed_transaction ptx = db.push_transaction( tx ); + processed_transaction ptx = PUSH_TX( db, tx ); rex_id = ptx.operation_results.back().get< object_id_type >(); // Try to create another account rex2 which is bbo on same asset @@ -2448,7 +2448,7 @@ BOOST_AUTO_TEST_CASE( buyback ) tx.operations.back().get< account_create_operation >().name = "rex2"; sign( tx, izzy_private_key ); sign( tx, philbin_private_key ); - GRAPHENE_CHECK_THROW( db.push_transaction(tx), account_create_buyback_already_exists ); + GRAPHENE_CHECK_THROW( PUSH_TX(db, tx), account_create_buyback_already_exists ); } // issue some BUYME to Alice From 883ec6a7f3ffb01fcba3130ec0f21a1d39977749 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 11 Oct 2018 17:57:22 +0200 Subject: [PATCH 074/172] Avoid one level of indirection on precompute block --- libraries/chain/db_block.cpp | 27 +++++++------------ .../chain/include/graphene/chain/database.hpp | 1 - 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index ada5167ba2..b26f2380cf 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -765,18 +765,16 @@ void database::_precompute_parallel( const Trx* trx, const size_t count, const u } } -void database::_precompute_parallel( const signed_block& block, const uint32_t skip )const +fc::future database::precompute_parallel( const signed_block& block, const uint32_t skip )const { try { - const bool cheap = (skip & skip_expensive) == skip_expensive; std::vector> workers; if( !block.transactions.empty() ) { - if( cheap ) + if( (skip & skip_expensive) == skip_expensive ) _precompute_parallel( &block.transactions[0], block.transactions.size(), skip ); else { uint32_t chunks = fc::asio::default_io_service_scope::get_num_threads(); - if( !chunks ) return; uint32_t chunk_size = block.transactions.size() / chunks; if( chunks * chunk_size < block.transactions.size() ) chunk_size++; @@ -795,21 +793,16 @@ void database::_precompute_parallel( const signed_block& block, const uint32_t s if( !(skip&skip_merkle_check) ) block.calculate_merkle_root(); block.id(); - for( auto& worker : workers ) - worker.wait(); -} FC_LOG_AND_RETHROW() } -fc::future database::precompute_parallel( const signed_block& block, const uint32_t skip )const -{ - if( block.transactions.empty() || (skip & skip_expensive) == skip_expensive ) - { - _precompute_parallel( block, skip ); + if( workers.empty() ) return fc::future< void >( fc::promise< void >::ptr( new fc::promise< void >( true ) ) ); - } - return fc::do_parallel([this,&block,skip] () { - _precompute_parallel( block, skip ); - }); -} + + auto first = workers.begin(); + auto worker = first; + while( ++worker != workers.end() ) + worker->wait(); + return *first; +} FC_LOG_AND_RETHROW() } fc::future database::precompute_parallel( const precomputable_transaction& trx )const { diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index bf2795ea1f..84e4ad4190 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -437,7 +437,6 @@ namespace graphene { namespace chain { private: template void _precompute_parallel( const Trx* trx, const size_t count, const uint32_t skip )const; - void _precompute_parallel( const signed_block& block, const uint32_t skip )const; protected: //Mark pop_undo() as protected -- we do not want outside calling pop_undo(); it should call pop_block() instead From d032890de9044fc5e2165e6185e721db5be07f68 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Thu, 11 Oct 2018 23:04:39 +0200 Subject: [PATCH 075/172] Make pubkey comparator generally available --- libraries/chain/account_object.cpp | 6 ++--- .../include/graphene/chain/account_object.hpp | 26 +++++++------------ .../include/graphene/chain/protocol/types.hpp | 8 ++++++ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libraries/chain/account_object.cpp b/libraries/chain/account_object.cpp index 952a4c7c2c..7bdf51a2de 100644 --- a/libraries/chain/account_object.cpp +++ b/libraries/chain/account_object.cpp @@ -121,9 +121,9 @@ set account_member_index::get_account_members(const account_obj result.insert(auth.first); return result; } -set account_member_index::get_key_members(const account_object& a)const +set account_member_index::get_key_members(const account_object& a)const { - set result; + set result; for( auto auth : a.owner.key_auths ) result.insert(auth.first); for( auto auth : a.active.key_auths ) @@ -215,7 +215,7 @@ void account_member_index::object_modified(const object& after) { - set after_key_members = get_key_members(a); + set after_key_members = get_key_members(a); vector removed; removed.reserve(before_key_members.size()); std::set_difference(before_key_members.begin(), before_key_members.end(), diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index cae9d35984..c3fdcee01f 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -292,14 +292,6 @@ namespace graphene { namespace chain { */ class account_member_index : public secondary_index { - class key_compare { - public: - inline bool operator()( const public_key_type& a, const public_key_type& b )const - { - return a.key_data < b.key_data; - } - }; - public: virtual void object_inserted( const object& obj ) override; virtual void object_removed( const object& obj ) override; @@ -308,20 +300,20 @@ namespace graphene { namespace chain { /** given an account or key, map it to the set of accounts that reference it in an active or owner authority */ - map< account_id_type, set > account_to_account_memberships; - map< public_key_type, set, key_compare > account_to_key_memberships; + map< account_id_type, set > account_to_account_memberships; + map< public_key_type, set, pubkey_comparator > account_to_key_memberships; /** some accounts use address authorities in the genesis block */ - map< address, set > account_to_address_memberships; + map< address, set > account_to_address_memberships; protected: - set get_account_members( const account_object& a )const; - set get_key_members( const account_object& a )const; - set
get_address_members( const account_object& a )const; + set get_account_members( const account_object& a )const; + set get_key_members( const account_object& a )const; + set
get_address_members( const account_object& a )const; - set before_account_members; - set before_key_members; - set
before_address_members; + set before_account_members; + set before_key_members; + set
before_address_members; }; diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp index bd04c071d3..4456d6d3a5 100644 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ b/libraries/chain/include/graphene/chain/protocol/types.hpp @@ -266,6 +266,14 @@ namespace graphene { namespace chain { friend bool operator != ( const public_key_type& p1, const public_key_type& p2); }; + class pubkey_comparator { + public: + inline bool operator()( const public_key_type& a, const public_key_type& b )const + { + return a.key_data < b.key_data; + } + }; + struct extended_public_key_type { struct binary_key From 2c01109c6479713cd8b0f0b01346c4ce2bb91e9a Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 7 Nov 2018 17:27:47 +0100 Subject: [PATCH 076/172] Address some review comments --- libraries/chain/db_block.cpp | 4 +--- .../chain/include/graphene/chain/protocol/transaction.hpp | 8 ++++---- libraries/chain/protocol/transaction.cpp | 4 ++-- libraries/plugins/delayed_node/delayed_node_plugin.cpp | 1 + tests/common/database_fixture.hpp | 1 + 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index b26f2380cf..9e0ff2c95b 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -775,9 +775,7 @@ fc::future database::precompute_parallel( const signed_block& block, const else { uint32_t chunks = fc::asio::default_io_service_scope::get_num_threads(); - uint32_t chunk_size = block.transactions.size() / chunks; - if( chunks * chunk_size < block.transactions.size() ) - chunk_size++; + uint32_t chunk_size = ( block.transactions.size() + chunks - 1 ) / chunks; workers.reserve( chunks + 1 ); for( size_t base = 0; base < block.transactions.size(); base += chunk_size ) workers.push_back( fc::do_parallel( [this,&block,base,chunk_size,skip] () { diff --git a/libraries/chain/include/graphene/chain/protocol/transaction.hpp b/libraries/chain/include/graphene/chain/protocol/transaction.hpp index 02f00799c6..84234afb9e 100644 --- a/libraries/chain/include/graphene/chain/protocol/transaction.hpp +++ b/libraries/chain/include/graphene/chain/protocol/transaction.hpp @@ -89,7 +89,6 @@ namespace graphene { namespace chain { digest_type digest()const; virtual const transaction_id_type& id()const; virtual void validate() const; - /// Calculate the digest used for signature validation void set_expiration( fc::time_point_sec expiration_time ); void set_reference_block( const block_id_type& reference_block ); @@ -115,6 +114,7 @@ namespace graphene { namespace chain { void get_required_authorities( flat_set& active, flat_set& owner, vector& other )const; protected: + // Calculate the digest used for signature validation digest_type sig_digest( const chain_id_type& chain_id )const; mutable transaction_id_type _tx_id_buffer; }; @@ -206,9 +206,9 @@ namespace graphene { namespace chain { precomputable_transaction( const signed_transaction& tx ) : signed_transaction(tx) {}; precomputable_transaction( signed_transaction&& tx ) : signed_transaction( std::move(tx) ) {}; - virtual const transaction_id_type& id()const; - virtual void validate() const; - virtual const flat_set& get_signature_keys( const chain_id_type& chain_id )const; + virtual const transaction_id_type& id()const override; + virtual void validate()const override; + virtual const flat_set& get_signature_keys( const chain_id_type& chain_id )const override; protected: mutable bool _validated = false; }; diff --git a/libraries/chain/protocol/transaction.cpp b/libraries/chain/protocol/transaction.cpp index c1dd817693..1a1293ca76 100644 --- a/libraries/chain/protocol/transaction.cpp +++ b/libraries/chain/protocol/transaction.cpp @@ -303,8 +303,6 @@ void verify_authority( const vector& ops, const flat_set& signed_transaction::get_signature_keys( const chain_id_type& chain_id )const { try { - // Strictly we should check whether the given chain ID is same as the one used to initialize the `signees` field. - // However, we don't pass in another chain ID so far, for better performance, we skip the check. auto d = sig_digest( chain_id ); flat_set result; for( const auto& sig : signatures ) @@ -397,6 +395,8 @@ void precomputable_transaction::validate() const const flat_set& precomputable_transaction::get_signature_keys( const chain_id_type& chain_id )const { + // Strictly we should check whether the given chain ID is same as the one used to initialize the `signees` field. + // However, we don't pass in another chain ID so far, for better performance, we skip the check. if( _signees.empty() ) signed_transaction::get_signature_keys( chain_id ); return _signees; diff --git a/libraries/plugins/delayed_node/delayed_node_plugin.cpp b/libraries/plugins/delayed_node/delayed_node_plugin.cpp index dd1d4705e6..f5e3f88cd9 100644 --- a/libraries/plugins/delayed_node/delayed_node_plugin.cpp +++ b/libraries/plugins/delayed_node/delayed_node_plugin.cpp @@ -103,6 +103,7 @@ void delayed_node_plugin::sync_with_trusted_node() while( remote_dpo.last_irreversible_block_num > db.head_block_num() ) { fc::optional block = my->database_api->get_block( db.head_block_num()+1 ); + // TODO: during sync, decouple requesting blocks from preprocessing + applying them FC_ASSERT(block, "Trusted node claims it has blocks it doesn't actually have."); ilog("Pushing block #${n}", ("n", block->block_num())); db.precompute_parallel( *block, graphene::chain::database::skip_nothing ).wait(); diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index 72744ff7e5..eceba6876b 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -172,6 +172,7 @@ namespace graphene { namespace chain { class clearable_block : public signed_block { public: + /** @brief Clears internal cached values like ID, signing key, Merkle root etc. */ void clear(); }; From c4b584c089d515ae81d00d3fed050c5daab24520 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 9 Dec 2018 13:43:17 +0100 Subject: [PATCH 077/172] direct_index: Added clarifying comment, ensure that object ID is not modified --- libraries/db/include/graphene/db/index.hpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index fd2923f599..ddee3833ed 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -194,6 +194,10 @@ namespace graphene { namespace db { * @brief A secondary index that tracks objects in vectors indexed by object * id. It is meant for fully (or almost fully) populated indexes only (will * fail when loading an object_database with large gaps). + * + * WARNING! If any of the methods called on insertion, removal or + * modification throws, subsequent behaviour is undefined! Such exceptions + * indicate that this index type is not appropriate for the use-case. */ template class direct_index : public secondary_index @@ -205,6 +209,7 @@ namespace graphene { namespace db { static const size_t _mask = ((1 << chunkbits) - 1); size_t next = 0; vector< vector< const Object* > > content; + object_id_type id_being_modified; public: direct_index() { @@ -254,13 +259,23 @@ namespace graphene { namespace db { content[instance >> chunkbits][instance & _mask] = nullptr; } + virtual void about_to_modify( const object& before ) + { + id_being_modified = before.id; + } + + virtual void object_modified( const object& after ) + { + FC_ASSERT( id_being_modified == after.id, "Modification of ID is not supported!"); + } + template< typename object_id > const Object* find( const object_id& id )const { static_assert( object_id::space_id == Object::space_id, "Space ID mismatch!" ); static_assert( object_id::type_id == Object::type_id, "Type_ID mismatch!" ); if( id.instance >= next ) return nullptr; - return content[id.instance >> chunkbits][id.instance & _mask]; + return content[id.instance.value >> chunkbits][id.instance.value & _mask]; }; template< typename object_id > From 9117c85dba00b6a507b9fad91cf16594423db2d5 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 9 Dec 2018 13:43:30 +0100 Subject: [PATCH 078/172] Added unit test for direct_index --- tests/tests/database_tests.cpp | 75 ++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/tests/tests/database_tests.cpp b/tests/tests/database_tests.cpp index 6b5ea8b96b..e8c1d24fe2 100644 --- a/tests/tests/database_tests.cpp +++ b/tests/tests/database_tests.cpp @@ -137,4 +137,79 @@ BOOST_AUTO_TEST_CASE( merge_test ) } } +BOOST_AUTO_TEST_CASE( direct_index_test ) +{ try { + try { + const graphene::db::primary_index< account_index, 6 > small_chunkbits( db ); + BOOST_FAIL( "Expected assertion failure!" ); + } catch( const fc::assert_exception& expected ) {} + + graphene::db::primary_index< account_index, 8 > my_accounts( db ); + const auto& direct = my_accounts.get_secondary_index>(); + BOOST_CHECK_EQUAL( 0, my_accounts.indices().size() ); + BOOST_CHECK( nullptr == direct.find( account_id_type( 1 ) ) ); + // BOOST_CHECK_THROW( direct.find( asset_id_type( 1 ) ), fc::assert_exception ); // compile-time error + BOOST_CHECK_THROW( direct.find( object_id_type( asset_id_type( 1 ) ) ), fc::assert_exception ); + BOOST_CHECK_THROW( direct.get( account_id_type( 1 ) ), fc::assert_exception ); + + account_object test_account; + test_account.id = account_id_type(1); + test_account.name = "account1"; + + my_accounts.load( fc::raw::pack( test_account ) ); + + BOOST_CHECK_EQUAL( 1, my_accounts.indices().size() ); + BOOST_CHECK( nullptr == direct.find( account_id_type( 0 ) ) ); + BOOST_CHECK( nullptr == direct.find( account_id_type( 2 ) ) ); + BOOST_CHECK( nullptr != direct.find( account_id_type( 1 ) ) ); + BOOST_CHECK_EQUAL( test_account.name, direct.get( test_account.id ).name ); + + // The following assumes that MAX_HOLE = 100 + test_account.id = account_id_type(102); + test_account.name = "account102"; + // highest insert was 1, direct.next is 2 => 102 is highest allowed instance + my_accounts.load( fc::raw::pack( test_account ) ); + BOOST_CHECK_EQUAL( test_account.name, direct.get( test_account.id ).name ); + + // direct.next is now 103, but index sequence counter is 0 + my_accounts.create( [] ( object& o ) { + account_object& acct = dynamic_cast< account_object& >( o ); + BOOST_CHECK_EQUAL( 0, acct.id.instance() ); + acct.name = "account0"; + } ); + + test_account.id = account_id_type(50); + test_account.name = "account50"; + my_accounts.load( fc::raw::pack( test_account ) ); + + // direct.next is still 103, so 204 is not allowed + test_account.id = account_id_type(204); + test_account.name = "account204"; + GRAPHENE_REQUIRE_THROW( my_accounts.load( fc::raw::pack( test_account ) ), fc::assert_exception ); + // This is actually undefined behaviour. The object has been inserted into + // the primary index, but the secondary has refused to insert it! + BOOST_CHECK_EQUAL( 5, my_accounts.indices().size() ); + + uint32_t count = 0; + for( uint32_t i = 0; i < 250; i++ ) + { + const account_object* aptr = dynamic_cast< const account_object* >( my_accounts.find( account_id_type( i ) ) ); + if( aptr ) + { + count++; + BOOST_CHECK( aptr->id.instance() == 0 || aptr->id.instance() == 1 + || aptr->id.instance() == 50 || aptr->id.instance() == 102 ); + BOOST_CHECK_EQUAL( i, aptr->id.instance() ); + BOOST_CHECK_EQUAL( "account" + std::to_string( i ), aptr->name ); + } + } + BOOST_CHECK_EQUAL( count, my_accounts.indices().size() - 1 ); + + GRAPHENE_REQUIRE_THROW( my_accounts.modify( direct.get( account_id_type( 1 ) ), [] ( object& acct ) { + acct.id = account_id_type(2); + }), fc::assert_exception ); + // This is actually undefined behaviour. The object has been modified, but + // but the secondary has not updated its representation +} FC_LOG_AND_RETHROW() } + BOOST_AUTO_TEST_SUITE_END() From 956f1c9c42869ec67ed3a1d98ad84689e4acc0d5 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 14 Dec 2018 10:24:57 -0300 Subject: [PATCH 079/172] bump database --- libraries/chain/include/graphene/chain/config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index 1ef28a0c67..3ab5f47f19 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -121,7 +121,7 @@ #define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4 #define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3 -#define GRAPHENE_CURRENT_DB_VERSION "BTS2.18" +#define GRAPHENE_CURRENT_DB_VERSION "BTS2.19" #define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT) From 115ed51b787ce96c2743c988897cfd2f1a6d75df Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 14 Dec 2018 11:49:10 -0300 Subject: [PATCH 080/172] clarify proxy vote test times --- tests/tests/voting_tests.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/tests/voting_tests.cpp b/tests/tests/voting_tests.cpp index b4af210637..141c19e0f3 100644 --- a/tests/tests/voting_tests.cpp +++ b/tests/tests/voting_tests.cpp @@ -460,7 +460,7 @@ BOOST_AUTO_TEST_CASE(last_voting_date_proxy) // witness to vote for auto witness1 = witness_id_type(1)(db); - // alice changes proxy, this is voting activity + // round1: alice changes proxy, this is voting activity { graphene::chain::account_update_operation op; op.account = alice_id; @@ -472,12 +472,12 @@ BOOST_AUTO_TEST_CASE(last_voting_date_proxy) } // alice last_vote_time is updated auto alice_stats_obj = db.get_account_stats_by_owner(alice_id); - auto now = db.head_block_time().sec_since_epoch(); - BOOST_CHECK_EQUAL(alice_stats_obj.last_vote_time.sec_since_epoch(), now); + auto round1 = db.head_block_time().sec_since_epoch(); + BOOST_CHECK_EQUAL(alice_stats_obj.last_vote_time.sec_since_epoch(), round1); generate_block(); - // alice update account but no proxy or voting changes are done + // round 2: alice update account but no proxy or voting changes are done { graphene::chain::account_update_operation op; op.account = alice_id; @@ -488,13 +488,13 @@ BOOST_AUTO_TEST_CASE(last_voting_date_proxy) PUSH_TX( db, trx, ~0 ); } // last_vote_time is not updated - now = db.head_block_time().sec_since_epoch(); + auto round2 = db.head_block_time().sec_since_epoch(); alice_stats_obj = db.get_account_stats_by_owner(alice_id); - BOOST_CHECK(alice_stats_obj.last_vote_time.sec_since_epoch() != now); + BOOST_CHECK_EQUAL(alice_stats_obj.last_vote_time.sec_since_epoch(), round1); generate_block(); - // bob votes + // round 3: bob votes { graphene::chain::account_update_operation op; op.account = bob_id; @@ -507,13 +507,13 @@ BOOST_AUTO_TEST_CASE(last_voting_date_proxy) } // last_vote_time for bob is updated as he voted - now = db.head_block_time().sec_since_epoch(); + auto round3 = db.head_block_time().sec_since_epoch(); auto bob_stats_obj = db.get_account_stats_by_owner(bob_id); - BOOST_CHECK_EQUAL(bob_stats_obj.last_vote_time.sec_since_epoch(), now); + BOOST_CHECK_EQUAL(bob_stats_obj.last_vote_time.sec_since_epoch(), round3); generate_block(); - // proxy votes + // round 4: proxy votes { graphene::chain::account_update_operation op; op.account = proxy_id; @@ -525,17 +525,17 @@ BOOST_AUTO_TEST_CASE(last_voting_date_proxy) } // proxy just voted so the last_vote_time is updated - now = db.head_block_time().sec_since_epoch(); + auto round4 = db.head_block_time().sec_since_epoch(); auto proxy_stats_obj = db.get_account_stats_by_owner(proxy_id); - BOOST_CHECK_EQUAL(proxy_stats_obj.last_vote_time.sec_since_epoch(), now); + BOOST_CHECK_EQUAL(proxy_stats_obj.last_vote_time.sec_since_epoch(), round4); // alice haves proxy, proxy votes but last_vote_time is not updated for alice alice_stats_obj = db.get_account_stats_by_owner(alice_id); - BOOST_CHECK(alice_stats_obj.last_vote_time.sec_since_epoch() != now); + BOOST_CHECK_EQUAL(alice_stats_obj.last_vote_time.sec_since_epoch(), round1); // bob haves nothing to do with proxy so last_vote_time is not updated bob_stats_obj = db.get_account_stats_by_owner(bob_id); - BOOST_CHECK(bob_stats_obj.last_vote_time.sec_since_epoch() != now); + BOOST_CHECK_EQUAL(bob_stats_obj.last_vote_time.sec_since_epoch(), round3); } FC_LOG_AND_RETHROW() } From 4a3f45b1766067d1a1f356474166e04df329d624 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Fri, 14 Dec 2018 18:15:14 +0100 Subject: [PATCH 081/172] Fixed code smell --- libraries/db/include/graphene/db/index.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index ddee3833ed..babfbda91f 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -204,7 +204,7 @@ namespace graphene { namespace db { { static_assert( chunkbits < 64, "Do you really want arrays with more than 2^63 elements???" ); - private: + // private static const size_t MAX_HOLE = 100; static const size_t _mask = ((1 << chunkbits) - 1); size_t next = 0; From dd6c7fc4e7bf09b63b67c7cad095faaf9a701ba6 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sat, 15 Dec 2018 21:24:45 +0100 Subject: [PATCH 082/172] Properly initialize inner vectors, support nested modifications --- libraries/db/include/graphene/db/index.hpp | 14 +++++++++----- tests/tests/database_tests.cpp | 10 ++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index babfbda91f..3687b5d803 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -23,11 +23,14 @@ */ #pragma once #include + #include #include #include #include + #include +#include namespace graphene { namespace db { class object_database; @@ -209,7 +212,7 @@ namespace graphene { namespace db { static const size_t _mask = ((1 << chunkbits) - 1); size_t next = 0; vector< vector< const Object* > > content; - object_id_type id_being_modified; + std::stack< object_id_type > ids_being_modified; public: direct_index() { @@ -226,7 +229,7 @@ namespace graphene { namespace db { if( !(next & _mask) ) { content.resize((next >> chunkbits) + 1); - content[next >> chunkbits].reserve( 1 << chunkbits ); + content[next >> chunkbits].resize( 1 << chunkbits, nullptr ); } next++; } @@ -238,7 +241,7 @@ namespace graphene { namespace db { if( !(next & _mask) || (next & (~_mask)) != (instance & (~_mask)) ) { content.resize((instance >> chunkbits) + 1); - content[instance >> chunkbits].reserve( 1 << chunkbits ); + content[instance >> chunkbits].resize( 1 << chunkbits, nullptr ); } while( next <= instance ) { @@ -261,12 +264,13 @@ namespace graphene { namespace db { virtual void about_to_modify( const object& before ) { - id_being_modified = before.id; + ids_being_modified.emplace( before.id ); } virtual void object_modified( const object& after ) { - FC_ASSERT( id_being_modified == after.id, "Modification of ID is not supported!"); + FC_ASSERT( ids_being_modified.top() == after.id, "Modification of ID is not supported!"); + ids_being_modified.pop(); } template< typename object_id > diff --git a/tests/tests/database_tests.cpp b/tests/tests/database_tests.cpp index e8c1d24fe2..6158c2eb05 100644 --- a/tests/tests/database_tests.cpp +++ b/tests/tests/database_tests.cpp @@ -182,6 +182,16 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) test_account.name = "account50"; my_accounts.load( fc::raw::pack( test_account ) ); + // can handle nested modification + my_accounts.modify( direct.get( account_id_type(0) ), [&direct,&my_accounts] ( object& outer ) { + account_object& _outer = dynamic_cast< account_object& >( outer ); + my_accounts.modify( direct.get( account_id_type(50) ), [] ( object& inner ) { + account_object& _inner = dynamic_cast< account_object& >( inner ); + _inner.referrer = account_id_type(102); + }); + _outer.options.voting_account = GRAPHENE_PROXY_TO_SELF_ACCOUNT; + }); + // direct.next is still 103, so 204 is not allowed test_account.id = account_id_type(204); test_account.name = "account204"; From 69c4011cf483819f0fc4cd31c34dc21bbb68c66b Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sat, 15 Dec 2018 21:26:23 +0100 Subject: [PATCH 083/172] Removed obsolete hardfork code to avoid problems with next commit --- libraries/chain/db_block.cpp | 8 -------- tests/tests/block_tests.cpp | 5 ----- 2 files changed, 13 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index efc5562a89..629c9b8605 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -683,14 +683,6 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx } ptrx.operation_results = std::move(eval_state.operation_results); - if( head_block_time() < HARDFORK_CORE_1040_TIME ) // TODO totally remove this code block after hard fork - { - //Make sure the temp account has no non-zero balances - const auto& index = get_index_type().indices().get(); - auto range = index.equal_range( boost::make_tuple( GRAPHENE_TEMP_ACCOUNT ) ); - std::for_each(range.first, range.second, [](const account_balance_object& b) { FC_ASSERT(b.balance == 0); }); - } - return ptrx; } FC_CAPTURE_AND_RETHROW( (trx) ) } diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index e71642726b..8af8e8777c 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -1830,11 +1830,6 @@ BOOST_FIXTURE_TEST_CASE( temp_account_balance, database_fixture ) top.to = GRAPHENE_COMMITTEE_ACCOUNT; trx.operations.push_back( top ); - sign( trx, alice_private_key ); - BOOST_CHECK_THROW( PUSH_TX( db, trx ), fc::assert_exception ); - - generate_blocks( HARDFORK_CORE_1040_TIME ); - set_expiration( db, trx ); trx.clear_signatures(); sign( trx, alice_private_key ); From 2409104bb075a9a49e261185fb3858243fb7b237 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sat, 15 Dec 2018 21:28:05 +0100 Subject: [PATCH 084/172] Added direct_index-like replacement for by_account_asset subindex --- libraries/app/database_api.cpp | 16 +++--- libraries/chain/account_object.cpp | 50 +++++++++++++++++++ libraries/chain/db_balance.cpp | 19 +++---- libraries/chain/db_init.cpp | 5 +- libraries/chain/db_maint.cpp | 12 ++--- .../include/graphene/chain/account_object.hpp | 32 +++++++++--- 6 files changed, 98 insertions(+), 36 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 9316cfa4b6..9a86afba4a 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -799,11 +799,9 @@ std::map database_api_impl::get_full_accounts( const // Add the account's balances - auto balance_range = _db.get_index_type().indices().get().equal_range(boost::make_tuple(account->id)); - std::for_each(balance_range.first, balance_range.second, - [&acnt](const account_balance_object& balance) { - acnt.balances.emplace_back(balance); - }); + const auto& balances = _db.get_index_type< primary_index< account_balance_index > >().get_secondary_index< balances_by_account_index >().get_account_balances( account->id ); + for( const auto balance : balances ) + acnt.balances.emplace_back( *balance.second ); // Add the account's vesting balances auto vesting_range = _db.get_index_type().indices().get().equal_range(account->id); @@ -955,10 +953,10 @@ vector database_api_impl::get_account_balances(const std::string& account if (assets.empty()) { // if the caller passes in an empty list of assets, return balances for all assets the account owns - const account_balance_index& balance_index = _db.get_index_type(); - auto range = balance_index.indices().get().equal_range(boost::make_tuple(acnt)); - for (const account_balance_object& balance : boost::make_iterator_range(range.first, range.second)) - result.push_back(asset(balance.get_balance())); + const auto& balance_index = _db.get_index_type< primary_index< account_balance_index > >(); + const auto& balances = balance_index.get_secondary_index< balances_by_account_index >().get_account_balances( acnt ); + for( const auto balance : balances ) + result.push_back( balance.second->get_balance() ); } else { diff --git a/libraries/chain/account_object.cpp b/libraries/chain/account_object.cpp index 952a4c7c2c..466f7a6fc9 100644 --- a/libraries/chain/account_object.cpp +++ b/libraries/chain/account_object.cpp @@ -269,4 +269,54 @@ void account_referrer_index::object_modified( const object& after ) { } +const uint8_t balances_by_account_index::bits = 20; +const uint64_t balances_by_account_index::mask = (1ULL << balances_by_account_index::bits) - 1; + +void balances_by_account_index::object_inserted( const object& obj ) +{ + const auto& abo = dynamic_cast< const account_balance_object& >( obj ); + while( balances.size() < (abo.owner.instance.value >> bits) + 1 ) + { + balances.reserve( (abo.owner.instance.value >> bits) + 1 ); + balances.resize( balances.size() + 1 ); + balances.back().resize( 1ULL << bits ); + } + balances[abo.owner.instance.value >> bits][abo.owner.instance.value & mask][abo.asset_type] = &abo; +} + +void balances_by_account_index::object_removed( const object& obj ) +{ + const auto& abo = dynamic_cast< const account_balance_object& >( obj ); + if( balances.size() < (abo.owner.instance.value >> bits) + 1 ) return; + balances[abo.owner.instance.value >> bits][abo.owner.instance.value & mask].erase( abo.asset_type ); +} + +void balances_by_account_index::about_to_modify( const object& before ) +{ + ids_being_modified.emplace( before.id ); +} + +void balances_by_account_index::object_modified( const object& after ) +{ + FC_ASSERT( ids_being_modified.top() == after.id, "Modification of ID is not supported!"); + ids_being_modified.pop(); +} + +const map< asset_id_type, const account_balance_object* >& balances_by_account_index::get_account_balances( const account_id_type& acct )const +{ + static const map< asset_id_type, const account_balance_object* > _empty; + + if( balances.size() < (acct.instance.value >> bits) + 1 ) return _empty; + return balances[acct.instance.value >> bits][acct.instance.value & mask]; +} + +const account_balance_object* balances_by_account_index::get_account_balance( const account_id_type& acct, const asset_id_type& asset )const +{ + if( balances.size() < (acct.instance.value >> bits) + 1 ) return nullptr; + const auto& mine = balances[acct.instance.value >> bits][acct.instance.value & mask]; + const auto itr = mine.find( asset ); + if( mine.end() == itr ) return nullptr; + return itr->second; +} + } } // graphene::chain diff --git a/libraries/chain/db_balance.cpp b/libraries/chain/db_balance.cpp index cf58cb432d..caa1eff63b 100644 --- a/libraries/chain/db_balance.cpp +++ b/libraries/chain/db_balance.cpp @@ -33,11 +33,11 @@ namespace graphene { namespace chain { asset database::get_balance(account_id_type owner, asset_id_type asset_id) const { - auto& index = get_index_type().indices().get(); - auto itr = index.find(boost::make_tuple(owner, asset_id)); - if( itr == index.end() ) + auto& index = get_index_type< primary_index< account_balance_index > >().get_secondary_index(); + auto abo = index.get_account_balance( owner, asset_id ); + if( !abo ) return asset(0, asset_id); - return itr->get_balance(); + return abo->get_balance(); } asset database::get_balance(const account_object& owner, const asset_object& asset_obj) const @@ -55,9 +55,9 @@ void database::adjust_balance(account_id_type account, asset delta ) if( delta.amount == 0 ) return; - auto& index = get_index_type().indices().get(); - auto itr = index.find(boost::make_tuple(account, delta.asset_id)); - if(itr == index.end()) + auto& index = get_index_type< primary_index< account_balance_index > >().get_secondary_index(); + auto abo = index.get_account_balance( account, delta.asset_id ); + if( !abo ) { FC_ASSERT( delta.amount > 0, "Insufficient Balance: ${a}'s balance of ${b} is less than required ${r}", ("a",account(*this).name) @@ -72,8 +72,9 @@ void database::adjust_balance(account_id_type account, asset delta ) }); } else { if( delta.amount < 0 ) - FC_ASSERT( itr->get_balance() >= -delta, "Insufficient Balance: ${a}'s balance of ${b} is less than required ${r}", ("a",account(*this).name)("b",to_pretty_string(itr->get_balance()))("r",to_pretty_string(-delta))); - modify(*itr, [delta](account_balance_object& b) { + FC_ASSERT( abo->get_balance() >= -delta, "Insufficient Balance: ${a}'s balance of ${b} is less than required ${r}", + ("a",account(*this).name)("b",to_pretty_string(abo->get_balance()))("r",to_pretty_string(-delta))); + modify(*abo, [delta](account_balance_object& b) { b.adjust_balance(delta); }); } diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index c87d9ec6a6..4ecd578fba 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -205,7 +205,10 @@ void database::initialize_indexes() //Implementation object indexes add_index< primary_index >(); - add_index< primary_index >(); + + auto bal_idx = add_index< primary_index >(); + bal_idx->add_secondary_index(); + add_index< primary_index >(); // 8192 add_index< primary_index> >(); add_index< primary_index> >(); diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index d011740a6c..4ee7cb2825 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -693,7 +693,7 @@ void distribute_fba_balances( database& db ) void create_buyback_orders( database& db ) { const auto& bbo_idx = db.get_index_type< buyback_index >().indices().get(); - const auto& bal_idx = db.get_index_type< account_balance_index >().indices().get< by_account_asset >(); + const auto& bal_idx = db.get_index_type< primary_index< account_balance_index > >().get_secondary_index< balances_by_account_index >(); for( const buyback_object& bbo : bbo_idx ) { @@ -701,7 +701,6 @@ void create_buyback_orders( database& db ) assert( asset_to_buy.buyback_account.valid() ); const account_object& buyback_account = (*(asset_to_buy.buyback_account))(db); - asset_id_type next_asset = asset_id_type(); if( !buyback_account.allowed_assets.valid() ) { @@ -709,16 +708,11 @@ void create_buyback_orders( database& db ) continue; } - while( true ) + for( const auto& entry : bal_idx.get_account_balances( buyback_account.id ) ) { - auto it = bal_idx.lower_bound( boost::make_tuple( buyback_account.id, next_asset ) ); - if( it == bal_idx.end() ) - break; - if( it->owner != buyback_account.id ) - break; + const auto* it = entry.second; asset_id_type asset_to_sell = it->asset_type; share_type amount_to_sell = it->balance; - next_asset = asset_to_sell + 1; if( asset_to_sell == asset_to_buy.id ) continue; if( amount_to_sell == 0 ) diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index cae9d35984..1c4526fde0 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -341,7 +341,30 @@ namespace graphene { namespace chain { map< account_id_type, set > referred_by; }; - struct by_account_asset; + /** + * @brief This secondary index will allow fast access to the balance objects + * that belonging to an account. + */ + class balances_by_account_index : public secondary_index + { + public: + virtual void object_inserted( const object& obj ) override; + virtual void object_removed( const object& obj ) override; + virtual void about_to_modify( const object& before ) override; + virtual void object_modified( const object& after ) override; + + const map< asset_id_type, const account_balance_object* >& get_account_balances( const account_id_type& acct )const; + const account_balance_object* get_account_balance( const account_id_type& acct, const asset_id_type& asset )const; + + private: + static const uint8_t bits; + static const uint64_t mask; + + /** Maps each account to its balance objects */ + vector< vector< map< asset_id_type, const account_balance_object* > > > balances; + std::stack< object_id_type > ids_being_modified; + }; + struct by_asset_balance; struct by_maintenance_flag; /** @@ -353,13 +376,6 @@ namespace graphene { namespace chain { ordered_unique< tag, member< object, object_id_type, &object::id > >, ordered_non_unique< tag, member< account_balance_object, bool, &account_balance_object::maintenance_flag > >, - ordered_unique< tag, - composite_key< - account_balance_object, - member, - member - > - >, ordered_unique< tag, composite_key< account_balance_object, From a8020a7da022cf8ec24063b64a84a46a06ab82c8 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 17 Dec 2018 10:46:38 -0300 Subject: [PATCH 085/172] reverse delayed node and only add auto to needed plugins --- programs/delayed_node/main.cpp | 50 ++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index 311911adcb..a8ef7daddb 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -60,32 +60,32 @@ fc::optional load_logging_config_from_ini_file(const fc::pat int main(int argc, char** argv) { try { - app::application* node = new app::application(); + app::application node; bpo::options_description app_options("Graphene Delayed Node"); bpo::options_description cfg_options("Graphene Delayed Node"); app_options.add_options() - ("help,h", "Print this help message and exit.") - ("data-dir,d", bpo::value()->default_value("delayed_node_data_dir"), "Directory containing databases, configuration file, etc.") - ; + ("help,h", "Print this help message and exit.") + ("data-dir,d", bpo::value()->default_value("delayed_node_data_dir"), "Directory containing databases, configuration file, etc.") + ; bpo::variables_map options; - auto delayed_plug = node->register_plugin(true); - auto history_plug = node->register_plugin(true); - auto market_history_plug = node->register_plugin(true); + auto delayed_plug = node.register_plugin(true); + auto history_plug = node.register_plugin(true); + auto market_history_plug = node.register_plugin(true); try { bpo::options_description cli, cfg; - node->set_program_options(cli, cfg); + node.set_program_options(cli, cfg); app_options.add(cli); cfg_options.add(cfg); bpo::store(bpo::parse_command_line(argc, argv, app_options), options); } catch (const boost::program_options::error& e) { - std::cerr << "Error parsing command line: " << e.what() << "\n"; - return 1; + std::cerr << "Error parsing command line: " << e.what() << "\n"; + return 1; } if( options.count("help") ) @@ -160,24 +160,26 @@ int main(int argc, char** argv) { elog("Error parsing configuration file: ${e}", ("e", e.what())); return 1; } + if( !options.count("plugins") ) + options.insert( std::make_pair( "plugins", bpo::variable_value(std::string("delayed_node account_history market_history"), true) ) ); - node->initialize(data_dir, options); - node->initialize_plugins( options ); + node.initialize(data_dir, options); + node.initialize_plugins( options ); - node->startup(); - node->startup_plugins(); + node.startup(); + node.startup_plugins(); fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); fc::set_signal_handler([&exit_promise](int signal) { - exit_promise->set_value(signal); + exit_promise->set_value(signal); }, SIGINT); - ilog("Started delayed node on a chain with ${h} blocks.", ("h", node->chain_database()->head_block_num())); - ilog("Chain ID is ${id}", ("id", node->chain_database()->get_chain_id()) ); + ilog("Started delayed node on a chain with ${h} blocks.", ("h", node.chain_database()->head_block_num())); + ilog("Chain ID is ${id}", ("id", node.chain_database()->get_chain_id()) ); int signal = exit_promise->wait(); ilog("Exiting from signal ${n}", ("n", signal)); - node->shutdown_plugins(); + node.shutdown_plugins(); return 0; } catch( const fc::exception& e ) { elog("Exiting with error:\n${e}", ("e", e.to_detail_string())); @@ -239,14 +241,14 @@ fc::optional load_logging_config_from_ini_file(const fc::pat // stdout/stderr will be taken from ini file, everything else hard-coded here fc::console_appender::config console_appender_config; console_appender_config.level_colors.emplace_back( - fc::console_appender::level_color(fc::log_level::debug, - fc::console_appender::color::green)); + fc::console_appender::level_color(fc::log_level::debug, + fc::console_appender::color::green)); console_appender_config.level_colors.emplace_back( - fc::console_appender::level_color(fc::log_level::warn, - fc::console_appender::color::brown)); + fc::console_appender::level_color(fc::log_level::warn, + fc::console_appender::color::brown)); console_appender_config.level_colors.emplace_back( - fc::console_appender::level_color(fc::log_level::error, - fc::console_appender::color::cyan)); + fc::console_appender::level_color(fc::log_level::error, + fc::console_appender::color::cyan)); console_appender_config.stream = fc::variant(stream_name, 1).as(1); logging_config.appenders.push_back(fc::appender_config(console_appender_name, "console", fc::variant(console_appender_config, GRAPHENE_MAX_NESTED_OBJECTS))); found_logging_config = true; From 1326a5c126d8fcf99cfa717925dac58c0bbb0a0d Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 17 Dec 2018 11:15:13 -0300 Subject: [PATCH 086/172] make plugins option work in delayed --- programs/delayed_node/main.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index a8ef7daddb..4a43535ac6 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -66,13 +66,15 @@ int main(int argc, char** argv) { app_options.add_options() ("help,h", "Print this help message and exit.") ("data-dir,d", bpo::value()->default_value("delayed_node_data_dir"), "Directory containing databases, configuration file, etc.") + ("plugins", bpo::value()->default_value("delayed_node account_history market_history"), + "Space-separated list of plugins to activate"); ; bpo::variables_map options; - auto delayed_plug = node.register_plugin(true); - auto history_plug = node.register_plugin(true); - auto market_history_plug = node.register_plugin(true); + auto delayed_plug = node.register_plugin(); + auto history_plug = node.register_plugin(); + auto market_history_plug = node.register_plugin(); try { @@ -160,9 +162,20 @@ int main(int argc, char** argv) { elog("Error parsing configuration file: ${e}", ("e", e.what())); return 1; } - if( !options.count("plugins") ) - options.insert( std::make_pair( "plugins", bpo::variable_value(std::string("delayed_node account_history market_history"), true) ) ); + std::set plugins; + boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); + + if(plugins.count("account_history") && plugins.count("elasticsearch")) { + std::cerr << "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin\n"; + return 1; + } + + std::for_each(plugins.begin(), plugins.end(), [&](const std::string& plug) mutable { + if (!plug.empty()) { + node.enable_plugin(plug); + } + }); node.initialize(data_dir, options); node.initialize_plugins( options ); From 1e8ccab7b411de624b418be2ad4cbd68d0cf442f Mon Sep 17 00:00:00 2001 From: Alfredo Date: Tue, 18 Dec 2018 15:22:56 -0300 Subject: [PATCH 087/172] change adaptor response to be mutable_variant_object --- libraries/plugins/es_objects/es_objects.cpp | 9 +++------ .../include/graphene/es_objects/es_objects.hpp | 8 +++----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/libraries/plugins/es_objects/es_objects.cpp b/libraries/plugins/es_objects/es_objects.cpp index 01ec4722a6..5695064325 100644 --- a/libraries/plugins/es_objects/es_objects.cpp +++ b/libraries/plugins/es_objects/es_objects.cpp @@ -198,14 +198,11 @@ void es_objects_plugin_impl::prepareTemplate(T blockchain_object, string index_n bulk_header["_id"] = string(blockchain_object.id); } - auto blockchain_object_string = fc::json::to_string(blockchain_object, fc::json::legacy_generator); - variant blockchain_object_variant = fc::json::from_string(blockchain_object_string); - fc::mutable_variant_object o; - adaptor_struct adaptor; - auto adapted = adaptor.adapt(blockchain_object_variant.get_object()); + fc::variant blockchain_object_variant; + fc::to_variant( blockchain_object, blockchain_object_variant, GRAPHENE_NET_MAX_NESTED_OBJECTS ); + fc::mutable_variant_object o = adaptor.adapt(blockchain_object_variant.get_object()); - fc::from_variant(adapted, o, FC_PACK_MAX_DEPTH); o["object_id"] = string(blockchain_object.id); o["block_time"] = block_time; o["block_number"] = block_number; diff --git a/libraries/plugins/es_objects/include/graphene/es_objects/es_objects.hpp b/libraries/plugins/es_objects/include/graphene/es_objects/es_objects.hpp index a66e299551..fa91e3bde4 100644 --- a/libraries/plugins/es_objects/include/graphene/es_objects/es_objects.hpp +++ b/libraries/plugins/es_objects/include/graphene/es_objects/es_objects.hpp @@ -54,7 +54,7 @@ class es_objects_plugin : public graphene::app::plugin }; struct adaptor_struct { - variant adapt(const variant_object &obj) { + fc::mutable_variant_object adapt(const variant_object &obj) { fc::mutable_variant_object o(obj); vector keys_to_rename; for (auto i = o.begin(); i != o.end(); ++i) { @@ -94,10 +94,8 @@ struct adaptor_struct { { o["operations"] = fc::json::to_string(o["operations"]); } - - variant v; - fc::to_variant(o, v, FC_PACK_MAX_DEPTH); - return v; + + return o; } void adapt(fc::variants &v) { From 53d3538495c1654e6d1ac80f7d5d6bafc5a41d1a Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 25 Dec 2018 09:47:24 -0500 Subject: [PATCH 088/172] create test --- tests/common/database_fixture.cpp | 22 ++++++++++++++-------- tests/tests/history_api_tests.cpp | 31 ++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 874e2f8241..a77854cd22 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -111,8 +111,17 @@ database_fixture::database_fixture() open_database(); + /** + * Test specific settings + */ + auto current_test_name = boost::unit_test::framework::current_test_case().p_name.value; + auto current_test_suite_id = boost::unit_test::framework::current_test_case().p_parent_id; + if (current_test_name == "get_account_history_operations") + { + options.insert(std::make_pair("max-ops-per-account", boost::program_options::variable_value((uint64_t)75, false))); + } // add account tracking for ahplugin for special test case with track-account enabled - if( !options.count("track-account") && boost::unit_test::framework::current_test_case().p_name.value == "track_account") { + if( !options.count("track-account") && current_test_name == "track_account") { std::vector track_account; std::string track = "\"1.2.17\""; track_account.push_back(track); @@ -120,7 +129,7 @@ database_fixture::database_fixture() options.insert(std::make_pair("partial-operations", boost::program_options::variable_value(true, false))); } // account tracking 2 accounts - if( !options.count("track-account") && boost::unit_test::framework::current_test_case().p_name.value == "track_account2") { + if( !options.count("track-account") && current_test_name == "track_account2") { std::vector track_account; std::string track = "\"1.2.0\""; track_account.push_back(track); @@ -133,10 +142,7 @@ database_fixture::database_fixture() boost::unit_test::framework::current_test_case().p_name.value == "track_votes_committee_disabled") { app.chain_database()->enable_standby_votes_tracking( false ); } - - auto test_name = boost::unit_test::framework::current_test_case().p_name.value; - auto test_suite_id = boost::unit_test::framework::current_test_case().p_parent_id; - if(test_name == "elasticsearch_account_history" || test_name == "elasticsearch_suite") { + if(current_test_name == "elasticsearch_account_history" || current_test_name == "elasticsearch_suite") { auto esplugin = app.register_plugin(); esplugin->plugin_set_app(&app); @@ -149,7 +155,7 @@ database_fixture::database_fixture() esplugin->plugin_initialize(options); esplugin->plugin_startup(); } - else if( boost::unit_test::framework::get(test_suite_id).p_name.value != "performance_tests" ) + else if( boost::unit_test::framework::get(current_test_suite_id).p_name.value != "performance_tests" ) { auto ahplugin = app.register_plugin(); ahplugin->plugin_set_app(&app); @@ -157,7 +163,7 @@ database_fixture::database_fixture() ahplugin->plugin_startup(); } - if(test_name == "elasticsearch_objects" || test_name == "elasticsearch_suite") { + if(current_test_name == "elasticsearch_objects" || current_test_name == "elasticsearch_suite") { auto esobjects_plugin = app.register_plugin(); esobjects_plugin->plugin_set_app(&app); diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 1255864c20..f1935caf57 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -549,32 +549,53 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { int asset_create_op_id = operation::tag::value; int account_create_op_id = operation::tag::value; + int transfer_op_id = operation::tag::value; //account_id_type() did 1 asset_create op - vector histories = hist_api.get_account_history_operations("committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); + vector histories = hist_api.get_account_history_operations( + "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); BOOST_CHECK_EQUAL(histories.size(), 1); BOOST_CHECK_EQUAL(histories[0].id.instance(), 0); BOOST_CHECK_EQUAL(histories[0].op.which(), asset_create_op_id); //account_id_type() did 2 account_create ops - histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); + histories = hist_api.get_account_history_operations( + "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); BOOST_CHECK_EQUAL(histories.size(), 2); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // No asset_create op larger than id1 - histories = hist_api.get_account_history_operations("committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(1), 100); + histories = hist_api.get_account_history_operations( + "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(1), 100); BOOST_CHECK_EQUAL(histories.size(), 0); // Limit 1 returns 1 result - histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 1); + histories = hist_api.get_account_history_operations( + "committee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 1); BOOST_CHECK_EQUAL(histories.size(), 1); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // alice has 1 op - histories = hist_api.get_account_history_operations("alice", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 100); + histories = hist_api.get_account_history_operations( + "alice", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 100); BOOST_CHECK_EQUAL(histories.size(), 1); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + // create a bunch of accounts + for(int i = 0; i < 110; ++i) + { + std::string acct_name = "mytempacct" + std::to_string(i); + create_account(acct_name); + } + generate_block(); + + histories = hist_api.get_account_history_operations( + "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); + BOOST_CHECK_EQUAL(histories.size(), 100); + if (histories.size() > 0) + BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); + + } catch (fc::exception &e) { edump((e.to_detail_string())); throw; From 20a2f6270d82f3e1953ab9106487e9e7e5935b05 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 25 Dec 2018 09:58:47 -0500 Subject: [PATCH 089/172] catching exception if history_object no longer in memory --- libraries/app/api.cpp | 9 ++++++--- tests/tests/history_api_tests.cpp | 7 +++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index f3cffa70ff..877a49e788 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -376,9 +376,12 @@ namespace graphene { namespace app { else node = &node->next(db); } if( stop.instance.value == 0 && result.size() < limit ) { - const account_transaction_history_object head = account_transaction_history_id_type()(db); - if( head.account == account && head.operation_id(db).op.which() == operation_id ) - result.push_back(head.operation_id(db)); + try + { + const account_transaction_history_object head = account_transaction_history_id_type()(db); + if( head.account == account && head.operation_id(db).op.which() == operation_id ) + result.push_back(head.operation_id(db)); + } catch (fc::exception& ignore) { /* limit of history reached, head not found */ } } return result; } diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index f1935caf57..b8f8856384 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -582,16 +582,19 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // create a bunch of accounts - for(int i = 0; i < 110; ++i) + for(int i = 0; i < 80; ++i) { std::string acct_name = "mytempacct" + std::to_string(i); create_account(acct_name); } generate_block(); + // history is set to limit transactions to 75 (see database_fixture.hpp) + // so asking for more should only return 75 (and not throw exception, + // see https://github.com/bitshares/bitshares-core/issues/1490 histories = hist_api.get_account_history_operations( "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); - BOOST_CHECK_EQUAL(histories.size(), 100); + BOOST_CHECK_EQUAL(histories.size(), 75); if (histories.size() > 0) BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); From 35037685c75a8b7af031462b77f47c6a2f230768 Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 27 Dec 2018 17:54:07 -0500 Subject: [PATCH 090/172] limit subscribed accounts to 100 --- libraries/app/database_api.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index f067a101e8..5e53c74713 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -259,7 +259,7 @@ class database_api_impl : public std::enable_shared_from_this bool _notify_remove_create = false; mutable fc::bloom_filter _subscribe_filter; - std::set _subscribed_accounts; + mutable std::set _subscribed_accounts; std::function _subscribe_callback; std::function _pending_trx_callback; std::function _block_applied_callback; @@ -594,8 +594,16 @@ vector> database_api_impl::get_key_references( vector Date: Fri, 28 Dec 2018 06:11:57 -0500 Subject: [PATCH 091/172] Add ilog message when plugin starts --- libraries/app/application.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index cc7828034f..f2cf80285d 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -1151,7 +1151,10 @@ void application::initialize_plugins( const boost::program_options::variables_ma void application::startup_plugins() { for( auto& entry : my->_active_plugins ) + { entry.second->plugin_startup(); + ilog( "Plugin ${name} started", ( "name", entry.second->plugin_name() ) ); + } return; } From bbd6773e148ff65f5c4eedef4df8de57543f08dc Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 28 Dec 2018 09:45:01 -0500 Subject: [PATCH 092/172] Reduce warning messages, constructor still throws --- libraries/db/include/graphene/db/undo_database.hpp | 12 +----------- libraries/db/undo_database.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/libraries/db/include/graphene/db/undo_database.hpp b/libraries/db/include/graphene/db/undo_database.hpp index cf6f06247d..f2f77d607d 100644 --- a/libraries/db/include/graphene/db/undo_database.hpp +++ b/libraries/db/include/graphene/db/undo_database.hpp @@ -59,17 +59,7 @@ namespace graphene { namespace db { { mv._apply_undo = false; } - ~session() { - try { - if( _apply_undo ) _db.undo(); - } - catch ( const fc::exception& e ) - { - elog( "${e}", ("e",e.to_detail_string() ) ); - throw; // maybe crash.. - } - if( _disable_on_exit ) _db.disable(); - } + ~session(); // defined in implementation file to prevent repeated compiler warnings void commit() { _apply_undo = false; _db.commit(); } void undo() { if( _apply_undo ) _db.undo(); _apply_undo = false; } void merge() { if( _apply_undo ) _db.merge(); _apply_undo = false; } diff --git a/libraries/db/undo_database.cpp b/libraries/db/undo_database.cpp index c5f2ef65df..bb05f2a6eb 100644 --- a/libraries/db/undo_database.cpp +++ b/libraries/db/undo_database.cpp @@ -30,6 +30,19 @@ namespace graphene { namespace db { void undo_database::enable() { _disabled = false; } void undo_database::disable() { _disabled = true; } +undo_database::session::~session() +{ + try { + if( _apply_undo ) _db.undo(); + } + catch ( const fc::exception& e ) + { + elog( "${e}", ("e",e.to_detail_string() ) ); + throw; // maybe crash.. + } + if( _disable_on_exit ) _db.disable(); +} + undo_database::session undo_database::start_undo_session( bool force_enable ) { if( _disabled && !force_enable ) return session(*this); From f52636d69c3ce4039672daaf34ec639e00cd95f9 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 28 Dec 2018 09:53:01 -0500 Subject: [PATCH 093/172] Squelch memaccess and parentheses warnings --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index faf3a59f6d..b81422ae50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,7 +115,7 @@ else( WIN32 ) # Apple AND Linux else( APPLE ) # Linux Specific Options Here message( STATUS "Configuring BitShares on Linux" ) - set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall" ) + set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall -Wno-class-memaccess -Wno-parentheses" ) if(USE_PROFILER) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg" ) endif( USE_PROFILER ) From d4231adee917f8ba1f8651b6e3b45ddd43e59000 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 28 Dec 2018 11:01:28 -0500 Subject: [PATCH 094/172] fixed comparison warnings --- tests/app/main.cpp | 26 +- tests/cli/main.cpp | 2 +- tests/tests/asset_api_tests.cpp | 2 +- tests/tests/authority_tests.cpp | 4 +- tests/tests/block_tests.cpp | 20 +- tests/tests/database_tests.cpp | 12 +- tests/tests/fee_tests.cpp | 30 +- tests/tests/history_api_tests.cpp | 374 ++++++++++---------- tests/tests/market_rounding_tests.cpp | 4 +- tests/tests/network_broadcast_api_tests.cpp | 2 +- tests/tests/operation_tests.cpp | 24 +- tests/tests/operation_tests2.cpp | 4 +- tests/tests/smartcoin_tests.cpp | 268 +++++++------- tests/tests/swan_tests.cpp | 6 +- tests/tests/voting_tests.cpp | 81 +++-- 15 files changed, 429 insertions(+), 430 deletions(-) diff --git a/tests/app/main.cpp b/tests/app/main.cpp index b68cdf78a0..26e494d10d 100644 --- a/tests/app/main.cpp +++ b/tests/app/main.cpp @@ -78,8 +78,8 @@ BOOST_AUTO_TEST_CASE(load_configuration_options_test_config_logging_files_create /// check post-conditions BOOST_CHECK(fc::exists(config_ini_file)); BOOST_CHECK(fc::exists(logging_ini_file)); - BOOST_CHECK_GT(fc::file_size(config_ini_file), 0); - BOOST_CHECK_GT(fc::file_size(logging_ini_file), 0); + BOOST_CHECK_GT(fc::file_size(config_ini_file), 0u); + BOOST_CHECK_GT(fc::file_size(logging_ini_file), 0u); } BOOST_AUTO_TEST_CASE(load_configuration_options_test_config_ini_options) @@ -109,8 +109,8 @@ BOOST_AUTO_TEST_CASE(load_configuration_options_test_config_ini_options) /// check the options values are parsed into the output map BOOST_CHECK(!options.empty()); - BOOST_CHECK_EQUAL(options.count("option1"), 1); - BOOST_CHECK_EQUAL(options.count("option2"), 1); + BOOST_CHECK_EQUAL(options.count("option1"), 1u); + BOOST_CHECK_EQUAL(options.count("option2"), 1u); BOOST_CHECK_EQUAL(options["option1"].as(), "is present"); BOOST_CHECK_EQUAL(options["option2"].as(), 1); @@ -151,9 +151,9 @@ BOOST_AUTO_TEST_CASE(load_configuration_options_test_logging_ini_options) /// this is a little bit tricky since load_configuration_options() doesn't provide output variable for logging_config auto logger_map = fc::get_logger_map(); auto appender_map = fc::get_appender_map(); - BOOST_CHECK_EQUAL(logger_map.size(), 1); + BOOST_CHECK_EQUAL(logger_map.size(), 1u); BOOST_CHECK(logger_map.count("default")); - BOOST_CHECK_EQUAL(appender_map.size(), 1); + BOOST_CHECK_EQUAL(appender_map.size(), 1u); BOOST_CHECK(appender_map.count("default")); } @@ -195,16 +195,16 @@ BOOST_AUTO_TEST_CASE(load_configuration_options_test_legacy_config_ini_options) /// check the options values are parsed into the output map BOOST_CHECK(!options.empty()); - BOOST_CHECK_EQUAL(options.count("option1"), 1); - BOOST_CHECK_EQUAL(options.count("option2"), 1); + BOOST_CHECK_EQUAL(options.count("option1"), 1u); + BOOST_CHECK_EQUAL(options.count("option2"), 1u); BOOST_CHECK_EQUAL(options["option1"].as(), "is present"); BOOST_CHECK_EQUAL(options["option2"].as(), 1); auto logger_map = fc::get_logger_map(); auto appender_map = fc::get_appender_map(); - BOOST_CHECK_EQUAL(logger_map.size(), 1); + BOOST_CHECK_EQUAL(logger_map.size(), 1u); BOOST_CHECK(logger_map.count("default")); - BOOST_CHECK_EQUAL(appender_map.size(), 1); + BOOST_CHECK_EQUAL(appender_map.size(), 1u); BOOST_CHECK(appender_map.count("default")); } @@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE( two_node_network ) app2.startup(); fc::usleep(fc::milliseconds(500)); - BOOST_REQUIRE_EQUAL(app1.p2p_node()->get_connection_count(), 1); + BOOST_REQUIRE_EQUAL(app1.p2p_node()->get_connection_count(), 1u); BOOST_CHECK_EQUAL(std::string(app1.p2p_node()->get_connected_peers().front().host.get_address()), "127.0.0.1"); BOOST_TEST_MESSAGE( "app1 and app2 successfully connected" ); @@ -321,8 +321,8 @@ BOOST_AUTO_TEST_CASE( two_node_network ) fc::usleep(fc::milliseconds(500)); BOOST_TEST_MESSAGE( "Verifying nodes are still connected" ); - BOOST_CHECK_EQUAL(app1.p2p_node()->get_connection_count(), 1); - BOOST_CHECK_EQUAL(app1.chain_database()->head_block_num(), 1); + BOOST_CHECK_EQUAL(app1.p2p_node()->get_connection_count(), 1u); + BOOST_CHECK_EQUAL(app1.chain_database()->head_block_num(), 1u); BOOST_TEST_MESSAGE( "Checking GRAPHENE_NULL_ACCOUNT has balance" ); } catch( fc::exception& e ) { diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 393dce4d83..4ef2552073 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -549,7 +549,7 @@ BOOST_FIXTURE_TEST_CASE( account_history_pagination, cli_fixture ) // now get account history and make sure everything is there (and no duplicates) std::vector history = con.wallet_api_ptr->get_account_history("jmjatlanta", 300); - BOOST_CHECK_EQUAL(201, history.size() ); + BOOST_CHECK_EQUAL(201u, history.size() ); std::set operation_ids; diff --git a/tests/tests/asset_api_tests.cpp b/tests/tests/asset_api_tests.cpp index aaa517a962..332f1b13b4 100644 --- a/tests/tests/asset_api_tests.cpp +++ b/tests/tests/asset_api_tests.cpp @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE( asset_holders ) // make call vector holders = asset_api.get_asset_holders(asset_id_type(), 0, 100); - BOOST_CHECK_EQUAL(holders.size(), 4); + BOOST_CHECK_EQUAL(holders.size(), 4u); // by now we can guarantee the order BOOST_CHECK(holders[0].name == "committee-account"); diff --git a/tests/tests/authority_tests.cpp b/tests/tests/authority_tests.cpp index cf9df59142..bb32f806e9 100644 --- a/tests/tests/authority_tests.cpp +++ b/tests/tests/authority_tests.cpp @@ -1734,7 +1734,7 @@ BOOST_AUTO_TEST_CASE( self_approving_proposal ) trx.operations.push_back(pop); const proposal_id_type pid1 = PUSH_TX( db, trx, ~0 ).operation_results[0].get(); trx.clear(); - BOOST_REQUIRE_EQUAL( 0, pid1.instance.value ); + BOOST_REQUIRE_EQUAL( 0u, pid1.instance.value ); db.get(pid1); trx.operations.push_back(pup); @@ -1765,7 +1765,7 @@ BOOST_AUTO_TEST_CASE( self_deleting_proposal ) trx.operations.push_back( pop ); const proposal_id_type pid1 = PUSH_TX( db, trx, ~0 ).operation_results[0].get(); trx.clear(); - BOOST_REQUIRE_EQUAL( 0, pid1.instance.value ); + BOOST_REQUIRE_EQUAL( 0u, pid1.instance.value ); db.get(pid1); proposal_update_operation pup; diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index 76d9c0b75c..2c7eec7d05 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -847,7 +847,7 @@ BOOST_FIXTURE_TEST_CASE( maintenance_interval, database_fixture ) { try { generate_block(); - BOOST_CHECK_EQUAL(db.head_block_num(), 2); + BOOST_CHECK_EQUAL(db.head_block_num(), 2u); fc::time_point_sec maintenence_time = db.get_dynamic_global_properties().next_maintenance_time; BOOST_CHECK_GT(maintenence_time.sec_since_epoch(), db.head_block_time().sec_since_epoch()); @@ -1024,17 +1024,17 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture ) } BOOST_TEST_MESSAGE( "Verifying that the interval didn't change immediately" ); - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.block_interval, 5); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.block_interval, 5u); auto past_time = db.head_block_time().sec_since_epoch(); generate_block(); - BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 5); + BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 5u); generate_block(); - BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 10); + BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 10u); BOOST_TEST_MESSAGE( "Generating blocks until proposal expires" ); generate_blocks(proposal_id_type()(db).expiration_time + 5); BOOST_TEST_MESSAGE( "Verify that the block interval is still 5 seconds" ); - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.block_interval, 5); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.block_interval, 5u); BOOST_TEST_MESSAGE( "Generating blocks until next maintenance interval" ); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); @@ -1044,9 +1044,9 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture ) BOOST_CHECK_EQUAL(db.get_global_properties().parameters.block_interval, 1); past_time = db.head_block_time().sec_since_epoch(); generate_block(); - BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 1); + BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 1u); generate_block(); - BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 2); + BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 2u); } FC_LOG_AND_RETHROW() } BOOST_FIXTURE_TEST_CASE( pop_block_twice, database_fixture ) @@ -1122,7 +1122,7 @@ BOOST_FIXTURE_TEST_CASE( rsf_missed_blocks, database_fixture ) "1111111111111111111111111111111111111111111111111111111111111111" "1111111111111111111111111111111111111111111111111111111111111111" ); - BOOST_CHECK_EQUAL( db.witness_participation_rate(), GRAPHENE_100_PERCENT ); + BOOST_CHECK_EQUAL( db.witness_participation_rate(), (uint32_t)GRAPHENE_100_PERCENT ); generate_block( ~0, init_account_priv_key, 1 ); BOOST_CHECK_EQUAL( rsf(), @@ -1419,7 +1419,7 @@ BOOST_AUTO_TEST_CASE( genesis_reserve_ids ) BOOST_FIXTURE_TEST_CASE( miss_some_blocks, database_fixture ) { try { std::vector witnesses = witness_schedule_id_type()(db).current_shuffled_witnesses; - BOOST_CHECK_EQUAL( 10, witnesses.size() ); + BOOST_CHECK_EQUAL( 10u, witnesses.size() ); // database_fixture constructor calls generate_block once, signed by witnesses[0] generate_block(); // witnesses[1] generate_block(); // witnesses[2] @@ -1914,7 +1914,7 @@ BOOST_FIXTURE_TEST_CASE( block_size_test, database_fixture ) idump( (fc::raw::pack_size(good_block)) ); } // make sure we have tested at least once pushing a large block - BOOST_CHECK_GT( large_block_count, 0 ); + BOOST_CHECK_GT( large_block_count, 0u ); } catch( fc::exception& e ) { diff --git a/tests/tests/database_tests.cpp b/tests/tests/database_tests.cpp index 6158c2eb05..748fab041d 100644 --- a/tests/tests/database_tests.cpp +++ b/tests/tests/database_tests.cpp @@ -73,13 +73,13 @@ BOOST_AUTO_TEST_CASE(failed_modify_test) obj.owner = account_id_type(123); }); account_balance_id_type obj_id = obj.id; - BOOST_CHECK_EQUAL(obj.owner.instance.value, 123); + BOOST_CHECK_EQUAL(obj.owner.instance.value, 123u); // Modify dummy object, check that changes stick db.modify(obj, [](account_balance_object& obj) { obj.owner = account_id_type(234); }); - BOOST_CHECK_EQUAL(obj_id(db).owner.instance.value, 234); + BOOST_CHECK_EQUAL(obj_id(db).owner.instance.value, 234u); // Throw exception when modifying object, check that object still exists after BOOST_CHECK_THROW(db.modify(obj, [](account_balance_object& obj) { @@ -146,7 +146,7 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) graphene::db::primary_index< account_index, 8 > my_accounts( db ); const auto& direct = my_accounts.get_secondary_index>(); - BOOST_CHECK_EQUAL( 0, my_accounts.indices().size() ); + BOOST_CHECK_EQUAL( 0u, my_accounts.indices().size() ); BOOST_CHECK( nullptr == direct.find( account_id_type( 1 ) ) ); // BOOST_CHECK_THROW( direct.find( asset_id_type( 1 ) ), fc::assert_exception ); // compile-time error BOOST_CHECK_THROW( direct.find( object_id_type( asset_id_type( 1 ) ) ), fc::assert_exception ); @@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) my_accounts.load( fc::raw::pack( test_account ) ); - BOOST_CHECK_EQUAL( 1, my_accounts.indices().size() ); + BOOST_CHECK_EQUAL( 1u, my_accounts.indices().size() ); BOOST_CHECK( nullptr == direct.find( account_id_type( 0 ) ) ); BOOST_CHECK( nullptr == direct.find( account_id_type( 2 ) ) ); BOOST_CHECK( nullptr != direct.find( account_id_type( 1 ) ) ); @@ -174,7 +174,7 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) // direct.next is now 103, but index sequence counter is 0 my_accounts.create( [] ( object& o ) { account_object& acct = dynamic_cast< account_object& >( o ); - BOOST_CHECK_EQUAL( 0, acct.id.instance() ); + BOOST_CHECK_EQUAL( 0u, acct.id.instance() ); acct.name = "account0"; } ); @@ -198,7 +198,7 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) GRAPHENE_REQUIRE_THROW( my_accounts.load( fc::raw::pack( test_account ) ), fc::assert_exception ); // This is actually undefined behaviour. The object has been inserted into // the primary index, but the secondary has refused to insert it! - BOOST_CHECK_EQUAL( 5, my_accounts.indices().size() ); + BOOST_CHECK_EQUAL( 5u, my_accounts.indices().size() ); uint32_t count = 0; for( uint32_t i = 0; i < 250; i++ ) diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index 587814815c..a9b24d0ab3 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -437,11 +437,11 @@ BOOST_AUTO_TEST_CASE( cashback_test ) PREP_ACTOR(stud); PREP_ACTOR(pleb); // use ##_public_key vars to silence unused variable warning - BOOST_CHECK_GT(ann_public_key.key_data.size(), 0); - BOOST_CHECK_GT(scud_public_key.key_data.size(), 0); - BOOST_CHECK_GT(dumy_public_key.key_data.size(), 0); - BOOST_CHECK_GT(stud_public_key.key_data.size(), 0); - BOOST_CHECK_GT(pleb_public_key.key_data.size(), 0); + BOOST_CHECK_GT(ann_public_key.key_data.size(), 0u); + BOOST_CHECK_GT(scud_public_key.key_data.size(), 0u); + BOOST_CHECK_GT(dumy_public_key.key_data.size(), 0u); + BOOST_CHECK_GT(stud_public_key.key_data.size(), 0u); + BOOST_CHECK_GT(pleb_public_key.key_data.size(), 0u); account_id_type ann_id, scud_id, dumy_id, stud_id, pleb_id; actor_audit alife, arog, aann, ascud, adumy, astud, apleb; @@ -716,23 +716,23 @@ BOOST_AUTO_TEST_CASE( account_create_fee_scaling ) for( int i = db.get_dynamic_global_properties().accounts_registered_this_interval; i < accounts_per_scale; ++i ) { - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 1); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 1u); create_account("shill" + fc::to_string(i)); } for( int i = 0; i < accounts_per_scale; ++i ) { - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 16); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 16u); create_account("moreshills" + fc::to_string(i)); } for( int i = 0; i < accounts_per_scale; ++i ) { - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 256); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 256u); create_account("moarshills" + fc::to_string(i)); } - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 4096); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 4096u); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 1); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 1u); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( fee_refund_test ) @@ -3651,31 +3651,31 @@ BOOST_AUTO_TEST_CASE( defaults_test ) // no fees set yet -> default asset fee = schedule.calculate_fee( limit_order_create_operation() ); - BOOST_CHECK_EQUAL( default_order_fee.fee, fee.amount.value ); + BOOST_CHECK_EQUAL( (int64_t)default_order_fee.fee, fee.amount.value ); limit_order_create_operation::fee_parameters_type new_order_fee; new_order_fee.fee = 123; // set fee + check schedule.parameters.insert( new_order_fee ); fee = schedule.calculate_fee( limit_order_create_operation() ); - BOOST_CHECK_EQUAL( new_order_fee.fee, fee.amount.value ); + BOOST_CHECK_EQUAL( (int64_t)new_order_fee.fee, fee.amount.value ); // bid_collateral fee defaults to call_order_update fee // call_order_update fee is unset -> default const call_order_update_operation::fee_parameters_type default_short_fee {}; call_order_update_operation::fee_parameters_type new_short_fee; new_short_fee.fee = 123; fee = schedule.calculate_fee( bid_collateral_operation() ); - BOOST_CHECK_EQUAL( default_short_fee.fee, fee.amount.value ); + BOOST_CHECK_EQUAL( (int64_t)default_short_fee.fee, fee.amount.value ); // set call_order_update fee + check bid_collateral fee schedule.parameters.insert( new_short_fee ); fee = schedule.calculate_fee( bid_collateral_operation() ); - BOOST_CHECK_EQUAL( new_short_fee.fee, fee.amount.value ); + BOOST_CHECK_EQUAL( (int64_t)new_short_fee.fee, fee.amount.value ); // set bid_collateral fee + check bid_collateral_operation::fee_parameters_type new_bid_fee; new_bid_fee.fee = 124; schedule.parameters.insert( new_bid_fee ); fee = schedule.calculate_fee( bid_collateral_operation() ); - BOOST_CHECK_EQUAL( new_bid_fee.fee, fee.amount.value ); + BOOST_CHECK_EQUAL( (int64_t)new_bid_fee.fee, fee.amount.value ); } catch( const fc::exception& e ) { diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 1255864c20..8f135d08f5 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -56,25 +56,25 @@ BOOST_AUTO_TEST_CASE(get_account_history) { //account_id_type() did 3 ops and includes id0 vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 100, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 7u); BOOST_CHECK_EQUAL(histories[2].op.which(), asset_create_op_id); // 1 account_create op larger than id1 histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 100, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK(histories[0].id.instance() != 0); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // Limit 2 returns 2 result histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 2, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 2); + BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK(histories[1].id.instance() != 0); BOOST_CHECK_EQUAL(histories[1].op.which(), account_create_op_id); // bob has 1 op histories = hist_api.get_account_history("bob", operation_history_id_type(), 100, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); @@ -93,14 +93,14 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) { // no history at all in the chain vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(0), 4, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); create_bitasset("USD", account_id_type()); // create op 0 generate_block(); // what if the account only has one history entry and it is 0? histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u); const account_object& dan = create_account("dan"); // create op 1 @@ -114,262 +114,262 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) { // f(A, 0, 4, 9) = { 5, 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(9)); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); // f(A, 0, 4, 6) = { 5, 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(6)); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); // f(A, 0, 4, 5) = { 5, 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(5)); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); // f(A, 0, 4, 4) = { 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(4)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); // f(A, 0, 4, 3) = { 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(3)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); // f(A, 0, 4, 2) = { 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); // f(A, 0, 4, 1) = { 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(1)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); // f(A, 0, 4, 0) = { 5, 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); // f(A, 1, 5, 9) = { 5, 3 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(9)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); // f(A, 1, 5, 6) = { 5, 3 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(6)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); // f(A, 1, 5, 5) = { 5, 3 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(5)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); // f(A, 1, 5, 4) = { 3 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(4)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); // f(A, 1, 5, 3) = { 3 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(3)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); // f(A, 1, 5, 2) = { } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // f(A, 1, 5, 1) = { } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(1)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // f(A, 1, 5, 0) = { 5, 3 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); // f(A, 0, 3, 9) = { 5, 3, 1 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(9)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); // f(A, 0, 3, 6) = { 5, 3, 1 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(6)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); // f(A, 0, 3, 5) = { 5, 3, 1 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(5)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); // f(A, 0, 3, 4) = { 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(4)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); // f(A, 0, 3, 3) = { 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(3)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); // f(A, 0, 3, 2) = { 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); // f(A, 0, 3, 1) = { 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(1)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); // f(A, 0, 3, 0) = { 5, 3, 1 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); // f(B, 0, 4, 9) = { 6, 4, 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(9)); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u); // f(B, 0, 4, 6) = { 6, 4, 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(6)); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u); // f(B, 0, 4, 5) = { 4, 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(5)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); // f(B, 0, 4, 4) = { 4, 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(4)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); // f(B, 0, 4, 3) = { 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(3)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); // f(B, 0, 4, 2) = { 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); // f(B, 0, 4, 1) = { 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(1)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); // f(B, 0, 4, 0) = { 6, 4, 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u); // f(B, 2, 4, 9) = { 6, 4 } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(9)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); // f(B, 2, 4, 6) = { 6, 4 } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(6)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); // f(B, 2, 4, 5) = { 4 } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(5)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 4); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); // f(B, 2, 4, 4) = { 4 } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(4)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 4); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); // f(B, 2, 4, 3) = { } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(3)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // f(B, 2, 4, 2) = { } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // f(B, 2, 4, 1) = { } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(1)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // f(B, 2, 4, 0) = { 6, 4 } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); // 0 limits histories = hist_api.get_account_history("dan", operation_history_id_type(0), 0, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("1.2.0", operation_history_id_type(3), 0, operation_history_id_type(9)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // non existent account histories = hist_api.get_account_history("1.2.18", operation_history_id_type(0), 4, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // create a new account C = alice { 7 } create_account("alice"); @@ -378,21 +378,21 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) { // f(C, 0, 4, 10) = { 7 } histories = hist_api.get_account_history("alice", operation_history_id_type(0), 4, operation_history_id_type(10)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 7); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 7u); // f(C, 8, 4, 10) = { } histories = hist_api.get_account_history("alice", operation_history_id_type(8), 4, operation_history_id_type(10)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // f(A, 0, 10, 0) = { 7, 5, 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 5); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 7); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[4].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 5u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 7u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[4].id.instance(), 0u); } catch (fc::exception &e) { @@ -425,25 +425,25 @@ BOOST_AUTO_TEST_CASE(track_account) { // anything against account_id_type() should be {} vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 1, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // anything against alice should be {} histories = hist_api.get_account_history("alice", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("alice", operation_history_id_type(1), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("alice", operation_history_id_type(1), 1, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // dan should have history histories = hist_api.get_account_history("dan", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); // create more ops, starting with an untracked account create_bitasset( "BTC", account_id_type() ); @@ -452,10 +452,10 @@ BOOST_AUTO_TEST_CASE(track_account) { generate_block( ~database::skip_fork_db ); histories = hist_api.get_account_history("dan", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 3u); db.pop_block(); @@ -466,10 +466,10 @@ BOOST_AUTO_TEST_CASE(track_account) { generate_block(); histories = hist_api.get_account_history("dan", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 3u); } catch (fc::exception &e) { edump((e.to_detail_string())); throw; @@ -499,35 +499,35 @@ BOOST_AUTO_TEST_CASE(track_account2) { // all account_id_type() should have 4 ops {4,2,1,0} vector histories = hist_api.get_account_history("committee-account", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); // all alice account should have 2 ops {3, 0} histories = hist_api.get_account_history("alice", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); // alice first op should be {0} histories = hist_api.get_account_history("alice", operation_history_id_type(0), 1, operation_history_id_type(1)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u); // alice second op should be {3} histories = hist_api.get_account_history("alice", operation_history_id_type(1), 1, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); // anything against dan should be {} histories = hist_api.get_account_history("dan", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("dan", operation_history_id_type(1), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("dan", operation_history_id_type(1), 1, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); } catch (fc::exception &e) { edump((e.to_detail_string())); @@ -552,27 +552,27 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { //account_id_type() did 1 asset_create op vector histories = hist_api.get_account_history_operations("committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[0].op.which(), asset_create_op_id); //account_id_type() did 2 account_create ops histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); - BOOST_CHECK_EQUAL(histories.size(), 2); + BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // No asset_create op larger than id1 histories = hist_api.get_account_history_operations("committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(1), 100); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // Limit 1 returns 1 result histories = hist_api.get_account_history_operations("committee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 1); - BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // alice has 1 op histories = hist_api.get_account_history_operations("alice", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 100); - BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); } catch (fc::exception &e) { diff --git a/tests/tests/market_rounding_tests.cpp b/tests/tests/market_rounding_tests.cpp index 8c406f32e7..b71e1cd0ff 100644 --- a/tests/tests/market_rounding_tests.cpp +++ b/tests/tests/market_rounding_tests.cpp @@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE( trade_amount_equals_zero ) fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread auto result = get_market_order_history(core_id, test_id); - BOOST_CHECK_EQUAL(result.size(), 4); + BOOST_CHECK_EQUAL(result.size(), 4u); BOOST_CHECK(result[0].op.pays == core_id(db).amount(0)); BOOST_CHECK(result[0].op.receives == test_id(db).amount(1)); BOOST_CHECK(result[1].op.pays == test_id(db).amount(1)); @@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE( trade_amount_equals_zero_after_hf_184 ) fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread auto result = get_market_order_history(core_id, test_id); - BOOST_CHECK_EQUAL(result.size(), 2); + BOOST_CHECK_EQUAL(result.size(), 2u); BOOST_CHECK(result[0].op.pays == core_id(db).amount(1)); BOOST_CHECK(result[0].op.receives == test_id(db).amount(2)); BOOST_CHECK(result[1].op.pays == test_id(db).amount(2)); diff --git a/tests/tests/network_broadcast_api_tests.cpp b/tests/tests/network_broadcast_api_tests.cpp index 83d4c7fd1d..a566750b67 100644 --- a/tests/tests/network_broadcast_api_tests.cpp +++ b/tests/tests/network_broadcast_api_tests.cpp @@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE( broadcast_transaction_with_callback_test ) { fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread - BOOST_CHECK_EQUAL( called, 1 ); + BOOST_CHECK_EQUAL( called, 1u ); } FC_LOG_AND_RETHROW() } diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index 398eb42b11..b2edab15ad 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -1731,7 +1731,7 @@ BOOST_AUTO_TEST_CASE( witness_feeds ) vector active_witnesses; for( const witness_id_type& wit_id : global_props.active_witnesses ) active_witnesses.push_back( wit_id(db).witness_account ); - BOOST_REQUIRE_EQUAL(active_witnesses.size(), 10); + BOOST_REQUIRE_EQUAL(active_witnesses.size(), 10u); asset_publish_feed_operation op; op.publisher = active_witnesses[0]; @@ -1828,7 +1828,7 @@ BOOST_AUTO_TEST_CASE( witness_pay_test ) const asset_object* core = &asset_id_type()(db); const account_object* nathan = &get_account("nathan"); enable_fees(); - BOOST_CHECK_GT(db.current_fee_schedule().get().membership_lifetime_fee, 0); + BOOST_CHECK_GT(db.current_fee_schedule().get().membership_lifetime_fee, 0u); // Based on the size of the reserve fund later in the test, the witness budget will be set to this value const uint64_t ref_budget = ((uint64_t( db.current_fee_schedule().get().membership_lifetime_fee ) @@ -1838,10 +1838,10 @@ BOOST_AUTO_TEST_CASE( witness_pay_test ) ) >> GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS ; // change this if ref_budget changes - BOOST_CHECK_EQUAL( ref_budget, 594 ); + BOOST_CHECK_EQUAL( ref_budget, 594u ); const uint64_t witness_ppb = ref_budget * 10 / 23 + 1; // change this if ref_budget changes - BOOST_CHECK_EQUAL( witness_ppb, 259 ); + BOOST_CHECK_EQUAL( witness_ppb, 259u ); // following two inequalities need to hold for maximal code coverage BOOST_CHECK_LT( witness_ppb * 2, ref_budget ); BOOST_CHECK_GT( witness_ppb * 3, ref_budget ); @@ -1887,28 +1887,28 @@ BOOST_AUTO_TEST_CASE( witness_pay_test ) generate_block(); BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, 0 ); } - BOOST_CHECK_EQUAL( db.head_block_time().sec_since_epoch() - pay_fee_time, 24 * block_interval ); + BOOST_CHECK_EQUAL( db.head_block_time().sec_since_epoch() - pay_fee_time, 24u * block_interval ); schedule_maint(); // The 80% lifetime referral fee went to the committee account, which burned it. Check that it's here. BOOST_CHECK( core->reserved(db).value == 8000*prec ); generate_block(); BOOST_CHECK_EQUAL( core->reserved(db).value, 999999406 ); - BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, ref_budget ); + BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, (int64_t)ref_budget ); // first witness paid from old budget (so no pay) BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, 0 ); // second witness finally gets paid! generate_block(); - BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, witness_ppb ); - BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, ref_budget - witness_ppb ); + BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, (int64_t)witness_ppb ); + BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, (int64_t)(ref_budget - witness_ppb) ); generate_block(); - BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, witness_ppb ); - BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, ref_budget - 2 * witness_ppb ); + BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, (int64_t)witness_ppb ); + BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, (int64_t)(ref_budget - 2 * witness_ppb) ); generate_block(); - BOOST_CHECK_LT( last_witness_vbo_balance().value, witness_ppb ); - BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, ref_budget - 2 * witness_ppb ); + BOOST_CHECK_LT( last_witness_vbo_balance().value, (int64_t)witness_ppb ); + BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, (int64_t)(ref_budget - 2 * witness_ppb) ); BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, 0 ); generate_block(); diff --git a/tests/tests/operation_tests2.cpp b/tests/tests/operation_tests2.cpp index 15df1b2ece..a5c7b839c9 100644 --- a/tests/tests/operation_tests2.cpp +++ b/tests/tests/operation_tests2.cpp @@ -968,7 +968,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds ) } { const asset_bitasset_data_object& obj = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(obj.feeds.size(), 3); + BOOST_CHECK_EQUAL(obj.feeds.size(), 3u); BOOST_CHECK(obj.current_feed == price_feed()); } { @@ -1086,7 +1086,7 @@ BOOST_AUTO_TEST_CASE( witness_create ) witness_id_type nathan_witness_id = create_witness(nathan_id, nathan_private_key, skip).id; // nathan should be in the cache - BOOST_CHECK_EQUAL( caching_witnesses.count(nathan_witness_id), 1 ); + BOOST_CHECK_EQUAL( caching_witnesses.count(nathan_witness_id), 1u ); // nathan's key in the cache should still be null before a new block is generated auto nathan_itr = wit_key_cache.find( nathan_witness_id ); diff --git a/tests/tests/smartcoin_tests.cpp b/tests/tests/smartcoin_tests.cpp index ffa80f7551..9610e456ab 100644 --- a/tests/tests/smartcoin_tests.cpp +++ b/tests/tests/smartcoin_tests.cpp @@ -132,17 +132,17 @@ BOOST_AUTO_TEST_CASE(bsip36) // Check current default witnesses, default chain is configured with 10 witnesses auto witnesses = db.get_global_properties().active_witnesses; - BOOST_CHECK_EQUAL(witnesses.size(), 10); - BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 1); - BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 2); - BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 3); - BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 4); - BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 5); - BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 6); - BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 7); - BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 8); - BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 9); - BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 10); + BOOST_CHECK_EQUAL(witnesses.size(), 10u); + BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 1u); + BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 2u); + BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 3u); + BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 4u); + BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 5u); + BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 6u); + BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 7u); + BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 8u); + BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 9u); + BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 10u); // We need to activate 11 witnesses by voting for each of them. // Each witness is voted with incremental stake so last witness created will be the ones with more votes @@ -172,18 +172,18 @@ BOOST_AUTO_TEST_CASE(bsip36) // Check my witnesses are now in control of the system witnesses = db.get_global_properties().active_witnesses; - BOOST_CHECK_EQUAL(witnesses.size(), 11); - BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 11); - BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 12); - BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 13); - BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 14); - BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 15); - BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 16); - BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 17); - BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 18); - BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 19); - BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 20); - BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 21); + BOOST_CHECK_EQUAL(witnesses.size(), 11u); + BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 11u); + BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 12u); + BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 13u); + BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 14u); + BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 15u); + BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 16u); + BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 17u); + BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 18u); + BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 19u); + BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 20u); + BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 21u); // Adding 2 feeds with witnesses 0 and 1, checking if they get inserted const asset_object &core = asset_id_type()(db); @@ -192,18 +192,18 @@ BOOST_AUTO_TEST_CASE(bsip36) publish_feed(bit_usd_id(db), witness0_id(db), feed); asset_bitasset_data_object bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1u); auto itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16u); feed.settlement_price = bit_usd_id(db).amount(2) / core.amount(5); publish_feed(bit_usd_id(db), witness1_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 17); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 17u); // Activate witness11 with voting stake, will kick the witness with less votes(witness0) out of the active list transfer(committee_account, witness11_id, asset(121)); @@ -228,32 +228,32 @@ BOOST_AUTO_TEST_CASE(bsip36) // Check active witness list now witnesses = db.get_global_properties().active_witnesses; - BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 12); - BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 13); - BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 14); - BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 15); - BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 16); - BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 17); - BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 18); - BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 19); - BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 20); - BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 21); - BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 22); + BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 12u); + BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 13u); + BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 14u); + BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 15u); + BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 16u); + BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 17u); + BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 18u); + BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 19u); + BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 20u); + BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 21u); + BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 22u); // witness0 has been removed but it was a feeder before // Feed persist in the blockchain, this reproduces the issue bitasset_data = bit_usd_id(db).bitasset_data(db); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16u); // Feed persist after expiration const auto feed_lifetime = bit_usd_id(db).bitasset_data(db).options.feed_lifetime_sec; generate_blocks(db.head_block_time() + feed_lifetime + 1); bitasset_data = bit_usd_id(db).bitasset_data(db); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16u); // Other witnesses add more feeds feed.settlement_price = bit_usd_id(db).amount(4) / core.amount(5); @@ -264,14 +264,14 @@ BOOST_AUTO_TEST_CASE(bsip36) // But the one from witness0 is never removed bitasset_data = bit_usd_id(db).bitasset_data(db); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 4); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 4u); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16u); // Feed from witness1 is also expired but never deleted // All feeds should be deleted at this point const auto minimum_feeds = bit_usd_id(db).bitasset_data(db).options.minimum_feeds; - BOOST_CHECK_EQUAL(minimum_feeds, 1); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 17); + BOOST_CHECK_EQUAL(minimum_feeds, 1u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 17u); // Advancing into HF time generate_blocks(HARDFORK_CORE_518_TIME); @@ -281,15 +281,15 @@ BOOST_AUTO_TEST_CASE(bsip36) // All expired feeds are deleted bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 0); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 0u); // witness1 start feed producing again feed.settlement_price = bit_usd_id(db).amount(1) / core.amount(5); publish_feed(bit_usd_id(db), witness1_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); // generate some blocks up to expiration but feed will not be deleted yet as need next maint time generate_blocks(itr[0].second.first + feed_lifetime + 1); @@ -298,10 +298,10 @@ BOOST_AUTO_TEST_CASE(bsip36) feed.settlement_price = bit_usd_id(db).amount(1) / core.amount(5); publish_feed(bit_usd_id(db), witness2_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18u); // make the first feed expire generate_blocks(itr[0].second.first + feed_lifetime + 1); @@ -309,23 +309,23 @@ BOOST_AUTO_TEST_CASE(bsip36) // feed from witness0 expires and gets deleted, feed from witness is on time so persist bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 18); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 18u); // expire everything generate_blocks(itr[0].second.first + feed_lifetime + 1); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 0); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 0u); // add new feed with witness1 feed.settlement_price = bit_usd_id(db).amount(1) / core.amount(5); publish_feed(bit_usd_id(db), witness1_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); // Reactivate witness0 transfer(committee_account, witness0_id, asset(100)); @@ -350,29 +350,29 @@ BOOST_AUTO_TEST_CASE(bsip36) // Checking witnesses = db.get_global_properties().active_witnesses; - BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 11); - BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 13); - BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 14); - BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 15); - BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 16); - BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 17); - BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 18); - BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 19); - BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 20); - BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 21); - BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 22); + BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 11u); + BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 13u); + BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 14u); + BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 15u); + BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 16u); + BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 17u); + BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 18u); + BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 19u); + BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 20u); + BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 21u); + BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 22u); // feed from witness1 is still here as the witness is no longer a producer but the feed is not yet expired - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); // make feed from witness1 expire generate_blocks(itr[0].second.first + feed_lifetime + 1); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 0); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 0u); } FC_LOG_AND_RETHROW() } @@ -418,11 +418,11 @@ BOOST_AUTO_TEST_CASE(bsip36_update_feed_producers) // Bitshares will create entries in the field feed after feed producers are added auto bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3u); auto itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 17); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 18); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 17u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 18u); // Removing a feed producer { @@ -439,19 +439,19 @@ BOOST_AUTO_TEST_CASE(bsip36_update_feed_producers) // Feed for removed producer is removed bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18u); // Feed persist after expiration const auto feed_lifetime = bit_usd_id(db).bitasset_data(db).options.feed_lifetime_sec; generate_blocks(db.head_block_time() + feed_lifetime + 1); bitasset_data = bit_usd_id(db).bitasset_data(db); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18u); // Advancing into HF time generate_blocks(HARDFORK_CORE_518_TIME); @@ -462,9 +462,9 @@ BOOST_AUTO_TEST_CASE(bsip36_update_feed_producers) // Expired feeds persist, no changes bitasset_data = bit_usd_id(db).bitasset_data(db); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18u); } FC_LOG_AND_RETHROW() } @@ -507,9 +507,9 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness5_id(db), feed); auto bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1u); auto itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); @@ -517,10 +517,10 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness6_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22u); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); @@ -528,11 +528,11 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness7_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23u); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); @@ -540,12 +540,12 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness8_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 4); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 4u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23); - BOOST_CHECK_EQUAL(itr[3].first.instance.value, 24); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23u); + BOOST_CHECK_EQUAL(itr[3].first.instance.value, 24u); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); @@ -553,13 +553,13 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness9_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 5); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 5u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23); - BOOST_CHECK_EQUAL(itr[3].first.instance.value, 24); - BOOST_CHECK_EQUAL(itr[4].first.instance.value, 25); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23u); + BOOST_CHECK_EQUAL(itr[3].first.instance.value, 24u); + BOOST_CHECK_EQUAL(itr[4].first.instance.value, 25u); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); @@ -567,27 +567,27 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness10_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 6); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 6u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23); - BOOST_CHECK_EQUAL(itr[3].first.instance.value, 24); - BOOST_CHECK_EQUAL(itr[4].first.instance.value, 25); - BOOST_CHECK_EQUAL(itr[5].first.instance.value, 26); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23u); + BOOST_CHECK_EQUAL(itr[3].first.instance.value, 24u); + BOOST_CHECK_EQUAL(itr[4].first.instance.value, 25u); + BOOST_CHECK_EQUAL(itr[5].first.instance.value, 26u); // make the older feed expire generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 5); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 5u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 22); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 23); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 24); - BOOST_CHECK_EQUAL(itr[3].first.instance.value, 25); - BOOST_CHECK_EQUAL(itr[4].first.instance.value, 26); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 22u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 23u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 24u); + BOOST_CHECK_EQUAL(itr[3].first.instance.value, 25u); + BOOST_CHECK_EQUAL(itr[4].first.instance.value, 26u); // make older 2 feeds expire generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); @@ -596,41 +596,41 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) generate_block(); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 24); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 25); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 26); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 24u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 25u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 26u); // witness5 add new feed, feeds are sorted by witness_id not by feed_time feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness5_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 4); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 4u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 24); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 25); - BOOST_CHECK_EQUAL(itr[3].first.instance.value, 26); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 24u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 25u); + BOOST_CHECK_EQUAL(itr[3].first.instance.value, 26u); // another feed expires generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 25); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 26); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 25u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 26u); // another feed expires generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 26); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 26u); // and so on diff --git a/tests/tests/swan_tests.cpp b/tests/tests/swan_tests.cpp index 5b9b5c3f20..8488e839fa 100644 --- a/tests/tests/swan_tests.cpp +++ b/tests/tests/swan_tests.cpp @@ -368,13 +368,13 @@ BOOST_AUTO_TEST_CASE( recollateralize ) graphene::app::database_api db_api(db); GRAPHENE_REQUIRE_THROW( db_api.get_collateral_bids(back().id, 100, 0), fc::assert_exception ); vector bids = db_api.get_collateral_bids(_swan, 100, 1); - BOOST_CHECK_EQUAL( 1, bids.size() ); + BOOST_CHECK_EQUAL( 1u, bids.size() ); FC_ASSERT( _borrower2 == bids[0].bidder ); bids = db_api.get_collateral_bids(_swan, 1, 0); - BOOST_CHECK_EQUAL( 1, bids.size() ); + BOOST_CHECK_EQUAL( 1u, bids.size() ); FC_ASSERT( _borrower == bids[0].bidder ); bids = db_api.get_collateral_bids(_swan, 100, 0); - BOOST_CHECK_EQUAL( 2, bids.size() ); + BOOST_CHECK_EQUAL( 2u, bids.size() ); FC_ASSERT( _borrower == bids[0].bidder ); FC_ASSERT( _borrower2 == bids[1].bidder ); diff --git a/tests/tests/voting_tests.cpp b/tests/tests/voting_tests.cpp index 141c19e0f3..df92ccf061 100644 --- a/tests/tests/voting_tests.cpp +++ b/tests/tests/voting_tests.cpp @@ -129,17 +129,17 @@ BOOST_AUTO_TEST_CASE(put_my_witnesses) // Check current default witnesses, default chain is configured with 10 witnesses auto witnesses = db.get_global_properties().active_witnesses; - BOOST_CHECK_EQUAL(witnesses.size(), 10); - BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 1); - BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 2); - BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 3); - BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 4); - BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 5); - BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 6); - BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 7); - BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 8); - BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 9); - BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 10); + BOOST_CHECK_EQUAL(witnesses.size(), 10u); + BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 1u); + BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 2u); + BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 3u); + BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 4u); + BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 5u); + BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 6u); + BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 7u); + BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 8u); + BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 9u); + BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 10u); // Activate all witnesses // Each witness is voted with incremental stake so last witness created will be the ones with more votes @@ -168,18 +168,18 @@ BOOST_AUTO_TEST_CASE(put_my_witnesses) // Check my witnesses are now in control of the system witnesses = db.get_global_properties().active_witnesses; - BOOST_CHECK_EQUAL(witnesses.size(), 11); - BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 14); - BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 15); - BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 16); - BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 17); - BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 18); - BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 19); - BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 20); - BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 21); - BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 22); - BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 23); - BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 24); + BOOST_CHECK_EQUAL(witnesses.size(), 11u); + BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 14u); + BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 15u); + BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 16u); + BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 17u); + BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 18u); + BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 19u); + BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 20u); + BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 21u); + BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 22u); + BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 23u); + BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 24u); } FC_LOG_AND_RETHROW() } @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(track_votes_witnesses_enabled) const account_id_type witness1_id= get_account("witness1").id; auto witness1_object = db_api1.get_witness_by_account(witness1_id(db).name); - BOOST_CHECK_EQUAL(witness1_object->total_votes, 111); + BOOST_CHECK_EQUAL(witness1_object->total_votes, 111u); } FC_LOG_AND_RETHROW() } @@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE(track_votes_witnesses_disabled) const account_id_type witness1_id= get_account("witness1").id; auto witness1_object = db_api1.get_witness_by_account(witness1_id(db).name); - BOOST_CHECK_EQUAL(witness1_object->total_votes, 0); + BOOST_CHECK_EQUAL(witness1_object->total_votes, 0u); } FC_LOG_AND_RETHROW() } @@ -306,17 +306,17 @@ BOOST_AUTO_TEST_CASE(put_my_committee_members) // Check current default witnesses, default chain is configured with 10 witnesses auto committee_members = db.get_global_properties().active_committee_members; - BOOST_CHECK_EQUAL(committee_members.size(), 10); - BOOST_CHECK_EQUAL(committee_members.begin()[0].instance.value, 0); - BOOST_CHECK_EQUAL(committee_members.begin()[1].instance.value, 1); - BOOST_CHECK_EQUAL(committee_members.begin()[2].instance.value, 2); - BOOST_CHECK_EQUAL(committee_members.begin()[3].instance.value, 3); - BOOST_CHECK_EQUAL(committee_members.begin()[4].instance.value, 4); - BOOST_CHECK_EQUAL(committee_members.begin()[5].instance.value, 5); - BOOST_CHECK_EQUAL(committee_members.begin()[6].instance.value, 6); - BOOST_CHECK_EQUAL(committee_members.begin()[7].instance.value, 7); - BOOST_CHECK_EQUAL(committee_members.begin()[8].instance.value, 8); - BOOST_CHECK_EQUAL(committee_members.begin()[9].instance.value, 9); + BOOST_CHECK_EQUAL(committee_members.size(), 10u); + BOOST_CHECK_EQUAL(committee_members.begin()[0].instance.value, 0u); + BOOST_CHECK_EQUAL(committee_members.begin()[1].instance.value, 1u); + BOOST_CHECK_EQUAL(committee_members.begin()[2].instance.value, 2u); + BOOST_CHECK_EQUAL(committee_members.begin()[3].instance.value, 3u); + BOOST_CHECK_EQUAL(committee_members.begin()[4].instance.value, 4u); + BOOST_CHECK_EQUAL(committee_members.begin()[5].instance.value, 5u); + BOOST_CHECK_EQUAL(committee_members.begin()[6].instance.value, 6u); + BOOST_CHECK_EQUAL(committee_members.begin()[7].instance.value, 7u); + BOOST_CHECK_EQUAL(committee_members.begin()[8].instance.value, 8u); + BOOST_CHECK_EQUAL(committee_members.begin()[9].instance.value, 9u); // Activate all committee // Each witness is voted with incremental stake so last witness created will be the ones with more votes @@ -345,7 +345,7 @@ BOOST_AUTO_TEST_CASE(put_my_committee_members) // Check my witnesses are now in control of the system committee_members = db.get_global_properties().active_committee_members; - BOOST_CHECK_EQUAL(committee_members.size(), 11); + BOOST_CHECK_EQUAL(committee_members.size(), 11u); /* TODO we are not in full control, seems to committee members have votes by default BOOST_CHECK_EQUAL(committee_members.begin()[0].instance.value, 14); @@ -373,7 +373,7 @@ BOOST_AUTO_TEST_CASE(track_votes_committee_enabled) const account_id_type committee1_id= get_account("committee1").id; auto committee1_object = db_api1.get_committee_member_by_account(committee1_id(db).name); - BOOST_CHECK_EQUAL(committee1_object->total_votes, 111); + BOOST_CHECK_EQUAL(committee1_object->total_votes, 111u); } FC_LOG_AND_RETHROW() } @@ -388,7 +388,7 @@ BOOST_AUTO_TEST_CASE(track_votes_committee_disabled) const account_id_type committee1_id= get_account("committee1").id; auto committee1_object = db_api1.get_committee_member_by_account(committee1_id(db).name); - BOOST_CHECK_EQUAL(committee1_object->total_votes, 0); + BOOST_CHECK_EQUAL(committee1_object->total_votes, 0u); } FC_LOG_AND_RETHROW() } @@ -426,7 +426,7 @@ BOOST_AUTO_TEST_CASE(last_voting_date) auto witness1 = witness_id_type(1)(db); auto stats_obj = db.get_account_stats_by_owner(alice_id); - BOOST_CHECK_EQUAL(stats_obj.last_vote_time.sec_since_epoch(), 0); + BOOST_CHECK_EQUAL(stats_obj.last_vote_time.sec_since_epoch(), 0u); // alice votes graphene::chain::account_update_operation op; @@ -488,7 +488,6 @@ BOOST_AUTO_TEST_CASE(last_voting_date_proxy) PUSH_TX( db, trx, ~0 ); } // last_vote_time is not updated - auto round2 = db.head_block_time().sec_since_epoch(); alice_stats_obj = db.get_account_stats_by_owner(alice_id); BOOST_CHECK_EQUAL(alice_stats_obj.last_vote_time.sec_since_epoch(), round1); From bea4a5dbf4b2b9d45b5c0970bdec0a23f11165c4 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 28 Dec 2018 15:04:48 -0500 Subject: [PATCH 095/172] revert accidental change --- tests/tests/history_api_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 8f135d08f5..fb397aa82b 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE(get_account_history) { vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 100, operation_history_id_type()); BOOST_CHECK_EQUAL(histories.size(), 3u); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 7u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[2].op.which(), asset_create_op_id); // 1 account_create op larger than id1 From 32847975eb326e46ea0bbaf809dbe6d4789b4308 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 30 Dec 2018 10:10:44 +0100 Subject: [PATCH 096/172] Fixed linker error --- libraries/chain/db_management.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index 9167768f48..231cc3ebc9 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include From ebc860358a2a12a8163e71c93f75a029cb7496b4 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 31 Dec 2018 06:56:52 -0500 Subject: [PATCH 097/172] use find instead of try/catch --- libraries/app/api.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 877a49e788..61e9637a9f 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -370,18 +370,15 @@ namespace graphene { namespace app { if(node->operation_id(db).op.which() == operation_id) result.push_back( node->operation_id(db) ); - } + } if( node->next == account_transaction_history_id_type() ) node = nullptr; else node = &node->next(db); } if( stop.instance.value == 0 && result.size() < limit ) { - try - { - const account_transaction_history_object head = account_transaction_history_id_type()(db); - if( head.account == account && head.operation_id(db).op.which() == operation_id ) - result.push_back(head.operation_id(db)); - } catch (fc::exception& ignore) { /* limit of history reached, head not found */ } + auto head = db.find(account_transaction_history_id_type()); + if (head != nullptr && head->account == account && head->operation_id(db).op.which() == operation_id) + result.push_back(head->operation_id(db)); } return result; } From c6474f91458b74d48deb23080d6fa5a0d63f1ecd Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 1 Jan 2019 09:53:00 -0500 Subject: [PATCH 098/172] Do not subscribe to associated accounts --- libraries/app/database_api.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 5e53c74713..3afa4dc643 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -259,7 +259,7 @@ class database_api_impl : public std::enable_shared_from_this bool _notify_remove_create = false; mutable fc::bloom_filter _subscribe_filter; - mutable std::set _subscribed_accounts; + std::set _subscribed_accounts; std::function _subscribe_callback; std::function _pending_trx_callback; std::function _block_applied_callback; @@ -594,17 +594,6 @@ vector> database_api_impl::get_key_references( vector Date: Tue, 1 Jan 2019 10:28:19 -0500 Subject: [PATCH 099/172] Revert adding compile switches -Wno-??? --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b81422ae50..faf3a59f6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,7 +115,7 @@ else( WIN32 ) # Apple AND Linux else( APPLE ) # Linux Specific Options Here message( STATUS "Configuring BitShares on Linux" ) - set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall -Wno-class-memaccess -Wno-parentheses" ) + set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall" ) if(USE_PROFILER) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg" ) endif( USE_PROFILER ) From 15882750e6396593bdf39ecd3bfb4600cab7c5d2 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 28 Dec 2018 09:45:01 -0500 Subject: [PATCH 100/172] Reduce warning messages, constructor still throws --- libraries/db/include/graphene/db/undo_database.hpp | 12 +----------- libraries/db/undo_database.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/libraries/db/include/graphene/db/undo_database.hpp b/libraries/db/include/graphene/db/undo_database.hpp index cf6f06247d..f2f77d607d 100644 --- a/libraries/db/include/graphene/db/undo_database.hpp +++ b/libraries/db/include/graphene/db/undo_database.hpp @@ -59,17 +59,7 @@ namespace graphene { namespace db { { mv._apply_undo = false; } - ~session() { - try { - if( _apply_undo ) _db.undo(); - } - catch ( const fc::exception& e ) - { - elog( "${e}", ("e",e.to_detail_string() ) ); - throw; // maybe crash.. - } - if( _disable_on_exit ) _db.disable(); - } + ~session(); // defined in implementation file to prevent repeated compiler warnings void commit() { _apply_undo = false; _db.commit(); } void undo() { if( _apply_undo ) _db.undo(); _apply_undo = false; } void merge() { if( _apply_undo ) _db.merge(); _apply_undo = false; } diff --git a/libraries/db/undo_database.cpp b/libraries/db/undo_database.cpp index c5f2ef65df..bb05f2a6eb 100644 --- a/libraries/db/undo_database.cpp +++ b/libraries/db/undo_database.cpp @@ -30,6 +30,19 @@ namespace graphene { namespace db { void undo_database::enable() { _disabled = false; } void undo_database::disable() { _disabled = true; } +undo_database::session::~session() +{ + try { + if( _apply_undo ) _db.undo(); + } + catch ( const fc::exception& e ) + { + elog( "${e}", ("e",e.to_detail_string() ) ); + throw; // maybe crash.. + } + if( _disable_on_exit ) _db.disable(); +} + undo_database::session undo_database::start_undo_session( bool force_enable ) { if( _disabled && !force_enable ) return session(*this); From c97988b39106dd16e11a0c45e00a0d092d77ab85 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 28 Dec 2018 09:53:01 -0500 Subject: [PATCH 101/172] Squelch memaccess and parentheses warnings --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index faf3a59f6d..b81422ae50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,7 +115,7 @@ else( WIN32 ) # Apple AND Linux else( APPLE ) # Linux Specific Options Here message( STATUS "Configuring BitShares on Linux" ) - set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall" ) + set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall -Wno-class-memaccess -Wno-parentheses" ) if(USE_PROFILER) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg" ) endif( USE_PROFILER ) From 52b0fe3c45d1156b6b11b0dfa450f670214fd4c6 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 28 Dec 2018 11:01:28 -0500 Subject: [PATCH 102/172] fixed comparison warnings --- tests/app/main.cpp | 26 +- tests/cli/main.cpp | 2 +- tests/tests/asset_api_tests.cpp | 2 +- tests/tests/authority_tests.cpp | 4 +- tests/tests/block_tests.cpp | 20 +- tests/tests/database_tests.cpp | 12 +- tests/tests/fee_tests.cpp | 30 +- tests/tests/history_api_tests.cpp | 376 ++++++++++---------- tests/tests/market_rounding_tests.cpp | 4 +- tests/tests/network_broadcast_api_tests.cpp | 2 +- tests/tests/operation_tests.cpp | 24 +- tests/tests/operation_tests2.cpp | 4 +- tests/tests/smartcoin_tests.cpp | 268 +++++++------- tests/tests/swan_tests.cpp | 6 +- tests/tests/voting_tests.cpp | 81 +++-- 15 files changed, 430 insertions(+), 431 deletions(-) diff --git a/tests/app/main.cpp b/tests/app/main.cpp index b68cdf78a0..26e494d10d 100644 --- a/tests/app/main.cpp +++ b/tests/app/main.cpp @@ -78,8 +78,8 @@ BOOST_AUTO_TEST_CASE(load_configuration_options_test_config_logging_files_create /// check post-conditions BOOST_CHECK(fc::exists(config_ini_file)); BOOST_CHECK(fc::exists(logging_ini_file)); - BOOST_CHECK_GT(fc::file_size(config_ini_file), 0); - BOOST_CHECK_GT(fc::file_size(logging_ini_file), 0); + BOOST_CHECK_GT(fc::file_size(config_ini_file), 0u); + BOOST_CHECK_GT(fc::file_size(logging_ini_file), 0u); } BOOST_AUTO_TEST_CASE(load_configuration_options_test_config_ini_options) @@ -109,8 +109,8 @@ BOOST_AUTO_TEST_CASE(load_configuration_options_test_config_ini_options) /// check the options values are parsed into the output map BOOST_CHECK(!options.empty()); - BOOST_CHECK_EQUAL(options.count("option1"), 1); - BOOST_CHECK_EQUAL(options.count("option2"), 1); + BOOST_CHECK_EQUAL(options.count("option1"), 1u); + BOOST_CHECK_EQUAL(options.count("option2"), 1u); BOOST_CHECK_EQUAL(options["option1"].as(), "is present"); BOOST_CHECK_EQUAL(options["option2"].as(), 1); @@ -151,9 +151,9 @@ BOOST_AUTO_TEST_CASE(load_configuration_options_test_logging_ini_options) /// this is a little bit tricky since load_configuration_options() doesn't provide output variable for logging_config auto logger_map = fc::get_logger_map(); auto appender_map = fc::get_appender_map(); - BOOST_CHECK_EQUAL(logger_map.size(), 1); + BOOST_CHECK_EQUAL(logger_map.size(), 1u); BOOST_CHECK(logger_map.count("default")); - BOOST_CHECK_EQUAL(appender_map.size(), 1); + BOOST_CHECK_EQUAL(appender_map.size(), 1u); BOOST_CHECK(appender_map.count("default")); } @@ -195,16 +195,16 @@ BOOST_AUTO_TEST_CASE(load_configuration_options_test_legacy_config_ini_options) /// check the options values are parsed into the output map BOOST_CHECK(!options.empty()); - BOOST_CHECK_EQUAL(options.count("option1"), 1); - BOOST_CHECK_EQUAL(options.count("option2"), 1); + BOOST_CHECK_EQUAL(options.count("option1"), 1u); + BOOST_CHECK_EQUAL(options.count("option2"), 1u); BOOST_CHECK_EQUAL(options["option1"].as(), "is present"); BOOST_CHECK_EQUAL(options["option2"].as(), 1); auto logger_map = fc::get_logger_map(); auto appender_map = fc::get_appender_map(); - BOOST_CHECK_EQUAL(logger_map.size(), 1); + BOOST_CHECK_EQUAL(logger_map.size(), 1u); BOOST_CHECK(logger_map.count("default")); - BOOST_CHECK_EQUAL(appender_map.size(), 1); + BOOST_CHECK_EQUAL(appender_map.size(), 1u); BOOST_CHECK(appender_map.count("default")); } @@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE( two_node_network ) app2.startup(); fc::usleep(fc::milliseconds(500)); - BOOST_REQUIRE_EQUAL(app1.p2p_node()->get_connection_count(), 1); + BOOST_REQUIRE_EQUAL(app1.p2p_node()->get_connection_count(), 1u); BOOST_CHECK_EQUAL(std::string(app1.p2p_node()->get_connected_peers().front().host.get_address()), "127.0.0.1"); BOOST_TEST_MESSAGE( "app1 and app2 successfully connected" ); @@ -321,8 +321,8 @@ BOOST_AUTO_TEST_CASE( two_node_network ) fc::usleep(fc::milliseconds(500)); BOOST_TEST_MESSAGE( "Verifying nodes are still connected" ); - BOOST_CHECK_EQUAL(app1.p2p_node()->get_connection_count(), 1); - BOOST_CHECK_EQUAL(app1.chain_database()->head_block_num(), 1); + BOOST_CHECK_EQUAL(app1.p2p_node()->get_connection_count(), 1u); + BOOST_CHECK_EQUAL(app1.chain_database()->head_block_num(), 1u); BOOST_TEST_MESSAGE( "Checking GRAPHENE_NULL_ACCOUNT has balance" ); } catch( fc::exception& e ) { diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 393dce4d83..4ef2552073 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -549,7 +549,7 @@ BOOST_FIXTURE_TEST_CASE( account_history_pagination, cli_fixture ) // now get account history and make sure everything is there (and no duplicates) std::vector history = con.wallet_api_ptr->get_account_history("jmjatlanta", 300); - BOOST_CHECK_EQUAL(201, history.size() ); + BOOST_CHECK_EQUAL(201u, history.size() ); std::set operation_ids; diff --git a/tests/tests/asset_api_tests.cpp b/tests/tests/asset_api_tests.cpp index aaa517a962..332f1b13b4 100644 --- a/tests/tests/asset_api_tests.cpp +++ b/tests/tests/asset_api_tests.cpp @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE( asset_holders ) // make call vector holders = asset_api.get_asset_holders(asset_id_type(), 0, 100); - BOOST_CHECK_EQUAL(holders.size(), 4); + BOOST_CHECK_EQUAL(holders.size(), 4u); // by now we can guarantee the order BOOST_CHECK(holders[0].name == "committee-account"); diff --git a/tests/tests/authority_tests.cpp b/tests/tests/authority_tests.cpp index cf9df59142..bb32f806e9 100644 --- a/tests/tests/authority_tests.cpp +++ b/tests/tests/authority_tests.cpp @@ -1734,7 +1734,7 @@ BOOST_AUTO_TEST_CASE( self_approving_proposal ) trx.operations.push_back(pop); const proposal_id_type pid1 = PUSH_TX( db, trx, ~0 ).operation_results[0].get(); trx.clear(); - BOOST_REQUIRE_EQUAL( 0, pid1.instance.value ); + BOOST_REQUIRE_EQUAL( 0u, pid1.instance.value ); db.get(pid1); trx.operations.push_back(pup); @@ -1765,7 +1765,7 @@ BOOST_AUTO_TEST_CASE( self_deleting_proposal ) trx.operations.push_back( pop ); const proposal_id_type pid1 = PUSH_TX( db, trx, ~0 ).operation_results[0].get(); trx.clear(); - BOOST_REQUIRE_EQUAL( 0, pid1.instance.value ); + BOOST_REQUIRE_EQUAL( 0u, pid1.instance.value ); db.get(pid1); proposal_update_operation pup; diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index 76d9c0b75c..2c7eec7d05 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -847,7 +847,7 @@ BOOST_FIXTURE_TEST_CASE( maintenance_interval, database_fixture ) { try { generate_block(); - BOOST_CHECK_EQUAL(db.head_block_num(), 2); + BOOST_CHECK_EQUAL(db.head_block_num(), 2u); fc::time_point_sec maintenence_time = db.get_dynamic_global_properties().next_maintenance_time; BOOST_CHECK_GT(maintenence_time.sec_since_epoch(), db.head_block_time().sec_since_epoch()); @@ -1024,17 +1024,17 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture ) } BOOST_TEST_MESSAGE( "Verifying that the interval didn't change immediately" ); - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.block_interval, 5); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.block_interval, 5u); auto past_time = db.head_block_time().sec_since_epoch(); generate_block(); - BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 5); + BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 5u); generate_block(); - BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 10); + BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 10u); BOOST_TEST_MESSAGE( "Generating blocks until proposal expires" ); generate_blocks(proposal_id_type()(db).expiration_time + 5); BOOST_TEST_MESSAGE( "Verify that the block interval is still 5 seconds" ); - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.block_interval, 5); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.block_interval, 5u); BOOST_TEST_MESSAGE( "Generating blocks until next maintenance interval" ); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); @@ -1044,9 +1044,9 @@ BOOST_FIXTURE_TEST_CASE( change_block_interval, database_fixture ) BOOST_CHECK_EQUAL(db.get_global_properties().parameters.block_interval, 1); past_time = db.head_block_time().sec_since_epoch(); generate_block(); - BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 1); + BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 1u); generate_block(); - BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 2); + BOOST_CHECK_EQUAL(db.head_block_time().sec_since_epoch() - past_time, 2u); } FC_LOG_AND_RETHROW() } BOOST_FIXTURE_TEST_CASE( pop_block_twice, database_fixture ) @@ -1122,7 +1122,7 @@ BOOST_FIXTURE_TEST_CASE( rsf_missed_blocks, database_fixture ) "1111111111111111111111111111111111111111111111111111111111111111" "1111111111111111111111111111111111111111111111111111111111111111" ); - BOOST_CHECK_EQUAL( db.witness_participation_rate(), GRAPHENE_100_PERCENT ); + BOOST_CHECK_EQUAL( db.witness_participation_rate(), (uint32_t)GRAPHENE_100_PERCENT ); generate_block( ~0, init_account_priv_key, 1 ); BOOST_CHECK_EQUAL( rsf(), @@ -1419,7 +1419,7 @@ BOOST_AUTO_TEST_CASE( genesis_reserve_ids ) BOOST_FIXTURE_TEST_CASE( miss_some_blocks, database_fixture ) { try { std::vector witnesses = witness_schedule_id_type()(db).current_shuffled_witnesses; - BOOST_CHECK_EQUAL( 10, witnesses.size() ); + BOOST_CHECK_EQUAL( 10u, witnesses.size() ); // database_fixture constructor calls generate_block once, signed by witnesses[0] generate_block(); // witnesses[1] generate_block(); // witnesses[2] @@ -1914,7 +1914,7 @@ BOOST_FIXTURE_TEST_CASE( block_size_test, database_fixture ) idump( (fc::raw::pack_size(good_block)) ); } // make sure we have tested at least once pushing a large block - BOOST_CHECK_GT( large_block_count, 0 ); + BOOST_CHECK_GT( large_block_count, 0u ); } catch( fc::exception& e ) { diff --git a/tests/tests/database_tests.cpp b/tests/tests/database_tests.cpp index 6158c2eb05..748fab041d 100644 --- a/tests/tests/database_tests.cpp +++ b/tests/tests/database_tests.cpp @@ -73,13 +73,13 @@ BOOST_AUTO_TEST_CASE(failed_modify_test) obj.owner = account_id_type(123); }); account_balance_id_type obj_id = obj.id; - BOOST_CHECK_EQUAL(obj.owner.instance.value, 123); + BOOST_CHECK_EQUAL(obj.owner.instance.value, 123u); // Modify dummy object, check that changes stick db.modify(obj, [](account_balance_object& obj) { obj.owner = account_id_type(234); }); - BOOST_CHECK_EQUAL(obj_id(db).owner.instance.value, 234); + BOOST_CHECK_EQUAL(obj_id(db).owner.instance.value, 234u); // Throw exception when modifying object, check that object still exists after BOOST_CHECK_THROW(db.modify(obj, [](account_balance_object& obj) { @@ -146,7 +146,7 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) graphene::db::primary_index< account_index, 8 > my_accounts( db ); const auto& direct = my_accounts.get_secondary_index>(); - BOOST_CHECK_EQUAL( 0, my_accounts.indices().size() ); + BOOST_CHECK_EQUAL( 0u, my_accounts.indices().size() ); BOOST_CHECK( nullptr == direct.find( account_id_type( 1 ) ) ); // BOOST_CHECK_THROW( direct.find( asset_id_type( 1 ) ), fc::assert_exception ); // compile-time error BOOST_CHECK_THROW( direct.find( object_id_type( asset_id_type( 1 ) ) ), fc::assert_exception ); @@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) my_accounts.load( fc::raw::pack( test_account ) ); - BOOST_CHECK_EQUAL( 1, my_accounts.indices().size() ); + BOOST_CHECK_EQUAL( 1u, my_accounts.indices().size() ); BOOST_CHECK( nullptr == direct.find( account_id_type( 0 ) ) ); BOOST_CHECK( nullptr == direct.find( account_id_type( 2 ) ) ); BOOST_CHECK( nullptr != direct.find( account_id_type( 1 ) ) ); @@ -174,7 +174,7 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) // direct.next is now 103, but index sequence counter is 0 my_accounts.create( [] ( object& o ) { account_object& acct = dynamic_cast< account_object& >( o ); - BOOST_CHECK_EQUAL( 0, acct.id.instance() ); + BOOST_CHECK_EQUAL( 0u, acct.id.instance() ); acct.name = "account0"; } ); @@ -198,7 +198,7 @@ BOOST_AUTO_TEST_CASE( direct_index_test ) GRAPHENE_REQUIRE_THROW( my_accounts.load( fc::raw::pack( test_account ) ), fc::assert_exception ); // This is actually undefined behaviour. The object has been inserted into // the primary index, but the secondary has refused to insert it! - BOOST_CHECK_EQUAL( 5, my_accounts.indices().size() ); + BOOST_CHECK_EQUAL( 5u, my_accounts.indices().size() ); uint32_t count = 0; for( uint32_t i = 0; i < 250; i++ ) diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index 587814815c..a9b24d0ab3 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -437,11 +437,11 @@ BOOST_AUTO_TEST_CASE( cashback_test ) PREP_ACTOR(stud); PREP_ACTOR(pleb); // use ##_public_key vars to silence unused variable warning - BOOST_CHECK_GT(ann_public_key.key_data.size(), 0); - BOOST_CHECK_GT(scud_public_key.key_data.size(), 0); - BOOST_CHECK_GT(dumy_public_key.key_data.size(), 0); - BOOST_CHECK_GT(stud_public_key.key_data.size(), 0); - BOOST_CHECK_GT(pleb_public_key.key_data.size(), 0); + BOOST_CHECK_GT(ann_public_key.key_data.size(), 0u); + BOOST_CHECK_GT(scud_public_key.key_data.size(), 0u); + BOOST_CHECK_GT(dumy_public_key.key_data.size(), 0u); + BOOST_CHECK_GT(stud_public_key.key_data.size(), 0u); + BOOST_CHECK_GT(pleb_public_key.key_data.size(), 0u); account_id_type ann_id, scud_id, dumy_id, stud_id, pleb_id; actor_audit alife, arog, aann, ascud, adumy, astud, apleb; @@ -716,23 +716,23 @@ BOOST_AUTO_TEST_CASE( account_create_fee_scaling ) for( int i = db.get_dynamic_global_properties().accounts_registered_this_interval; i < accounts_per_scale; ++i ) { - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 1); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 1u); create_account("shill" + fc::to_string(i)); } for( int i = 0; i < accounts_per_scale; ++i ) { - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 16); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 16u); create_account("moreshills" + fc::to_string(i)); } for( int i = 0; i < accounts_per_scale; ++i ) { - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 256); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 256u); create_account("moarshills" + fc::to_string(i)); } - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 4096); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 4096u); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); - BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 1); + BOOST_CHECK_EQUAL(db.get_global_properties().parameters.current_fees->get().basic_fee, 1u); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( fee_refund_test ) @@ -3651,31 +3651,31 @@ BOOST_AUTO_TEST_CASE( defaults_test ) // no fees set yet -> default asset fee = schedule.calculate_fee( limit_order_create_operation() ); - BOOST_CHECK_EQUAL( default_order_fee.fee, fee.amount.value ); + BOOST_CHECK_EQUAL( (int64_t)default_order_fee.fee, fee.amount.value ); limit_order_create_operation::fee_parameters_type new_order_fee; new_order_fee.fee = 123; // set fee + check schedule.parameters.insert( new_order_fee ); fee = schedule.calculate_fee( limit_order_create_operation() ); - BOOST_CHECK_EQUAL( new_order_fee.fee, fee.amount.value ); + BOOST_CHECK_EQUAL( (int64_t)new_order_fee.fee, fee.amount.value ); // bid_collateral fee defaults to call_order_update fee // call_order_update fee is unset -> default const call_order_update_operation::fee_parameters_type default_short_fee {}; call_order_update_operation::fee_parameters_type new_short_fee; new_short_fee.fee = 123; fee = schedule.calculate_fee( bid_collateral_operation() ); - BOOST_CHECK_EQUAL( default_short_fee.fee, fee.amount.value ); + BOOST_CHECK_EQUAL( (int64_t)default_short_fee.fee, fee.amount.value ); // set call_order_update fee + check bid_collateral fee schedule.parameters.insert( new_short_fee ); fee = schedule.calculate_fee( bid_collateral_operation() ); - BOOST_CHECK_EQUAL( new_short_fee.fee, fee.amount.value ); + BOOST_CHECK_EQUAL( (int64_t)new_short_fee.fee, fee.amount.value ); // set bid_collateral fee + check bid_collateral_operation::fee_parameters_type new_bid_fee; new_bid_fee.fee = 124; schedule.parameters.insert( new_bid_fee ); fee = schedule.calculate_fee( bid_collateral_operation() ); - BOOST_CHECK_EQUAL( new_bid_fee.fee, fee.amount.value ); + BOOST_CHECK_EQUAL( (int64_t)new_bid_fee.fee, fee.amount.value ); } catch( const fc::exception& e ) { diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index b8f8856384..495a26aa06 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -56,25 +56,25 @@ BOOST_AUTO_TEST_CASE(get_account_history) { //account_id_type() did 3 ops and includes id0 vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 100, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 7u); BOOST_CHECK_EQUAL(histories[2].op.which(), asset_create_op_id); // 1 account_create op larger than id1 histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 100, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK(histories[0].id.instance() != 0); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // Limit 2 returns 2 result histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 2, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 2); + BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK(histories[1].id.instance() != 0); BOOST_CHECK_EQUAL(histories[1].op.which(), account_create_op_id); // bob has 1 op histories = hist_api.get_account_history("bob", operation_history_id_type(), 100, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); @@ -93,14 +93,14 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) { // no history at all in the chain vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(0), 4, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); create_bitasset("USD", account_id_type()); // create op 0 generate_block(); // what if the account only has one history entry and it is 0? histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u); const account_object& dan = create_account("dan"); // create op 1 @@ -114,262 +114,262 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) { // f(A, 0, 4, 9) = { 5, 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(9)); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); // f(A, 0, 4, 6) = { 5, 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(6)); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); // f(A, 0, 4, 5) = { 5, 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(5)); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); // f(A, 0, 4, 4) = { 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(4)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); // f(A, 0, 4, 3) = { 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(3)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); // f(A, 0, 4, 2) = { 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); // f(A, 0, 4, 1) = { 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type(1)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); // f(A, 0, 4, 0) = { 5, 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 4, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); // f(A, 1, 5, 9) = { 5, 3 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(9)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); // f(A, 1, 5, 6) = { 5, 3 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(6)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); // f(A, 1, 5, 5) = { 5, 3 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(5)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); // f(A, 1, 5, 4) = { 3 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(4)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); // f(A, 1, 5, 3) = { 3 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(3)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); // f(A, 1, 5, 2) = { } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // f(A, 1, 5, 1) = { } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(1)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // f(A, 1, 5, 0) = { 5, 3 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 5, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); // f(A, 0, 3, 9) = { 5, 3, 1 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(9)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); // f(A, 0, 3, 6) = { 5, 3, 1 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(6)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); // f(A, 0, 3, 5) = { 5, 3, 1 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(5)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); // f(A, 0, 3, 4) = { 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(4)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); // f(A, 0, 3, 3) = { 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(3)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); // f(A, 0, 3, 2) = { 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); // f(A, 0, 3, 1) = { 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type(1)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); // f(A, 0, 3, 0) = { 5, 3, 1 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 3, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); // f(B, 0, 4, 9) = { 6, 4, 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(9)); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u); // f(B, 0, 4, 6) = { 6, 4, 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(6)); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u); // f(B, 0, 4, 5) = { 4, 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(5)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); // f(B, 0, 4, 4) = { 4, 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(4)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); // f(B, 0, 4, 3) = { 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(3)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); // f(B, 0, 4, 2) = { 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 1u); // f(B, 0, 4, 1) = { 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type(1)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 1u); // f(B, 0, 4, 0) = { 6, 4, 2, 1 } histories = hist_api.get_account_history("dan", operation_history_id_type(), 4, operation_history_id_type()); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 1); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u); // f(B, 2, 4, 9) = { 6, 4 } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(9)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); // f(B, 2, 4, 6) = { 6, 4 } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(6)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); // f(B, 2, 4, 5) = { 4 } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(5)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 4); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); // f(B, 2, 4, 4) = { 4 } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(4)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 4); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); // f(B, 2, 4, 3) = { } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(3)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // f(B, 2, 4, 2) = { } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // f(B, 2, 4, 1) = { } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(1)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // f(B, 2, 4, 0) = { 6, 4 } histories = hist_api.get_account_history("dan", operation_history_id_type(2), 4, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); // 0 limits histories = hist_api.get_account_history("dan", operation_history_id_type(0), 0, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("1.2.0", operation_history_id_type(3), 0, operation_history_id_type(9)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // non existent account histories = hist_api.get_account_history("1.2.18", operation_history_id_type(0), 4, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // create a new account C = alice { 7 } create_account("alice"); @@ -378,21 +378,21 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) { // f(C, 0, 4, 10) = { 7 } histories = hist_api.get_account_history("alice", operation_history_id_type(0), 4, operation_history_id_type(10)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 7); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 7u); // f(C, 8, 4, 10) = { } histories = hist_api.get_account_history("alice", operation_history_id_type(8), 4, operation_history_id_type(10)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // f(A, 0, 10, 0) = { 7, 5, 3, 1, 0 } histories = hist_api.get_account_history("1.2.0", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 5); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 7); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 5); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[4].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 5u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 7u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 5u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[4].id.instance(), 0u); } catch (fc::exception &e) { @@ -425,25 +425,25 @@ BOOST_AUTO_TEST_CASE(track_account) { // anything against account_id_type() should be {} vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("1.2.0", operation_history_id_type(1), 1, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // anything against alice should be {} histories = hist_api.get_account_history("alice", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("alice", operation_history_id_type(1), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("alice", operation_history_id_type(1), 1, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // dan should have history histories = hist_api.get_account_history("dan", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u); // create more ops, starting with an untracked account create_bitasset( "BTC", account_id_type() ); @@ -452,10 +452,10 @@ BOOST_AUTO_TEST_CASE(track_account) { generate_block( ~database::skip_fork_db ); histories = hist_api.get_account_history("dan", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 3u); db.pop_block(); @@ -466,10 +466,10 @@ BOOST_AUTO_TEST_CASE(track_account) { generate_block(); histories = hist_api.get_account_history("dan", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 3); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 6); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 3u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 6u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 3u); } catch (fc::exception &e) { edump((e.to_detail_string())); throw; @@ -499,35 +499,35 @@ BOOST_AUTO_TEST_CASE(track_account2) { // all account_id_type() should have 4 ops {4,2,1,0} vector histories = hist_api.get_account_history("committee-account", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 4); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 4); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 2); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 1); - BOOST_CHECK_EQUAL(histories[3].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 4u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 4u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 2u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 1u); + BOOST_CHECK_EQUAL(histories[3].id.instance(), 0u); // all alice account should have 2 ops {3, 0} histories = hist_api.get_account_history("alice", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 2); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); - BOOST_CHECK_EQUAL(histories[1].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 2u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); + BOOST_CHECK_EQUAL(histories[1].id.instance(), 0u); // alice first op should be {0} histories = hist_api.get_account_history("alice", operation_history_id_type(0), 1, operation_history_id_type(1)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u); // alice second op should be {3} histories = hist_api.get_account_history("alice", operation_history_id_type(1), 1, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 3); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 3u); // anything against dan should be {} histories = hist_api.get_account_history("dan", operation_history_id_type(0), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("dan", operation_history_id_type(1), 10, operation_history_id_type(0)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); histories = hist_api.get_account_history("dan", operation_history_id_type(1), 1, operation_history_id_type(2)); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); } catch (fc::exception &e) { edump((e.to_detail_string())); @@ -554,31 +554,31 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { //account_id_type() did 1 asset_create op vector histories = hist_api.get_account_history_operations( "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); - BOOST_CHECK_EQUAL(histories.size(), 1); - BOOST_CHECK_EQUAL(histories[0].id.instance(), 0); + BOOST_CHECK_EQUAL(histories.size(), 1u); + BOOST_CHECK_EQUAL(histories[0].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[0].op.which(), asset_create_op_id); //account_id_type() did 2 account_create ops histories = hist_api.get_account_history_operations( "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); - BOOST_CHECK_EQUAL(histories.size(), 2); + BOOST_CHECK_EQUAL(histories.size(), 2u); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // No asset_create op larger than id1 histories = hist_api.get_account_history_operations( "committee-account", asset_create_op_id, operation_history_id_type(), operation_history_id_type(1), 100); - BOOST_CHECK_EQUAL(histories.size(), 0); + BOOST_CHECK_EQUAL(histories.size(), 0u); // Limit 1 returns 1 result histories = hist_api.get_account_history_operations( "committee-account", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 1); - BOOST_CHECK_EQUAL(histories.size(), 1); + BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // alice has 1 op histories = hist_api.get_account_history_operations( - "alice", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 100); - BOOST_CHECK_EQUAL(histories.size(), 1); + "alice", account_create_op_id, operation_history_id_type(),operation_history_id_type(), 100); + BOOST_CHECK_EQUAL(histories.size(), 1u); BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); // create a bunch of accounts diff --git a/tests/tests/market_rounding_tests.cpp b/tests/tests/market_rounding_tests.cpp index 8c406f32e7..b71e1cd0ff 100644 --- a/tests/tests/market_rounding_tests.cpp +++ b/tests/tests/market_rounding_tests.cpp @@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE( trade_amount_equals_zero ) fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread auto result = get_market_order_history(core_id, test_id); - BOOST_CHECK_EQUAL(result.size(), 4); + BOOST_CHECK_EQUAL(result.size(), 4u); BOOST_CHECK(result[0].op.pays == core_id(db).amount(0)); BOOST_CHECK(result[0].op.receives == test_id(db).amount(1)); BOOST_CHECK(result[1].op.pays == test_id(db).amount(1)); @@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE( trade_amount_equals_zero_after_hf_184 ) fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread auto result = get_market_order_history(core_id, test_id); - BOOST_CHECK_EQUAL(result.size(), 2); + BOOST_CHECK_EQUAL(result.size(), 2u); BOOST_CHECK(result[0].op.pays == core_id(db).amount(1)); BOOST_CHECK(result[0].op.receives == test_id(db).amount(2)); BOOST_CHECK(result[1].op.pays == test_id(db).amount(2)); diff --git a/tests/tests/network_broadcast_api_tests.cpp b/tests/tests/network_broadcast_api_tests.cpp index 83d4c7fd1d..a566750b67 100644 --- a/tests/tests/network_broadcast_api_tests.cpp +++ b/tests/tests/network_broadcast_api_tests.cpp @@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE( broadcast_transaction_with_callback_test ) { fc::usleep(fc::milliseconds(200)); // sleep a while to execute callback in another thread - BOOST_CHECK_EQUAL( called, 1 ); + BOOST_CHECK_EQUAL( called, 1u ); } FC_LOG_AND_RETHROW() } diff --git a/tests/tests/operation_tests.cpp b/tests/tests/operation_tests.cpp index 398eb42b11..b2edab15ad 100644 --- a/tests/tests/operation_tests.cpp +++ b/tests/tests/operation_tests.cpp @@ -1731,7 +1731,7 @@ BOOST_AUTO_TEST_CASE( witness_feeds ) vector active_witnesses; for( const witness_id_type& wit_id : global_props.active_witnesses ) active_witnesses.push_back( wit_id(db).witness_account ); - BOOST_REQUIRE_EQUAL(active_witnesses.size(), 10); + BOOST_REQUIRE_EQUAL(active_witnesses.size(), 10u); asset_publish_feed_operation op; op.publisher = active_witnesses[0]; @@ -1828,7 +1828,7 @@ BOOST_AUTO_TEST_CASE( witness_pay_test ) const asset_object* core = &asset_id_type()(db); const account_object* nathan = &get_account("nathan"); enable_fees(); - BOOST_CHECK_GT(db.current_fee_schedule().get().membership_lifetime_fee, 0); + BOOST_CHECK_GT(db.current_fee_schedule().get().membership_lifetime_fee, 0u); // Based on the size of the reserve fund later in the test, the witness budget will be set to this value const uint64_t ref_budget = ((uint64_t( db.current_fee_schedule().get().membership_lifetime_fee ) @@ -1838,10 +1838,10 @@ BOOST_AUTO_TEST_CASE( witness_pay_test ) ) >> GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS ; // change this if ref_budget changes - BOOST_CHECK_EQUAL( ref_budget, 594 ); + BOOST_CHECK_EQUAL( ref_budget, 594u ); const uint64_t witness_ppb = ref_budget * 10 / 23 + 1; // change this if ref_budget changes - BOOST_CHECK_EQUAL( witness_ppb, 259 ); + BOOST_CHECK_EQUAL( witness_ppb, 259u ); // following two inequalities need to hold for maximal code coverage BOOST_CHECK_LT( witness_ppb * 2, ref_budget ); BOOST_CHECK_GT( witness_ppb * 3, ref_budget ); @@ -1887,28 +1887,28 @@ BOOST_AUTO_TEST_CASE( witness_pay_test ) generate_block(); BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, 0 ); } - BOOST_CHECK_EQUAL( db.head_block_time().sec_since_epoch() - pay_fee_time, 24 * block_interval ); + BOOST_CHECK_EQUAL( db.head_block_time().sec_since_epoch() - pay_fee_time, 24u * block_interval ); schedule_maint(); // The 80% lifetime referral fee went to the committee account, which burned it. Check that it's here. BOOST_CHECK( core->reserved(db).value == 8000*prec ); generate_block(); BOOST_CHECK_EQUAL( core->reserved(db).value, 999999406 ); - BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, ref_budget ); + BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, (int64_t)ref_budget ); // first witness paid from old budget (so no pay) BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, 0 ); // second witness finally gets paid! generate_block(); - BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, witness_ppb ); - BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, ref_budget - witness_ppb ); + BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, (int64_t)witness_ppb ); + BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, (int64_t)(ref_budget - witness_ppb) ); generate_block(); - BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, witness_ppb ); - BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, ref_budget - 2 * witness_ppb ); + BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, (int64_t)witness_ppb ); + BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, (int64_t)(ref_budget - 2 * witness_ppb) ); generate_block(); - BOOST_CHECK_LT( last_witness_vbo_balance().value, witness_ppb ); - BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, ref_budget - 2 * witness_ppb ); + BOOST_CHECK_LT( last_witness_vbo_balance().value, (int64_t)witness_ppb ); + BOOST_CHECK_EQUAL( last_witness_vbo_balance().value, (int64_t)(ref_budget - 2 * witness_ppb) ); BOOST_CHECK_EQUAL( db.get_dynamic_global_properties().witness_budget.value, 0 ); generate_block(); diff --git a/tests/tests/operation_tests2.cpp b/tests/tests/operation_tests2.cpp index 15df1b2ece..a5c7b839c9 100644 --- a/tests/tests/operation_tests2.cpp +++ b/tests/tests/operation_tests2.cpp @@ -968,7 +968,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds ) } { const asset_bitasset_data_object& obj = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(obj.feeds.size(), 3); + BOOST_CHECK_EQUAL(obj.feeds.size(), 3u); BOOST_CHECK(obj.current_feed == price_feed()); } { @@ -1086,7 +1086,7 @@ BOOST_AUTO_TEST_CASE( witness_create ) witness_id_type nathan_witness_id = create_witness(nathan_id, nathan_private_key, skip).id; // nathan should be in the cache - BOOST_CHECK_EQUAL( caching_witnesses.count(nathan_witness_id), 1 ); + BOOST_CHECK_EQUAL( caching_witnesses.count(nathan_witness_id), 1u ); // nathan's key in the cache should still be null before a new block is generated auto nathan_itr = wit_key_cache.find( nathan_witness_id ); diff --git a/tests/tests/smartcoin_tests.cpp b/tests/tests/smartcoin_tests.cpp index ffa80f7551..9610e456ab 100644 --- a/tests/tests/smartcoin_tests.cpp +++ b/tests/tests/smartcoin_tests.cpp @@ -132,17 +132,17 @@ BOOST_AUTO_TEST_CASE(bsip36) // Check current default witnesses, default chain is configured with 10 witnesses auto witnesses = db.get_global_properties().active_witnesses; - BOOST_CHECK_EQUAL(witnesses.size(), 10); - BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 1); - BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 2); - BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 3); - BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 4); - BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 5); - BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 6); - BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 7); - BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 8); - BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 9); - BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 10); + BOOST_CHECK_EQUAL(witnesses.size(), 10u); + BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 1u); + BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 2u); + BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 3u); + BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 4u); + BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 5u); + BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 6u); + BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 7u); + BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 8u); + BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 9u); + BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 10u); // We need to activate 11 witnesses by voting for each of them. // Each witness is voted with incremental stake so last witness created will be the ones with more votes @@ -172,18 +172,18 @@ BOOST_AUTO_TEST_CASE(bsip36) // Check my witnesses are now in control of the system witnesses = db.get_global_properties().active_witnesses; - BOOST_CHECK_EQUAL(witnesses.size(), 11); - BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 11); - BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 12); - BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 13); - BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 14); - BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 15); - BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 16); - BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 17); - BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 18); - BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 19); - BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 20); - BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 21); + BOOST_CHECK_EQUAL(witnesses.size(), 11u); + BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 11u); + BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 12u); + BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 13u); + BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 14u); + BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 15u); + BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 16u); + BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 17u); + BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 18u); + BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 19u); + BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 20u); + BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 21u); // Adding 2 feeds with witnesses 0 and 1, checking if they get inserted const asset_object &core = asset_id_type()(db); @@ -192,18 +192,18 @@ BOOST_AUTO_TEST_CASE(bsip36) publish_feed(bit_usd_id(db), witness0_id(db), feed); asset_bitasset_data_object bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1u); auto itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16u); feed.settlement_price = bit_usd_id(db).amount(2) / core.amount(5); publish_feed(bit_usd_id(db), witness1_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 17); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 17u); // Activate witness11 with voting stake, will kick the witness with less votes(witness0) out of the active list transfer(committee_account, witness11_id, asset(121)); @@ -228,32 +228,32 @@ BOOST_AUTO_TEST_CASE(bsip36) // Check active witness list now witnesses = db.get_global_properties().active_witnesses; - BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 12); - BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 13); - BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 14); - BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 15); - BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 16); - BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 17); - BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 18); - BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 19); - BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 20); - BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 21); - BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 22); + BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 12u); + BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 13u); + BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 14u); + BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 15u); + BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 16u); + BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 17u); + BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 18u); + BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 19u); + BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 20u); + BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 21u); + BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 22u); // witness0 has been removed but it was a feeder before // Feed persist in the blockchain, this reproduces the issue bitasset_data = bit_usd_id(db).bitasset_data(db); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16u); // Feed persist after expiration const auto feed_lifetime = bit_usd_id(db).bitasset_data(db).options.feed_lifetime_sec; generate_blocks(db.head_block_time() + feed_lifetime + 1); bitasset_data = bit_usd_id(db).bitasset_data(db); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16u); // Other witnesses add more feeds feed.settlement_price = bit_usd_id(db).amount(4) / core.amount(5); @@ -264,14 +264,14 @@ BOOST_AUTO_TEST_CASE(bsip36) // But the one from witness0 is never removed bitasset_data = bit_usd_id(db).bitasset_data(db); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 4); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 4u); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16u); // Feed from witness1 is also expired but never deleted // All feeds should be deleted at this point const auto minimum_feeds = bit_usd_id(db).bitasset_data(db).options.minimum_feeds; - BOOST_CHECK_EQUAL(minimum_feeds, 1); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 17); + BOOST_CHECK_EQUAL(minimum_feeds, 1u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 17u); // Advancing into HF time generate_blocks(HARDFORK_CORE_518_TIME); @@ -281,15 +281,15 @@ BOOST_AUTO_TEST_CASE(bsip36) // All expired feeds are deleted bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 0); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 0u); // witness1 start feed producing again feed.settlement_price = bit_usd_id(db).amount(1) / core.amount(5); publish_feed(bit_usd_id(db), witness1_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); // generate some blocks up to expiration but feed will not be deleted yet as need next maint time generate_blocks(itr[0].second.first + feed_lifetime + 1); @@ -298,10 +298,10 @@ BOOST_AUTO_TEST_CASE(bsip36) feed.settlement_price = bit_usd_id(db).amount(1) / core.amount(5); publish_feed(bit_usd_id(db), witness2_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18u); // make the first feed expire generate_blocks(itr[0].second.first + feed_lifetime + 1); @@ -309,23 +309,23 @@ BOOST_AUTO_TEST_CASE(bsip36) // feed from witness0 expires and gets deleted, feed from witness is on time so persist bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 18); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 18u); // expire everything generate_blocks(itr[0].second.first + feed_lifetime + 1); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 0); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 0u); // add new feed with witness1 feed.settlement_price = bit_usd_id(db).amount(1) / core.amount(5); publish_feed(bit_usd_id(db), witness1_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); // Reactivate witness0 transfer(committee_account, witness0_id, asset(100)); @@ -350,29 +350,29 @@ BOOST_AUTO_TEST_CASE(bsip36) // Checking witnesses = db.get_global_properties().active_witnesses; - BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 11); - BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 13); - BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 14); - BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 15); - BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 16); - BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 17); - BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 18); - BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 19); - BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 20); - BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 21); - BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 22); + BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 11u); + BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 13u); + BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 14u); + BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 15u); + BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 16u); + BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 17u); + BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 18u); + BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 19u); + BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 20u); + BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 21u); + BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 22u); // feed from witness1 is still here as the witness is no longer a producer but the feed is not yet expired - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); // make feed from witness1 expire generate_blocks(itr[0].second.first + feed_lifetime + 1); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 0); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 0u); } FC_LOG_AND_RETHROW() } @@ -418,11 +418,11 @@ BOOST_AUTO_TEST_CASE(bsip36_update_feed_producers) // Bitshares will create entries in the field feed after feed producers are added auto bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3u); auto itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 17); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 18); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 16u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 17u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 18u); // Removing a feed producer { @@ -439,19 +439,19 @@ BOOST_AUTO_TEST_CASE(bsip36_update_feed_producers) // Feed for removed producer is removed bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18u); // Feed persist after expiration const auto feed_lifetime = bit_usd_id(db).bitasset_data(db).options.feed_lifetime_sec; generate_blocks(db.head_block_time() + feed_lifetime + 1); bitasset_data = bit_usd_id(db).bitasset_data(db); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18u); // Advancing into HF time generate_blocks(HARDFORK_CORE_518_TIME); @@ -462,9 +462,9 @@ BOOST_AUTO_TEST_CASE(bsip36_update_feed_producers) // Expired feeds persist, no changes bitasset_data = bit_usd_id(db).bitasset_data(db); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 17u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 18u); } FC_LOG_AND_RETHROW() } @@ -507,9 +507,9 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness5_id(db), feed); auto bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 1u); auto itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); @@ -517,10 +517,10 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness6_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22u); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); @@ -528,11 +528,11 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness7_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23u); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); @@ -540,12 +540,12 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness8_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 4); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 4u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23); - BOOST_CHECK_EQUAL(itr[3].first.instance.value, 24); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23u); + BOOST_CHECK_EQUAL(itr[3].first.instance.value, 24u); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); @@ -553,13 +553,13 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness9_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 5); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 5u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23); - BOOST_CHECK_EQUAL(itr[3].first.instance.value, 24); - BOOST_CHECK_EQUAL(itr[4].first.instance.value, 25); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23u); + BOOST_CHECK_EQUAL(itr[3].first.instance.value, 24u); + BOOST_CHECK_EQUAL(itr[4].first.instance.value, 25u); generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); @@ -567,27 +567,27 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness10_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 6); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 6u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23); - BOOST_CHECK_EQUAL(itr[3].first.instance.value, 24); - BOOST_CHECK_EQUAL(itr[4].first.instance.value, 25); - BOOST_CHECK_EQUAL(itr[5].first.instance.value, 26); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 22u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 23u); + BOOST_CHECK_EQUAL(itr[3].first.instance.value, 24u); + BOOST_CHECK_EQUAL(itr[4].first.instance.value, 25u); + BOOST_CHECK_EQUAL(itr[5].first.instance.value, 26u); // make the older feed expire generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 5); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 5u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 22); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 23); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 24); - BOOST_CHECK_EQUAL(itr[3].first.instance.value, 25); - BOOST_CHECK_EQUAL(itr[4].first.instance.value, 26); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 22u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 23u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 24u); + BOOST_CHECK_EQUAL(itr[3].first.instance.value, 25u); + BOOST_CHECK_EQUAL(itr[4].first.instance.value, 26u); // make older 2 feeds expire generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); @@ -596,41 +596,41 @@ BOOST_AUTO_TEST_CASE(bsip36_additional) generate_block(); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 24); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 25); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 26); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 24u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 25u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 26u); // witness5 add new feed, feeds are sorted by witness_id not by feed_time feed.settlement_price = bit_usd_id(db).amount(1) / core_id(db).amount(5); publish_feed(bit_usd_id(db), witness5_id(db), feed); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 4); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 4u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 24); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 25); - BOOST_CHECK_EQUAL(itr[3].first.instance.value, 26); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 24u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 25u); + BOOST_CHECK_EQUAL(itr[3].first.instance.value, 26u); // another feed expires generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 3u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[1].first.instance.value, 25); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 26); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[1].first.instance.value, 25u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 26u); // another feed expires generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); generate_block(); bitasset_data = bit_usd_id(db).bitasset_data(db); - BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2); + BOOST_CHECK_EQUAL(bitasset_data.feeds.size(), 2u); itr = bitasset_data.feeds.begin(); - BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21); - BOOST_CHECK_EQUAL(itr[2].first.instance.value, 26); + BOOST_CHECK_EQUAL(itr[0].first.instance.value, 21u); + BOOST_CHECK_EQUAL(itr[2].first.instance.value, 26u); // and so on diff --git a/tests/tests/swan_tests.cpp b/tests/tests/swan_tests.cpp index 5b9b5c3f20..8488e839fa 100644 --- a/tests/tests/swan_tests.cpp +++ b/tests/tests/swan_tests.cpp @@ -368,13 +368,13 @@ BOOST_AUTO_TEST_CASE( recollateralize ) graphene::app::database_api db_api(db); GRAPHENE_REQUIRE_THROW( db_api.get_collateral_bids(back().id, 100, 0), fc::assert_exception ); vector bids = db_api.get_collateral_bids(_swan, 100, 1); - BOOST_CHECK_EQUAL( 1, bids.size() ); + BOOST_CHECK_EQUAL( 1u, bids.size() ); FC_ASSERT( _borrower2 == bids[0].bidder ); bids = db_api.get_collateral_bids(_swan, 1, 0); - BOOST_CHECK_EQUAL( 1, bids.size() ); + BOOST_CHECK_EQUAL( 1u, bids.size() ); FC_ASSERT( _borrower == bids[0].bidder ); bids = db_api.get_collateral_bids(_swan, 100, 0); - BOOST_CHECK_EQUAL( 2, bids.size() ); + BOOST_CHECK_EQUAL( 2u, bids.size() ); FC_ASSERT( _borrower == bids[0].bidder ); FC_ASSERT( _borrower2 == bids[1].bidder ); diff --git a/tests/tests/voting_tests.cpp b/tests/tests/voting_tests.cpp index 141c19e0f3..df92ccf061 100644 --- a/tests/tests/voting_tests.cpp +++ b/tests/tests/voting_tests.cpp @@ -129,17 +129,17 @@ BOOST_AUTO_TEST_CASE(put_my_witnesses) // Check current default witnesses, default chain is configured with 10 witnesses auto witnesses = db.get_global_properties().active_witnesses; - BOOST_CHECK_EQUAL(witnesses.size(), 10); - BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 1); - BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 2); - BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 3); - BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 4); - BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 5); - BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 6); - BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 7); - BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 8); - BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 9); - BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 10); + BOOST_CHECK_EQUAL(witnesses.size(), 10u); + BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 1u); + BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 2u); + BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 3u); + BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 4u); + BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 5u); + BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 6u); + BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 7u); + BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 8u); + BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 9u); + BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 10u); // Activate all witnesses // Each witness is voted with incremental stake so last witness created will be the ones with more votes @@ -168,18 +168,18 @@ BOOST_AUTO_TEST_CASE(put_my_witnesses) // Check my witnesses are now in control of the system witnesses = db.get_global_properties().active_witnesses; - BOOST_CHECK_EQUAL(witnesses.size(), 11); - BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 14); - BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 15); - BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 16); - BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 17); - BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 18); - BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 19); - BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 20); - BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 21); - BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 22); - BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 23); - BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 24); + BOOST_CHECK_EQUAL(witnesses.size(), 11u); + BOOST_CHECK_EQUAL(witnesses.begin()[0].instance.value, 14u); + BOOST_CHECK_EQUAL(witnesses.begin()[1].instance.value, 15u); + BOOST_CHECK_EQUAL(witnesses.begin()[2].instance.value, 16u); + BOOST_CHECK_EQUAL(witnesses.begin()[3].instance.value, 17u); + BOOST_CHECK_EQUAL(witnesses.begin()[4].instance.value, 18u); + BOOST_CHECK_EQUAL(witnesses.begin()[5].instance.value, 19u); + BOOST_CHECK_EQUAL(witnesses.begin()[6].instance.value, 20u); + BOOST_CHECK_EQUAL(witnesses.begin()[7].instance.value, 21u); + BOOST_CHECK_EQUAL(witnesses.begin()[8].instance.value, 22u); + BOOST_CHECK_EQUAL(witnesses.begin()[9].instance.value, 23u); + BOOST_CHECK_EQUAL(witnesses.begin()[10].instance.value, 24u); } FC_LOG_AND_RETHROW() } @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(track_votes_witnesses_enabled) const account_id_type witness1_id= get_account("witness1").id; auto witness1_object = db_api1.get_witness_by_account(witness1_id(db).name); - BOOST_CHECK_EQUAL(witness1_object->total_votes, 111); + BOOST_CHECK_EQUAL(witness1_object->total_votes, 111u); } FC_LOG_AND_RETHROW() } @@ -209,7 +209,7 @@ BOOST_AUTO_TEST_CASE(track_votes_witnesses_disabled) const account_id_type witness1_id= get_account("witness1").id; auto witness1_object = db_api1.get_witness_by_account(witness1_id(db).name); - BOOST_CHECK_EQUAL(witness1_object->total_votes, 0); + BOOST_CHECK_EQUAL(witness1_object->total_votes, 0u); } FC_LOG_AND_RETHROW() } @@ -306,17 +306,17 @@ BOOST_AUTO_TEST_CASE(put_my_committee_members) // Check current default witnesses, default chain is configured with 10 witnesses auto committee_members = db.get_global_properties().active_committee_members; - BOOST_CHECK_EQUAL(committee_members.size(), 10); - BOOST_CHECK_EQUAL(committee_members.begin()[0].instance.value, 0); - BOOST_CHECK_EQUAL(committee_members.begin()[1].instance.value, 1); - BOOST_CHECK_EQUAL(committee_members.begin()[2].instance.value, 2); - BOOST_CHECK_EQUAL(committee_members.begin()[3].instance.value, 3); - BOOST_CHECK_EQUAL(committee_members.begin()[4].instance.value, 4); - BOOST_CHECK_EQUAL(committee_members.begin()[5].instance.value, 5); - BOOST_CHECK_EQUAL(committee_members.begin()[6].instance.value, 6); - BOOST_CHECK_EQUAL(committee_members.begin()[7].instance.value, 7); - BOOST_CHECK_EQUAL(committee_members.begin()[8].instance.value, 8); - BOOST_CHECK_EQUAL(committee_members.begin()[9].instance.value, 9); + BOOST_CHECK_EQUAL(committee_members.size(), 10u); + BOOST_CHECK_EQUAL(committee_members.begin()[0].instance.value, 0u); + BOOST_CHECK_EQUAL(committee_members.begin()[1].instance.value, 1u); + BOOST_CHECK_EQUAL(committee_members.begin()[2].instance.value, 2u); + BOOST_CHECK_EQUAL(committee_members.begin()[3].instance.value, 3u); + BOOST_CHECK_EQUAL(committee_members.begin()[4].instance.value, 4u); + BOOST_CHECK_EQUAL(committee_members.begin()[5].instance.value, 5u); + BOOST_CHECK_EQUAL(committee_members.begin()[6].instance.value, 6u); + BOOST_CHECK_EQUAL(committee_members.begin()[7].instance.value, 7u); + BOOST_CHECK_EQUAL(committee_members.begin()[8].instance.value, 8u); + BOOST_CHECK_EQUAL(committee_members.begin()[9].instance.value, 9u); // Activate all committee // Each witness is voted with incremental stake so last witness created will be the ones with more votes @@ -345,7 +345,7 @@ BOOST_AUTO_TEST_CASE(put_my_committee_members) // Check my witnesses are now in control of the system committee_members = db.get_global_properties().active_committee_members; - BOOST_CHECK_EQUAL(committee_members.size(), 11); + BOOST_CHECK_EQUAL(committee_members.size(), 11u); /* TODO we are not in full control, seems to committee members have votes by default BOOST_CHECK_EQUAL(committee_members.begin()[0].instance.value, 14); @@ -373,7 +373,7 @@ BOOST_AUTO_TEST_CASE(track_votes_committee_enabled) const account_id_type committee1_id= get_account("committee1").id; auto committee1_object = db_api1.get_committee_member_by_account(committee1_id(db).name); - BOOST_CHECK_EQUAL(committee1_object->total_votes, 111); + BOOST_CHECK_EQUAL(committee1_object->total_votes, 111u); } FC_LOG_AND_RETHROW() } @@ -388,7 +388,7 @@ BOOST_AUTO_TEST_CASE(track_votes_committee_disabled) const account_id_type committee1_id= get_account("committee1").id; auto committee1_object = db_api1.get_committee_member_by_account(committee1_id(db).name); - BOOST_CHECK_EQUAL(committee1_object->total_votes, 0); + BOOST_CHECK_EQUAL(committee1_object->total_votes, 0u); } FC_LOG_AND_RETHROW() } @@ -426,7 +426,7 @@ BOOST_AUTO_TEST_CASE(last_voting_date) auto witness1 = witness_id_type(1)(db); auto stats_obj = db.get_account_stats_by_owner(alice_id); - BOOST_CHECK_EQUAL(stats_obj.last_vote_time.sec_since_epoch(), 0); + BOOST_CHECK_EQUAL(stats_obj.last_vote_time.sec_since_epoch(), 0u); // alice votes graphene::chain::account_update_operation op; @@ -488,7 +488,6 @@ BOOST_AUTO_TEST_CASE(last_voting_date_proxy) PUSH_TX( db, trx, ~0 ); } // last_vote_time is not updated - auto round2 = db.head_block_time().sec_since_epoch(); alice_stats_obj = db.get_account_stats_by_owner(alice_id); BOOST_CHECK_EQUAL(alice_stats_obj.last_vote_time.sec_since_epoch(), round1); From 33d6d99bb50beb23ebb9a29870c659c8a6d4ff77 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 28 Dec 2018 15:04:48 -0500 Subject: [PATCH 103/172] revert accidental change --- tests/tests/history_api_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 495a26aa06..48e4833da2 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE(get_account_history) { vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(), 100, operation_history_id_type()); BOOST_CHECK_EQUAL(histories.size(), 3u); - BOOST_CHECK_EQUAL(histories[2].id.instance(), 7u); + BOOST_CHECK_EQUAL(histories[2].id.instance(), 0u); BOOST_CHECK_EQUAL(histories[2].op.which(), asset_create_op_id); // 1 account_create op larger than id1 From d3c2b57338d169ea68920a135ebb57dc79637099 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 1 Jan 2019 10:28:19 -0500 Subject: [PATCH 104/172] Revert adding compile switches -Wno-??? --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b81422ae50..faf3a59f6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,7 +115,7 @@ else( WIN32 ) # Apple AND Linux else( APPLE ) # Linux Specific Options Here message( STATUS "Configuring BitShares on Linux" ) - set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall -Wno-class-memaccess -Wno-parentheses" ) + set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wall" ) if(USE_PROFILER) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg" ) endif( USE_PROFILER ) From a97880500ea41415b285e61ac2a98781466515ca Mon Sep 17 00:00:00 2001 From: John Jones Date: Wed, 2 Jan 2019 09:57:09 -0500 Subject: [PATCH 105/172] prevent throw in destructor --- libraries/db/undo_database.cpp | 2 +- tests/common/database_fixture.cpp | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/libraries/db/undo_database.cpp b/libraries/db/undo_database.cpp index bb05f2a6eb..3e340728e3 100644 --- a/libraries/db/undo_database.cpp +++ b/libraries/db/undo_database.cpp @@ -38,7 +38,7 @@ undo_database::session::~session() catch ( const fc::exception& e ) { elog( "${e}", ("e",e.to_detail_string() ) ); - throw; // maybe crash.. + std::terminate(); } if( _disable_on_exit ) _db.disable(); } diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index a77854cd22..1f08d0ef25 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -208,16 +208,20 @@ database_fixture::database_fixture() } database_fixture::~database_fixture() -{ try { - // If we're unwinding due to an exception, don't do any more checks. - // This way, boost test's last checkpoint tells us approximately where the error was. - if( !std::uncaught_exception() ) - { - verify_asset_supplies(db); - BOOST_CHECK( db.get_node_properties().skip_flags == database::skip_nothing ); +{ + try { + // If we're unwinding due to an exception, don't do any more checks. + // This way, boost test's last checkpoint tells us approximately where the error was. + if( !std::uncaught_exception() ) + { + verify_asset_supplies(db); + BOOST_CHECK( db.get_node_properties().skip_flags == database::skip_nothing ); + } + return; + } catch (fc::exception& ex) { + BOOST_FAIL( ex.to_detail_string() ); } - return; -} FC_CAPTURE_AND_RETHROW() } +} fc::ecc::private_key database_fixture::generate_private_key(string seed) { From 14f71f23becb4933bc1761930c45d69e2d2b4d3d Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 4 Jan 2019 08:18:06 -0500 Subject: [PATCH 106/172] removed boost signals (no longer used) --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index faf3a59f6d..948d7412cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,6 @@ LIST(APPEND BOOST_COMPONENTS thread system filesystem program_options - signals serialization chrono unit_test_framework From e338fdbd5773e07ef817bf530e60bde1acb52eb0 Mon Sep 17 00:00:00 2001 From: jmjatlanta Date: Mon, 7 Jan 2019 10:47:53 -0500 Subject: [PATCH 107/172] refactor template instantiation --- libraries/chain/db_management.cpp | 1 - libraries/chain/fork_database.cpp | 2 -- libraries/chain/protocol/fee_schedule.cpp | 1 + 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index 231cc3ebc9..9167768f48 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -31,7 +31,6 @@ #include #include -#include #include #include diff --git a/libraries/chain/fork_database.cpp b/libraries/chain/fork_database.cpp index 71da27629b..c77b7ee58e 100644 --- a/libraries/chain/fork_database.cpp +++ b/libraries/chain/fork_database.cpp @@ -24,8 +24,6 @@ #include #include -#include - namespace graphene { namespace chain { fork_database::fork_database() { diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/chain/protocol/fee_schedule.cpp index 911f7ac924..d71c58a0aa 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/chain/protocol/fee_schedule.cpp @@ -33,6 +33,7 @@ namespace fc //template graphene::chain::fee_schedule& smart_ref::operator=(const smart_ref&); //template smart_ref::smart_ref(); //template const graphene::chain::fee_schedule& smart_ref::operator*() const; + template smart_ref::smart_ref(smart_ref const&); } #define MAX_FEE_STABILIZATION_ITERATION 4 From 07bedf78f5f62ae6fea84eb6757f41b978eac8dd Mon Sep 17 00:00:00 2001 From: jmjatlanta Date: Mon, 7 Jan 2019 12:05:45 -0500 Subject: [PATCH 108/172] switch variable from size_t to uint64_t --- libraries/db/include/graphene/db/index.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index 4b54862899..2ba0c76a3c 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -210,7 +210,7 @@ namespace graphene { namespace db { // private static const size_t MAX_HOLE = 100; static const size_t _mask = ((1 << chunkbits) - 1); - size_t next = 0; + uint64_t next = 0; vector< vector< const Object* > > content; std::stack< object_id_type > ids_being_modified; From 53feeff43874a85bddb052f5d32befe9700002ae Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 7 Jan 2019 13:58:55 -0500 Subject: [PATCH 109/172] Reject get_key_references with > 100 keys --- libraries/app/database_api.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 3afa4dc643..28182fd08d 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -539,6 +539,7 @@ dynamic_global_property_object database_api_impl::get_dynamic_global_properties( vector> database_api::get_key_references( vector key )const { + FC_ASSERT(key.size() <= 100, "Number of keys must be 100 or less"); return my->get_key_references( key ); } From 87dcfa1658e79aaa8fbfe1a0fa604d02a65bf3b6 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 7 Jan 2019 14:32:50 -0500 Subject: [PATCH 110/172] Remove use of skip_fork_db flag --- libraries/chain/db_block.cpp | 134 +++++++++--------- .../chain/include/graphene/chain/database.hpp | 1 - tests/tests/history_api_tests.cpp | 4 +- 3 files changed, 66 insertions(+), 73 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index fdf4b4a15e..6571586445 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -129,77 +129,74 @@ bool database::push_block(const signed_block& new_block, uint32_t skip) bool database::_push_block(const signed_block& new_block) { try { uint32_t skip = get_node_properties().skip_flags; - if( !(skip&skip_fork_db) ) - { - /// TODO: if the block is greater than the head block and before the next maitenance interval - // verify that the block signer is in the current set of active witnesses. + /// TODO: if the block is greater than the head block and before the next maitenance interval + // verify that the block signer is in the current set of active witnesses. - shared_ptr new_head = _fork_db.push_block(new_block); - //If the head block from the longest chain does not build off of the current head, we need to switch forks. - if( new_head->data.previous != head_block_id() ) + shared_ptr new_head = _fork_db.push_block(new_block); + //If the head block from the longest chain does not build off of the current head, we need to switch forks. + if( new_head->data.previous != head_block_id() ) + { + //If the newly pushed block is the same height as head, we get head back in new_head + //Only switch forks if new_head is actually higher than head + if( new_head->data.block_num() > head_block_num() ) { - //If the newly pushed block is the same height as head, we get head back in new_head - //Only switch forks if new_head is actually higher than head - if( new_head->data.block_num() > head_block_num() ) + wlog( "Switching to fork: ${id}", ("id",new_head->data.id()) ); + auto branches = _fork_db.fetch_branch_from(new_head->data.id(), head_block_id()); + + // pop blocks until we hit the forked block + while( head_block_id() != branches.second.back()->data.previous ) + { + ilog( "popping block #${n} ${id}", ("n",head_block_num())("id",head_block_id()) ); + pop_block(); + } + + // push all blocks on the new fork + for( auto ritr = branches.first.rbegin(); ritr != branches.first.rend(); ++ritr ) { - wlog( "Switching to fork: ${id}", ("id",new_head->data.id()) ); - auto branches = _fork_db.fetch_branch_from(new_head->data.id(), head_block_id()); - - // pop blocks until we hit the forked block - while( head_block_id() != branches.second.back()->data.previous ) - { - ilog( "popping block #${n} ${id}", ("n",head_block_num())("id",head_block_id()) ); - pop_block(); - } - - // push all blocks on the new fork - for( auto ritr = branches.first.rbegin(); ritr != branches.first.rend(); ++ritr ) - { - ilog( "pushing block from fork #${n} ${id}", ("n",(*ritr)->data.block_num())("id",(*ritr)->id) ); - optional except; - try { - undo_database::session session = _undo_db.start_undo_session(); - apply_block( (*ritr)->data, skip ); - _block_id_to_block.store( (*ritr)->id, (*ritr)->data ); - session.commit(); - } - catch ( const fc::exception& e ) { except = e; } - if( except ) - { - wlog( "exception thrown while switching forks ${e}", ("e",except->to_detail_string() ) ); - // remove the rest of branches.first from the fork_db, those blocks are invalid - while( ritr != branches.first.rend() ) - { - ilog( "removing block from fork_db #${n} ${id}", ("n",(*ritr)->data.block_num())("id",(*ritr)->id) ); - _fork_db.remove( (*ritr)->id ); - ++ritr; - } - _fork_db.set_head( branches.second.front() ); - - // pop all blocks from the bad fork - while( head_block_id() != branches.second.back()->data.previous ) - { - ilog( "popping block #${n} ${id}", ("n",head_block_num())("id",head_block_id()) ); - pop_block(); - } - - ilog( "Switching back to fork: ${id}", ("id",branches.second.front()->data.id()) ); - // restore all blocks from the good fork - for( auto ritr2 = branches.second.rbegin(); ritr2 != branches.second.rend(); ++ritr2 ) - { - ilog( "pushing block #${n} ${id}", ("n",(*ritr2)->data.block_num())("id",(*ritr2)->id) ); - auto session = _undo_db.start_undo_session(); - apply_block( (*ritr2)->data, skip ); - _block_id_to_block.store( (*ritr2)->id, (*ritr2)->data ); - session.commit(); - } - throw *except; - } - } - return true; + ilog( "pushing block from fork #${n} ${id}", ("n",(*ritr)->data.block_num())("id",(*ritr)->id) ); + optional except; + try { + undo_database::session session = _undo_db.start_undo_session(); + apply_block( (*ritr)->data, skip ); + _block_id_to_block.store( (*ritr)->id, (*ritr)->data ); + session.commit(); + } + catch ( const fc::exception& e ) { except = e; } + if( except ) + { + wlog( "exception thrown while switching forks ${e}", ("e",except->to_detail_string() ) ); + // remove the rest of branches.first from the fork_db, those blocks are invalid + while( ritr != branches.first.rend() ) + { + ilog( "removing block from fork_db #${n} ${id}", ("n",(*ritr)->data.block_num())("id",(*ritr)->id) ); + _fork_db.remove( (*ritr)->id ); + ++ritr; + } + _fork_db.set_head( branches.second.front() ); + + // pop all blocks from the bad fork + while( head_block_id() != branches.second.back()->data.previous ) + { + ilog( "popping block #${n} ${id}", ("n",head_block_num())("id",head_block_id()) ); + pop_block(); + } + + ilog( "Switching back to fork: ${id}", ("id",branches.second.front()->data.id()) ); + // restore all blocks from the good fork + for( auto ritr2 = branches.second.rbegin(); ritr2 != branches.second.rend(); ++ritr2 ) + { + ilog( "pushing block #${n} ${id}", ("n",(*ritr2)->data.block_num())("id",(*ritr2)->id) ); + auto session = _undo_db.start_undo_session(); + apply_block( (*ritr2)->data, skip ); + _block_id_to_block.store( (*ritr2)->id, (*ritr2)->data ); + session.commit(); + } + throw *except; + } } - else return false; + return true; } + else return false; } try { @@ -209,10 +206,7 @@ bool database::_push_block(const signed_block& new_block) session.commit(); } catch ( const fc::exception& e ) { elog("Failed to push new block:\n${e}", ("e", e.to_detail_string())); - if( !(skip&skip_fork_db) ) - { - _fork_db.remove( new_block.id() ); - } + _fork_db.remove( new_block.id() ); throw; } diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index 84e4ad4190..7fa190cb66 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -66,7 +66,6 @@ namespace graphene { namespace chain { skip_witness_signature = 1 << 0, ///< used while reindexing skip_transaction_signatures = 1 << 1, ///< used by non-witness nodes skip_transaction_dupe_check = 1 << 2, ///< used while reindexing - skip_fork_db = 1 << 3, ///< used while reindexing skip_block_size_check = 1 << 4, ///< used when applying locally generated transactions skip_tapos_check = 1 << 5, ///< used while reindexing -- note this skips expiration check as well // skip_authority_check = 1 << 6, ///< removed because effectively identical to skip_transaction_signatures diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index b8f8856384..8a21d37aee 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -421,7 +421,7 @@ BOOST_AUTO_TEST_CASE(track_account) { // dan makes 1 op create_bitasset("EUR", dan_id); - generate_block( ~database::skip_fork_db ); + generate_block(); // anything against account_id_type() should be {} vector histories = hist_api.get_account_history("1.2.0", operation_history_id_type(0), 10, operation_history_id_type(0)); @@ -449,7 +449,7 @@ BOOST_AUTO_TEST_CASE(track_account) { create_bitasset( "BTC", account_id_type() ); create_bitasset( "GBP", dan_id ); - generate_block( ~database::skip_fork_db ); + generate_block(); histories = hist_api.get_account_history("dan", operation_history_id_type(0), 10, operation_history_id_type(0)); BOOST_CHECK_EQUAL(histories.size(), 3); From 7fa01fbf0d8d9b3582981208c085d973e1f2a179 Mon Sep 17 00:00:00 2001 From: jmjatlanta Date: Mon, 7 Jan 2019 12:05:45 -0500 Subject: [PATCH 111/172] change seq. counter 'next' used by db indexes to uint64_t --- libraries/db/include/graphene/db/index.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index 4b54862899..2ba0c76a3c 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -210,7 +210,7 @@ namespace graphene { namespace db { // private static const size_t MAX_HOLE = 100; static const size_t _mask = ((1 << chunkbits) - 1); - size_t next = 0; + uint64_t next = 0; vector< vector< const Object* > > content; std::stack< object_id_type > ids_being_modified; From 0e6b07e0707a6afa9fbf3327d9d8534cd61e6c80 Mon Sep 17 00:00:00 2001 From: jmjatlanta Date: Tue, 8 Jan 2019 10:39:02 -0500 Subject: [PATCH 112/172] added template specialization for mac release builds --- libraries/chain/protocol/fee_schedule.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/chain/protocol/fee_schedule.cpp index d71c58a0aa..649f90dff4 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/chain/protocol/fee_schedule.cpp @@ -27,23 +27,20 @@ namespace fc { - // explicitly instantiate the smart_ref, gcc fails to instantiate it in some release builds - //template graphene::chain::fee_schedule& smart_ref::operator=(smart_ref&&); - //template graphene::chain::fee_schedule& smart_ref::operator=(U&&); - //template graphene::chain::fee_schedule& smart_ref::operator=(const smart_ref&); - //template smart_ref::smart_ref(); - //template const graphene::chain::fee_schedule& smart_ref::operator*() const; - template smart_ref::smart_ref(smart_ref const&); + // these are required on certain platforms in Release mode + template<> + bool smart_ref::operator !()const + { + throw std::logic_error("Not Implemented"); + } + + template class smart_ref; } #define MAX_FEE_STABILIZATION_ITERATION 4 namespace graphene { namespace chain { - typedef fc::smart_ref smart_fee_schedule; - - static smart_fee_schedule tmp; - fee_schedule::fee_schedule() { } From b4bd649268402de7b8cf8d94f386d42685c4ea4b Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 8 Jan 2019 17:05:53 -0500 Subject: [PATCH 113/172] Make sure price_to_string works and throws as it should --- tests/tests/app_util_tests.cpp | 54 +++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/tests/tests/app_util_tests.cpp b/tests/tests/app_util_tests.cpp index 9b913fd7cd..71e750cc0a 100644 --- a/tests/tests/app_util_tests.cpp +++ b/tests/tests/app_util_tests.cpp @@ -214,30 +214,36 @@ BOOST_AUTO_TEST_CASE(price_to_string_test) { GRAPHENE_REQUIRE_THROW( price_to_string( p[i][j], 0, 20 ), fc::exception ); } try { - idump( (i) (j) (p[i][j]) ); - idump( - (price_to_string(p[i][j],0,0)) - (price_to_string(p[i][j],0,1)) - (price_to_string(p[i][j],0,2)) - (price_to_string(p[i][j],0,8)) - (price_to_string(p[i][j],0,19)) - (price_to_string(p[i][j],1,0)) - (price_to_string(p[i][j],1,15)) - (price_to_string(p[i][j],2,6)) - (price_to_string(p[i][j],2,10)) - (price_to_string(p[i][j],5,0)) - (price_to_string(p[i][j],9,1)) - (price_to_string(p[i][j],9,9)) - (price_to_string(p[i][j],9,19)) - (price_to_string(p[i][j],18,10)) - (price_to_string(p[i][j],18,13)) - (price_to_string(p[i][j],18,19)) - (price_to_string(p[i][j],19,0)) - (price_to_string(p[i][j],19,7)) - (price_to_string(p[i][j],19,19)) - (price_diff_percent_string(p[i][j],p[j][i])) - ); - } catch(...) {} + price pr = p[i][j]; + idump( (i) (j) (pr) ); + if ( pr.base.amount == 0 || (pr.base.amount > 0 && pr.quote.amount >= 0 ) ) + { + idump( (price_to_string( pr ,0,0)) ); + idump( (price_to_string( pr ,0,1)) ); + idump( (price_to_string( pr ,0,2)) ); + idump( (price_to_string( pr ,0,8)) ); + idump( (price_to_string( pr ,0,19)) ); + idump( (price_to_string( pr ,1,0)) ); + idump( (price_to_string( pr ,1,15)) ); + idump( (price_to_string( pr ,2,6)) ); + idump( (price_to_string( pr ,2,10)) ); + idump( (price_to_string( pr ,5,0)) ); + idump( (price_to_string( pr ,9,1)) ); + idump( (price_to_string( pr ,9,9)) ); + idump( (price_to_string( pr ,9,19)) ); + idump( (price_to_string( pr ,18,10)) ); + idump( (price_to_string( pr ,18,13)) ); + idump( (price_to_string( pr ,18,19)) ); + idump( (price_to_string( pr ,19,0)) ); + idump( (price_to_string( pr ,19,7)) ); + idump( (price_to_string( pr ,19,19)) ); + idump( (price_diff_percent_string( pr ,p[j][i])) ); + } else { + GRAPHENE_REQUIRE_THROW( price_to_string( pr, 0, 0 ), fc::exception ); + } + } catch(...) { + BOOST_FAIL( "Failure to log price_to_string" ); + } } } From 834e47635d441464043a1abb3dc464ae2c0e0fb4 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 11 Jan 2019 10:20:14 -0500 Subject: [PATCH 114/172] Separate throws from edge cases that should work --- tests/tests/app_util_tests.cpp | 79 +++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 25 deletions(-) diff --git a/tests/tests/app_util_tests.cpp b/tests/tests/app_util_tests.cpp index 71e750cc0a..b85c9a3e8d 100644 --- a/tests/tests/app_util_tests.cpp +++ b/tests/tests/app_util_tests.cpp @@ -32,7 +32,7 @@ using namespace graphene::chain; using namespace graphene::chain::test; using namespace graphene::app; -BOOST_FIXTURE_TEST_SUITE(app_util_tests, database_fixture) +BOOST_AUTO_TEST_SUITE(app_util_tests) BOOST_AUTO_TEST_CASE(uint128_amount_to_string_test) { @@ -179,7 +179,7 @@ BOOST_AUTO_TEST_CASE(uint128_amount_to_string_test) { } -BOOST_AUTO_TEST_CASE(price_to_string_test) { +BOOST_AUTO_TEST_CASE(price_to_string_throws) { int64_t m = std::numeric_limits::max(); int64_t n = -1; @@ -194,8 +194,10 @@ BOOST_AUTO_TEST_CASE(price_to_string_test) { p[i][j] = price( asset( a[i] ), asset( a[j] ) ); for( int i = 0; i < 11; ++i ) + { for( int j = 0; j < 11; ++j ) { + price pr = p[i][j]; if( i == 0 ) { GRAPHENE_REQUIRE_THROW( price_to_string( p[i][j], 0, 0 ), fc::exception ); @@ -214,38 +216,65 @@ BOOST_AUTO_TEST_CASE(price_to_string_test) { GRAPHENE_REQUIRE_THROW( price_to_string( p[i][j], 0, 20 ), fc::exception ); } try { - price pr = p[i][j]; - idump( (i) (j) (pr) ); if ( pr.base.amount == 0 || (pr.base.amount > 0 && pr.quote.amount >= 0 ) ) { - idump( (price_to_string( pr ,0,0)) ); - idump( (price_to_string( pr ,0,1)) ); - idump( (price_to_string( pr ,0,2)) ); - idump( (price_to_string( pr ,0,8)) ); - idump( (price_to_string( pr ,0,19)) ); - idump( (price_to_string( pr ,1,0)) ); - idump( (price_to_string( pr ,1,15)) ); - idump( (price_to_string( pr ,2,6)) ); - idump( (price_to_string( pr ,2,10)) ); - idump( (price_to_string( pr ,5,0)) ); - idump( (price_to_string( pr ,9,1)) ); - idump( (price_to_string( pr ,9,9)) ); - idump( (price_to_string( pr ,9,19)) ); - idump( (price_to_string( pr ,18,10)) ); - idump( (price_to_string( pr ,18,13)) ); - idump( (price_to_string( pr ,18,19)) ); - idump( (price_to_string( pr ,19,0)) ); - idump( (price_to_string( pr ,19,7)) ); - idump( (price_to_string( pr ,19,19)) ); - idump( (price_diff_percent_string( pr ,p[j][i])) ); + // idump( (i) (j) (pr) ); // for debugging + // These should not throw + // TODO: Verify results + BOOST_CHECK( !price_to_string( pr ,0,0).empty() ); + BOOST_CHECK( !price_to_string( pr ,0,1).empty() ); + BOOST_CHECK( !price_to_string( pr ,0,2).empty() ); + BOOST_CHECK( !price_to_string( pr ,0,8).empty() ); + BOOST_CHECK( !price_to_string( pr ,0,19).empty() ); + BOOST_CHECK( !price_to_string( pr ,1,0).empty() ); + BOOST_CHECK( !price_to_string( pr ,1,15).empty() ); + BOOST_CHECK( !price_to_string( pr ,2,6).empty() ); + BOOST_CHECK( !price_to_string( pr ,2,10).empty() ); + BOOST_CHECK( !price_to_string( pr ,5,0).empty() ); + BOOST_CHECK( !price_to_string( pr ,9,1).empty() ); + BOOST_CHECK( !price_to_string( pr ,9,9).empty() ); + BOOST_CHECK( !price_to_string( pr ,9,19).empty() ); + BOOST_CHECK( !price_to_string( pr ,18,10).empty() ); + BOOST_CHECK( !price_to_string( pr ,18,13).empty() ); + BOOST_CHECK( !price_to_string( pr ,18,19).empty() ); + BOOST_CHECK( !price_to_string( pr ,19,0).empty() ); + BOOST_CHECK( !price_to_string( pr ,19,7).empty() ); + BOOST_CHECK( !price_to_string( pr ,19,19).empty() ); + price new_price = p[j][i]; + if (pr.quote.amount >= 0) + BOOST_CHECK( !price_diff_percent_string( pr, new_price ).empty() ); + else + GRAPHENE_REQUIRE_THROW( price_diff_percent_string( pr, new_price ), fc::exception ); } else { GRAPHENE_REQUIRE_THROW( price_to_string( pr, 0, 0 ), fc::exception ); } + } catch(fc::exception& fcx) { + BOOST_FAIL( "FC Exception logging price_to_string: " + fcx.to_detail_string() ); } catch(...) { - BOOST_FAIL( "Failure to log price_to_string" ); + BOOST_FAIL( "Uncaught exception in price_to_string. i=" + std::to_string(i) + " j=" + std::to_string(j)); } } + } +} +/** + * Verify that price_to_string comes back with the correct results. Put edge cases here. + */ +BOOST_AUTO_TEST_CASE(price_to_string_verify) +{ + try + { + BOOST_CHECK_EQUAL( price_to_string( price{ asset(1), asset(1) }, 0, 0 ), "1" ); + BOOST_CHECK_EQUAL( price_to_string( price{ asset(10), asset(10) }, 0, 0), "1" ); + int64_t mx = std::numeric_limits::max(); + BOOST_CHECK_EQUAL( price_to_string( price{ asset(mx), asset(mx) }, 0, 0), "1" ); + BOOST_CHECK_EQUAL( price_to_string( price{ asset(1), asset(mx) }, 0, 0), "0.0000000000000000001" ); + BOOST_CHECK_EQUAL( price_to_string( price{ asset(mx), asset(1) }, 0, 0), "9223372036854775807" ); + } + catch (fc::exception& fx) + { + BOOST_FAIL( "FC Exception: " + fx.to_detail_string() ); + } } BOOST_AUTO_TEST_SUITE_END() From e9f03124a90e5af7f9dc22b8c56d57c972c1fd0a Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 14 Jan 2019 10:53:51 -0500 Subject: [PATCH 115/172] Fix comment typo --- libraries/chain/db_block.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 6571586445..28a6608c19 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -129,7 +129,7 @@ bool database::push_block(const signed_block& new_block, uint32_t skip) bool database::_push_block(const signed_block& new_block) { try { uint32_t skip = get_node_properties().skip_flags; - /// TODO: if the block is greater than the head block and before the next maitenance interval + // TODO: If the block is greater than the head block and before the next maitenance interval // verify that the block signer is in the current set of active witnesses. shared_ptr new_head = _fork_db.push_block(new_block); From 60e8a8d7607dd183e4d208d25c3cf729825acb50 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 14 Jan 2019 13:54:27 -0500 Subject: [PATCH 116/172] shut down without calling exit --- libraries/app/application.cpp | 18 ++++++++++-------- libraries/app/application_impl.hxx | 2 +- .../app/include/graphene/app/application.hpp | 12 ++++++++++-- programs/delayed_node/main.cpp | 10 ++++++++-- programs/witness_node/main.cpp | 12 ++++++++++-- 5 files changed, 39 insertions(+), 15 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index f2cf80285d..3cf7cff63b 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -318,7 +318,7 @@ void application_impl::set_dbg_init_key( graphene::chain::genesis_state_type& ge genesis.initial_witness_candidates[i].block_signing_key = init_pubkey; } -void application_impl::startup() +bool application_impl::startup() { try { fc::create_directories(_data_dir / "blockchain"); @@ -454,7 +454,7 @@ void application_impl::startup() { elog("Failed to load file from ${path}", ("path", _options->at("api-access").as().string())); - std::exit(EXIT_FAILURE); + return false; } } else @@ -475,6 +475,7 @@ void application_impl::startup() reset_p2p_node(_data_dir); reset_websocket_server(); reset_websocket_tls_server(); + return true; } FC_LOG_AND_RETHROW() } optional< api_access_info > application_impl::get_api_access_info(const string& username)const @@ -1000,7 +1001,7 @@ void application::set_program_options(boost::program_options::options_descriptio configuration_file_options.add(_cfg_options); } -void application::initialize(const fc::path& data_dir, const boost::program_options::variables_map& options) +bool application::initialize(const fc::path& data_dir, const boost::program_options::variables_map& options) { my->_data_dir = data_dir; my->_options = &options; @@ -1018,7 +1019,7 @@ void application::initialize(const fc::path& data_dir, const boost::program_opti << "\nWould you like to replace it? [y/N] "; char response = std::cin.get(); if( toupper(response) != 'Y' ) - return; + return false; } std::cerr << "Updating genesis state in file " << genesis_out.generic_string() << "\n"; @@ -1027,7 +1028,7 @@ void application::initialize(const fc::path& data_dir, const boost::program_opti } fc::json::save_to_file(genesis_state, genesis_out); - std::exit(EXIT_SUCCESS); + return false; } if ( options.count("io-threads") ) @@ -1058,16 +1059,17 @@ void application::initialize(const fc::path& data_dir, const boost::program_opti if(es_ah_conflict_counter > 1) { elog("Can't start program with elasticsearch and account_history plugin at the same time"); - std::exit(EXIT_FAILURE); + return false; } if (!it.empty()) enable_plugin(it); } + return true; } -void application::startup() +bool application::startup() { try { - my->startup(); + return my->startup(); } catch ( const fc::exception& e ) { elog( "${e}", ("e",e.to_detail_string()) ); throw; diff --git a/libraries/app/application_impl.hxx b/libraries/app/application_impl.hxx index 9f601bce79..f5368da6a1 100644 --- a/libraries/app/application_impl.hxx +++ b/libraries/app/application_impl.hxx @@ -42,7 +42,7 @@ class application_impl : public net::node_delegate void set_dbg_init_key( graphene::chain::genesis_state_type& genesis, const std::string& init_key ); - void startup(); + bool startup(); fc::optional< api_access_info > get_api_access_info(const string& username)const; diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 4892bb9a27..96684a65a0 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -50,9 +50,17 @@ namespace graphene { namespace app { void set_program_options( boost::program_options::options_description& command_line_options, boost::program_options::options_description& configuration_file_options )const; - void initialize(const fc::path& data_dir, const boost::program_options::variables_map&options); + /** + * Initializes the application + * @returns true if the calling method should continue, false otherwise + */ + bool initialize(const fc::path& data_dir, const boost::program_options::variables_map&options); void initialize_plugins( const boost::program_options::variables_map& options ); - void startup(); + /*** + * Performs startup + * @returns true if the calling method should continue, false otherwise + */ + bool startup(); void shutdown(); void startup_plugins(); void shutdown_plugins(); diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index 0ba1e6944d..76d68c7bec 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -163,10 +163,15 @@ int main(int argc, char** argv) { if( !options.count("plugins") ) options.insert( std::make_pair( "plugins", bpo::variable_value(std::string("delayed_node account_history market_history"), true) ) ); - node.initialize(data_dir, options); + if (!node.initialize(data_dir, options)) + return 0; + node.initialize_plugins( options ); - node.startup(); + if (!node.startup()) + { + return 0; + } node.startup_plugins(); fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); @@ -180,6 +185,7 @@ int main(int argc, char** argv) { int signal = exit_promise->wait(); ilog("Exiting from signal ${n}", ("n", signal)); node.shutdown_plugins(); + node.shutdown(); return 0; } catch( const fc::exception& e ) { elog("Exiting with error:\n${e}", ("e", e.to_detail_string())); diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 07c17a9010..0d5cbd1cfd 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -120,10 +120,18 @@ int main(int argc, char** argv) { app::load_configuration_options(data_dir, cfg_options, options); bpo::notify(options); - node->initialize(data_dir, options); + if (!node->initialize(data_dir, options)) + { + delete node; + return 0; + } node->initialize_plugins( options ); - node->startup(); + if (!node->startup()) + { + delete node; + return 0; + } node->startup_plugins(); fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); From 7c3968b589a07fa40eb64d4b050784c4440de78a Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 14 Jan 2019 13:55:13 -0500 Subject: [PATCH 117/172] prevent segfault when destructing application obj --- libraries/chain/db_management.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index 231cc3ebc9..16e38f43da 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -223,6 +223,9 @@ void database::open( void database::close(bool rewind) { + if (!_opened) + return; + // TODO: Save pending tx's on close() clear_pending(); From 02299573e5d1ae0d5bdcf11ce17b124c405c9e97 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 14 Jan 2019 16:08:27 -0500 Subject: [PATCH 118/172] Added human-readable message to assert --- libraries/chain/market_evaluator.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index 62dfc7c7b4..9badba481b 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -49,9 +49,11 @@ void_result limit_order_create_evaluator::do_evaluate(const limit_order_create_o _receive_asset = &op.min_to_receive.asset_id(d); if( _sell_asset->options.whitelist_markets.size() ) - FC_ASSERT( _sell_asset->options.whitelist_markets.find(_receive_asset->id) != _sell_asset->options.whitelist_markets.end() ); + FC_ASSERT( _sell_asset->options.whitelist_markets.find(_receive_asset->id) != _sell_asset->options.whitelist_markets.end(), + "This market has not been whitelisted." ); if( _sell_asset->options.blacklist_markets.size() ) - FC_ASSERT( _sell_asset->options.blacklist_markets.find(_receive_asset->id) == _sell_asset->options.blacklist_markets.end() ); + FC_ASSERT( _sell_asset->options.blacklist_markets.find(_receive_asset->id) == _sell_asset->options.blacklist_markets.end(), + "This market has been blacklisted." ); FC_ASSERT( is_authorized_asset( d, *_seller, *_sell_asset ) ); FC_ASSERT( is_authorized_asset( d, *_seller, *_receive_asset ) ); From 28875e1435164256723d412e2165239cfc9de249 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 14 Jan 2019 16:26:33 -0500 Subject: [PATCH 119/172] fixed long lines --- libraries/chain/market_evaluator.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index 9badba481b..58dd0ac53f 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -49,10 +49,12 @@ void_result limit_order_create_evaluator::do_evaluate(const limit_order_create_o _receive_asset = &op.min_to_receive.asset_id(d); if( _sell_asset->options.whitelist_markets.size() ) - FC_ASSERT( _sell_asset->options.whitelist_markets.find(_receive_asset->id) != _sell_asset->options.whitelist_markets.end(), + FC_ASSERT( _sell_asset->options.whitelist_markets.find(_receive_asset->id) + != _sell_asset->options.whitelist_markets.end(), "This market has not been whitelisted." ); if( _sell_asset->options.blacklist_markets.size() ) - FC_ASSERT( _sell_asset->options.blacklist_markets.find(_receive_asset->id) == _sell_asset->options.blacklist_markets.end(), + FC_ASSERT( _sell_asset->options.blacklist_markets.find(_receive_asset->id) + == _sell_asset->options.blacklist_markets.end(), "This market has been blacklisted." ); FC_ASSERT( is_authorized_asset( d, *_seller, *_sell_asset ) ); From 3b0891a17ec6dbd210a29973394ee109c5623781 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 15 Jan 2019 10:06:07 -0500 Subject: [PATCH 120/172] keep return value --- libraries/app/application.cpp | 16 ++++++++-------- libraries/app/application_impl.hxx | 2 +- .../app/include/graphene/app/application.hpp | 12 ++++++++---- programs/delayed_node/main.cpp | 16 ++++++++-------- programs/witness_node/main.cpp | 15 +++++++++------ 5 files changed, 34 insertions(+), 27 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 3cf7cff63b..6ae8dfea78 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -318,7 +318,7 @@ void application_impl::set_dbg_init_key( graphene::chain::genesis_state_type& ge genesis.initial_witness_candidates[i].block_signing_key = init_pubkey; } -bool application_impl::startup() +uint8_t application_impl::startup() { try { fc::create_directories(_data_dir / "blockchain"); @@ -454,7 +454,7 @@ bool application_impl::startup() { elog("Failed to load file from ${path}", ("path", _options->at("api-access").as().string())); - return false; + return EXIT_FAILURE; } } else @@ -475,7 +475,7 @@ bool application_impl::startup() reset_p2p_node(_data_dir); reset_websocket_server(); reset_websocket_tls_server(); - return true; + return DO_NOT_EXIT; } FC_LOG_AND_RETHROW() } optional< api_access_info > application_impl::get_api_access_info(const string& username)const @@ -1001,7 +1001,7 @@ void application::set_program_options(boost::program_options::options_descriptio configuration_file_options.add(_cfg_options); } -bool application::initialize(const fc::path& data_dir, const boost::program_options::variables_map& options) +uint8_t application::initialize(const fc::path& data_dir, const boost::program_options::variables_map& options) { my->_data_dir = data_dir; my->_options = &options; @@ -1019,7 +1019,7 @@ bool application::initialize(const fc::path& data_dir, const boost::program_opti << "\nWould you like to replace it? [y/N] "; char response = std::cin.get(); if( toupper(response) != 'Y' ) - return false; + return EXIT_FAILURE; } std::cerr << "Updating genesis state in file " << genesis_out.generic_string() << "\n"; @@ -1028,7 +1028,7 @@ bool application::initialize(const fc::path& data_dir, const boost::program_opti } fc::json::save_to_file(genesis_state, genesis_out); - return false; + return EXIT_SUCCESS; } if ( options.count("io-threads") ) @@ -1059,14 +1059,14 @@ bool application::initialize(const fc::path& data_dir, const boost::program_opti if(es_ah_conflict_counter > 1) { elog("Can't start program with elasticsearch and account_history plugin at the same time"); - return false; + return EXIT_FAILURE; } if (!it.empty()) enable_plugin(it); } return true; } -bool application::startup() +uint8_t application::startup() { try { return my->startup(); diff --git a/libraries/app/application_impl.hxx b/libraries/app/application_impl.hxx index f5368da6a1..25f7ee9d4c 100644 --- a/libraries/app/application_impl.hxx +++ b/libraries/app/application_impl.hxx @@ -42,7 +42,7 @@ class application_impl : public net::node_delegate void set_dbg_init_key( graphene::chain::genesis_state_type& genesis, const std::string& init_key ); - bool startup(); + uint8_t startup(); fc::optional< api_access_info > get_api_access_info(const string& username)const; diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 96684a65a0..579f49fdc0 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -29,6 +29,10 @@ #include +#ifndef DO_NOT_EXIT + #define DO_NOT_EXIT 254 +#endif + namespace graphene { namespace app { namespace detail { class application_impl; } using std::string; @@ -52,15 +56,15 @@ namespace graphene { namespace app { boost::program_options::options_description& configuration_file_options )const; /** * Initializes the application - * @returns true if the calling method should continue, false otherwise + * @returns DO_NOT_EXIT if the calling method should continue, otherwise EXIT_SUCCESS or EXIT_FAILURE */ - bool initialize(const fc::path& data_dir, const boost::program_options::variables_map&options); + uint8_t initialize(const fc::path& data_dir, const boost::program_options::variables_map&options); void initialize_plugins( const boost::program_options::variables_map& options ); /*** * Performs startup - * @returns true if the calling method should continue, false otherwise + * @returns DO_NOT_EXIT if the calling method should continue, otherwise EXIT_SUCCESS or EXIT_FAILURE */ - bool startup(); + uint8_t startup(); void shutdown(); void startup_plugins(); void shutdown_plugins(); diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index 76d68c7bec..ff2284962a 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -163,15 +163,15 @@ int main(int argc, char** argv) { if( !options.count("plugins") ) options.insert( std::make_pair( "plugins", bpo::variable_value(std::string("delayed_node account_history market_history"), true) ) ); - if (!node.initialize(data_dir, options)) - return 0; + uint8_t ret_val; + if ( (ret_val = node.initialize(data_dir, options)) != DO_NOT_EXIT ) + return ret_val; node.initialize_plugins( options ); - if (!node.startup()) - { - return 0; - } + if ( (ret_val = node.startup()) != DO_NOT_EXIT ) + return ret_val; + node.startup_plugins(); fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); @@ -186,10 +186,10 @@ int main(int argc, char** argv) { ilog("Exiting from signal ${n}", ("n", signal)); node.shutdown_plugins(); node.shutdown(); - return 0; + return EXIT_SUCCESS; } catch( const fc::exception& e ) { elog("Exiting with error:\n${e}", ("e", e.to_detail_string())); - return 1; + return EXIT_FAILURE; } } diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 0d5cbd1cfd..dabcdd46a8 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -120,18 +120,21 @@ int main(int argc, char** argv) { app::load_configuration_options(data_dir, cfg_options, options); bpo::notify(options); - if (!node->initialize(data_dir, options)) + + uint8_t ret_val; + if ( ( ret_val = node->initialize(data_dir, options)) != DO_NOT_EXIT ) { delete node; - return 0; + return ret_val; } node->initialize_plugins( options ); - if (!node->startup()) + if ( (ret_val = node->startup()) != DO_NOT_EXIT ) { delete node; - return 0; + return ret_val; } + node->startup_plugins(); fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); @@ -154,7 +157,7 @@ int main(int argc, char** argv) { node->shutdown_plugins(); node->shutdown(); delete node; - return 0; + return EXIT_SUCCESS; } catch( const fc::exception& e ) { // deleting the node can yield, so do this outside the exception handler unhandled_exception = e; @@ -165,7 +168,7 @@ int main(int argc, char** argv) { elog("Exiting with error:\n${e}", ("e", unhandled_exception->to_detail_string())); node->shutdown(); delete node; - return 1; + return EXIT_FAILURE; } } From 7462d398ab3caecb50d8ae776e591730e67f4f2e Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 15 Jan 2019 10:50:35 -0500 Subject: [PATCH 121/172] Fix typo --- libraries/chain/db_block.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 28a6608c19..3b0a985c66 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -129,7 +129,7 @@ bool database::push_block(const signed_block& new_block, uint32_t skip) bool database::_push_block(const signed_block& new_block) { try { uint32_t skip = get_node_properties().skip_flags; - // TODO: If the block is greater than the head block and before the next maitenance interval + // TODO: If the block is greater than the head block and before the next maintenance interval // verify that the block signer is in the current set of active witnesses. shared_ptr new_head = _fork_db.push_block(new_block); From a590c25c52573d2391a44bb532d1a10c8e791edd Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 16 Jan 2019 10:58:30 -0300 Subject: [PATCH 122/172] remove useless check --- programs/delayed_node/main.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index 4a43535ac6..b13fafff92 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -166,11 +166,6 @@ int main(int argc, char** argv) { std::set plugins; boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); - if(plugins.count("account_history") && plugins.count("elasticsearch")) { - std::cerr << "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin\n"; - return 1; - } - std::for_each(plugins.begin(), plugins.end(), [&](const std::string& plug) mutable { if (!plug.empty()) { node.enable_plugin(plug); From caf7f7fe99aa9b53898ced00effd0142204f46c9 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 16 Jan 2019 10:59:02 -0300 Subject: [PATCH 123/172] add default value to trusted-node --- libraries/plugins/delayed_node/delayed_node_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/plugins/delayed_node/delayed_node_plugin.cpp b/libraries/plugins/delayed_node/delayed_node_plugin.cpp index 24a46cc066..57b271b896 100644 --- a/libraries/plugins/delayed_node/delayed_node_plugin.cpp +++ b/libraries/plugins/delayed_node/delayed_node_plugin.cpp @@ -58,7 +58,7 @@ delayed_node_plugin::~delayed_node_plugin() void delayed_node_plugin::plugin_set_program_options(bpo::options_description& cli, bpo::options_description& cfg) { cli.add_options() - ("trusted-node", boost::program_options::value(), "RPC endpoint of a trusted validating node (required)") + ("trusted-node", boost::program_options::value()->default_value("127.0.0.1:8090"), "RPC endpoint of a trusted validating node (required)") ; cfg.add(cli); } From 6e11c31d40a8e63f52402887860349d9f96d883b Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 16 Jan 2019 15:47:26 +0000 Subject: [PATCH 124/172] Remove gui_version file which is no longer used --- gui_version | 1 - 1 file changed, 1 deletion(-) delete mode 100644 gui_version diff --git a/gui_version b/gui_version deleted file mode 100644 index f7a4e4ce15..0000000000 --- a/gui_version +++ /dev/null @@ -1 +0,0 @@ -2.0.170522 From 241e605f9df8a60938083c359e891e150f0844f4 Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 16 Jan 2019 15:49:24 +0000 Subject: [PATCH 125/172] Remove old testnet files --- testnet-shared-accounts.txt | 556 --------------------------- testnet-shared-balances.txt | 41 -- testnet-shared-committee-members.txt | 204 ---------- testnet-shared-private-keys.txt | 10 - testnet-shared-vesting-balances.txt | 71 ---- testnet-shared-witnesses.txt | 304 --------------- 6 files changed, 1186 deletions(-) delete mode 100644 testnet-shared-accounts.txt delete mode 100644 testnet-shared-balances.txt delete mode 100644 testnet-shared-committee-members.txt delete mode 100644 testnet-shared-private-keys.txt delete mode 100644 testnet-shared-vesting-balances.txt delete mode 100644 testnet-shared-witnesses.txt diff --git a/testnet-shared-accounts.txt b/testnet-shared-accounts.txt deleted file mode 100644 index 99392365ca..0000000000 --- a/testnet-shared-accounts.txt +++ /dev/null @@ -1,556 +0,0 @@ - "initial_accounts": [{ - "name": "init0", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init1", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init2", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init3", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init4", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init5", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init6", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init7", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init8", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init9", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init10", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init11", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init12", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init13", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init14", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init15", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init16", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init17", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init18", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init19", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init20", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init21", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init22", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init23", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init24", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init25", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init26", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init27", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init28", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init29", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init30", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init31", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init32", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init33", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init34", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init35", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init36", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init37", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init38", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init39", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init40", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init41", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init42", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init43", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init44", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init45", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init46", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init47", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init48", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init49", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init50", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init51", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init52", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init53", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init54", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init55", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init56", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init57", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init58", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init59", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init60", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init61", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init62", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init63", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init64", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init65", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init66", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init67", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init68", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init69", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init70", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init71", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init72", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init73", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init74", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init75", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init76", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init77", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init78", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init79", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init80", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init81", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init82", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init83", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init84", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init85", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init86", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init87", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init88", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init89", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init90", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init91", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init92", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init93", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init94", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init95", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init96", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init97", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init98", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init99", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "init100", - "owner_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "active_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", - "is_lifetime_member": true - },{ - "name": "dummy0", - "owner_key": "BTS6qkMe8pHmQ4zUetLV1bbVKoQJYTNb1fSUbkQzuzpscYhonWpgk", - "active_key": "BTS6qkMe8pHmQ4zUetLV1bbVKoQJYTNb1fSUbkQzuzpscYhonWpgk", - "is_lifetime_member": true - },{ - "name": "dummy1", - "owner_key": "BTS7wXsTzBBR2QEetjrgxcSmN7Kuzey3RAzQWNNHwbPQsKYxkP6fp", - "active_key": "BTS7wXsTzBBR2QEetjrgxcSmN7Kuzey3RAzQWNNHwbPQsKYxkP6fp", - "is_lifetime_member": true - },{ - "name": "dummy2", - "owner_key": "BTS7rzifzfJxS8RWhev9aU8HDYoJi1EGwJRHG9B2fJKxnZAiF2Rsh", - "active_key": "BTS7rzifzfJxS8RWhev9aU8HDYoJi1EGwJRHG9B2fJKxnZAiF2Rsh", - "is_lifetime_member": true - },{ - "name": "dummy3", - "owner_key": "BTS6QZdcwFEFMtHsfW27YBGTv9KLaLTvgx5wgGrPHeUxDTrYEQJ2d", - "active_key": "BTS6QZdcwFEFMtHsfW27YBGTv9KLaLTvgx5wgGrPHeUxDTrYEQJ2d", - "is_lifetime_member": true - },{ - "name": "dummy4", - "owner_key": "BTS7q5MqhSP2a6CRTWaJk77ZcGdpnv14JbT4cVzbXaoAsWJoCxFJG", - "active_key": "BTS7q5MqhSP2a6CRTWaJk77ZcGdpnv14JbT4cVzbXaoAsWJoCxFJG", - "is_lifetime_member": true - },{ - "name": "dummy5", - "owner_key": "BTS5sRXxgDCnteHLUS623xtxJM5WKKVygwDMzEso6LigwxvprJqBA", - "active_key": "BTS5sRXxgDCnteHLUS623xtxJM5WKKVygwDMzEso6LigwxvprJqBA", - "is_lifetime_member": true - },{ - "name": "dummy6", - "owner_key": "BTS5V4HEQJbVbMjUWASeknQ42NT3NP9bZaygt83XMuvy6v4QMJuSP", - "active_key": "BTS5V4HEQJbVbMjUWASeknQ42NT3NP9bZaygt83XMuvy6v4QMJuSP", - "is_lifetime_member": true - },{ - "name": "dummy7", - "owner_key": "BTS86ukuPAufzKouerZf1dCxjVSmxQPA5kLwvnYEjn9GRqi5qXBop", - "active_key": "BTS86ukuPAufzKouerZf1dCxjVSmxQPA5kLwvnYEjn9GRqi5qXBop", - "is_lifetime_member": true - },{ - "name": "dummy8", - "owner_key": "BTS7Sdg3kQuz2pPT8mA8Yr3mkBe7zr6293mnBmoR36z9xxtRdiMmJ", - "active_key": "BTS7Sdg3kQuz2pPT8mA8Yr3mkBe7zr6293mnBmoR36z9xxtRdiMmJ", - "is_lifetime_member": true - },{ - "name": "dummy9", - "owner_key": "BTS5WCj1mMiiqEE4QRs7xhaFfSaiFroejUp3GuZE9wvfue9nxhPPn", - "active_key": "BTS5WCj1mMiiqEE4QRs7xhaFfSaiFroejUp3GuZE9wvfue9nxhPPn", - "is_lifetime_member": true - },{ diff --git a/testnet-shared-balances.txt b/testnet-shared-balances.txt deleted file mode 100644 index dc9061fa77..0000000000 --- a/testnet-shared-balances.txt +++ /dev/null @@ -1,41 +0,0 @@ - "initial_balances": [{ - "owner": "BTSHYhQcrjVg5kBzCoeeD38eQdncCC5pBgee", - "asset_symbol": "CORE", - "amount": 100000000000 - },{ - "owner": "BTSPgQZg5929ht1NBdEvsGKqoQ7buRu3nKf4", - "asset_symbol": "CORE", - "amount": 100000000000 - },{ - "owner": "BTSC9zrLXSAPUQaVmQPk1S9dMqSzT7jPqYU7", - "asset_symbol": "CORE", - "amount": 100000000000 - },{ - "owner": "BTS93aQPtbbkXwaSjtHaREsNVcCvbfHo93aZ", - "asset_symbol": "CORE", - "amount": 100000000000 - },{ - "owner": "BTS6RM4UfsYFPDuhbmgkvDS9ip8Kvqundvyk", - "asset_symbol": "CORE", - "amount": 100000000000 - },{ - "owner": "BTSNVkZXdqWWSzqHVxvfetMe347is6kEkC4K", - "asset_symbol": "CORE", - "amount": 100000000000 - },{ - "owner": "BTS5GHzWZ64Luoajqsz6JGjTKVMgWYkGV9SQ", - "asset_symbol": "CORE", - "amount": 100000000000 - },{ - "owner": "BTSDCVRFez92bW9doRLjnFCKLJnpM58mgmMb", - "asset_symbol": "CORE", - "amount": 100000000000 - },{ - "owner": "BTS5CCdX3JYLBptYMuCjbsezqGYzN9vG9JCu", - "asset_symbol": "CORE", - "amount": 100000000000 - },{ - "owner": "BTSEQ3yQdr3EMDL2eRqGiceMCpoanaW16Puw", - "asset_symbol": "CORE", - "amount": 100000000000 - },{ diff --git a/testnet-shared-committee-members.txt b/testnet-shared-committee-members.txt deleted file mode 100644 index 7d7ae11b04..0000000000 --- a/testnet-shared-committee-members.txt +++ /dev/null @@ -1,204 +0,0 @@ - "initial_committee_candidates": [{ - "owner_name": "init0" - },{ - "owner_name": "init1" - },{ - "owner_name": "init2" - },{ - "owner_name": "init3" - },{ - "owner_name": "init4" - },{ - "owner_name": "init5" - },{ - "owner_name": "init6" - },{ - "owner_name": "init7" - },{ - "owner_name": "init8" - },{ - "owner_name": "init9" - },{ - "owner_name": "init10" - },{ - "owner_name": "init11" - },{ - "owner_name": "init12" - },{ - "owner_name": "init13" - },{ - "owner_name": "init14" - },{ - "owner_name": "init15" - },{ - "owner_name": "init16" - },{ - "owner_name": "init17" - },{ - "owner_name": "init18" - },{ - "owner_name": "init19" - },{ - "owner_name": "init20" - },{ - "owner_name": "init21" - },{ - "owner_name": "init22" - },{ - "owner_name": "init23" - },{ - "owner_name": "init24" - },{ - "owner_name": "init25" - },{ - "owner_name": "init26" - },{ - "owner_name": "init27" - },{ - "owner_name": "init28" - },{ - "owner_name": "init29" - },{ - "owner_name": "init30" - },{ - "owner_name": "init31" - },{ - "owner_name": "init32" - },{ - "owner_name": "init33" - },{ - "owner_name": "init34" - },{ - "owner_name": "init35" - },{ - "owner_name": "init36" - },{ - "owner_name": "init37" - },{ - "owner_name": "init38" - },{ - "owner_name": "init39" - },{ - "owner_name": "init40" - },{ - "owner_name": "init41" - },{ - "owner_name": "init42" - },{ - "owner_name": "init43" - },{ - "owner_name": "init44" - },{ - "owner_name": "init45" - },{ - "owner_name": "init46" - },{ - "owner_name": "init47" - },{ - "owner_name": "init48" - },{ - "owner_name": "init49" - },{ - "owner_name": "init50" - },{ - "owner_name": "init51" - },{ - "owner_name": "init52" - },{ - "owner_name": "init53" - },{ - "owner_name": "init54" - },{ - "owner_name": "init55" - },{ - "owner_name": "init56" - },{ - "owner_name": "init57" - },{ - "owner_name": "init58" - },{ - "owner_name": "init59" - },{ - "owner_name": "init60" - },{ - "owner_name": "init61" - },{ - "owner_name": "init62" - },{ - "owner_name": "init63" - },{ - "owner_name": "init64" - },{ - "owner_name": "init65" - },{ - "owner_name": "init66" - },{ - "owner_name": "init67" - },{ - "owner_name": "init68" - },{ - "owner_name": "init69" - },{ - "owner_name": "init70" - },{ - "owner_name": "init71" - },{ - "owner_name": "init72" - },{ - "owner_name": "init73" - },{ - "owner_name": "init74" - },{ - "owner_name": "init75" - },{ - "owner_name": "init76" - },{ - "owner_name": "init77" - },{ - "owner_name": "init78" - },{ - "owner_name": "init79" - },{ - "owner_name": "init80" - },{ - "owner_name": "init81" - },{ - "owner_name": "init82" - },{ - "owner_name": "init83" - },{ - "owner_name": "init84" - },{ - "owner_name": "init85" - },{ - "owner_name": "init86" - },{ - "owner_name": "init87" - },{ - "owner_name": "init88" - },{ - "owner_name": "init89" - },{ - "owner_name": "init90" - },{ - "owner_name": "init91" - },{ - "owner_name": "init92" - },{ - "owner_name": "init93" - },{ - "owner_name": "init94" - },{ - "owner_name": "init95" - },{ - "owner_name": "init96" - },{ - "owner_name": "init97" - },{ - "owner_name": "init98" - },{ - "owner_name": "init99" - },{ - "owner_name": "init100" - } - ], diff --git a/testnet-shared-private-keys.txt b/testnet-shared-private-keys.txt deleted file mode 100644 index e2a8d7ddc0..0000000000 --- a/testnet-shared-private-keys.txt +++ /dev/null @@ -1,10 +0,0 @@ -5KCNDLVGqvX8p3GcMFun9sMe6XbMvycVTm4bGrkB5aZGWCbAAtr -5HvFQ1bcAWk8H1A2qXj1AqSNp93GUAb6b2w5TVfLb1jWL6yNF3f -5JSxv2kgaBSm9nGseRNhLhgEKTBmoKJ5CkgLbbk5RW4RBCNsLJC -5K5E2TQtrodDFzsqPq3oVFi9rVX15AN8sLE3iTHfVsX1b49y49J -5HxC3fwN7VDZXKVkbbX3SzCczh18Fetx8TXBfJ3z3ovDUSPKvVd -5KSr4w978PDanQDYtftarcfJVvGe4wedYb1sYbdH6HNpi15heRa -5Kan4si6qWvDVpZuqug4c6KQH4zkvDhwspaGQiFKYniJv6qji6t -5KcZri5DDsMcDp1DjNeMkZSijkWurPoAoR7gBKTnnetNQ9CpXoJ -5K5TRZyEhC6GPgi57t5FhiSMRGVTHEbwXngbBEtCA41gM8LPFhF -5KXVG4oP4Vj3RawRpta79UFAg7pWp17FGf4DnrKfkr69ELytDMv diff --git a/testnet-shared-vesting-balances.txt b/testnet-shared-vesting-balances.txt deleted file mode 100644 index 1dd0023014..0000000000 --- a/testnet-shared-vesting-balances.txt +++ /dev/null @@ -1,71 +0,0 @@ - "initial_vesting_balances": [{ - "owner": "BTSHYhQcrjVg5kBzCoeeD38eQdncCC5pBgee", - "asset_symbol": "BTS", - "amount": 50000000000, - "begin_timestamp": "2014-11-06T00:00:00", - "vesting_duration_seconds": 63072000, - "begin_balance": 50000000000 - },{ - "owner": "BTSPgQZg5929ht1NBdEvsGKqoQ7buRu3nKf4", - "asset_symbol": "BTS", - "amount": 50000000000, - "begin_timestamp": "2014-11-06T00:00:00", - "vesting_duration_seconds": 63072000, - "begin_balance": 50000000000 - },{ - "owner": "BTSC9zrLXSAPUQaVmQPk1S9dMqSzT7jPqYU7", - "asset_symbol": "BTS", - "amount": 50000000000, - "begin_timestamp": "2014-11-06T00:00:00", - "vesting_duration_seconds": 63072000, - "begin_balance": 50000000000 - },{ - "owner": "BTS93aQPtbbkXwaSjtHaREsNVcCvbfHo93aZ", - "asset_symbol": "BTS", - "amount": 50000000000, - "begin_timestamp": "2014-11-06T00:00:00", - "vesting_duration_seconds": 63072000, - "begin_balance": 50000000000 - },{ - "owner": "BTS6RM4UfsYFPDuhbmgkvDS9ip8Kvqundvyk", - "asset_symbol": "BTS", - "amount": 50000000000, - "begin_timestamp": "2014-11-06T00:00:00", - "vesting_duration_seconds": 63072000, - "begin_balance": 50000000000 - },{ - "owner": "BTSNVkZXdqWWSzqHVxvfetMe347is6kEkC4K", - "asset_symbol": "BTS", - "amount": 50000000000, - "begin_timestamp": "2014-11-06T00:00:00", - "vesting_duration_seconds": 63072000, - "begin_balance": 50000000000 - },{ - "owner": "BTS5GHzWZ64Luoajqsz6JGjTKVMgWYkGV9SQ", - "asset_symbol": "BTS", - "amount": 50000000000, - "begin_timestamp": "2014-11-06T00:00:00", - "vesting_duration_seconds": 63072000, - "begin_balance": 50000000000 - },{ - "owner": "BTSDCVRFez92bW9doRLjnFCKLJnpM58mgmMb", - "asset_symbol": "BTS", - "amount": 50000000000, - "begin_timestamp": "2014-11-06T00:00:00", - "vesting_duration_seconds": 63072000, - "begin_balance": 50000000000 - },{ - "owner": "BTS5CCdX3JYLBptYMuCjbsezqGYzN9vG9JCu", - "asset_symbol": "BTS", - "amount": 50000000000, - "begin_timestamp": "2014-11-06T00:00:00", - "vesting_duration_seconds": 63072000, - "begin_balance": 50000000000 - },{ - "owner": "BTSEQ3yQdr3EMDL2eRqGiceMCpoanaW16Puw", - "asset_symbol": "BTS", - "amount": 50000000000, - "begin_timestamp": "2014-11-06T00:00:00", - "vesting_duration_seconds": 63072000, - "begin_balance": 50000000000 - },{ diff --git a/testnet-shared-witnesses.txt b/testnet-shared-witnesses.txt deleted file mode 100644 index c09b132961..0000000000 --- a/testnet-shared-witnesses.txt +++ /dev/null @@ -1,304 +0,0 @@ - "initial_witness_candidates": [{ - "owner_name": "init0", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init1", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init2", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init3", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init4", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init5", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init6", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init7", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init8", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init9", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init10", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init11", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init12", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init13", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init14", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init15", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init16", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init17", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init18", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init19", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init20", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init21", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init22", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init23", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init24", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init25", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init26", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init27", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init28", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init29", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init30", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init31", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init32", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init33", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init34", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init35", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init36", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init37", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init38", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init39", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init40", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init41", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init42", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init43", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init44", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init45", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init46", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init47", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init48", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init49", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init50", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init51", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init52", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init53", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init54", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init55", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init56", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init57", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init58", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init59", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init60", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init61", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init62", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init63", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init64", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init65", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init66", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init67", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init68", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init69", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init70", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init71", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init72", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init73", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init74", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init75", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init76", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init77", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init78", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init79", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init80", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init81", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init82", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init83", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init84", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init85", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init86", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init87", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init88", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init89", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init90", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init91", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init92", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init93", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init94", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init95", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init96", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init97", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init98", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init99", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ - "owner_name": "init100", - "block_signing_key": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV" - },{ From e198552d0dd1a36dd68067b16195dc4706bc740c Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Thu, 17 Jan 2019 12:37:30 -0300 Subject: [PATCH 126/172] remove default option in delayed plugin --- libraries/plugins/delayed_node/delayed_node_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/plugins/delayed_node/delayed_node_plugin.cpp b/libraries/plugins/delayed_node/delayed_node_plugin.cpp index 9fec61c8c5..0329d018b2 100644 --- a/libraries/plugins/delayed_node/delayed_node_plugin.cpp +++ b/libraries/plugins/delayed_node/delayed_node_plugin.cpp @@ -58,7 +58,7 @@ delayed_node_plugin::~delayed_node_plugin() void delayed_node_plugin::plugin_set_program_options(bpo::options_description& cli, bpo::options_description& cfg) { cli.add_options() - ("trusted-node", boost::program_options::value()->default_value("127.0.0.1:8090"), "RPC endpoint of a trusted validating node (required for delayed_node)") + ("trusted-node", boost::program_options::value(), "RPC endpoint of a trusted validating node (required for delayed_node)") ; cfg.add(cli); } From 540a5362ab469cadd8b042b9d029195a8b794957 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 18 Jan 2019 12:02:47 -0300 Subject: [PATCH 127/172] add readme to libraries and programs --- libraries/README.md | 18 ++++++++++++++++++ programs/README.md | 20 ++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 libraries/README.md create mode 100644 programs/README.md diff --git a/libraries/README.md b/libraries/README.md new file mode 100644 index 0000000000..fa7e4d5ce4 --- /dev/null +++ b/libraries/README.md @@ -0,0 +1,18 @@ +# BitShares Libraries + +The libraries are the core of the project and defines everything where applications can build on top. + +A **graphene** blockchain software will use the `app` library to define what the application will do, what services it will offer. The blockchain is defined by the `chain` library and include all the objects, types, operations, protocols that builds current consensus blockchain. The lowest level in memory database of Bitshares is developed at the `db` library. The `fc` is a helper module broadly used in the libraries code, `egenesis` will help with the genesis file, `plugins` will be loaded optionally to the application. Wallet software like the cli_wallet will benefit from the `wallet` library. + +Code in libraries is the most important part of **bitshares-core** project and it is maintained by the Bitshares Core Team and contributors. +# Available Libraries + +Folder | Name | Description | Category | Status +-----------------------------------|--------------------------|-----------------------------------------------------------------------------|----------------|--------------- +[app](app) | Application | Control the behaviour of the `witness_node` application, connect to the seeds, open he API, load plugins, etc. | Library | Active +[chain](chain) | Blockchain | Define all objects, operations and types. This include the consensus protocol, defines the whole blockchain behaviour. | Library | Active +[db](db) | Database | Define the internal database graphene uses. | Library | Active +[egenesis](egenesis) | Genesis | | Library | Active +[fc](fc) | Fast-compiling C++ library | https://github.com/bitshares/bitshares-fc | Library | Active +[plugins](plugins) | Plugins | All plugin modules are stored here. | Library | Active +[wallet](wallet) | Wallet | Wallet definition for the `cli_wallet` software. | Library | Active | \ No newline at end of file diff --git a/programs/README.md b/programs/README.md new file mode 100644 index 0000000000..2fb1def850 --- /dev/null +++ b/programs/README.md @@ -0,0 +1,20 @@ +# BitShares Programs + +The bitshares programs are a collection of binaries to run the blockchain, interact with it or utilities. + +The main program is the `witness_node`, used to run a bitshares block producer, API or plugin node. The second in importance is the `cli_wallet`, used to interact with the blockchain. This 2 programs are the most used by the community and updated by the developers, rest of the programs are utilities. + +Programs in here are part of the **bitshares-core** project and are maintained by the bitshares core team and contributors. + + +# Available Programs + +Folder | Name | Description | Category | Status | Help +-----------------------------------|--------------------------|-----------------------------------------------------------------------------|----------------|---------------|--------------| +[witness_node](witness_node) | Witness Node | Main blockchain software | Node | Active | `./witness_node --help` +[cli_wallet](cli_wallet) | CLI Wallet | Command line wallet | Wallet | Active | `./cli_wallet --help` +[delayed_node](delayed_node) | Delayed Node | Runs a node with `delayed_node` plugin loaded. This is deprecatd in favour of `./witness_node --plugins "delayed_node"` | Node | Deprecated | `./delayed_node --help` +[js_operation_serializer](js_operation_serializer) | Operation Serializer | Dump all blockchain operations and types. Used by the UI. | Tool | Old | `./js_operation_serializer` +[size_checker](size_checker) | Size Checker | Provides wire size average in bytes of all the operations | Tool | Old | `./size_checker` +[build_helpers](build_helpers) | Build Helpers | | Tool | Old | `./member_enumerator` and `./cat-parts` +[genesis_util](genesis_util) | Gensis Utils | | Tool | Old | \ No newline at end of file From 46e248ed30de0e207c53bdf9c1e10f970949fb23 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 18 Jan 2019 13:42:21 -0500 Subject: [PATCH 128/172] Remove create-genesis-json --- libraries/app/application.cpp | 65 ++++--------------- libraries/app/application_impl.hxx | 4 +- .../app/include/graphene/app/application.hpp | 16 +---- programs/delayed_node/main.cpp | 8 +-- programs/witness_node/main.cpp | 14 +--- 5 files changed, 22 insertions(+), 85 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 6ae8dfea78..c89ec21be0 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -318,7 +318,7 @@ void application_impl::set_dbg_init_key( graphene::chain::genesis_state_type& ge genesis.initial_witness_candidates[i].block_signing_key = init_pubkey; } -uint8_t application_impl::startup() +void application_impl::startup() { try { fc::create_directories(_data_dir / "blockchain"); @@ -444,18 +444,14 @@ uint8_t application_impl::startup() if( _options->count("api-access") ) { - if(fc::exists(_options->at("api-access").as())) - { - _apiaccess = fc::json::from_file( _options->at("api-access").as() ).as( 20 ); - ilog( "Using api access file from ${path}", - ("path", _options->at("api-access").as().string()) ); - } - else - { - elog("Failed to load file from ${path}", - ("path", _options->at("api-access").as().string())); - return EXIT_FAILURE; - } + fc::path api_access_file = _options->at("api-access").as(); + + FC_ASSERT( fc::exists(api_access_file), + "Failed to load file from ${path}", ("path", api_access_file) ); + + _apiaccess = fc::json::from_file( api_access_file ).as( 20 ); + ilog( "Using api access file from ${path}", + ("path", api_access_file) ); } else { @@ -475,7 +471,6 @@ uint8_t application_impl::startup() reset_p2p_node(_data_dir); reset_websocket_server(); reset_websocket_tls_server(); - return DO_NOT_EXIT; } FC_LOG_AND_RETHROW() } optional< api_access_info > application_impl::get_api_access_info(const string& username)const @@ -986,10 +981,6 @@ void application::set_program_options(boost::program_options::options_descriptio ; command_line_options.add(configuration_file_options); command_line_options.add_options() - ("create-genesis-json", bpo::value(), - "Path to create a Genesis State at. If a well-formed JSON file exists at the path, it will be parsed and any " - "missing fields in a Genesis State will be added, and any unknown fields will be removed. If no file or an " - "invalid file is found, it will be replaced with an example Genesis State.") ("replay-blockchain", "Rebuild object graph by replaying all blocks without validation") ("revalidate-blockchain", "Rebuild object graph by replaying all blocks with full validation") ("resync-blockchain", "Delete all blocks and re-sync with network from scratch") @@ -1001,36 +992,11 @@ void application::set_program_options(boost::program_options::options_descriptio configuration_file_options.add(_cfg_options); } -uint8_t application::initialize(const fc::path& data_dir, const boost::program_options::variables_map& options) +void application::initialize(const fc::path& data_dir, const boost::program_options::variables_map& options) { my->_data_dir = data_dir; my->_options = &options; - if( options.count("create-genesis-json") ) - { - fc::path genesis_out = options.at("create-genesis-json").as(); - genesis_state_type genesis_state = detail::create_example_genesis(); - if( fc::exists(genesis_out) ) - { - try { - genesis_state = fc::json::from_file(genesis_out).as( 20 ); - } catch(const fc::exception& e) { - std::cerr << "Unable to parse existing genesis file:\n" << e.to_string() - << "\nWould you like to replace it? [y/N] "; - char response = std::cin.get(); - if( toupper(response) != 'Y' ) - return EXIT_FAILURE; - } - - std::cerr << "Updating genesis state in file " << genesis_out.generic_string() << "\n"; - } else { - std::cerr << "Creating example genesis state in file " << genesis_out.generic_string() << "\n"; - } - fc::json::save_to_file(genesis_state, genesis_out); - - return EXIT_SUCCESS; - } - if ( options.count("io-threads") ) { const uint16_t num_threads = options["io-threads"].as(); @@ -1057,19 +1023,16 @@ uint8_t application::initialize(const fc::path& data_dir, const boost::program_o if(it == "elasticsearch") ++es_ah_conflict_counter; - if(es_ah_conflict_counter > 1) { - elog("Can't start program with elasticsearch and account_history plugin at the same time"); - return EXIT_FAILURE; - } + FC_ASSERT(es_ah_conflict_counter <= 1, "Can't start program with elasticsearch and account_history plugin at the same time"); + if (!it.empty()) enable_plugin(it); } - return true; } -uint8_t application::startup() +void application::startup() { try { - return my->startup(); + my->startup(); } catch ( const fc::exception& e ) { elog( "${e}", ("e",e.to_detail_string()) ); throw; diff --git a/libraries/app/application_impl.hxx b/libraries/app/application_impl.hxx index 25f7ee9d4c..2d5d48080d 100644 --- a/libraries/app/application_impl.hxx +++ b/libraries/app/application_impl.hxx @@ -36,13 +36,13 @@ class application_impl : public net::node_delegate { } - ~application_impl() + virtual ~application_impl() { } void set_dbg_init_key( graphene::chain::genesis_state_type& genesis, const std::string& init_key ); - uint8_t startup(); + void startup(); fc::optional< api_access_info > get_api_access_info(const string& username)const; diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 579f49fdc0..4892bb9a27 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -29,10 +29,6 @@ #include -#ifndef DO_NOT_EXIT - #define DO_NOT_EXIT 254 -#endif - namespace graphene { namespace app { namespace detail { class application_impl; } using std::string; @@ -54,17 +50,9 @@ namespace graphene { namespace app { void set_program_options( boost::program_options::options_description& command_line_options, boost::program_options::options_description& configuration_file_options )const; - /** - * Initializes the application - * @returns DO_NOT_EXIT if the calling method should continue, otherwise EXIT_SUCCESS or EXIT_FAILURE - */ - uint8_t initialize(const fc::path& data_dir, const boost::program_options::variables_map&options); + void initialize(const fc::path& data_dir, const boost::program_options::variables_map&options); void initialize_plugins( const boost::program_options::variables_map& options ); - /*** - * Performs startup - * @returns DO_NOT_EXIT if the calling method should continue, otherwise EXIT_SUCCESS or EXIT_FAILURE - */ - uint8_t startup(); + void startup(); void shutdown(); void startup_plugins(); void shutdown_plugins(); diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index ff2284962a..ac44686d46 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -163,14 +163,10 @@ int main(int argc, char** argv) { if( !options.count("plugins") ) options.insert( std::make_pair( "plugins", bpo::variable_value(std::string("delayed_node account_history market_history"), true) ) ); - uint8_t ret_val; - if ( (ret_val = node.initialize(data_dir, options)) != DO_NOT_EXIT ) - return ret_val; - + node.initialize(data_dir, options); node.initialize_plugins( options ); - if ( (ret_val = node.startup()) != DO_NOT_EXIT ) - return ret_val; + node.startup(); node.startup_plugins(); diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index dabcdd46a8..41bbce769f 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -121,20 +121,10 @@ int main(int argc, char** argv) { bpo::notify(options); - uint8_t ret_val; - if ( ( ret_val = node->initialize(data_dir, options)) != DO_NOT_EXIT ) - { - delete node; - return ret_val; - } + node->initialize(data_dir, options); node->initialize_plugins( options ); - if ( (ret_val = node->startup()) != DO_NOT_EXIT ) - { - delete node; - return ret_val; - } - + node->startup(); node->startup_plugins(); fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); From e49c04951e4a8ccc782d226473ecef4fd663d6bf Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 18 Jan 2019 14:21:13 -0500 Subject: [PATCH 129/172] Removed comment --- libraries/db/include/graphene/db/undo_database.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/db/include/graphene/db/undo_database.hpp b/libraries/db/include/graphene/db/undo_database.hpp index f2f77d607d..5234ac65aa 100644 --- a/libraries/db/include/graphene/db/undo_database.hpp +++ b/libraries/db/include/graphene/db/undo_database.hpp @@ -59,7 +59,7 @@ namespace graphene { namespace db { { mv._apply_undo = false; } - ~session(); // defined in implementation file to prevent repeated compiler warnings + ~session(); void commit() { _apply_undo = false; _db.commit(); } void undo() { if( _apply_undo ) _db.undo(); _apply_undo = false; } void merge() { if( _apply_undo ) _db.merge(); _apply_undo = false; } From 9fc89830a94d159184bfdf0ff5ef3117fbab55ca Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 18 Jan 2019 14:22:45 -0500 Subject: [PATCH 130/172] Removed comment --- libraries/db/include/graphene/db/undo_database.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/db/include/graphene/db/undo_database.hpp b/libraries/db/include/graphene/db/undo_database.hpp index f2f77d607d..5234ac65aa 100644 --- a/libraries/db/include/graphene/db/undo_database.hpp +++ b/libraries/db/include/graphene/db/undo_database.hpp @@ -59,7 +59,7 @@ namespace graphene { namespace db { { mv._apply_undo = false; } - ~session(); // defined in implementation file to prevent repeated compiler warnings + ~session(); void commit() { _apply_undo = false; _db.commit(); } void undo() { if( _apply_undo ) _db.undo(); _apply_undo = false; } void merge() { if( _apply_undo ) _db.merge(); _apply_undo = false; } From f2acea8e1f25dc94177545bb94a21000c9c7999f Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 21 Jan 2019 11:01:57 -0300 Subject: [PATCH 131/172] add utilities, net libraries, change app description --- libraries/README.md | 20 +++++++++++--------- programs/README.md | 18 +++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/libraries/README.md b/libraries/README.md index fa7e4d5ce4..c59fbf7135 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -7,12 +7,14 @@ A **graphene** blockchain software will use the `app` library to define what the Code in libraries is the most important part of **bitshares-core** project and it is maintained by the Bitshares Core Team and contributors. # Available Libraries -Folder | Name | Description | Category | Status ------------------------------------|--------------------------|-----------------------------------------------------------------------------|----------------|--------------- -[app](app) | Application | Control the behaviour of the `witness_node` application, connect to the seeds, open he API, load plugins, etc. | Library | Active -[chain](chain) | Blockchain | Define all objects, operations and types. This include the consensus protocol, defines the whole blockchain behaviour. | Library | Active -[db](db) | Database | Define the internal database graphene uses. | Library | Active -[egenesis](egenesis) | Genesis | | Library | Active -[fc](fc) | Fast-compiling C++ library | https://github.com/bitshares/bitshares-fc | Library | Active -[plugins](plugins) | Plugins | All plugin modules are stored here. | Library | Active -[wallet](wallet) | Wallet | Wallet definition for the `cli_wallet` software. | Library | Active | \ No newline at end of file +Folder | Name | Description | Category | Status +---|---|---|---|--- +[app](app) | Application | Bundles component libraries (chain, network, plugins) into a useful application. Also provides API access. | Library | Active +[chain](chain) | Blockchain | Define all objects, operations and types. This include the consensus protocol, defines the whole blockchain behaviour. | Library | Active +[db](db) | Database | Define the internal database graphene uses. | Library | Active +[egenesis](egenesis) | Genesis | | Library | Active +[fc](fc) | Fast-compiling C++ library | https://github.com/bitshares/bitshares-fc | Library | Active +[net](net) | Network | The graphene p2p layer. | Library | Active +[plugins](plugins) | Plugins | All plugin modules are stored here. | Library | Active +[utilities](utilities) | Network | Provide common utility calls used in applications or other libraries. | Library | Active +[wallet](wallet) | Wallet | Wallet definition for the `cli_wallet` software. | Library | Active diff --git a/programs/README.md b/programs/README.md index 2fb1def850..5f126447f1 100644 --- a/programs/README.md +++ b/programs/README.md @@ -9,12 +9,12 @@ Programs in here are part of the **bitshares-core** project and are maintained b # Available Programs -Folder | Name | Description | Category | Status | Help ------------------------------------|--------------------------|-----------------------------------------------------------------------------|----------------|---------------|--------------| -[witness_node](witness_node) | Witness Node | Main blockchain software | Node | Active | `./witness_node --help` -[cli_wallet](cli_wallet) | CLI Wallet | Command line wallet | Wallet | Active | `./cli_wallet --help` -[delayed_node](delayed_node) | Delayed Node | Runs a node with `delayed_node` plugin loaded. This is deprecatd in favour of `./witness_node --plugins "delayed_node"` | Node | Deprecated | `./delayed_node --help` -[js_operation_serializer](js_operation_serializer) | Operation Serializer | Dump all blockchain operations and types. Used by the UI. | Tool | Old | `./js_operation_serializer` -[size_checker](size_checker) | Size Checker | Provides wire size average in bytes of all the operations | Tool | Old | `./size_checker` -[build_helpers](build_helpers) | Build Helpers | | Tool | Old | `./member_enumerator` and `./cat-parts` -[genesis_util](genesis_util) | Gensis Utils | | Tool | Old | \ No newline at end of file +Folder | Name | Description | Category | Status | Help +---|---|---|---|---|--- +[witness_node](witness_node) | Witness Node | Main blockchain software | Node | Active | `./witness_node --help` +[cli_wallet](cli_wallet) | CLI Wallet | Command line wallet | Wallet | Active | `./cli_wallet --help` +[delayed_node](delayed_node) | Delayed Node | Runs a node with `delayed_node` plugin loaded. This is deprecatd in favour of `./witness_node --plugins "delayed_node"` | Node | Deprecated | `./delayed_node --help` +[js_operation_serializer](js_operation_serializer) | Operation Serializer | Dump all blockchain operations and types. Used by the UI. | Tool | Old | `./js_operation_serializer` +[size_checker](size_checker) | Size Checker | Provides wire size average in bytes of all the operations | Tool | Old | `./size_checker` +[build_helpers](build_helpers) | Build Helpers | | Tool | Old | `./member_enumerator` and `./cat-parts` +[genesis_util](genesis_util) | Genesis Utils | | Tool | Old | \ No newline at end of file From 4f079fa86b69cd1eb5eae91b70ac49152c2909a9 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Tue, 22 Jan 2019 11:38:14 -0300 Subject: [PATCH 132/172] remove category column --- libraries/README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/README.md b/libraries/README.md index c59fbf7135..36ded3611a 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -7,14 +7,14 @@ A **graphene** blockchain software will use the `app` library to define what the Code in libraries is the most important part of **bitshares-core** project and it is maintained by the Bitshares Core Team and contributors. # Available Libraries -Folder | Name | Description | Category | Status ----|---|---|---|--- -[app](app) | Application | Bundles component libraries (chain, network, plugins) into a useful application. Also provides API access. | Library | Active -[chain](chain) | Blockchain | Define all objects, operations and types. This include the consensus protocol, defines the whole blockchain behaviour. | Library | Active -[db](db) | Database | Define the internal database graphene uses. | Library | Active +Folder | Name | Description | Status +---|---|---|--- +[app](app) | Application | Bundles component libraries (chain, network, plugins) into a useful application. Also provides API access. | Active +[chain](chain) | Blockchain | Define all objects, operations and types. This include the consensus protocol, defines the whole blockchain behaviour. | Active +[db](db) | Database | Define the internal database graphene uses. | Active [egenesis](egenesis) | Genesis | | Library | Active -[fc](fc) | Fast-compiling C++ library | https://github.com/bitshares/bitshares-fc | Library | Active +[fc](fc) | Fast-compiling C++ library | https://github.com/bitshares/bitshares-fc | Active [net](net) | Network | The graphene p2p layer. | Library | Active -[plugins](plugins) | Plugins | All plugin modules are stored here. | Library | Active -[utilities](utilities) | Network | Provide common utility calls used in applications or other libraries. | Library | Active -[wallet](wallet) | Wallet | Wallet definition for the `cli_wallet` software. | Library | Active +[plugins](plugins) | Plugins | All plugin modules are stored here. | Active +[utilities](utilities) | Network | Provide common utility calls used in applications or other libraries. | Active +[wallet](wallet) | Wallet | Wallet definition for the `cli_wallet` software. | Active From f3da5289677fc2639542030c416cbc2e4247c0d6 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Tue, 22 Jan 2019 11:52:30 -0300 Subject: [PATCH 133/172] change some descriptions in libraries --- libraries/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/README.md b/libraries/README.md index 36ded3611a..39909d4c24 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -10,11 +10,11 @@ Code in libraries is the most important part of **bitshares-core** project and i Folder | Name | Description | Status ---|---|---|--- [app](app) | Application | Bundles component libraries (chain, network, plugins) into a useful application. Also provides API access. | Active -[chain](chain) | Blockchain | Define all objects, operations and types. This include the consensus protocol, defines the whole blockchain behaviour. | Active -[db](db) | Database | Define the internal database graphene uses. | Active -[egenesis](egenesis) | Genesis | | Library | Active +[chain](chain) | Blockchain | Defines all objects, operations and types. This include the consensus protocol, defines the whole blockchain behaviour. | Active +[db](db) | Database | Defines the internal database graphene uses. | Active +[egenesis](egenesis) | Genesis | | Active [fc](fc) | Fast-compiling C++ library | https://github.com/bitshares/bitshares-fc | Active -[net](net) | Network | The graphene p2p layer. | Library | Active -[plugins](plugins) | Plugins | All plugin modules are stored here. | Active -[utilities](utilities) | Network | Provide common utility calls used in applications or other libraries. | Active +[net](net) | Network | The graphene p2p layer. | Active +[plugins](plugins) | Plugins | Collection of singleton designed modules used for extending the bitshares-core. | Active +[utilities](utilities) | Network | Common utility calls used in applications or other libraries. | Active [wallet](wallet) | Wallet | Wallet definition for the `cli_wallet` software. | Active From 8624fad31375dedaef86a0b1bb31c13223d24c53 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Tue, 22 Jan 2019 12:21:22 -0300 Subject: [PATCH 134/172] change some descriptions in programs --- programs/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/programs/README.md b/programs/README.md index 5f126447f1..2726bcdf37 100644 --- a/programs/README.md +++ b/programs/README.md @@ -11,10 +11,10 @@ Programs in here are part of the **bitshares-core** project and are maintained b Folder | Name | Description | Category | Status | Help ---|---|---|---|---|--- -[witness_node](witness_node) | Witness Node | Main blockchain software | Node | Active | `./witness_node --help` -[cli_wallet](cli_wallet) | CLI Wallet | Command line wallet | Wallet | Active | `./cli_wallet --help` -[delayed_node](delayed_node) | Delayed Node | Runs a node with `delayed_node` plugin loaded. This is deprecatd in favour of `./witness_node --plugins "delayed_node"` | Node | Deprecated | `./delayed_node --help` +[witness_node](witness_node) | Witness Node | Main software used to sign blocks or provide services. | Node | Active | `./witness_node --help` +[cli_wallet](cli_wallet) | CLI Wallet | Software to interact with the blockchain by command line. | Wallet | Active | `./cli_wallet --help` +[delayed_node](delayed_node) | Delayed Node | Runs a node with `delayed_node` plugin loaded. This is deprecated in favour of `./witness_node --plugins "delayed_node"`. | Node | Deprecated | `./delayed_node --help` [js_operation_serializer](js_operation_serializer) | Operation Serializer | Dump all blockchain operations and types. Used by the UI. | Tool | Old | `./js_operation_serializer` -[size_checker](size_checker) | Size Checker | Provides wire size average in bytes of all the operations | Tool | Old | `./size_checker` +[size_checker](size_checker) | Size Checker | Return wire size average in bytes of all the operations. | Tool | Old | `./size_checker` [build_helpers](build_helpers) | Build Helpers | | Tool | Old | `./member_enumerator` and `./cat-parts` [genesis_util](genesis_util) | Genesis Utils | | Tool | Old | \ No newline at end of file From a4588a620507b44c6ea67fd8096849de8b034485 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Tue, 22 Jan 2019 18:41:38 -0300 Subject: [PATCH 135/172] add subprograms --- programs/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/programs/README.md b/programs/README.md index 2726bcdf37..794645c439 100644 --- a/programs/README.md +++ b/programs/README.md @@ -16,5 +16,8 @@ Folder | Name | Description | Category | Status | Help [delayed_node](delayed_node) | Delayed Node | Runs a node with `delayed_node` plugin loaded. This is deprecated in favour of `./witness_node --plugins "delayed_node"`. | Node | Deprecated | `./delayed_node --help` [js_operation_serializer](js_operation_serializer) | Operation Serializer | Dump all blockchain operations and types. Used by the UI. | Tool | Old | `./js_operation_serializer` [size_checker](size_checker) | Size Checker | Return wire size average in bytes of all the operations. | Tool | Old | `./size_checker` -[build_helpers](build_helpers) | Build Helpers | | Tool | Old | `./member_enumerator` and `./cat-parts` -[genesis_util](genesis_util) | Genesis Utils | | Tool | Old | \ No newline at end of file +[cat-parts](build_helpers/cat-parts.cpp) | Cat parts | Used to create `hardfork.hpp` from individual files. | Tool | Old | `./cat-parts` +[check_reflect](build_helpers/check_reflect.py) | Check reflect | Check reflected fields automatically(https://github.com/cryptonomex/graphene/issues/562) | Tool | Old | `doxygen;cp -rf doxygen programs/build_helpers; ./check_reflect.py` +[member_enumerator](build_helpers/member_enumerator.cpp) | Member enumerator | | Tool | Deprecated | `./member_enumerator` +[get_dev_key](genesis_util/get_dev_key.cpp) | Get Dev Key | Create public, private and address keys. Useful in private testnets, `genesis.json` files, new blockchain creation and others. | Tool | Active | `/programs/genesis_util/get_dev_key -h` +[genesis_util](genesis_util) | Genesis Utils | Other utilities for genesis creation. | Tool | Old | From 41bff6ead331c4f340e874c5c9102d23deb487be Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 24 Jan 2019 16:08:23 -0300 Subject: [PATCH 136/172] add egenesis library description --- libraries/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/README.md b/libraries/README.md index 39909d4c24..256d15029b 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -12,9 +12,9 @@ Folder | Name | Description | Status [app](app) | Application | Bundles component libraries (chain, network, plugins) into a useful application. Also provides API access. | Active [chain](chain) | Blockchain | Defines all objects, operations and types. This include the consensus protocol, defines the whole blockchain behaviour. | Active [db](db) | Database | Defines the internal database graphene uses. | Active -[egenesis](egenesis) | Genesis | | Active +[egenesis](egenesis) | Genesis | Hardcodes the `genesis.json` file into the `witness_node` executable.| Active [fc](fc) | Fast-compiling C++ library | https://github.com/bitshares/bitshares-fc | Active [net](net) | Network | The graphene p2p layer. | Active [plugins](plugins) | Plugins | Collection of singleton designed modules used for extending the bitshares-core. | Active -[utilities](utilities) | Network | Common utility calls used in applications or other libraries. | Active +[utilities](utilities) | Utilities | Common utility calls used in applications or other libraries. | Active [wallet](wallet) | Wallet | Wallet definition for the `cli_wallet` software. | Active From 10f528214d8d97ce4975ded33ca4cdb71d489b46 Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 24 Jan 2019 14:33:03 -0500 Subject: [PATCH 137/172] Fix CMake Doxygen Perl reference --- libraries/wallet/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/wallet/CMakeLists.txt b/libraries/wallet/CMakeLists.txt index cd0000e58a..8ff42dc95f 100644 --- a/libraries/wallet/CMakeLists.txt +++ b/libraries/wallet/CMakeLists.txt @@ -17,7 +17,7 @@ if( PERL_FOUND AND DOXYGEN_FOUND AND NOT "${CMAKE_GENERATOR}" STREQUAL "Ninja" ) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/doxygen/perlmod/DoxyDocs.pm ) else(MSVC) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp - COMMAND PERLLIB=${CMAKE_CURRENT_SOURCE_DIR} ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new + COMMAND PERLLIB=${CMAKE_CURRENT_BINARY_DIR} ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp.new DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generate_api_documentation.pl ${CMAKE_CURRENT_BINARY_DIR}/doxygen/perlmod/DoxyDocs.pm ) From accc38152b38d6264e62245957bcbcb2eefdad59 Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 24 Jan 2019 15:38:01 -0500 Subject: [PATCH 138/172] catch exception in destructor --- tests/common/database_fixture.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 1f08d0ef25..ac379db839 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -219,7 +219,11 @@ database_fixture::~database_fixture() } return; } catch (fc::exception& ex) { - BOOST_FAIL( ex.to_detail_string() ); + BOOST_FAIL( std::string("fc::exception in ~database_fixture: ") + ex.to_detail_string() ); + } catch (std::exception& e) { + BOOST_FAIL( std::string("std::exception in ~database_fixture:") + e.what() ); + } catch (...) { + BOOST_FAIL( "Uncaught exception in ~database_fixture" ); } } From a26dc47ad31379cb6e1bb0744777cfab7ba3585a Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 24 Jan 2019 15:38:27 -0500 Subject: [PATCH 139/172] fix warnings in test --- tests/tests/history_api_tests.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 48e4833da2..72fc4010f3 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -549,7 +549,6 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { int asset_create_op_id = operation::tag::value; int account_create_op_id = operation::tag::value; - int transfer_op_id = operation::tag::value; //account_id_type() did 1 asset_create op vector histories = hist_api.get_account_history_operations( @@ -594,7 +593,7 @@ BOOST_AUTO_TEST_CASE(get_account_history_operations) { // see https://github.com/bitshares/bitshares-core/issues/1490 histories = hist_api.get_account_history_operations( "committee-account", account_create_op_id, operation_history_id_type(), operation_history_id_type(), 100); - BOOST_CHECK_EQUAL(histories.size(), 75); + BOOST_CHECK_EQUAL(histories.size(), 75u); if (histories.size() > 0) BOOST_CHECK_EQUAL(histories[0].op.which(), account_create_op_id); From cf2682fb309c03c1e95620d63274f076ba490a64 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 25 Jan 2019 11:05:09 -0300 Subject: [PATCH 140/172] add es-objects-start-es-after-block option --- libraries/plugins/es_objects/es_objects.cpp | 158 ++++++++++---------- 1 file changed, 81 insertions(+), 77 deletions(-) diff --git a/libraries/plugins/es_objects/es_objects.cpp b/libraries/plugins/es_objects/es_objects.cpp index 5695064325..d588fdbe21 100644 --- a/libraries/plugins/es_objects/es_objects.cpp +++ b/libraries/plugins/es_objects/es_objects.cpp @@ -63,6 +63,7 @@ class es_objects_plugin_impl bool _es_objects_limit_orders = true; bool _es_objects_asset_bitasset = true; std::string _es_objects_index_prefix = "objects-"; + uint32_t _es_objects_start_es_after_block = 0; // disabled CURL *curl; // curl handler vector bulk; vector prepare; @@ -84,88 +85,87 @@ bool es_objects_plugin_impl::index_database( const vector& ids, block_time = db.head_block_time(); block_number = db.head_block_num(); - // check if we are in replay or in sync and change number of bulk documents accordingly - uint32_t limit_documents = 0; - if((fc::time_point::now() - block_time) < fc::seconds(30)) - limit_documents = _es_objects_bulk_sync; - else - limit_documents = _es_objects_bulk_replay; - - for(auto const& value: ids) { - if(value.is() && _es_objects_proposals) { - auto obj = db.find_object(value); - auto p = static_cast(obj); - if(p != nullptr) { - if(action == "delete") - remove_from_database(p->id, "proposal"); - else - prepareTemplate(*p, "proposal"); - } - } - else if(value.is() && _es_objects_accounts) { - auto obj = db.find_object(value); - auto a = static_cast(obj); - if(a != nullptr) { - if(action == "delete") - remove_from_database(a->id, "account"); - else - prepareTemplate(*a, "account"); - } - } - else if(value.is() && _es_objects_assets) { - auto obj = db.find_object(value); - auto a = static_cast(obj); - if(a != nullptr) { - if(action == "delete") - remove_from_database(a->id, "asset"); - else - prepareTemplate(*a, "asset"); - } - } - else if(value.is() && _es_objects_balances) { - auto obj = db.find_object(value); - auto b = static_cast(obj); - if(b != nullptr) { - if(action == "delete") - remove_from_database(b->id, "balance"); - else - prepareTemplate(*b, "balance"); - } - } - else if(value.is() && _es_objects_limit_orders) { - auto obj = db.find_object(value); - auto l = static_cast(obj); - if(l != nullptr) { - if(action == "delete") - remove_from_database(l->id, "limitorder"); - else - prepareTemplate(*l, "limitorder"); - } - } - else if(value.is() && _es_objects_asset_bitasset) { - auto obj = db.find_object(value); - auto ba = static_cast(obj); - if(ba != nullptr) { - if(action == "delete") - remove_from_database(ba->id, "bitasset"); - else - prepareTemplate(*ba, "bitasset"); + if(_es_objects_start_es_after_block == 0 || block_number > _es_objects_start_es_after_block) { + + // check if we are in replay or in sync and change number of bulk documents accordingly + uint32_t limit_documents = 0; + if ((fc::time_point::now() - block_time) < fc::seconds(30)) + limit_documents = _es_objects_bulk_sync; + else + limit_documents = _es_objects_bulk_replay; + + + for (auto const &value: ids) { + if (value.is() && _es_objects_proposals) { + auto obj = db.find_object(value); + auto p = static_cast(obj); + if (p != nullptr) { + if (action == "delete") + remove_from_database(p->id, "proposal"); + else + prepareTemplate(*p, "proposal"); + } + } else if (value.is() && _es_objects_accounts) { + auto obj = db.find_object(value); + auto a = static_cast(obj); + if (a != nullptr) { + if (action == "delete") + remove_from_database(a->id, "account"); + else + prepareTemplate(*a, "account"); + } + } else if (value.is() && _es_objects_assets) { + auto obj = db.find_object(value); + auto a = static_cast(obj); + if (a != nullptr) { + if (action == "delete") + remove_from_database(a->id, "asset"); + else + prepareTemplate(*a, "asset"); + } + } else if (value.is() && _es_objects_balances) { + auto obj = db.find_object(value); + auto b = static_cast(obj); + if (b != nullptr) { + if (action == "delete") + remove_from_database(b->id, "balance"); + else + prepareTemplate(*b, "balance"); + } + } else if (value.is() && _es_objects_limit_orders) { + auto obj = db.find_object(value); + auto l = static_cast(obj); + if (l != nullptr) { + if (action == "delete") + remove_from_database(l->id, "limitorder"); + else + prepareTemplate(*l, "limitorder"); + } + } else if (value.is() && _es_objects_asset_bitasset) { + auto obj = db.find_object(value); + auto ba = static_cast(obj); + if (ba != nullptr) { + if (action == "delete") + remove_from_database(ba->id, "bitasset"); + else + prepareTemplate(*ba, "bitasset"); + } } } - } - if (curl && bulk.size() >= limit_documents) { // we are in bulk time, ready to add data to elasticsearech + if (curl && bulk.size() >= limit_documents) { // we are in bulk time, ready to add data to elasticsearech - graphene::utilities::ES es; - es.curl = curl; - es.bulk_lines = bulk; - es.elasticsearch_url = _es_objects_elasticsearch_url; - es.auth = _es_objects_auth; + graphene::utilities::ES es; + es.curl = curl; + es.bulk_lines = bulk; + es.elasticsearch_url = _es_objects_elasticsearch_url; + es.auth = _es_objects_auth; - if(!graphene::utilities::SendBulk(std::move(es))) - return false; - else - bulk.clear(); + if (!graphene::utilities::SendBulk(std::move(es))) + return false; + else + bulk.clear(); + } } return true; @@ -257,6 +257,7 @@ void es_objects_plugin::plugin_set_program_options( ("es-objects-asset-bitasset", boost::program_options::value(), "Store feed data(true)") ("es-objects-index-prefix", boost::program_options::value(), "Add a prefix to the index(objects-)") ("es-objects-keep-only-current", boost::program_options::value(), "Keep only current state of the objects(true)") + ("es-objects-start-es-after-block", boost::program_options::value(), "Start doing ES job after block(0)") ; cfg.add(cli); } @@ -319,6 +320,9 @@ void es_objects_plugin::plugin_initialize(const boost::program_options::variable if (options.count("es-objects-keep-only-current")) { my->_es_objects_keep_only_current = options["es-objects-keep-only-current"].as(); } + if (options.count("es-objects-start-es-after-block")) { + my->_es_objects_start_es_after_block = options["es-objects-start-es-after-block"].as(); + } } void es_objects_plugin::plugin_startup() From bc48dae42c22a038754dd183012f6f06fb147cef Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 25 Jan 2019 18:45:49 -0300 Subject: [PATCH 141/172] change cat-parts from old to active --- programs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/README.md b/programs/README.md index 794645c439..26b2b36886 100644 --- a/programs/README.md +++ b/programs/README.md @@ -16,7 +16,7 @@ Folder | Name | Description | Category | Status | Help [delayed_node](delayed_node) | Delayed Node | Runs a node with `delayed_node` plugin loaded. This is deprecated in favour of `./witness_node --plugins "delayed_node"`. | Node | Deprecated | `./delayed_node --help` [js_operation_serializer](js_operation_serializer) | Operation Serializer | Dump all blockchain operations and types. Used by the UI. | Tool | Old | `./js_operation_serializer` [size_checker](size_checker) | Size Checker | Return wire size average in bytes of all the operations. | Tool | Old | `./size_checker` -[cat-parts](build_helpers/cat-parts.cpp) | Cat parts | Used to create `hardfork.hpp` from individual files. | Tool | Old | `./cat-parts` +[cat-parts](build_helpers/cat-parts.cpp) | Cat parts | Used to create `hardfork.hpp` from individual files. | Tool | Active | `./cat-parts` [check_reflect](build_helpers/check_reflect.py) | Check reflect | Check reflected fields automatically(https://github.com/cryptonomex/graphene/issues/562) | Tool | Old | `doxygen;cp -rf doxygen programs/build_helpers; ./check_reflect.py` [member_enumerator](build_helpers/member_enumerator.cpp) | Member enumerator | | Tool | Deprecated | `./member_enumerator` [get_dev_key](genesis_util/get_dev_key.cpp) | Get Dev Key | Create public, private and address keys. Useful in private testnets, `genesis.json` files, new blockchain creation and others. | Tool | Active | `/programs/genesis_util/get_dev_key -h` From 95b4aa66bd8878b0df76d37ca26d4c5cfe3f13bc Mon Sep 17 00:00:00 2001 From: abitmore Date: Sat, 26 Jan 2019 22:54:13 +0000 Subject: [PATCH 142/172] Rename API param operation_id to operation_type in order to reduce confusion, because we usually use "operation_type" to indicate the type of an operation, but use "operation_id" for operation_history_id_type. --- libraries/app/api.cpp | 6 +++--- libraries/app/include/graphene/app/api.hpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 61e9637a9f..8bd48b6df4 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -345,7 +345,7 @@ namespace graphene { namespace app { } vector history_api::get_account_history_operations( const std::string account_id_or_name, - int operation_id, + int operation_type, operation_history_id_type start, operation_history_id_type stop, unsigned limit) const @@ -368,7 +368,7 @@ namespace graphene { namespace app { { if( node->operation_id.instance.value <= start.instance.value ) { - if(node->operation_id(db).op.which() == operation_id) + if(node->operation_id(db).op.which() == operation_type) result.push_back( node->operation_id(db) ); } if( node->next == account_transaction_history_id_type() ) @@ -377,7 +377,7 @@ namespace graphene { namespace app { } if( stop.instance.value == 0 && result.size() < limit ) { auto head = db.find(account_transaction_history_id_type()); - if (head != nullptr && head->account == account && head->operation_id(db).op.which() == operation_id) + if (head != nullptr && head->account == account && head->operation_id(db).op.which() == operation_type) result.push_back(head->operation_id(db)); } return result; diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index af34bbaf73..54ed6bfc20 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -153,7 +153,7 @@ namespace graphene { namespace app { /** * @brief Get only asked operations relevant to the specified account * @param account_id_or_name The account ID or name whose history should be queried - * @param operation_id The ID of the operation we want to get operations in the account + * @param operation_type The type of the operation we want to get operations in the account * ( 0 = transfer , 1 = limit order create, ...) * @param stop ID of the earliest operation to retrieve * @param limit Maximum number of operations to retrieve (must not exceed 100) @@ -162,7 +162,7 @@ namespace graphene { namespace app { */ vector get_account_history_operations( const std::string account_id_or_name, - int operation_id, + int operation_type, operation_history_id_type start = operation_history_id_type(), operation_history_id_type stop = operation_history_id_type(), unsigned limit = 100 From aa469bc8e2210e2860fc9f77576819ecc7fbcc25 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sun, 27 Jan 2019 10:27:38 -0300 Subject: [PATCH 143/172] remove special case 0 for start after block in both ES plugins --- libraries/plugins/elasticsearch/elasticsearch_plugin.cpp | 4 ++-- libraries/plugins/es_objects/es_objects.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp index 6af2df19ac..dd29c38b39 100644 --- a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp +++ b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp @@ -59,7 +59,7 @@ class elasticsearch_plugin_impl std::string _elasticsearch_basic_auth = ""; std::string _elasticsearch_index_prefix = "bitshares-"; bool _elasticsearch_operation_object = false; - uint32_t _elasticsearch_start_es_after_block = 0; // disabled + uint32_t _elasticsearch_start_es_after_block = 0; CURL *curl; // curl handler vector bulk_lines; // vector of op lines vector prepare; @@ -283,7 +283,7 @@ bool elasticsearch_plugin_impl::add_elasticsearch( const account_id_type account const auto &stats_obj = getStatsObject(account_id); const auto &ath = addNewEntry(stats_obj, account_id, oho); growStats(stats_obj, ath); - if(_elasticsearch_start_es_after_block == 0 || block_number > _elasticsearch_start_es_after_block) { + if(block_number > _elasticsearch_start_es_after_block) { createBulkLine(ath); prepareBulk(ath.id); } diff --git a/libraries/plugins/es_objects/es_objects.cpp b/libraries/plugins/es_objects/es_objects.cpp index d588fdbe21..10ee8ba473 100644 --- a/libraries/plugins/es_objects/es_objects.cpp +++ b/libraries/plugins/es_objects/es_objects.cpp @@ -63,7 +63,7 @@ class es_objects_plugin_impl bool _es_objects_limit_orders = true; bool _es_objects_asset_bitasset = true; std::string _es_objects_index_prefix = "objects-"; - uint32_t _es_objects_start_es_after_block = 0; // disabled + uint32_t _es_objects_start_es_after_block = 0; CURL *curl; // curl handler vector bulk; vector prepare; @@ -85,7 +85,7 @@ bool es_objects_plugin_impl::index_database( const vector& ids, block_time = db.head_block_time(); block_number = db.head_block_num(); - if(_es_objects_start_es_after_block == 0 || block_number > _es_objects_start_es_after_block) { + if(block_number > _es_objects_start_es_after_block) { // check if we are in replay or in sync and change number of bulk documents accordingly uint32_t limit_documents = 0; From 8aa3ebdefee4a20ce90f9e9031b45e5999912328 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 29 Jan 2019 18:41:24 +0100 Subject: [PATCH 144/172] Try to make docker build work again --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index fa58c2da1b..363460d2c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,6 +38,7 @@ RUN \ git submodule update --init --recursive && \ cmake \ -DCMAKE_BUILD_TYPE=Release \ + -DGRAPHENE_DISABLE_UNITY_BUILD=ON \ . && \ make witness_node cli_wallet && \ install -s programs/witness_node/witness_node programs/cli_wallet/cli_wallet /usr/local/bin && \ From 16206f90226fcf959686ad6a2eb4854997287c89 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 29 Jan 2019 18:41:53 +0100 Subject: [PATCH 145/172] Remove unused boost::serialization dependency --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 948d7412cb..e10b61ac92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,6 @@ LIST(APPEND BOOST_COMPONENTS thread system filesystem program_options - serialization chrono unit_test_framework context From b579a544be459df636db38181c1925c67ca41f77 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 29 Jan 2019 16:10:23 -0500 Subject: [PATCH 146/172] Implement API changes --- libraries/app/api.cpp | 31 +++++++++++++------ libraries/app/database_api.cpp | 5 +++ libraries/app/include/graphene/app/api.hpp | 26 +++++++++------- .../app/include/graphene/app/database_api.hpp | 7 +++++ libraries/wallet/wallet.cpp | 2 +- tests/tests/asset_api_tests.cpp | 4 +-- 6 files changed, 51 insertions(+), 24 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 8bd48b6df4..ff8c65e50a 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -101,7 +101,7 @@ namespace graphene { namespace app { } else if( api_name == "asset_api" ) { - _asset_api = std::make_shared< asset_api >( std::ref( *_app.chain_database() ) ); + _asset_api = std::make_shared< asset_api >( _app ); } else if( api_name == "orders_api" ) { @@ -284,10 +284,12 @@ namespace graphene { namespace app { return *_debug_api; } - vector history_api::get_fill_order_history( asset_id_type a, asset_id_type b, uint32_t limit )const + vector history_api::get_fill_order_history( std::string asset_a, std::string asset_b, uint32_t limit )const { FC_ASSERT(_app.chain_database()); const auto& db = *_app.chain_database(); + asset_id_type a = database_api.get_asset_id_from_string( asset_a ); + asset_id_type b = database_api.get_asset_id_from_string( asset_b ); if( a > b ) std::swap(a,b); const auto& history_idx = db.get_index_type().indices().get(); history_key hkey; @@ -443,11 +445,13 @@ namespace graphene { namespace app { return result; } - vector history_api::get_market_history( asset_id_type a, asset_id_type b, + vector history_api::get_market_history( std::string asset_a, std::string asset_b, uint32_t bucket_seconds, fc::time_point_sec start, fc::time_point_sec end )const { try { FC_ASSERT(_app.chain_database()); const auto& db = *_app.chain_database(); + asset_id_type a = database_api.get_asset_id_from_string( asset_a ); + asset_id_type b = database_api.get_asset_id_from_string( asset_b ); vector result; result.reserve(200); @@ -467,7 +471,7 @@ namespace graphene { namespace app { ++itr; } return result; - } FC_CAPTURE_AND_RETHROW( (a)(b)(bucket_seconds)(start)(end) ) } + } FC_CAPTURE_AND_RETHROW( (asset_a)(asset_b)(bucket_seconds)(start)(end) ) } crypto_api::crypto_api(){}; @@ -526,12 +530,17 @@ namespace graphene { namespace app { } // asset_api - asset_api::asset_api(graphene::chain::database& db) : _db(db) { } + asset_api::asset_api(graphene::app::application& app) : + _db( *app.chain_database()), + database_api( std::ref(*app.chain_database()), &(app.get_options()) + ) { } asset_api::~asset_api() { } - vector asset_api::get_asset_holders( asset_id_type asset_id, uint32_t start, uint32_t limit ) const { + vector asset_api::get_asset_holders( std::string asset, uint32_t start, uint32_t limit ) const { FC_ASSERT(limit <= 100); + asset_id_type asset_id = database_api.get_asset_id_from_string( asset ); + const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); @@ -562,9 +571,10 @@ namespace graphene { namespace app { return result; } // get number of asset holders. - int asset_api::get_asset_holders_count( asset_id_type asset_id ) const { + int asset_api::get_asset_holders_count( std::string asset ) const { const auto& bal_idx = _db.get_index_type< account_balance_index >().indices().get< by_asset_balance >(); + asset_id_type asset_id = database_api.get_asset_id_from_string( asset ); auto range = bal_idx.equal_range( boost::make_tuple( asset_id ) ); int count = boost::distance(range) - 1; @@ -607,8 +617,8 @@ namespace graphene { namespace app { return plugin->tracked_groups(); } - vector< limit_order_group > orders_api::get_grouped_limit_orders( asset_id_type base_asset_id, - asset_id_type quote_asset_id, + vector< limit_order_group > orders_api::get_grouped_limit_orders( std::string base_asset, + std::string quote_asset, uint16_t group, optional start, uint32_t limit )const @@ -619,6 +629,9 @@ namespace graphene { namespace app { const auto& limit_groups = plugin->limit_order_groups(); vector< limit_order_group > result; + asset_id_type base_asset_id = database_api.get_asset_id_from_string( base_asset ); + asset_id_type quote_asset_id = database_api.get_asset_id_from_string( quote_asset ); + price max_price = price::max( base_asset_id, quote_asset_id ); price min_price = price::min( base_asset_id, quote_asset_id ); if( start.valid() && !start->is_null() ) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index d37cf5989a..ee55fce992 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -1109,6 +1109,11 @@ vector database_api_impl::get_vesting_balances( const st // // ////////////////////////////////////////////////////////////////////// +asset_id_type database_api::get_asset_id_from_string(const std::string& name_or_id)const +{ + return my->get_asset_from_string( name_or_id )->id; // safe? +} + vector> database_api::get_assets(const vector& asset_symbols_or_ids)const { return my->get_assets( asset_symbols_or_ids ); diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 54ed6bfc20..9109c8c453 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -192,7 +192,7 @@ namespace graphene { namespace app { * @param limit Maximum records to return * @return a list of order_history objects, in "most recent first" order */ - vector get_fill_order_history( asset_id_type a, asset_id_type b, uint32_t limit )const; + vector get_fill_order_history( std::string a, std::string b, uint32_t limit )const; /** * @brief Get OHLCV data of a trading pair in a time range @@ -205,7 +205,7 @@ namespace graphene { namespace app { * @return A list of OHLCV data, in "least recent first" order. * If there are more than 200 records in the specified time range, the first 200 records will be returned. */ - vector get_market_history( asset_id_type a, asset_id_type b, uint32_t bucket_seconds, + vector get_market_history( std::string a, std::string b, uint32_t bucket_seconds, fc::time_point_sec start, fc::time_point_sec end )const; /** @@ -438,24 +438,24 @@ namespace graphene { namespace app { class asset_api { public: - asset_api(graphene::chain::database& db); + asset_api(graphene::app::application& app); ~asset_api(); /** * @brief Get asset holders for a specific asset - * @param asset_id The specific asset + * @param asset The specific asset id or name * @param start The start index * @param limit Maximum limit must not exceed 100 * @return A list of asset holders for the specified asset */ - vector get_asset_holders( asset_id_type asset_id, uint32_t start, uint32_t limit )const; + vector get_asset_holders( std::string asset, uint32_t start, uint32_t limit )const; /** * @brief Get asset holders count for a specific asset - * @param asset_id The specific asset + * @param asset The specific asset id or name * @return Holders count for the specified asset */ - int get_asset_holders_count( asset_id_type asset_id )const; + int get_asset_holders_count( std::string asset )const; /** * @brief Get all asset holders @@ -465,6 +465,7 @@ namespace graphene { namespace app { private: graphene::chain::database& _db; + graphene::app::database_api database_api; }; /** @@ -473,7 +474,7 @@ namespace graphene { namespace app { class orders_api { public: - orders_api(application& app):_app(app){} + orders_api(application& app):_app(app), database_api( std::ref(*app.chain_database()), &(app.get_options()) ){} //virtual ~orders_api() {} /** @@ -485,21 +486,22 @@ namespace graphene { namespace app { /** * @breif Get grouped limit orders in given market. * - * @param base_asset_id ID of asset being sold - * @param quote_asset_id ID of asset being purchased + * @param base_asset ID or name of asset being sold + * @param quote_asset ID or name of asset being purchased * @param group Maximum price diff within each order group, have to be one of configured values * @param start Optional price to indicate the first order group to retrieve * @param limit Maximum number of order groups to retrieve (must not exceed 101) * @return The grouped limit orders, ordered from best offered price to worst */ - vector< limit_order_group > get_grouped_limit_orders( asset_id_type base_asset_id, - asset_id_type quote_asset_id, + vector< limit_order_group > get_grouped_limit_orders( std::string base_asset, + std::string quote_asset, uint16_t group, optional start, uint32_t limit )const; private: application& _app; + graphene::app::database_api database_api; }; /** diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 772476a8e3..b5437556bc 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -373,6 +373,13 @@ class database_api // Assets // //////////// + /** + * @brief Get asset id from a name or ID + * @param name_or_id ID or name of the asset + * @return asset id + */ + asset_id_type get_asset_id_from_string(const std::string& name_or_id) const; + /** * @brief Get a list of assets by ID * @param asset_symbols_or_ids Symbol names or IDs of the assets to retrieve diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index c980fb7b0d..f57110ed99 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3190,7 +3190,7 @@ vector wallet_api::get_market_history( fc::time_point_sec start, fc::time_point_sec end )const { - return my->_remote_hist->get_market_history( get_asset_id(symbol1), get_asset_id(symbol2), bucket, start, end ); + return my->_remote_hist->get_market_history( symbol1, symbol2, bucket, start, end ); } vector wallet_api::get_account_limit_orders( diff --git a/tests/tests/asset_api_tests.cpp b/tests/tests/asset_api_tests.cpp index 332f1b13b4..ff3eeb9785 100644 --- a/tests/tests/asset_api_tests.cpp +++ b/tests/tests/asset_api_tests.cpp @@ -37,7 +37,7 @@ BOOST_FIXTURE_TEST_SUITE(asset_api_tests, database_fixture) BOOST_AUTO_TEST_CASE( asset_holders ) { - graphene::app::asset_api asset_api(db); + graphene::app::asset_api asset_api(app); // create an asset and some accounts create_bitasset("USD", account_id_type()); @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE( asset_holders ) transfer(account_id_type()(db), bob, asset(300)); // make call - vector holders = asset_api.get_asset_holders(asset_id_type(), 0, 100); + vector holders = asset_api.get_asset_holders( std::string( static_cast(asset_id_type())), 0, 100); BOOST_CHECK_EQUAL(holders.size(), 4u); // by now we can guarantee the order From 4c0062cb552eed801250767fee37ccd71eb5bb51 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 29 Jan 2019 21:38:11 +0100 Subject: [PATCH 147/172] Try to avoid travis timeouts better --- .travis.yml | 24 +++++------ programs/build_helpers/buildstep | 55 ++++++++++++++++++++++++++ programs/build_helpers/make_with_sonar | 8 ++++ 3 files changed, 76 insertions(+), 11 deletions(-) create mode 100755 programs/build_helpers/buildstep create mode 100755 programs/build_helpers/make_with_sonar diff --git a/.travis.yml b/.travis.yml index 236fa6ef78..7225d9d669 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,16 +27,18 @@ env: - CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,time_macros script: - - 'echo $((`date +%s` - 120)) >_start_time' + - programs/build_helpers/buildstep -s 3450 - ccache -s - - '( [ `ccache -s | grep "files in cache" | cut -c 20-` = 0 ] && touch _empty_cache ) || true' - - sed -i '/tests/d' libraries/fc/CMakeLists.txt - - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON . - - 'which build-wrapper-linux-x86-64 && build-wrapper-linux-x86-64 --out-dir bw-output make -j 2 cli_wallet witness_node chain_test cli_test || make -j 2 cli_wallet witness_node chain_test cli_test' + - programs/build_helpers/buildstep Prepare 1 "sed -i '/tests/d' libraries/fc/CMakeLists.txt" + - programs/build_helpers/buildstep cmake 5 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON ." + - programs/build_helpers/buildstep make.cli_wallet 2600 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_wallet" + - programs/build_helpers/buildstep make.witness_node 1800 "programs/build_helpers/make_with_sonar bw-output -j 2 witness_node" + - programs/build_helpers/buildstep make.chain_test 1800 "programs/build_helpers/make_with_sonar bw-output -j 2 chain_test" + - programs/build_helpers/buildstep make.cli_test 1800 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_test" - set -o pipefail - - '[ $((`date +%s` - `cat _start_time`)) -gt $((42 * 60)) ] && touch _empty_cache || true' - - '[ -r _empty_cache ] || tests/chain_test 2>&1 | cat' - - '[ -r _empty_cache ] || tests/cli_test 2>&1 | cat' - - 'find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d | while read d; do gcov -o "$d" "${d/CMakeFiles*.dir//}"/*.cpp; done >/dev/null' - - '[ -r _empty_cache ] || ( which sonar-scanner && sonar-scanner || true )' - - '[ ! -r _empty_cache ] || ( echo "WARNING! Skipped some tests due to compile time! Please restart with populated cache." && false )' + - programs/build_helpers/buildstep run.chain_test 240 "tests/chain_test 2>&1 | cat" + - programs/build_helpers/buildstep run.cli_test 30 "tests/cli_test 2>&1 | cat" + - programs/build_helpers/buildstep prepare.sonar 20 'find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d | while read d; do gcov -o "$d" "${d/CMakeFiles*.dir//}"/*.cpp; done >/dev/null' + - programs/build_helpers/buildstep run.sonar 1600 "which sonar-scanner && sonar-scanner || true" + - programs/build_helpers/buildstep end 0 + - ccache -s diff --git a/programs/build_helpers/buildstep b/programs/build_helpers/buildstep new file mode 100755 index 0000000000..35c164aabe --- /dev/null +++ b/programs/build_helpers/buildstep @@ -0,0 +1,55 @@ +#!/bin/sh + +usage () { + echo Usage: + echo " ${0##*/} [-h | --help] Display this help message" + echo " ${0##*/} -s | --start Initialize timing" + echo " ${0##*/} " + echo "The last form executes build step consisting of shell " + echo "if imated time is still available, otherwise it fails fast." + echo " and must be specified in seconds." + exit $1 +} + +if [ "$#" = 0 -o "$1" = "--help" -o "$1" = "-h" ]; then + usage `test "$#" = 1; echo $?` +fi + +NOW="$(date +%s)" + +if [ "$1" = "--start" -o "$1" = "-s" ]; then + if [ "$#" != 2 ]; then + usage 1 + fi + echo "$2 $NOW" >_start_time + echo "Starting at $(date --date=@$NOW)" + exit 0 +fi + +NAME="$1" +EST="$2" +CMD="$3" + +if [ ! -r _start_time ]; then + echo "Need to initialize with '$0 -s ' first!" 1>&2 + exit 1 +fi + +read max begin prev_name prev_begin <_start_time + +if [ "$prev_name" != "" ]; then + echo "'$prev_name' took $(($NOW - $prev_begin))s" +fi + +if [ "$CMD" != "" ]; then + if [ $(($NOW - $begin + $EST)) -lt $max ]; then + echo "Running '$NAME' at $NOW..." + echo "sh -c '$CMD'" + echo "$max $begin $NAME $NOW" >_start_time + exec sh -c "$CMD" + fi + echo "$(($begin + $max - $NOW))s left - insufficient to run '$NAME', exiting!" 1>&2 + exit 1 +fi + +exit 0 diff --git a/programs/build_helpers/make_with_sonar b/programs/build_helpers/make_with_sonar new file mode 100755 index 0000000000..a91470adf5 --- /dev/null +++ b/programs/build_helpers/make_with_sonar @@ -0,0 +1,8 @@ +#!/bin/sh + +OUT_DIR="$1" +shift +if which build-wrapper-linux-x86-64 >/dev/null; then + exec build-wrapper-linux-x86-64 --out-dir "$OUT_DIR" make "$@" +fi +exec make "$@" From f7212d76d102e74cbf89134cd57628723efe1e57 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 30 Jan 2019 13:18:57 +0100 Subject: [PATCH 148/172] Try to resolve "Bad substitution" error --- programs/build_helpers/buildstep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/build_helpers/buildstep b/programs/build_helpers/buildstep index 35c164aabe..44d5458a10 100755 --- a/programs/build_helpers/buildstep +++ b/programs/build_helpers/buildstep @@ -46,7 +46,7 @@ if [ "$CMD" != "" ]; then echo "Running '$NAME' at $NOW..." echo "sh -c '$CMD'" echo "$max $begin $NAME $NOW" >_start_time - exec sh -c "$CMD" + exec bash -c "$CMD" fi echo "$(($begin + $max - $NOW))s left - insufficient to run '$NAME', exiting!" 1>&2 exit 1 From a4211b6a9858948a3ffea9a8b889d5dd51787e44 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 30 Jan 2019 13:51:30 +0100 Subject: [PATCH 149/172] Removed unused boost-locale dependency --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e10b61ac92..1944af4dcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,8 +50,7 @@ LIST(APPEND BOOST_COMPONENTS thread program_options chrono unit_test_framework - context - locale) + context) SET( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" ) IF( WIN32 ) From f5cd910197d8e3e0aa4d95cfa7a84c2741176f8a Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 30 Jan 2019 13:52:05 +0100 Subject: [PATCH 150/172] Only install required boost packages, not all - should remove locale and signals after fc bump --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7225d9d669..5c1ee0e064 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ sudo: true install: - echo "deb http://de.archive.ubuntu.com/ubuntu xenial main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list - sudo apt-get update - - sudo apt-get install --allow-unauthenticated g++ libboost-all-dev cmake libreadline-dev libssl-dev autoconf parallel ccache + - sudo apt-get install --allow-unauthenticated g++ libboost-thread-dev libboost-iostreams-dev libboost-date-time-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-chrono-dev libboost-test-dev libboost-context-dev libboost-regex-dev libboost-locale-dev libboost-signals-dev libboost-coroutine-dev cmake libssl-dev autoconf parallel ccache addons: sonarcloud: From da0dba2b832d2e08ee7045c1577155bd8fd0bac6 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 30 Jan 2019 13:58:57 +0100 Subject: [PATCH 151/172] Build more stuff, run tests in parallel --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5c1ee0e064..b7da9ce30b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,11 +33,14 @@ script: - programs/build_helpers/buildstep cmake 5 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON ." - programs/build_helpers/buildstep make.cli_wallet 2600 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_wallet" - programs/build_helpers/buildstep make.witness_node 1800 "programs/build_helpers/make_with_sonar bw-output -j 2 witness_node" + - programs/build_helpers/buildstep make.serializer 20 "programs/build_helpers/make_with_sonar bw-output -j 2 js_operation_serializer" + - programs/build_helpers/buildstep make.get_dev_key 20 "programs/build_helpers/make_with_sonar bw-output -j 2 get_dev_key" - programs/build_helpers/buildstep make.chain_test 1800 "programs/build_helpers/make_with_sonar bw-output -j 2 chain_test" - programs/build_helpers/buildstep make.cli_test 1800 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_test" + - programs/build_helpers/buildstep make.perf_test 1800 "programs/build_helpers/make_with_sonar bw-output -j 2 performance_test" - set -o pipefail - - programs/build_helpers/buildstep run.chain_test 240 "tests/chain_test 2>&1 | cat" - - programs/build_helpers/buildstep run.cli_test 30 "tests/cli_test 2>&1 | cat" + - programs/build_helpers/buildstep run.chain_test 240 "libraries/fc/tests/run-parallel-tests.sh tests/chain_test" + - programs/build_helpers/buildstep run.cli_test 30 "libraries/fc/tests/run-parallel-tests.sh tests/cli_test" - programs/build_helpers/buildstep prepare.sonar 20 'find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d | while read d; do gcov -o "$d" "${d/CMakeFiles*.dir//}"/*.cpp; done >/dev/null' - programs/build_helpers/buildstep run.sonar 1600 "which sonar-scanner && sonar-scanner || true" - programs/build_helpers/buildstep end 0 From d589b5b4bc93abb435f1d44136068950077c8a1a Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 30 Jan 2019 15:18:13 +0100 Subject: [PATCH 152/172] Minor Dockerfile improvements --- Dockerfile | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 363460d2c5..25727cf1ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,16 +10,26 @@ RUN \ cmake \ git \ libbz2-dev \ - libreadline-dev \ - libboost-all-dev \ libcurl4-openssl-dev \ libssl-dev \ libncurses-dev \ + libboost-thread-dev \ + libboost-iostreams-dev \ + libboost-date-time-dev \ + libboost-system-dev \ + libboost-filesystem-dev \ + libboost-program-options-dev \ + libboost-chrono-dev \ + libboost-test-dev \ + libboost-context-dev \ + libboost-regex-dev \ + libboost-locale-dev \ + libboost-signals-dev \ + libboost-coroutine-dev \ doxygen \ ca-certificates \ + fish \ && \ - apt-get update -y && \ - apt-get install -y fish && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* @@ -40,8 +50,8 @@ RUN \ -DCMAKE_BUILD_TYPE=Release \ -DGRAPHENE_DISABLE_UNITY_BUILD=ON \ . && \ - make witness_node cli_wallet && \ - install -s programs/witness_node/witness_node programs/cli_wallet/cli_wallet /usr/local/bin && \ + make witness_node cli_wallet get_dev_key && \ + install -s programs/witness_node/witness_node programs/genesis_util/get_dev_key programs/cli_wallet/cli_wallet /usr/local/bin && \ # # Obtain version mkdir /etc/bitshares && \ From fb61b93a96221a0e9440f29b57761464d1159f94 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 30 Jan 2019 15:21:42 +0100 Subject: [PATCH 153/172] travis: switch to xenial build env --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index b7da9ce30b..5354f2aa39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,14 +5,12 @@ cache: ccache git: depth: 1 -dist: trusty +dist: xenial sudo: true install: - - echo "deb http://de.archive.ubuntu.com/ubuntu xenial main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list - - sudo apt-get update - - sudo apt-get install --allow-unauthenticated g++ libboost-thread-dev libboost-iostreams-dev libboost-date-time-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-chrono-dev libboost-test-dev libboost-context-dev libboost-regex-dev libboost-locale-dev libboost-signals-dev libboost-coroutine-dev cmake libssl-dev autoconf parallel ccache + - sudo apt-get install --allow-unauthenticated libboost-thread-dev libboost-iostreams-dev libboost-date-time-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-chrono-dev libboost-test-dev libboost-context-dev libboost-regex-dev libboost-locale-dev libboost-signals-dev libboost-coroutine-dev cmake parallel addons: sonarcloud: From dbd7eee97bb1bb3cd51cd7b192c0a3ad6c64a28c Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 30 Jan 2019 17:14:28 +0100 Subject: [PATCH 154/172] Modified build time expectations --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5354f2aa39..ec5c8b7c24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,17 +25,17 @@ env: - CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,time_macros script: - - programs/build_helpers/buildstep -s 3450 + - programs/build_helpers/buildstep -s 3500 - ccache -s - programs/build_helpers/buildstep Prepare 1 "sed -i '/tests/d' libraries/fc/CMakeLists.txt" - programs/build_helpers/buildstep cmake 5 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON ." - - programs/build_helpers/buildstep make.cli_wallet 2600 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_wallet" - - programs/build_helpers/buildstep make.witness_node 1800 "programs/build_helpers/make_with_sonar bw-output -j 2 witness_node" - - programs/build_helpers/buildstep make.serializer 20 "programs/build_helpers/make_with_sonar bw-output -j 2 js_operation_serializer" - - programs/build_helpers/buildstep make.get_dev_key 20 "programs/build_helpers/make_with_sonar bw-output -j 2 get_dev_key" - - programs/build_helpers/buildstep make.chain_test 1800 "programs/build_helpers/make_with_sonar bw-output -j 2 chain_test" - - programs/build_helpers/buildstep make.cli_test 1800 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_test" - - programs/build_helpers/buildstep make.perf_test 1800 "programs/build_helpers/make_with_sonar bw-output -j 2 performance_test" + - programs/build_helpers/buildstep make.cli_wallet 1600 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_wallet" + - programs/build_helpers/buildstep make.witness_node 300 "programs/build_helpers/make_with_sonar bw-output -j 2 witness_node" + - programs/build_helpers/buildstep make.serializer 45 "programs/build_helpers/make_with_sonar bw-output -j 2 js_operation_serializer" + - programs/build_helpers/buildstep make.get_dev_key 10 "programs/build_helpers/make_with_sonar bw-output -j 2 get_dev_key" + - programs/build_helpers/buildstep make.chain_test 900 "programs/build_helpers/make_with_sonar bw-output -j 2 chain_test" + - programs/build_helpers/buildstep make.cli_test 200 "programs/build_helpers/make_with_sonar bw-output -j 2 cli_test" + - programs/build_helpers/buildstep make.perf_test 120 "programs/build_helpers/make_with_sonar bw-output -j 2 performance_test" - set -o pipefail - programs/build_helpers/buildstep run.chain_test 240 "libraries/fc/tests/run-parallel-tests.sh tests/chain_test" - programs/build_helpers/buildstep run.cli_test 30 "libraries/fc/tests/run-parallel-tests.sh tests/cli_test" From 62db8bf0e9e7391cb31e0201cd95f6dc0aecd8bf Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 30 Jan 2019 17:40:07 +0100 Subject: [PATCH 155/172] Bumped fc + removed unused boost libs from travis + docker --- .travis.yml | 2 +- Dockerfile | 2 -- libraries/fc | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index ec5c8b7c24..eb1f3bc737 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ dist: xenial sudo: true install: - - sudo apt-get install --allow-unauthenticated libboost-thread-dev libboost-iostreams-dev libboost-date-time-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-chrono-dev libboost-test-dev libboost-context-dev libboost-regex-dev libboost-locale-dev libboost-signals-dev libboost-coroutine-dev cmake parallel + - sudo apt-get install --allow-unauthenticated libboost-thread-dev libboost-iostreams-dev libboost-date-time-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-chrono-dev libboost-test-dev libboost-context-dev libboost-regex-dev libboost-coroutine-dev cmake parallel addons: sonarcloud: diff --git a/Dockerfile b/Dockerfile index 25727cf1ac..6e36fd35c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,8 +23,6 @@ RUN \ libboost-test-dev \ libboost-context-dev \ libboost-regex-dev \ - libboost-locale-dev \ - libboost-signals-dev \ libboost-coroutine-dev \ doxygen \ ca-certificates \ diff --git a/libraries/fc b/libraries/fc index 0468884ea6..9e6c5ab6e2 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 0468884ea675afe3a16ffc61371672fecf6e7dde +Subproject commit 9e6c5ab6e2860a29bac0ef077bbd8a39b99b5971 From 708f01757d9cd6307ab3eb188bf24aa29b59d9e7 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 30 Jan 2019 22:35:17 +0100 Subject: [PATCH 156/172] Install libtool in docker build --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 6e36fd35c9..25fe0bb418 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,7 @@ RUN \ libboost-context-dev \ libboost-regex-dev \ libboost-coroutine-dev \ + libtool \ doxygen \ ca-certificates \ fish \ From e1eb934154f6add9b52dd2b59f4e10d14c665826 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 30 Jan 2019 22:36:02 +0100 Subject: [PATCH 157/172] travis: adjust expected sonar time --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index eb1f3bc737..76424128a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,6 @@ script: - programs/build_helpers/buildstep run.chain_test 240 "libraries/fc/tests/run-parallel-tests.sh tests/chain_test" - programs/build_helpers/buildstep run.cli_test 30 "libraries/fc/tests/run-parallel-tests.sh tests/cli_test" - programs/build_helpers/buildstep prepare.sonar 20 'find libraries/[acdenptuw]*/CMakeFiles/*.dir programs/[cdgjsw]*/CMakeFiles/*.dir -type d | while read d; do gcov -o "$d" "${d/CMakeFiles*.dir//}"/*.cpp; done >/dev/null' - - programs/build_helpers/buildstep run.sonar 1600 "which sonar-scanner && sonar-scanner || true" + - programs/build_helpers/buildstep run.sonar 400 "which sonar-scanner && sonar-scanner || true" - programs/build_helpers/buildstep end 0 - ccache -s From 052531b4998d3fd42d976d8546bd8e734a51f657 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 31 Jan 2019 17:33:25 -0300 Subject: [PATCH 158/172] refactor get_top_markets --- libraries/app/database_api.cpp | 131 ++++++++++-------- .../app/include/graphene/app/database_api.hpp | 12 +- 2 files changed, 80 insertions(+), 63 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 28182fd08d..61c85d19e7 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -121,7 +121,9 @@ class database_api_impl : public std::enable_shared_from_this market_ticker get_ticker( const string& base, const string& quote, bool skip_order_book = false )const; market_volume get_24_volume( const string& base, const string& quote )const; order_book get_order_book( const string& base, const string& quote, unsigned limit = 50 )const; - vector get_top_markets(uint32_t limit)const; + vector get_top_markets(uint32_t limit)const; + market_ticker build_ticker(const market_ticker_object& mto) const; + market_ticker append_orderbook_to_ticker(market_ticker& ticker) const; vector get_trade_history( const string& base, const string& quote, fc::time_point_sec start, fc::time_point_sec stop, unsigned limit = 100 )const; vector get_trade_history_by_sequence( const string& base, const string& quote, int64_t start, fc::time_point_sec stop, unsigned limit = 100 )const; @@ -310,6 +312,47 @@ database_api_impl::~database_api_impl() elog("freeing database api ${x}", ("x",int64_t(this)) ); } +////////////////////////////////////////////////////////////////////// +// // +// Market ticker constructor // +// // +////////////////////////////////////////////////////////////////////// +market_ticker::market_ticker(const market_ticker_object& mto, + const fc::time_point_sec& now, + const asset_object& asset_base, + const asset_object& asset_quote) +{ + time = now; + base = asset_base.symbol; + quote = asset_quote.symbol; + fc::uint128 bv; + fc::uint128 qv; + price latest_price = asset( mto.latest_base, mto.base ) / asset( mto.latest_quote, mto.quote ); + if( mto.base != asset_base.id ) + latest_price = ~latest_price; + latest = database_api_impl::price_to_string( latest_price, asset_base, asset_quote ); + if( mto.last_day_base != 0 && mto.last_day_quote != 0 // has trade data before 24 hours + && ( mto.last_day_base != mto.latest_base || mto.last_day_quote != mto.latest_quote ) ) // price changed + { + price last_day_price = asset( mto.last_day_base, mto.base ) / asset( mto.last_day_quote, mto.quote ); + if( mto.base != asset_base.id ) + last_day_price = ~last_day_price; + percent_change = price_diff_percent_string( last_day_price, latest_price ); + } + if( asset_base.id == mto.base ) + { + bv = mto.base_volume; + qv = mto.quote_volume; + } + else + { + bv = mto.quote_volume; + qv = mto.base_volume; + } + base_volume = uint128_amount_to_string( bv, asset_base.precision ); + quote_volume = uint128_amount_to_string( qv, asset_quote.precision ); +} + ////////////////////////////////////////////////////////////////////// // // // Objects // @@ -1302,66 +1345,25 @@ market_ticker database_api_impl::get_ticker( const string& base, const string& q FC_ASSERT( _app_options && _app_options->has_market_history_plugin, "Market history plugin is not enabled." ); const auto assets = lookup_asset_symbols( {base, quote} ); + FC_ASSERT( assets[0], "Invalid base asset symbol: ${s}", ("s",base) ); FC_ASSERT( assets[1], "Invalid quote asset symbol: ${s}", ("s",quote) ); - const fc::time_point_sec now = _db.head_block_time(); - - market_ticker result; - result.time = now; - result.base = base; - result.quote = quote; - result.latest = "0"; - result.lowest_ask = "0"; - result.highest_bid = "0"; - result.percent_change = "0"; - auto base_id = assets[0]->id; auto quote_id = assets[1]->id; if( base_id > quote_id ) std::swap( base_id, quote_id ); - - fc::uint128 base_volume; - fc::uint128 quote_volume; - const auto& ticker_idx = _db.get_index_type().indices().get(); auto itr = ticker_idx.find( std::make_tuple( base_id, quote_id ) ); + market_ticker ticker; if( itr != ticker_idx.end() ) { - price latest_price = asset( itr->latest_base, itr->base ) / asset( itr->latest_quote, itr->quote ); - if( itr->base != assets[0]->id ) - latest_price = ~latest_price; - result.latest = price_to_string( latest_price, *assets[0], *assets[1] ); - if( itr->last_day_base != 0 && itr->last_day_quote != 0 // has trade data before 24 hours - && ( itr->last_day_base != itr->latest_base || itr->last_day_quote != itr->latest_quote ) ) // price changed - { - price last_day_price = asset( itr->last_day_base, itr->base ) / asset( itr->last_day_quote, itr->quote ); - if( itr->base != assets[0]->id ) - last_day_price = ~last_day_price; - result.percent_change = price_diff_percent_string( last_day_price, latest_price ); - } - if( assets[0]->id == itr->base ) - { - base_volume = itr->base_volume; - quote_volume = itr->quote_volume; - } - else - { - base_volume = itr->quote_volume; - quote_volume = itr->base_volume; - } + ticker = build_ticker(*itr); } - - result.base_volume = uint128_amount_to_string( base_volume, assets[0]->precision ); - result.quote_volume = uint128_amount_to_string( quote_volume, assets[1]->precision ); - if( !skip_order_book ) { - const auto orders = get_order_book( base, quote, 1 ); - if( !orders.asks.empty() ) result.lowest_ask = orders.asks[0].price; - if( !orders.bids.empty() ) result.highest_bid = orders.bids[0].price; + return append_orderbook_to_ticker(ticker); } - - return result; + return ticker; } market_volume database_api::get_24_volume( const string& base, const string& quote )const @@ -1428,12 +1430,12 @@ order_book database_api_impl::get_order_book( const string& base, const string& return result; } -vector database_api::get_top_markets(uint32_t limit)const +vector database_api::get_top_markets(uint32_t limit)const { return my->get_top_markets(limit); } -vector database_api_impl::get_top_markets(uint32_t limit)const +vector database_api_impl::get_top_markets(uint32_t limit)const { FC_ASSERT( _app_options && _app_options->has_market_history_plugin, "Market history plugin is not enabled." ); @@ -1441,25 +1443,34 @@ vector database_api_impl::get_top_markets(uint32_t limit)const const auto& volume_idx = _db.get_index_type().indices().get(); auto itr = volume_idx.rbegin(); - vector result; + vector result; result.reserve(limit); - const fc::time_point_sec now = fc::time_point::now(); - while( itr != volume_idx.rend() && result.size() < limit) { - market_volume mv; - mv.time = now; - const auto assets = get_assets( { itr->base, itr->quote } ); - mv.base = assets[0]->symbol; - mv.quote = assets[1]->symbol; - mv.base_volume = uint128_amount_to_string( itr->base_volume, assets[0]->precision ); - mv.quote_volume = uint128_amount_to_string( itr->quote_volume, assets[1]->precision ); - result.emplace_back( std::move(mv) ); + auto ticker = build_ticker(*itr); + result.emplace_back( append_orderbook_to_ticker(ticker) ); ++itr; } return result; } +market_ticker database_api_impl::build_ticker(const market_ticker_object& mto) const +{ + const auto& assets = get_assets( { mto.base, mto.quote } ); + const fc::time_point_sec now = _db.head_block_time(); + market_ticker ticker(mto, now, *assets[0], *assets[1]); + return ticker; +} + +market_ticker database_api_impl::append_orderbook_to_ticker(market_ticker& ticker) const +{ + const auto& orders = get_order_book(ticker.base, ticker.quote, 1); + if (!orders.asks.empty()) + ticker.lowest_ask = orders.asks[0].price; + if (!orders.bids.empty()) + ticker.highest_bid = orders.bids[0].price; + return ticker; +} vector database_api::get_trade_history( const string& base, const string& quote, diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 506b427597..6ca261ac68 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -90,6 +90,12 @@ struct market_ticker string percent_change; string base_volume; string quote_volume; + + market_ticker() {} + market_ticker(const market_ticker_object& mto, + const fc::time_point_sec& now, + const asset_object& asset_base, + const asset_object& asset_quote); }; struct market_volume @@ -493,12 +499,12 @@ class database_api order_book get_order_book( const string& base, const string& quote, unsigned limit = 50 )const; /** - * @brief Returns vector of 24 hour volume markets sorted by reverse base_volume + * @brief Returns vector of tickers sorted by reverse base_volume * Note: this API is experimental and subject to change in next releases * @param limit Max number of results - * @return Desc Sorted volume vector + * @return Desc Sorted ticker vector */ - vector get_top_markets(uint32_t limit)const; + vector get_top_markets(uint32_t limit)const; /** * @brief Returns recent trades for the market base:quote, ordered by time, most recent first. From c0ac89825f3b4995c5364b3b93f8b7c430b31b59 Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 1 Feb 2019 11:46:26 -0500 Subject: [PATCH 159/172] Moved impl to fee_schedule.hpp --- libraries/app/api.cpp | 1 - libraries/app/application.cpp | 2 -- libraries/app/database_api.cpp | 1 - libraries/chain/account_evaluator.cpp | 2 -- libraries/chain/block_database.cpp | 1 - libraries/chain/committee_member_evaluator.cpp | 2 -- libraries/chain/confidential_evaluator.cpp | 2 -- libraries/chain/database.cpp | 1 - libraries/chain/db_block.cpp | 1 - libraries/chain/db_getter.cpp | 2 -- libraries/chain/db_init.cpp | 1 - libraries/chain/db_maint.cpp | 1 - libraries/chain/genesis_state.cpp | 3 +-- .../chain/include/graphene/chain/protocol/fee_schedule.hpp | 1 + libraries/chain/market_evaluator.cpp | 1 - libraries/chain/proposal_evaluator.cpp | 2 -- libraries/chain/protocol/fee_schedule.cpp | 1 - libraries/chain/protocol/proposal.cpp | 1 - libraries/chain/protocol/transaction.cpp | 1 - libraries/egenesis/embed_genesis.cpp | 1 - libraries/net/node.cpp | 1 - libraries/plugins/account_history/account_history_plugin.cpp | 1 - libraries/plugins/debug_witness/debug_api.cpp | 1 - libraries/plugins/debug_witness/debug_witness.cpp | 1 - libraries/plugins/delayed_node/delayed_node_plugin.cpp | 2 -- libraries/plugins/elasticsearch/elasticsearch_plugin.cpp | 1 - libraries/plugins/es_objects/es_objects.cpp | 2 -- libraries/plugins/market_history/market_history_plugin.cpp | 1 - libraries/plugins/witness/witness.cpp | 1 - libraries/wallet/wallet.cpp | 1 - programs/build_helpers/member_enumerator.cpp | 1 - programs/cli_wallet/main.cpp | 1 - programs/genesis_util/genesis_update.cpp | 1 - programs/js_operation_serializer/main.cpp | 1 - programs/size_checker/main.cpp | 1 - tests/app/main.cpp | 1 - tests/benchmarks/genesis_allocation.cpp | 1 - tests/cli/main.cpp | 1 - tests/common/database_fixture.cpp | 1 - tests/common/database_fixture.hpp | 1 - tests/generate_empty_blocks/main.cpp | 1 - tests/tests/fee_tests.cpp | 1 - 42 files changed, 2 insertions(+), 50 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 61e9637a9f..394d48e83b 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -37,7 +37,6 @@ #include #include -#include #include namespace graphene { namespace app { diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index f2cf80285d..9133bc1618 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -39,8 +39,6 @@ #include #include -#include - #include #include #include diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index f067a101e8..12227788d5 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index 086953dcfb..98e0766652 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -22,8 +22,6 @@ * THE SOFTWARE. */ -#include - #include #include #include diff --git a/libraries/chain/block_database.cpp b/libraries/chain/block_database.cpp index 8ec20dcc13..c5fa6636a8 100644 --- a/libraries/chain/block_database.cpp +++ b/libraries/chain/block_database.cpp @@ -24,7 +24,6 @@ #include #include #include -#include namespace graphene { namespace chain { diff --git a/libraries/chain/committee_member_evaluator.cpp b/libraries/chain/committee_member_evaluator.cpp index 4e7eb827e5..b01fa95faa 100644 --- a/libraries/chain/committee_member_evaluator.cpp +++ b/libraries/chain/committee_member_evaluator.cpp @@ -29,8 +29,6 @@ #include #include -#include - namespace graphene { namespace chain { void_result committee_member_create_evaluator::do_evaluate( const committee_member_create_operation& op ) diff --git a/libraries/chain/confidential_evaluator.cpp b/libraries/chain/confidential_evaluator.cpp index 9323d2d9ba..9946b492d0 100644 --- a/libraries/chain/confidential_evaluator.cpp +++ b/libraries/chain/confidential_evaluator.cpp @@ -29,8 +29,6 @@ #include #include -#include - namespace graphene { namespace chain { void_result transfer_to_blind_evaluator::do_evaluate( const transfer_to_blind_operation& o ) diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index 2d02b1840e..788a29f008 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -21,7 +21,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include #include "db_balance.cpp" #include "db_block.cpp" #include "db_debug.cpp" diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index fdf4b4a15e..095a6114ce 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -38,7 +38,6 @@ #include #include -#include namespace graphene { namespace chain { diff --git a/libraries/chain/db_getter.cpp b/libraries/chain/db_getter.cpp index 4b4c0ee10d..0de635c0e5 100644 --- a/libraries/chain/db_getter.cpp +++ b/libraries/chain/db_getter.cpp @@ -28,8 +28,6 @@ #include #include -#include - namespace graphene { namespace chain { const asset_object& database::get_core_asset() const diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index fe69967382..884a7b3c91 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -64,7 +64,6 @@ #include -#include #include #include diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 4ee7cb2825..2fdfa0f401 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -24,7 +24,6 @@ #include -#include #include #include diff --git a/libraries/chain/genesis_state.cpp b/libraries/chain/genesis_state.cpp index a278b68005..7c53c36ae3 100644 --- a/libraries/chain/genesis_state.cpp +++ b/libraries/chain/genesis_state.cpp @@ -24,8 +24,7 @@ #include -// these are required to serialize a genesis_state -#include // required for gcc in release mode +// this is required to serialize a genesis_state #include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp index a08ee98a2c..388dada2b0 100644 --- a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp +++ b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #pragma once +#include #include namespace graphene { namespace chain { diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index 62dfc7c7b4..5f380bc259 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -35,7 +35,6 @@ #include #include -#include namespace graphene { namespace chain { void_result limit_order_create_evaluator::do_evaluate(const limit_order_create_operation& op) diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index fce7fd2a35..348629d9ba 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -26,8 +26,6 @@ #include #include -#include - namespace graphene { namespace chain { diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/chain/protocol/fee_schedule.cpp index 649f90dff4..c52c229768 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/chain/protocol/fee_schedule.cpp @@ -23,7 +23,6 @@ */ #include #include -#include namespace fc { diff --git a/libraries/chain/protocol/proposal.cpp b/libraries/chain/protocol/proposal.cpp index 54fd728bbd..7d072e4a90 100644 --- a/libraries/chain/protocol/proposal.cpp +++ b/libraries/chain/protocol/proposal.cpp @@ -23,7 +23,6 @@ */ #include #include -#include namespace graphene { namespace chain { diff --git a/libraries/chain/protocol/transaction.cpp b/libraries/chain/protocol/transaction.cpp index 1a1293ca76..b642dea72e 100644 --- a/libraries/chain/protocol/transaction.cpp +++ b/libraries/chain/protocol/transaction.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include namespace graphene { namespace chain { diff --git a/libraries/egenesis/embed_genesis.cpp b/libraries/egenesis/embed_genesis.cpp index 1eab728345..6854e9f6d3 100644 --- a/libraries/egenesis/embed_genesis.cpp +++ b/libraries/egenesis/embed_genesis.cpp @@ -30,7 +30,6 @@ #include #include -#include // required for gcc in release mode #include #include #include diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index 612529f93c..b2fc5009b7 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -69,7 +69,6 @@ #include #include #include -#include #include #include diff --git a/libraries/plugins/account_history/account_history_plugin.cpp b/libraries/plugins/account_history/account_history_plugin.cpp index 59f238c43a..4697837faa 100644 --- a/libraries/plugins/account_history/account_history_plugin.cpp +++ b/libraries/plugins/account_history/account_history_plugin.cpp @@ -34,7 +34,6 @@ #include #include -#include #include namespace graphene { namespace account_history { diff --git a/libraries/plugins/debug_witness/debug_api.cpp b/libraries/plugins/debug_witness/debug_api.cpp index 823755f594..43ffd6cd38 100644 --- a/libraries/plugins/debug_witness/debug_api.cpp +++ b/libraries/plugins/debug_witness/debug_api.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include diff --git a/libraries/plugins/debug_witness/debug_witness.cpp b/libraries/plugins/debug_witness/debug_witness.cpp index 66ef2f58ec..7268006d3b 100644 --- a/libraries/plugins/debug_witness/debug_witness.cpp +++ b/libraries/plugins/debug_witness/debug_witness.cpp @@ -28,7 +28,6 @@ #include -#include #include #include diff --git a/libraries/plugins/delayed_node/delayed_node_plugin.cpp b/libraries/plugins/delayed_node/delayed_node_plugin.cpp index 0329d018b2..c56f8bb6b3 100644 --- a/libraries/plugins/delayed_node/delayed_node_plugin.cpp +++ b/libraries/plugins/delayed_node/delayed_node_plugin.cpp @@ -30,8 +30,6 @@ #include #include #include -#include - namespace graphene { namespace delayed_node { namespace bpo = boost::program_options; diff --git a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp index 6af2df19ac..ab5f396dff 100644 --- a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp +++ b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff --git a/libraries/plugins/es_objects/es_objects.cpp b/libraries/plugins/es_objects/es_objects.cpp index 5695064325..1db0febc71 100644 --- a/libraries/plugins/es_objects/es_objects.cpp +++ b/libraries/plugins/es_objects/es_objects.cpp @@ -24,8 +24,6 @@ #include -#include - #include #include #include diff --git a/libraries/plugins/market_history/market_history_plugin.cpp b/libraries/plugins/market_history/market_history_plugin.cpp index 004c3891b3..f6948dc59e 100644 --- a/libraries/plugins/market_history/market_history_plugin.cpp +++ b/libraries/plugins/market_history/market_history_plugin.cpp @@ -34,7 +34,6 @@ #include #include -#include namespace graphene { namespace market_history { diff --git a/libraries/plugins/witness/witness.cpp b/libraries/plugins/witness/witness.cpp index 5bebefb75f..af2101e9ea 100644 --- a/libraries/plugins/witness/witness.cpp +++ b/libraries/plugins/witness/witness.cpp @@ -28,7 +28,6 @@ #include -#include #include #include diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index ac33c180e9..db2a7e85ed 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -72,7 +72,6 @@ #include #include #include -#include #ifndef WIN32 # include diff --git a/programs/build_helpers/member_enumerator.cpp b/programs/build_helpers/member_enumerator.cpp index 16452c5bf8..53d1169037 100644 --- a/programs/build_helpers/member_enumerator.cpp +++ b/programs/build_helpers/member_enumerator.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include using namespace graphene::chain; diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 88c027a20e..2a949417ae 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include diff --git a/programs/genesis_util/genesis_update.cpp b/programs/genesis_util/genesis_update.cpp index 6a4d28cd28..7e251de8a7 100644 --- a/programs/genesis_util/genesis_update.cpp +++ b/programs/genesis_util/genesis_update.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include diff --git a/programs/js_operation_serializer/main.cpp b/programs/js_operation_serializer/main.cpp index e955f8d7fa..db170a0280 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -37,7 +37,6 @@ #include #include -#include #include using namespace graphene::chain; diff --git a/programs/size_checker/main.cpp b/programs/size_checker/main.cpp index d6853d108f..72d7d85f85 100644 --- a/programs/size_checker/main.cpp +++ b/programs/size_checker/main.cpp @@ -23,7 +23,6 @@ */ #include -#include #include #include diff --git a/tests/app/main.cpp b/tests/app/main.cpp index b68cdf78a0..6a16163ea2 100644 --- a/tests/app/main.cpp +++ b/tests/app/main.cpp @@ -35,7 +35,6 @@ #include #include -#include #include #include diff --git a/tests/benchmarks/genesis_allocation.cpp b/tests/benchmarks/genesis_allocation.cpp index a17a16fa8e..63e75db568 100644 --- a/tests/benchmarks/genesis_allocation.cpp +++ b/tests/benchmarks/genesis_allocation.cpp @@ -26,7 +26,6 @@ #include #include -#include #include diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 393dce4d83..ea191e892c 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -33,7 +33,6 @@ #include #include -#include #include #include #include diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index a77854cd22..ed850cf7cf 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -41,7 +41,6 @@ #include #include -#include #include diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index eceba6876b..dac219d69e 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include diff --git a/tests/generate_empty_blocks/main.cpp b/tests/generate_empty_blocks/main.cpp index ec399ea0d2..721747eef2 100644 --- a/tests/generate_empty_blocks/main.cpp +++ b/tests/generate_empty_blocks/main.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index 587814815c..7943be62a0 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -22,7 +22,6 @@ * THE SOFTWARE. */ -#include #include #include From 04f20af8333390416944e602c0380315ca4f7a88 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 1 Feb 2019 18:27:44 -0300 Subject: [PATCH 160/172] refactor for in-place construction --- libraries/app/database_api.cpp | 52 ++++++++----------- .../app/include/graphene/app/database_api.hpp | 3 +- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 61c85d19e7..8c9f8bf215 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -121,9 +121,7 @@ class database_api_impl : public std::enable_shared_from_this market_ticker get_ticker( const string& base, const string& quote, bool skip_order_book = false )const; market_volume get_24_volume( const string& base, const string& quote )const; order_book get_order_book( const string& base, const string& quote, unsigned limit = 50 )const; - vector get_top_markets(uint32_t limit)const; - market_ticker build_ticker(const market_ticker_object& mto) const; - market_ticker append_orderbook_to_ticker(market_ticker& ticker) const; + vector get_top_markets( uint32_t limit )const; vector get_trade_history( const string& base, const string& quote, fc::time_point_sec start, fc::time_point_sec stop, unsigned limit = 100 )const; vector get_trade_history_by_sequence( const string& base, const string& quote, int64_t start, fc::time_point_sec stop, unsigned limit = 100 )const; @@ -320,7 +318,8 @@ database_api_impl::~database_api_impl() market_ticker::market_ticker(const market_ticker_object& mto, const fc::time_point_sec& now, const asset_object& asset_base, - const asset_object& asset_quote) + const asset_object& asset_quote, + const order_book& orders) { time = now; base = asset_base.symbol; @@ -351,6 +350,11 @@ market_ticker::market_ticker(const market_ticker_object& mto, } base_volume = uint128_amount_to_string( bv, asset_base.precision ); quote_volume = uint128_amount_to_string( qv, asset_quote.precision ); + + if(!orders.asks.empty()) + lowest_ask = orders.asks[0].price; + if(!orders.bids.empty()) + highest_bid = orders.bids[0].price; } ////////////////////////////////////////////////////////////////////// @@ -1354,16 +1358,16 @@ market_ticker database_api_impl::get_ticker( const string& base, const string& q if( base_id > quote_id ) std::swap( base_id, quote_id ); const auto& ticker_idx = _db.get_index_type().indices().get(); auto itr = ticker_idx.find( std::make_tuple( base_id, quote_id ) ); - market_ticker ticker; + const fc::time_point_sec now = _db.head_block_time(); if( itr != ticker_idx.end() ) { - ticker = build_ticker(*itr); - } - if( !skip_order_book ) - { - return append_orderbook_to_ticker(ticker); + order_book orders; + if (!skip_order_book) + { + orders = get_order_book(assets[0]->symbol, assets[1]->symbol, 1); + } + return market_ticker(*itr, now, *assets[0], *assets[1], orders);; } - return ticker; } market_volume database_api::get_24_volume( const string& base, const string& quote )const @@ -1445,32 +1449,20 @@ vector database_api_impl::get_top_markets(uint32_t limit)const auto itr = volume_idx.rbegin(); vector result; result.reserve(limit); + const fc::time_point_sec now = _db.head_block_time(); while( itr != volume_idx.rend() && result.size() < limit) { - auto ticker = build_ticker(*itr); - result.emplace_back( append_orderbook_to_ticker(ticker) ); + const asset_object base = itr->base(_db); + const asset_object quote = itr->quote(_db); + order_book orders; + orders = get_order_book(base.symbol, quote.symbol, 1); + + result.emplace_back(market_ticker(*itr, now, base, quote, orders)); ++itr; } return result; } -market_ticker database_api_impl::build_ticker(const market_ticker_object& mto) const -{ - const auto& assets = get_assets( { mto.base, mto.quote } ); - const fc::time_point_sec now = _db.head_block_time(); - market_ticker ticker(mto, now, *assets[0], *assets[1]); - return ticker; -} - -market_ticker database_api_impl::append_orderbook_to_ticker(market_ticker& ticker) const -{ - const auto& orders = get_order_book(ticker.base, ticker.quote, 1); - if (!orders.asks.empty()) - ticker.lowest_ask = orders.asks[0].price; - if (!orders.bids.empty()) - ticker.highest_bid = orders.bids[0].price; - return ticker; -} vector database_api::get_trade_history( const string& base, const string& quote, diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 6ca261ac68..d5ef86e96a 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -95,7 +95,8 @@ struct market_ticker market_ticker(const market_ticker_object& mto, const fc::time_point_sec& now, const asset_object& asset_base, - const asset_object& asset_quote); + const asset_object& asset_quote, + const order_book& orders); }; struct market_volume From 18ac80a98f66c384a527ffc0295c7d44cb14bc9b Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sat, 2 Feb 2019 19:23:22 -0300 Subject: [PATCH 161/172] rename name_or_id with symbol_or_id --- libraries/app/database_api.cpp | 14 +++++++------- .../app/include/graphene/app/database_api.hpp | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index ee55fce992..1d88cca2d1 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -227,17 +227,17 @@ class database_api_impl : public std::enable_shared_from_this return account; } - const asset_object* get_asset_from_string( const std::string& name_or_id ) const + const asset_object* get_asset_from_string( const std::string& symbol_or_id ) const { // TODO cache the result to avoid repeatly fetching from db - FC_ASSERT( name_or_id.size() > 0); + FC_ASSERT( symbol_or_id.size() > 0); const asset_object* asset = nullptr; - if (std::isdigit(name_or_id[0])) - asset = _db.find(fc::variant(name_or_id, 1).as(1)); + if (std::isdigit(symbol_or_id[0])) + asset = _db.find(fc::variant(symbol_or_id, 1).as(1)); else { const auto& idx = _db.get_index_type().indices().get(); - auto itr = idx.find(name_or_id); + auto itr = idx.find(symbol_or_id); if (itr != idx.end()) asset = &*itr; } @@ -1109,9 +1109,9 @@ vector database_api_impl::get_vesting_balances( const st // // ////////////////////////////////////////////////////////////////////// -asset_id_type database_api::get_asset_id_from_string(const std::string& name_or_id)const +asset_id_type database_api::get_asset_id_from_string(const std::string& symbol_or_id)const { - return my->get_asset_from_string( name_or_id )->id; // safe? + return my->get_asset_from_string( symbol_or_id )->id; } vector> database_api::get_assets(const vector& asset_symbols_or_ids)const diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index b5437556bc..bece276b4b 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -374,11 +374,11 @@ class database_api //////////// /** - * @brief Get asset id from a name or ID - * @param name_or_id ID or name of the asset + * @brief Get asset id from a symbol or ID + * @param symbol_or_id ID or symbol of the asset * @return asset id */ - asset_id_type get_asset_id_from_string(const std::string& name_or_id) const; + asset_id_type get_asset_id_from_string(const std::string& symbol_or_id) const; /** * @brief Get a list of assets by ID From d256af696a972084ba8c002202f030b64c4dcf8b Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sat, 2 Feb 2019 19:52:31 -0300 Subject: [PATCH 162/172] expose get_asset_id_from_string --- libraries/app/database_api.cpp | 3 ++- libraries/app/include/graphene/app/database_api.hpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 1d88cca2d1..7988ced388 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -98,6 +98,7 @@ class database_api_impl : public std::enable_shared_from_this vector get_vesting_balances( const std::string account_id_or_name )const; // Assets + asset_id_type get_asset_id_from_string(const std::string& symbol_or_id)const; vector> get_assets(const vector& asset_symbols_or_ids)const; vector list_assets(const string& lower_bound_symbol, uint32_t limit)const; vector> lookup_asset_symbols(const vector& symbols_or_ids)const; @@ -698,7 +699,7 @@ bool database_api_impl::is_public_key_registered(string public_key) const account_id_type database_api::get_account_id_from_string(const std::string& name_or_id)const { - return my->get_account_from_string( name_or_id )->id; // safe? + return my->get_account_from_string( name_or_id )->id; } vector> database_api::get_accounts(const vector& account_names_or_ids)const diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index bece276b4b..9080e0a3da 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -797,6 +797,7 @@ FC_API(graphene::app::database_api, (list_assets) (lookup_asset_symbols) (get_asset_count) + (get_asset_id_from_string) // Markets / feeds (get_order_book) From 9eab093640d6d77a66381dd8db1ad2b7218677c6 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sun, 3 Feb 2019 11:37:06 -0300 Subject: [PATCH 163/172] change asset id or name to asset id or symbol in descriptions of api.hpp --- libraries/app/include/graphene/app/api.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 9109c8c453..b47445c0c4 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -443,7 +443,7 @@ namespace graphene { namespace app { /** * @brief Get asset holders for a specific asset - * @param asset The specific asset id or name + * @param asset The specific asset id or symbol * @param start The start index * @param limit Maximum limit must not exceed 100 * @return A list of asset holders for the specified asset @@ -452,7 +452,7 @@ namespace graphene { namespace app { /** * @brief Get asset holders count for a specific asset - * @param asset The specific asset id or name + * @param asset The specific asset id or symbol * @return Holders count for the specified asset */ int get_asset_holders_count( std::string asset )const; @@ -486,8 +486,8 @@ namespace graphene { namespace app { /** * @breif Get grouped limit orders in given market. * - * @param base_asset ID or name of asset being sold - * @param quote_asset ID or name of asset being purchased + * @param base_asset ID or symbol of asset being sold + * @param quote_asset ID or symbol of asset being purchased * @param group Maximum price diff within each order group, have to be one of configured values * @param start Optional price to indicate the first order group to retrieve * @param limit Maximum number of order groups to retrieve (must not exceed 101) From a38b5584c8838609c3c251155cbcaea9d2ebf230 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 4 Feb 2019 10:50:23 -0300 Subject: [PATCH 164/172] change some more docs --- libraries/app/include/graphene/app/api.hpp | 8 ++++---- libraries/app/include/graphene/app/database_api.hpp | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index b47445c0c4..7e1dc1552f 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -187,8 +187,8 @@ namespace graphene { namespace app { /** * @brief Get details of order executions occurred most recently in a trading pair - * @param a One asset in a trading pair - * @param b The other asset in the trading pair + * @param a Asset symbol or ID in a trading pair + * @param b The other asset symbol or ID in the trading pair * @param limit Maximum records to return * @return a list of order_history objects, in "most recent first" order */ @@ -196,8 +196,8 @@ namespace graphene { namespace app { /** * @brief Get OHLCV data of a trading pair in a time range - * @param a One asset in a trading pair - * @param b The other asset in the trading pair + * @param a Asset symbol or ID in a trading pair + * @param b The other asset symbol or ID in the trading pair * @param bucket_seconds Length of each time bucket in seconds. * Note: it need to be within result of get_market_history_buckets() API, otherwise no data will be returned * @param start The start of a time range, E.G. "2018-01-01T00:00:00" diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 9080e0a3da..a3856c239c 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -689,8 +689,7 @@ class database_api processed_transaction validate_transaction( const signed_transaction& trx )const; /** - * For each operation calculate the required fee in the specified asset type. If the asset type does - * not have a valid core_exchange_rate + * For each operation calculate the required fee in the specified asset type. */ vector< fc::variant > get_required_fees( const vector& ops, const std::string& asset_id_or_symbol )const; From 21a4d76cc31105e1ba642462446891142fddc9f0 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 4 Feb 2019 21:11:20 +0100 Subject: [PATCH 165/172] Fixed crash on empty/invalid node pubkey --- programs/network_mapper/network_mapper.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/programs/network_mapper/network_mapper.cpp b/programs/network_mapper/network_mapper.cpp index 6fef314254..2ecc724d8c 100644 --- a/programs/network_mapper/network_mapper.cpp +++ b/programs/network_mapper/network_mapper.cpp @@ -236,15 +236,18 @@ int main(int argc, char** argv) continue; } - graphene::net::address_info this_node_info; - this_node_info.direction = graphene::net::peer_connection_direction::outbound; - this_node_info.firewalled = graphene::net::firewalled_state::not_firewalled; - this_node_info.remote_endpoint = probe->_remote; - this_node_info.node_id = probe->_node_id; - - connections_by_node_id[this_node_info.node_id] = probe->_peers; - if (address_info_by_node_id.find(probe->_node_id) == address_info_by_node_id.end()) - address_info_by_node_id[probe->_node_id] = this_node_info; + if( probe->_node_id.valid() ) + { + graphene::net::address_info this_node_info; + this_node_info.direction = graphene::net::peer_connection_direction::outbound; + this_node_info.firewalled = graphene::net::firewalled_state::not_firewalled; + this_node_info.remote_endpoint = probe->_remote; + this_node_info.node_id = probe->_node_id; + + connections_by_node_id[this_node_info.node_id] = probe->_peers; + if (address_info_by_node_id.find(this_node_info.node_id) == address_info_by_node_id.end()) + address_info_by_node_id[this_node_info.node_id] = this_node_info; + } for (const graphene::net::address_info& info : probe->_peers) { From 82baee3112ca6fe6ca0e0d744479b628b473581c Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Tue, 5 Feb 2019 16:47:22 -0300 Subject: [PATCH 166/172] add network_mapper --- programs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/programs/README.md b/programs/README.md index 26b2b36886..11c92094b1 100644 --- a/programs/README.md +++ b/programs/README.md @@ -21,3 +21,4 @@ Folder | Name | Description | Category | Status | Help [member_enumerator](build_helpers/member_enumerator.cpp) | Member enumerator | | Tool | Deprecated | `./member_enumerator` [get_dev_key](genesis_util/get_dev_key.cpp) | Get Dev Key | Create public, private and address keys. Useful in private testnets, `genesis.json` files, new blockchain creation and others. | Tool | Active | `/programs/genesis_util/get_dev_key -h` [genesis_util](genesis_util) | Genesis Utils | Other utilities for genesis creation. | Tool | Old | +[network_mapper](network_mapper) | Network Mapper | Generates .DOT file that can be rendered by graphviz to make images of node connectivity. | Tool | Active | `./programs/network_mapper/network_mapper` From 5cefa46456ff1bed1b82729fefd1aa994cc84c4e Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Tue, 5 Feb 2019 19:03:28 -0300 Subject: [PATCH 167/172] change status of network mapper --- programs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/README.md b/programs/README.md index 11c92094b1..24f646ac0d 100644 --- a/programs/README.md +++ b/programs/README.md @@ -21,4 +21,4 @@ Folder | Name | Description | Category | Status | Help [member_enumerator](build_helpers/member_enumerator.cpp) | Member enumerator | | Tool | Deprecated | `./member_enumerator` [get_dev_key](genesis_util/get_dev_key.cpp) | Get Dev Key | Create public, private and address keys. Useful in private testnets, `genesis.json` files, new blockchain creation and others. | Tool | Active | `/programs/genesis_util/get_dev_key -h` [genesis_util](genesis_util) | Genesis Utils | Other utilities for genesis creation. | Tool | Old | -[network_mapper](network_mapper) | Network Mapper | Generates .DOT file that can be rendered by graphviz to make images of node connectivity. | Tool | Active | `./programs/network_mapper/network_mapper` +[network_mapper](network_mapper) | Network Mapper | Generates .DOT file that can be rendered by graphviz to make images of node connectivity. | Tool | Experimental | `./programs/network_mapper/network_mapper` From f66c9a5eac655c27fb91a6480cb7a1e59d580128 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 5 Feb 2019 17:04:03 -0500 Subject: [PATCH 168/172] bump FC for std::min macOS --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 9e6c5ab6e2..8ebd99b786 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 9e6c5ab6e2860a29bac0ef077bbd8a39b99b5971 +Subproject commit 8ebd99b786623bc8d55e89d42df82644a71a6885 From 2d5eb6c3a3cca859feb0d625c07266bbcd92805e Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Tue, 12 Feb 2019 16:30:23 -0300 Subject: [PATCH 169/172] add default empty result to get_ticker --- libraries/app/database_api.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 79c4716c88..c97db8273b 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -1430,8 +1430,11 @@ market_ticker database_api_impl::get_ticker( const string& base, const string& q { orders = get_order_book(assets[0]->symbol, assets[1]->symbol, 1); } - return market_ticker(*itr, now, *assets[0], *assets[1], orders);; + return market_ticker(*itr, now, *assets[0], *assets[1], orders); } + // if no ticker is found for this market we return an empty ticker + market_ticker empty_result; + return empty_result; } market_volume database_api::get_24_volume( const string& base, const string& quote )const From 05233f03f350c9365e64b7b84c09ede94b23f4fa Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Wed, 13 Feb 2019 10:06:06 -0300 Subject: [PATCH 170/172] update full node specs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e5147f0112..43c9daa823 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ In order to run a full node with all the account history you need to remove `par | Default | Full | Minimal | ElasticSearch | --- | --- | --- | --- -| 100G HDD, 16G RAM | 200G HDD, 160G RAM | 80G HDD, 4G RAM | 500G SSD, 32G RAM +| 100G HDD, 16G RAM | 640 SSD, 64G RAM | 80G HDD, 4G RAM | 500G SSD, 32G RAM After starting the witness node again, in a separate terminal you can run: From 8806e6fbfa78f4680e114ec82dbd5038cbdb3b6d Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Wed, 13 Feb 2019 16:14:11 -0300 Subject: [PATCH 171/172] add note to clarify new full node requirements --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 43c9daa823..3387ccf444 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,9 @@ In order to run a full node with all the account history you need to remove `par | Default | Full | Minimal | ElasticSearch | --- | --- | --- | --- -| 100G HDD, 16G RAM | 640 SSD, 64G RAM | 80G HDD, 4G RAM | 500G SSD, 32G RAM +| 100G HDD, 16G RAM | 640G SSD, 64G RAM * | 80G HDD, 4G RAM | 500G SSD, 32G RAM + +\* For this setup to work allocate all SSD space left(excluding OS and software) as Swap. After starting the witness node again, in a separate terminal you can run: From 27de12289dd0e9512f41380905a2349e56f56c93 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Thu, 14 Feb 2019 15:58:46 -0300 Subject: [PATCH 172/172] update full nodes setup notes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3387ccf444..a5c719aaa0 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ In order to run a full node with all the account history you need to remove `par | --- | --- | --- | --- | 100G HDD, 16G RAM | 640G SSD, 64G RAM * | 80G HDD, 4G RAM | 500G SSD, 32G RAM -\* For this setup to work allocate all SSD space left(excluding OS and software) as Swap. +\* For this setup, allocate at least 500GB of SSD as swap. After starting the witness node again, in a separate terminal you can run: