From f25c4f6ae6e92b0cdb8dab75a8c4d85e5ef68a1c Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 7 May 2019 08:27:57 +0200 Subject: [PATCH 01/77] Replace fc::uint128 with boost::multiprecision::uint128_t --- libraries/app/api.cpp | 1 + libraries/app/database_api.cpp | 1 - libraries/chain/account_object.cpp | 4 ++-- libraries/chain/asset_object.cpp | 5 +++-- libraries/chain/db_init.cpp | 5 ++--- libraries/chain/db_maint.cpp | 14 ++++++-------- libraries/chain/db_market.cpp | 2 +- libraries/chain/db_update.cpp | 2 -- libraries/chain/db_witness_schedule.cpp | 2 ++ libraries/chain/evaluator.cpp | 2 -- libraries/chain/genesis_state.cpp | 2 ++ .../graphene/chain/global_property_object.hpp | 2 -- .../include/graphene/chain/protocol/types.hpp | 1 - .../graphene/chain/vesting_balance_object.hpp | 8 ++++---- libraries/chain/market_evaluator.cpp | 1 - libraries/chain/protocol/asset.cpp | 1 + libraries/chain/protocol/fee_schedule.cpp | 3 ++- libraries/chain/protocol/operations.cpp | 5 +++-- libraries/chain/vesting_balance_object.cpp | 2 +- libraries/db/include/graphene/db/generic_index.hpp | 13 +------------ libraries/db/include/graphene/db/index.hpp | 1 - libraries/db/include/graphene/db/object.hpp | 14 ++++++++------ libraries/db/include/graphene/db/simple_index.hpp | 7 ------- libraries/db/object_database.cpp | 1 - libraries/fc | 2 +- .../market_history/market_history_plugin.hpp | 1 - libraries/wallet/wallet.cpp | 12 ++++++++++++ tests/tests/block_tests.cpp | 6 +++--- tests/tests/fee_tests.cpp | 4 +++- 29 files changed, 58 insertions(+), 66 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index c808a27c..ce056059 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -37,6 +37,7 @@ #include #include +#include #include #include #include diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 6b14f2bc..fa9677af 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -38,7 +38,6 @@ #include #include -#include #include diff --git a/libraries/chain/account_object.cpp b/libraries/chain/account_object.cpp index 71ee28de..30f3be14 100644 --- a/libraries/chain/account_object.cpp +++ b/libraries/chain/account_object.cpp @@ -36,10 +36,10 @@ share_type cut_fee(share_type a, uint16_t p) if( p == GRAPHENE_100_PERCENT ) return a; - fc::uint128 r(a.value); + fc::uint128_t r = a.value; r *= p; r /= GRAPHENE_100_PERCENT; - return r.to_uint64(); + return r.convert_to(); } void account_balance_object::adjust_balance(const asset& delta) diff --git a/libraries/chain/asset_object.cpp b/libraries/chain/asset_object.cpp index 79ad88ad..b074775a 100644 --- a/libraries/chain/asset_object.cpp +++ b/libraries/chain/asset_object.cpp @@ -38,10 +38,11 @@ share_type asset_bitasset_data_object::max_force_settlement_volume(share_type cu if( options.maximum_force_settlement_volume == GRAPHENE_100_PERCENT ) return current_supply + force_settled_volume; - fc::uint128 volume = current_supply.value + force_settled_volume.value; + fc::uint128_t volume = current_supply.value; + volume += force_settled_volume.value; volume *= options.maximum_force_settlement_volume; volume /= GRAPHENE_100_PERCENT; - return volume.to_uint64(); + return volume.convert_to(); } void asset_bitasset_data_object::update_median_feeds(time_point_sec current_time) diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 9ae1fb96..c1fe2f0b 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -89,7 +89,6 @@ #include #include -#include #include #include @@ -614,7 +613,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) p.time = genesis_state.initial_timestamp; p.dynamic_flags = 0; p.witness_budget = 0; - p.recent_slots_filled = fc::uint128::max_value(); + p.recent_slots_filled = std::numeric_limits::max(); }); create([&](global_betting_statistics_object& betting_statistics) { betting_statistics.number_of_active_events = 0; @@ -989,7 +988,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) _wso.last_scheduling_block = 0; - _wso.recent_slots_filled = fc::uint128::max_value(); + _wso.recent_slots_filled = fc::uint128_t::max_value(); // for shuffled for( const witness_id_type& wid : get_global_properties().active_witnesses ) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 03d2a274..f56df81f 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -22,8 +22,6 @@ * THE SOFTWARE. */ -#include - #include #include @@ -184,10 +182,10 @@ void database::pay_workers( share_type& budget ) // Note: if there is a good chance that passed_time_count == day_count, // for better performance, can avoid the 128 bit calculation by adding a check. // Since it's not the case on BitShares mainnet, we're not using a check here. - fc::uint128 pay(requested_pay.value); + fc::uint128_t pay = requested_pay.value; pay *= passed_time_count; pay /= day_count; - requested_pay = pay.to_uint64(); + requested_pay = pay.convert_to(); share_type actual_pay = std::min(budget, requested_pay); //ilog(" ==> Paying ${a} to worker ${w}", ("w", active_worker.id)("a", actual_pay)); @@ -436,7 +434,7 @@ void database::initialize_budget_record( fc::time_point_sec now, budget_record& budget_u128 >>= GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS; share_type budget; if( budget_u128 < reserve.value ) - rec.total_budget = share_type(budget_u128.to_uint64()); + rec.total_budget = share_type(budget_u128.convert_to()); else rec.total_budget = reserve; @@ -491,7 +489,7 @@ void database::process_budget() if( worker_budget_u128 >= available_funds.value ) worker_budget = available_funds; else - worker_budget = worker_budget_u128.to_uint64(); + worker_budget = worker_budget_u128.convert_to(); rec.worker_budget = worker_budget; available_funds -= worker_budget; @@ -631,12 +629,12 @@ void split_fba_balance( fc::uint128_t buyback_amount_128 = fba.accumulated_fba_fees.value; buyback_amount_128 *= designated_asset_buyback_pct; buyback_amount_128 /= GRAPHENE_100_PERCENT; - share_type buyback_amount = buyback_amount_128.to_uint64(); + share_type buyback_amount = buyback_amount_128.convert_to(); fc::uint128_t issuer_amount_128 = fba.accumulated_fba_fees.value; issuer_amount_128 *= designated_asset_issuer_pct; issuer_amount_128 /= GRAPHENE_100_PERCENT; - share_type issuer_amount = issuer_amount_128.to_uint64(); + share_type issuer_amount = issuer_amount_128.convert_to(); // this assert should never fail FC_ASSERT( buyback_amount + issuer_amount <= fba.accumulated_fba_fees ); diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index ad888532..49376f98 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -575,7 +575,7 @@ asset database::calculate_market_fee( const asset_object& trade_asset, const ass if( trade_asset.options.market_fee_percent == 0 ) return trade_asset.amount(0); - fc::uint128 a(trade_amount.amount.value); + fc::uint128_t a(trade_amount.amount.value); a *= trade_asset.options.market_fee_percent; a /= GRAPHENE_100_PERCENT; asset percent_fee = trade_asset.amount(a.to_uint64()); diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index 96f9e3ab..5703d04a 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -39,8 +39,6 @@ #include -#include - namespace graphene { namespace chain { void database::update_global_dynamic_data( const signed_block& b, const uint32_t missed_blocks ) diff --git a/libraries/chain/db_witness_schedule.cpp b/libraries/chain/db_witness_schedule.cpp index 762157bc..804fa46c 100644 --- a/libraries/chain/db_witness_schedule.cpp +++ b/libraries/chain/db_witness_schedule.cpp @@ -27,6 +27,8 @@ #include #include +#include + namespace graphene { namespace chain { using boost::container::flat_set; diff --git a/libraries/chain/evaluator.cpp b/libraries/chain/evaluator.cpp index 2ae8f0e7..d92564e9 100644 --- a/libraries/chain/evaluator.cpp +++ b/libraries/chain/evaluator.cpp @@ -35,8 +35,6 @@ #include #include -#include - namespace graphene { namespace chain { database& generic_evaluator::db()const { return trx_state->db(); } diff --git a/libraries/chain/genesis_state.cpp b/libraries/chain/genesis_state.cpp index 53311012..7e67180d 100644 --- a/libraries/chain/genesis_state.cpp +++ b/libraries/chain/genesis_state.cpp @@ -28,6 +28,8 @@ #include // required for gcc in release mode #include +#include + namespace graphene { namespace chain { chain_id_type genesis_state_type::compute_chain_id() const diff --git a/libraries/chain/include/graphene/chain/global_property_object.hpp b/libraries/chain/include/graphene/chain/global_property_object.hpp index 0ed401a1..789b1bd1 100644 --- a/libraries/chain/include/graphene/chain/global_property_object.hpp +++ b/libraries/chain/include/graphene/chain/global_property_object.hpp @@ -84,8 +84,6 @@ namespace graphene { namespace chain { * every time a block is found it decreases by * RECENTLY_MISSED_COUNT_DECREMENT. It is * never less than 0. - * - * If the recently_missed_count hits 2*UNDO_HISTORY then no new blocks may be pushed. */ uint32_t recently_missed_count = 0; diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp index 6fa2ab4d..f141b078 100644 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ b/libraries/chain/include/graphene/chain/protocol/types.hpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp index b03b8f7b..19acc0e7 100644 --- a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp +++ b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp @@ -89,11 +89,11 @@ namespace graphene { namespace chain { */ struct cdd_vesting_policy { - uint32_t vesting_seconds = 0; - fc::uint128_t coin_seconds_earned; + uint32_t vesting_seconds = 0; + fc::uint128_t coin_seconds_earned; /** while coindays may accrue over time, none may be claimed before first_claim date */ - fc::time_point_sec start_claim; - fc::time_point_sec coin_seconds_earned_last_update; + fc::time_point_sec start_claim; + fc::time_point_sec coin_seconds_earned_last_update; /** * Compute coin_seconds_earned. Used to diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index 60e07669..2ffb1f1d 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -34,7 +34,6 @@ #include -#include #include namespace graphene { namespace chain { diff --git a/libraries/chain/protocol/asset.cpp b/libraries/chain/protocol/asset.cpp index 525e193b..ebff3518 100644 --- a/libraries/chain/protocol/asset.cpp +++ b/libraries/chain/protocol/asset.cpp @@ -25,6 +25,7 @@ #include #include #include +#include namespace graphene { namespace chain { typedef boost::multiprecision::uint128_t uint128_t; diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/chain/protocol/fee_schedule.cpp index 6d494e37..dd0a1a3d 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/chain/protocol/fee_schedule.cpp @@ -36,6 +36,7 @@ namespace fc } #include +#include #define MAX_FEE_STABILIZATION_ITERATION 4 @@ -131,7 +132,7 @@ namespace graphene { namespace chain { auto itr = parameters.find(params); if( itr != parameters.end() ) params = *itr; auto base_value = op.visit( calc_fee_visitor( params ) ); - auto scaled = fc::uint128(base_value) * scale; + auto scaled = fc::uint128_t(base_value) * scale; scaled /= GRAPHENE_100_PERCENT; FC_ASSERT( scaled <= GRAPHENE_MAX_SHARE_SUPPLY ); //idump( (base_value)(scaled)(core_exchange_rate) ); diff --git a/libraries/chain/protocol/operations.cpp b/libraries/chain/protocol/operations.cpp index 7db51078..7ec951f2 100644 --- a/libraries/chain/protocol/operations.cpp +++ b/libraries/chain/protocol/operations.cpp @@ -25,14 +25,15 @@ #include #include #include +#include namespace graphene { namespace chain { uint64_t base_operation::calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte ) { - auto result = (fc::uint128(bytes) * price_per_kbyte) / 1024; + auto result = (fc::uint128_t(bytes) * price_per_kbyte) / 1024; FC_ASSERT( result <= GRAPHENE_MAX_SHARE_SUPPLY ); - return result.to_uint64(); + return result.convert_to(); } void balance_claim_operation::validate()const diff --git a/libraries/chain/vesting_balance_object.cpp b/libraries/chain/vesting_balance_object.cpp index 4674c974..b9e99ae9 100644 --- a/libraries/chain/vesting_balance_object.cpp +++ b/libraries/chain/vesting_balance_object.cpp @@ -127,7 +127,7 @@ asset cdd_vesting_policy::get_allowed_withdraw(const vesting_policy_context& ctx fc::uint128_t cs_earned = compute_coin_seconds_earned(ctx); fc::uint128_t withdraw_available = cs_earned / std::max(vesting_seconds, 1u); assert(withdraw_available <= ctx.balance.amount.value); - return asset(withdraw_available.to_uint64(), ctx.balance.asset_id); + return asset(static_cast(withdraw_available), ctx.balance.asset_id); } void cdd_vesting_policy::on_deposit(const vesting_policy_context& ctx) diff --git a/libraries/db/include/graphene/db/generic_index.hpp b/libraries/db/include/graphene/db/generic_index.hpp index 10e5d19e..2f760ee2 100644 --- a/libraries/db/include/graphene/db/generic_index.hpp +++ b/libraries/db/include/graphene/db/generic_index.hpp @@ -33,7 +33,7 @@ namespace graphene { namespace chain { using boost::multi_index_container; using namespace boost::multi_index; - struct by_id{}; + struct by_id; /** * Almost all objects can be tracked and managed via a boost::multi_index container that uses * an unordered_unique key on the object ID. This template class adapts the generic index interface @@ -112,18 +112,7 @@ namespace graphene { namespace chain { const index_type& indices()const { return _indices; } - virtual fc::uint128 hash()const override { - fc::uint128 result; - for( const auto& ptr : _indices ) - { - result += ptr.hash(); - } - - return result; - } - private: - fc::uint128 _current_hash; index_type _indices; }; diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index 1bc593f4..6a6fb3f1 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -129,7 +129,6 @@ namespace graphene { namespace db { } virtual void inspect_all_objects(std::function inspector)const = 0; - virtual fc::uint128 hash()const = 0; virtual void add_observer( const shared_ptr& ) = 0; virtual void object_from_variant( const fc::variant& var, object& obj, uint32_t max_depth )const = 0; diff --git a/libraries/db/include/graphene/db/object.hpp b/libraries/db/include/graphene/db/object.hpp index c410e273..09734d5f 100644 --- a/libraries/db/include/graphene/db/object.hpp +++ b/libraries/db/include/graphene/db/object.hpp @@ -23,9 +23,9 @@ */ #pragma once #include +#include #include #include -#include #define MAX_NESTING (200) @@ -77,7 +77,6 @@ namespace graphene { namespace db { virtual void move_from( object& obj ) = 0; virtual variant to_variant()const = 0; virtual vector pack()const = 0; - virtual fc::uint128 hash()const = 0; }; /** @@ -102,10 +101,6 @@ namespace graphene { namespace db { } virtual variant to_variant()const { return variant( static_cast(*this), MAX_NESTING ); } virtual vector pack()const { return fc::raw::pack( static_cast(*this) ); } - virtual fc::uint128 hash()const { - auto tmp = this->pack(); - return fc::city_hash_crc_128( tmp.data(), tmp.size() ); - } }; typedef flat_map annotation_map; @@ -139,6 +134,13 @@ namespace graphene { namespace db { } } // graphene::db +// Without this, pack(object_id) tries to match the template for +// pack(boost::multiprecision::uint128_t). No idea why. :-( +namespace boost { namespace multiprecision { namespace detail { +template +struct is_restricted_conversion : public mpl::true_ {}; +}}} + FC_REFLECT_TYPENAME( graphene::db::annotation_map ) FC_REFLECT( graphene::db::object, (id) ) FC_REFLECT_DERIVED_TEMPLATE( (typename Derived), graphene::db::annotated_object, (graphene::db::object), (annotations) ) diff --git a/libraries/db/include/graphene/db/simple_index.hpp b/libraries/db/include/graphene/db/simple_index.hpp index 0e807aef..51679be2 100644 --- a/libraries/db/include/graphene/db/simple_index.hpp +++ b/libraries/db/include/graphene/db/simple_index.hpp @@ -98,13 +98,6 @@ namespace graphene { namespace db { } } FC_CAPTURE_AND_RETHROW() } - virtual fc::uint128 hash()const override { - fc::uint128 result; - for( const auto& ptr : _objects ) - result += ptr->hash(); - - return result; - } class const_iterator { diff --git a/libraries/db/object_database.cpp b/libraries/db/object_database.cpp index fdde0fed..7e67c926 100644 --- a/libraries/db/object_database.cpp +++ b/libraries/db/object_database.cpp @@ -25,7 +25,6 @@ #include #include -#include namespace graphene { namespace db { diff --git a/libraries/fc b/libraries/fc index 9fa98d9a..69ebbf4b 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 9fa98d9a93ada3e84f48812b5c42b053b0dbf9da +Subproject commit 69ebbf4ba490482956de0e331b22f1018747d789 diff --git a/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp b/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp index b4d1254c..ad56e557 100644 --- a/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp +++ b/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp @@ -123,7 +123,6 @@ typedef multi_index_container< > > order_history_multi_index_type; - typedef generic_index bucket_index; typedef generic_index history_index; diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 97b31370..1846cb13 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -62,7 +62,13 @@ #include #include #include +<<<<<<< HEAD #include +======= +#include +#include +#include +>>>>>>> 8f1eca14... Replace fc::uint128 with boost::multiprecision::uint128_t #include #include @@ -680,7 +686,13 @@ public: " old"); result["next_maintenance_time"] = fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time); result["chain_id"] = chain_props.chain_id; +<<<<<<< HEAD result["participation"] = (100*dynamic_props.recent_slots_filled.popcount()) / 128.0; +======= + stringstream participation; + participation << fixed << std::setprecision(2) << (100.0*fc::popcount(dynamic_props.recent_slots_filled)) / 128.0; + result["participation"] = participation.str(); +>>>>>>> 8f1eca14... Replace fc::uint128 with boost::multiprecision::uint128_t result["active_witnesses"] = fc::variant(global_props.active_witnesses, GRAPHENE_MAX_NESTED_OBJECTS); result["active_committee_members"] = fc::variant(global_props.active_committee_members, GRAPHENE_MAX_NESTED_OBJECTS); result["entropy"] = fc::variant(dynamic_props.random, GRAPHENE_MAX_NESTED_OBJECTS); diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index b7ed69fe..60e25eff 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -1030,9 +1030,9 @@ BOOST_FIXTURE_TEST_CASE( rsf_missed_blocks, database_fixture ) { generate_block(); - auto rsf = [&]() -> string + auto rsf = [this]() -> string { - fc::uint128 rsf; + fc::uint128_t rsf; if (db.get_global_properties().parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM) rsf = db.get(witness_schedule_id_type()).recent_slots_filled; else @@ -1041,7 +1041,7 @@ BOOST_FIXTURE_TEST_CASE( rsf_missed_blocks, database_fixture ) result.reserve(128); for( int i=0; i<128; i++ ) { - result += ((rsf.lo & 1) == 0) ? '0' : '1'; + result += rsf & 1 ? '1' : '0'; rsf >>= 1; } return result; diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index 96494899..5d16dc72 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -35,6 +35,8 @@ #include #include +#include + #include #include "../common/database_fixture.hpp" @@ -245,7 +247,7 @@ uint64_t pct( uint64_t percentage, uint64_t val ) fc::uint128_t x = percentage; x *= val; x /= GRAPHENE_100_PERCENT; - return x.to_uint64(); + return static_cast(x); } uint64_t pct( uint64_t percentage0, uint64_t percentage1, uint64_t val ) From a24a6bfc683600d47f65a822de3ec171a71c158e Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 1 Feb 2019 15:38:52 -0500 Subject: [PATCH 02/77] replace smart_ref with shared_ptr --- libraries/app/api.cpp | 1 - libraries/app/application.cpp | 4 +--- libraries/app/database_api.cpp | 1 - libraries/chain/CMakeLists.txt | 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 | 2 -- libraries/chain/db_getter.cpp | 4 +--- libraries/chain/db_init.cpp | 2 +- libraries/chain/db_maint.cpp | 1 - libraries/chain/fork_database.cpp | 1 - libraries/chain/genesis_state.cpp | 1 - .../chain/protocol/chain_parameters.hpp | 5 ++--- .../graphene/chain/protocol/fee_schedule.hpp | 4 ++++ .../include/graphene/chain/protocol/types.hpp | 2 -- libraries/chain/market_evaluator.cpp | 2 +- libraries/chain/proposal_evaluator.cpp | 2 -- libraries/chain/protocol/chain_parameters.cpp | 8 ++++++++ libraries/chain/protocol/fee_schedule.cpp | 15 --------------- libraries/chain/protocol/proposal.cpp | 1 - libraries/chain/protocol/transaction.cpp | 1 - libraries/egenesis/embed_genesis.cpp | 1 - libraries/net/node.cpp | 1 - .../account_history/account_history_plugin.cpp | 1 - libraries/plugins/debug_witness/debug_api.cpp | 1 - .../plugins/debug_witness/debug_witness.cpp | 1 - .../delayed_node/delayed_node_plugin.cpp | 2 -- .../elasticsearch/elasticsearch_plugin.cpp | 1 - libraries/plugins/es_objects/es_objects.cpp | 2 -- .../market_history/market_history_plugin.cpp | 1 - libraries/plugins/witness/witness.cpp | 1 - libraries/wallet/wallet.cpp | 10 ++++------ 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 | 10 ---------- programs/size_checker/main.cpp | 1 - tests/app/main.cpp | 1 - tests/benchmarks/genesis_allocation.cpp | 1 - tests/common/database_fixture.cpp | 5 ++--- tests/common/database_fixture.hpp | 1 - tests/generate_empty_blocks/main.cpp | 1 - tests/tests/fee_tests.cpp | 18 +++++++++--------- 46 files changed, 34 insertions(+), 95 deletions(-) create mode 100644 libraries/chain/protocol/chain_parameters.cpp diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index ce056059..8832ac9d 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -39,7 +39,6 @@ #include #include -#include #include #include diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 2c7553f5..2a299625 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -37,8 +37,6 @@ #include #include -#include - #include #include #include @@ -80,7 +78,7 @@ namespace detail { auto nathan_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan"))); dlog("Allocating all stake to ${key}", ("key", utilities::key_to_wif(nathan_key))); genesis_state_type initial_state; - initial_state.initial_parameters.current_fees = fee_schedule::get_default();//->set_all_fees(GRAPHENE_BLOCKCHAIN_PRECISION); + initial_state.initial_parameters.current_fees = std::make_shared(fee_schedule::get_default()); initial_state.initial_active_witnesses = GRAPHENE_DEFAULT_MIN_WITNESS_COUNT; initial_state.initial_timestamp = time_point_sec(time_point::now().sec_since_epoch() / initial_state.initial_parameters.block_interval * diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index fa9677af..1af19618 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 88d868e5..01a4a8eb 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -43,6 +43,7 @@ add_library( graphene_chain protocol/assert.cpp protocol/account.cpp protocol/transfer.cpp + protocol/chain_parameters.cpp protocol/committee_member.cpp protocol/witness.cpp protocol/market.cpp diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index ad6ac5dc..515108ec 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 3dcdcba4..2dd9b7a2 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 73d7703b..01614f99 100644 --- a/libraries/chain/committee_member_evaluator.cpp +++ b/libraries/chain/committee_member_evaluator.cpp @@ -30,8 +30,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 9323d2d9..9946b492 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 7711f543..1e124902 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_bet.cpp" #include "db_block.cpp" diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index e2fc9aab..e667413d 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -42,8 +42,6 @@ #include #include -#include - namespace { struct proposed_operations_digest_accumulator diff --git a/libraries/chain/db_getter.cpp b/libraries/chain/db_getter.cpp index 0f7af1a8..ac31d437 100644 --- a/libraries/chain/db_getter.cpp +++ b/libraries/chain/db_getter.cpp @@ -31,8 +31,6 @@ #include #include -#include - #include #include @@ -65,7 +63,7 @@ const dynamic_global_property_object& database::get_dynamic_global_properties() const fee_schedule& database::current_fee_schedule()const { - return get_global_properties().parameters.current_fees; + return std::ref( *get_global_properties().parameters.current_fees ); } time_point_sec database::head_block_time()const diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index c1fe2f0b..9c3102fe 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -88,7 +88,7 @@ #include -#include +#include #include #include diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index f56df81f..b222b0de 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -22,7 +22,6 @@ * THE SOFTWARE. */ -#include #include #include diff --git a/libraries/chain/fork_database.cpp b/libraries/chain/fork_database.cpp index 83d4880c..1cb4f77b 100644 --- a/libraries/chain/fork_database.cpp +++ b/libraries/chain/fork_database.cpp @@ -24,7 +24,6 @@ #include #include #include -#include namespace graphene { namespace chain { fork_database::fork_database() diff --git a/libraries/chain/genesis_state.cpp b/libraries/chain/genesis_state.cpp index 7e67180d..3ad0ec46 100644 --- a/libraries/chain/genesis_state.cpp +++ b/libraries/chain/genesis_state.cpp @@ -25,7 +25,6 @@ #include // these are required to serialize a genesis_state -#include // required for gcc in release mode #include #include diff --git a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp b/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp index ddac3115..d07f613b 100644 --- a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp +++ b/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once +#include #include #include #include -#include #include <../hardfork.d/GPOS.hf> #include @@ -56,8 +56,7 @@ namespace graphene { namespace chain { struct chain_parameters { - /** using a smart ref breaks the circular dependency created between operations and the fee schedule */ - smart_ref current_fees; ///< current schedule of fees + std::shared_ptr current_fees; ///< current schedule of fees uint8_t block_interval = GRAPHENE_DEFAULT_BLOCK_INTERVAL; ///< interval in seconds between blocks uint32_t maintenance_interval = GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL; ///< interval in sections between blockchain maintenance events uint8_t maintenance_skip_slots = GRAPHENE_DEFAULT_MAINTENANCE_SKIP_SLOTS; ///< number of block_intervals to skip at maintenance time diff --git a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp index 9baaffc7..b650ab4c 100644 --- a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp +++ b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp @@ -84,6 +84,10 @@ namespace graphene { namespace chain { } } // graphene::chain +namespace fc { + template<> struct get_typename> { static const char* name() { return "shared_ptr"; } }; +} + FC_REFLECT_TYPENAME( graphene::chain::fee_parameters ) FC_REFLECT( graphene::chain::fee_schedule, (parameters)(scale) ) diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp index f141b078..7db63c0d 100644 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ b/libraries/chain/include/graphene/chain/protocol/types.hpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include @@ -88,7 +87,6 @@ namespace graphene { namespace chain { using std::tie; using std::make_pair; - using fc::smart_ref; using fc::variant_object; using fc::variant; using fc::enum_type; diff --git a/libraries/chain/market_evaluator.cpp b/libraries/chain/market_evaluator.cpp index 2ffb1f1d..4f219565 100644 --- a/libraries/chain/market_evaluator.cpp +++ b/libraries/chain/market_evaluator.cpp @@ -34,7 +34,7 @@ #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 ba714c21..70066066 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -31,8 +31,6 @@ #include #include -#include - namespace graphene { namespace chain { struct proposal_operation_hardfork_visitor diff --git a/libraries/chain/protocol/chain_parameters.cpp b/libraries/chain/protocol/chain_parameters.cpp new file mode 100644 index 00000000..2bfa624f --- /dev/null +++ b/libraries/chain/protocol/chain_parameters.cpp @@ -0,0 +1,8 @@ +#include +#include + +namespace graphene { namespace chain { + chain_parameters::chain_parameters() { + current_fees = std::make_shared(); + } +}} \ No newline at end of file diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/chain/protocol/fee_schedule.cpp index dd0a1a3d..7410cddf 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/chain/protocol/fee_schedule.cpp @@ -23,17 +23,6 @@ */ #include #include -#include - -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; -} #include #include @@ -42,10 +31,6 @@ namespace fc namespace graphene { namespace chain { - typedef fc::smart_ref smart_fee_schedule; - - static smart_fee_schedule tmp; - fee_schedule::fee_schedule() { } diff --git a/libraries/chain/protocol/proposal.cpp b/libraries/chain/protocol/proposal.cpp index c77e71e4..f14f057a 100644 --- a/libraries/chain/protocol/proposal.cpp +++ b/libraries/chain/protocol/proposal.cpp @@ -23,7 +23,6 @@ */ #include #include -#include #include diff --git a/libraries/chain/protocol/transaction.cpp b/libraries/chain/protocol/transaction.cpp index 62419948..6d6e526c 100644 --- a/libraries/chain/protocol/transaction.cpp +++ b/libraries/chain/protocol/transaction.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff --git a/libraries/egenesis/embed_genesis.cpp b/libraries/egenesis/embed_genesis.cpp index 26283080..c2ffd686 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 0fc61dde..14e32306 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -70,7 +70,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 67322f80..91c3264c 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 823755f5..43ffd6cd 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 66ef2f58..7268006d 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 d49129b0..599fc65c 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 484aef9c..169e684d 100644 --- a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp +++ b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include namespace graphene { namespace elasticsearch { diff --git a/libraries/plugins/es_objects/es_objects.cpp b/libraries/plugins/es_objects/es_objects.cpp index b9083cbc..5fd89107 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 80876a48..48c215f0 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 6ef7798b..1e7a9d6e 100644 --- a/libraries/plugins/witness/witness.cpp +++ b/libraries/plugins/witness/witness.cpp @@ -30,7 +30,6 @@ #include -#include #include #include diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 1846cb13..47230d3c 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -89,7 +89,6 @@ #include #include #include -#include #ifndef WIN32 # include @@ -667,10 +666,10 @@ public: return ob.template as( GRAPHENE_MAX_NESTED_OBJECTS ); } - void set_operation_fees( signed_transaction& tx, const fee_schedule& s ) + void set_operation_fees( signed_transaction& tx, const std::shared_ptr s ) { for( auto& op : tx.operations ) - s.set_fee(op); + s->set_fee(op); } variant info() const @@ -1316,8 +1315,7 @@ public: tx.operations.push_back( account_create_op ); - auto current_fees = _remote_db->get_global_properties().parameters.current_fees; - set_operation_fees( tx, current_fees ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); vector paying_keys = registrar_account_object.active.get_keys(); @@ -3159,7 +3157,7 @@ public: new_fees.scale = scale; chain_parameters new_params = current_params; - new_params.current_fees = new_fees; + new_params.current_fees = std::make_shared(new_fees); committee_member_update_global_parameters_operation update_op; update_op.new_parameters = new_params; diff --git a/programs/build_helpers/member_enumerator.cpp b/programs/build_helpers/member_enumerator.cpp index 915d7edf..d956af38 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 b7abdabe..3fd1051b 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 e753b8b7..4df7091f 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 94a3296a..f68b0554 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -48,7 +48,6 @@ #include #include -#include #include using namespace graphene::chain; @@ -121,7 +120,6 @@ struct js_name> template struct js_name> { static std::string name(){ return "bytes "+ fc::to_string(N); }; }; template struct js_name> { static std::string name(){ return "bytes "+ fc::to_string(N); }; }; template struct js_name< fc::optional > { static std::string name(){ return "optional " + js_name::name(); } }; -template struct js_name< fc::smart_ref > { static std::string name(){ return js_name::name(); } }; template<> struct js_name< object_id_type > { static std::string name(){ return "object_id_type"; } }; template struct js_name< fc::flat_set > { static std::string name(){ return "set " + js_name::name(); } }; template struct js_name< std::vector > { static std::string name(){ return "array " + js_name::name(); } }; @@ -249,14 +247,6 @@ struct serializer,false> static void generate() {} }; -template -struct serializer,false> -{ - static void init() { - serializer::init(); } - static void generate() {} -}; - template<> struct serializer,false> { diff --git a/programs/size_checker/main.cpp b/programs/size_checker/main.cpp index de071cfc..188e88e4 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 623f760e..d7a0f02e 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 a17a16fa..63e75db5 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/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 3a381585..be095092 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -48,7 +48,6 @@ #include #include -#include #include @@ -692,7 +691,7 @@ void database_fixture::change_fees( new_fees.scale = new_scale; chain_parameters new_chain_params = current_chain_params; - new_chain_params.current_fees = new_fees; + new_chain_params.current_fees = std::make_shared(new_fees); db.modify(db.get_global_properties(), [&](global_property_object& p) { p.parameters = new_chain_params; @@ -1019,7 +1018,7 @@ void database_fixture::enable_fees() { db.modify(global_property_id_type()(db), [](global_property_object& gpo) { - gpo.parameters.current_fees = fee_schedule::get_default(); + gpo.parameters.current_fees = std::make_shared(fee_schedule::get_default()); }); } diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index 200d1897..25a87855 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -26,7 +26,6 @@ #include #include #include -#include #include diff --git a/tests/generate_empty_blocks/main.cpp b/tests/generate_empty_blocks/main.cpp index 1960a151..298b03cd 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 5d16dc72..17607f6f 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -22,7 +22,6 @@ * THE SOFTWARE. */ -#include #include #include @@ -336,7 +335,7 @@ BOOST_AUTO_TEST_CASE( cashback_test ) upgrade_to_lifetime_member(rog_id); BOOST_TEST_MESSAGE("Enable fees"); - const auto& fees = db.get_global_properties().parameters.current_fees; + const auto& fees = *db.get_global_properties().parameters.current_fees; #define CustomRegisterActor(actor_name, registrar_name, referrer_name, referrer_rate) \ { \ @@ -348,7 +347,7 @@ BOOST_AUTO_TEST_CASE( cashback_test ) op.options.memo_key = actor_name ## _private_key.get_public_key(); \ op.active = authority(1, public_key_type(actor_name ## _private_key.get_public_key()), 1); \ op.owner = op.active; \ - op.fee = fees->calculate_fee(op); \ + op.fee = fees.calculate_fee(op); \ trx.operations = {op}; \ sign( trx, registrar_name ## _private_key ); \ actor_name ## _id = PUSH_TX( db, trx ).operation_results.front().get(); \ @@ -374,10 +373,10 @@ BOOST_AUTO_TEST_CASE( cashback_test ) CustomAuditActor( pleb ); \ } - int64_t reg_fee = fees->get< account_create_operation >().premium_fee; - int64_t xfer_fee = fees->get< transfer_operation >().fee; - int64_t upg_an_fee = fees->get< account_upgrade_operation >().membership_annual_fee; - int64_t upg_lt_fee = fees->get< account_upgrade_operation >().membership_lifetime_fee; + int64_t reg_fee = fees.get< account_create_operation >().premium_fee; + int64_t xfer_fee = fees.get< transfer_operation >().fee; + int64_t upg_an_fee = fees.get< account_upgrade_operation >().membership_annual_fee; + int64_t upg_lt_fee = fees.get< account_upgrade_operation >().membership_lifetime_fee; // all percentages here are cut from whole pie! uint64_t network_pct = 20 * P1; uint64_t lt_pct = 375 * P100 / 1000; @@ -584,7 +583,7 @@ BOOST_AUTO_TEST_CASE( account_create_fee_scaling ) auto accounts_per_scale = db.get_global_properties().parameters.accounts_per_fee_scale; db.modify(global_property_id_type()(db), [](global_property_object& gpo) { - gpo.parameters.current_fees = fee_schedule::get_default(); + gpo.parameters.current_fees = std::make_shared(fee_schedule::get_default()); gpo.parameters.current_fees->get().basic_fee = 1; }); @@ -1006,7 +1005,8 @@ BOOST_AUTO_TEST_CASE( issue_429_test ) // make sure the database requires our fee to be nonzero enable_fees(); - auto fees_to_pay = db.get_global_properties().parameters.current_fees->get(); + const auto& fees = *db.get_global_properties().parameters.current_fees; + auto fees_to_pay = fees.get(); { signed_transaction tx; From 953a1314a3aed8b4c64b9b1efdfdc6d0021a45f2 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 18 Aug 2020 18:11:17 -0500 Subject: [PATCH 03/77] Fixes/Remove Unused --- libraries/chain/include/graphene/chain/protocol/types.hpp | 2 -- libraries/net/include/graphene/net/message.hpp | 1 - libraries/net/include/graphene/net/stcp_socket.hpp | 2 -- 3 files changed, 5 deletions(-) diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp index 7db63c0d..d0b90a0d 100644 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ b/libraries/chain/include/graphene/chain/protocol/types.hpp @@ -92,7 +92,6 @@ namespace graphene { namespace chain { using fc::enum_type; using fc::optional; using fc::unsigned_int; - using fc::signed_int; using fc::time_point_sec; using fc::time_point; using fc::safe; @@ -323,7 +322,6 @@ namespace graphene { namespace chain { typedef object_id< implementation_ids, impl_sweeps_vesting_balance_object_type, sweeps_vesting_balance_object> sweeps_vesting_balance_id_type; typedef object_id< implementation_ids, impl_offer_history_object_type, offer_history_object> offer_history_id_type; - typedef fc::array symbol_type; typedef fc::ripemd160 block_id_type; typedef fc::ripemd160 checksum_type; typedef fc::ripemd160 transaction_id_type; diff --git a/libraries/net/include/graphene/net/message.hpp b/libraries/net/include/graphene/net/message.hpp index 686fea24..8f6d2b6e 100644 --- a/libraries/net/include/graphene/net/message.hpp +++ b/libraries/net/include/graphene/net/message.hpp @@ -26,7 +26,6 @@ #include -#include #include #include #include diff --git a/libraries/net/include/graphene/net/stcp_socket.hpp b/libraries/net/include/graphene/net/stcp_socket.hpp index cca94d57..ff0ea337 100644 --- a/libraries/net/include/graphene/net/stcp_socket.hpp +++ b/libraries/net/include/graphene/net/stcp_socket.hpp @@ -61,8 +61,6 @@ class stcp_socket : public virtual fc::iostream fc::sha512 _shared_secret; fc::ecc::private_key _priv_key; - fc::array _buf; - //uint32_t _buf_len; fc::tcp_socket _sock; fc::aes_encoder _send_aes; fc::aes_decoder _recv_aes; From 10adf05881f6770e8d2b3677d302701000b166e8 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Thu, 16 Mar 2017 12:46:09 -0500 Subject: [PATCH 04/77] Remove NTP time --- libraries/CMakeLists.txt | 2 - libraries/app/CMakeLists.txt | 3 +- libraries/time/CMakeLists.txt | 17 --- libraries/time/include/graphene/time/time.hpp | 46 ------- libraries/time/time.cpp | 126 ------------------ 5 files changed, 1 insertion(+), 193 deletions(-) delete mode 100644 libraries/time/CMakeLists.txt delete mode 100644 libraries/time/include/graphene/time/time.hpp delete mode 100644 libraries/time/time.cpp diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 18ca3130..04ad3781 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -4,8 +4,6 @@ add_subdirectory( db ) add_subdirectory( chain ) add_subdirectory( egenesis ) add_subdirectory( net ) -#add_subdirectory( p2p ) -add_subdirectory( time ) add_subdirectory( utilities ) add_subdirectory( app ) add_subdirectory( plugins ) diff --git a/libraries/app/CMakeLists.txt b/libraries/app/CMakeLists.txt index d66b4052..59a9368c 100644 --- a/libraries/app/CMakeLists.txt +++ b/libraries/app/CMakeLists.txt @@ -12,8 +12,7 @@ add_library( graphene_app ) # need to link graphene_debug_witness because plugins aren't sufficiently isolated #246 -#target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_chain fc graphene_db graphene_net graphene_utilities graphene_debug_witness ) -target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_accounts_list graphene_affiliate_stats graphene_chain fc graphene_db graphene_net graphene_time graphene_utilities graphene_debug_witness graphene_bookie graphene_elasticsearch ) +target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_accounts_list graphene_affiliate_stats graphene_chain fc graphene_db graphene_net graphene_utilities graphene_debug_witness graphene_bookie graphene_elasticsearch ) target_include_directories( graphene_app PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" ) diff --git a/libraries/time/CMakeLists.txt b/libraries/time/CMakeLists.txt deleted file mode 100644 index cc8a909d..00000000 --- a/libraries/time/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -file(GLOB HEADERS "include/graphene/time/*.hpp") - -add_library( graphene_time - time.cpp - ) - -target_link_libraries( graphene_time fc ) -target_include_directories( graphene_time - PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) - -install( TARGETS - graphene_time - - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) diff --git a/libraries/time/include/graphene/time/time.hpp b/libraries/time/include/graphene/time/time.hpp deleted file mode 100644 index 2979369c..00000000 --- a/libraries/time/include/graphene/time/time.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#pragma once - -#include -#include -#include - -namespace graphene { namespace time { - - typedef fc::signal time_discontinuity_signal_type; - extern time_discontinuity_signal_type time_discontinuity_signal; - - fc::optional ntp_time(); - fc::time_point now(); - fc::time_point nonblocking_now(); // identical to now() but guaranteed not to block - void update_ntp_time(); - fc::microseconds ntp_error(); - void shutdown_ntp_time(); - - void start_simulated_time( const fc::time_point sim_time ); - void advance_simulated_time_to( const fc::time_point sim_time ); - void advance_time( int32_t delta_seconds ); - -} } // graphene::time diff --git a/libraries/time/time.cpp b/libraries/time/time.cpp deleted file mode 100644 index 6ba0c126..00000000 --- a/libraries/time/time.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include - -#include -#include -#include -#include - -#include - -namespace graphene { namespace time { - -static int32_t simulated_time = 0; -static int32_t adjusted_time_sec = 0; - -time_discontinuity_signal_type time_discontinuity_signal; - -namespace detail -{ - std::atomic ntp_service(nullptr); - fc::mutex ntp_service_initialization_mutex; -} - -fc::optional ntp_time() -{ - fc::ntp* actual_ntp_service = detail::ntp_service.load(); - if (!actual_ntp_service) - { - fc::scoped_lock lock(detail::ntp_service_initialization_mutex); - actual_ntp_service = detail::ntp_service.load(); - if (!actual_ntp_service) - { - actual_ntp_service = new fc::ntp; - detail::ntp_service.store(actual_ntp_service); - } - } - return actual_ntp_service->get_time(); -} - -void shutdown_ntp_time() -{ - fc::ntp* actual_ntp_service = detail::ntp_service.exchange(nullptr); - delete actual_ntp_service; -} - -fc::time_point now() -{ - if( simulated_time ) - return fc::time_point() + fc::seconds( simulated_time + adjusted_time_sec ); - - fc::optional current_ntp_time = ntp_time(); - if( current_ntp_time.valid() ) - return *current_ntp_time + fc::seconds( adjusted_time_sec ); - else - return fc::time_point::now() + fc::seconds( adjusted_time_sec ); -} - -fc::time_point nonblocking_now() -{ - if (simulated_time) - return fc::time_point() + fc::seconds(simulated_time + adjusted_time_sec); - - fc::ntp* actual_ntp_service = detail::ntp_service.load(); - fc::optional current_ntp_time; - if (actual_ntp_service) - current_ntp_time = actual_ntp_service->get_time(); - - if (current_ntp_time) - return *current_ntp_time + fc::seconds(adjusted_time_sec); - else - return fc::time_point::now() + fc::seconds(adjusted_time_sec); -} - -void update_ntp_time() -{ - detail::ntp_service.load()->request_now(); -} - -fc::microseconds ntp_error() -{ - fc::optional current_ntp_time = ntp_time(); - FC_ASSERT( current_ntp_time, "We don't have NTP time!" ); - return *current_ntp_time - fc::time_point::now(); -} - -void start_simulated_time( const fc::time_point sim_time ) -{ - simulated_time = sim_time.sec_since_epoch(); - adjusted_time_sec = 0; -} -void advance_simulated_time_to( const fc::time_point sim_time ) -{ - simulated_time = sim_time.sec_since_epoch(); - adjusted_time_sec = 0; -} - -void advance_time( int32_t delta_seconds ) -{ - adjusted_time_sec += delta_seconds; - time_discontinuity_signal(); -} - -} } // graphene::time From ced4380664d844ee247ab8005765b41bbbee3c0e Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 18 Aug 2020 18:34:00 -0500 Subject: [PATCH 05/77] Remove old macro This macro is now in FC, so no need to define it here anymore --- .../include/graphene/chain/protocol/types.hpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp index d0b90a0d..e617c395 100644 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ b/libraries/chain/include/graphene/chain/protocol/types.hpp @@ -55,21 +55,6 @@ namespace raw { \ ext template void unpack< datastream, type >( datastream& s, type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ } } // fc::raw -#define FC_REFLECT_DERIVED_NO_TYPENAME( TYPE, INHERITS, MEMBERS ) \ -namespace fc { \ -template<> struct reflector {\ - typedef TYPE type; \ - typedef fc::true_type is_defined; \ - typedef fc::false_type is_enum; \ - enum member_count_enum { \ - local_member_count = 0 BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_MEMBER_COUNT, +, MEMBERS ),\ - total_member_count = local_member_count BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_BASE_MEMBER_COUNT, +, INHERITS )\ - }; \ - FC_REFLECT_DERIVED_IMPL_INLINE( TYPE, INHERITS, MEMBERS ) \ -}; \ -} // fc - - namespace graphene { namespace chain { using namespace graphene::db; From 0569efc068d17da7d907a47a4e8a3f607c613069 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Wed, 29 May 2019 11:22:42 +0200 Subject: [PATCH 06/77] Replaced fc::array with std::array --- .../graphene/chain/protocol/address.hpp | 2 +- .../include/graphene/chain/pts_address.hpp | 11 ++++++---- libraries/chain/protocol/address.cpp | 17 +++++++------- libraries/chain/pts_address.cpp | 22 +++++++++---------- .../net/include/graphene/net/stcp_socket.hpp | 2 ++ libraries/net/node.cpp | 2 +- programs/js_operation_serializer/main.cpp | 11 +++++----- 7 files changed, 37 insertions(+), 30 deletions(-) diff --git a/libraries/chain/include/graphene/chain/protocol/address.hpp b/libraries/chain/include/graphene/chain/protocol/address.hpp index 8bf0fab6..564bab53 100644 --- a/libraries/chain/include/graphene/chain/protocol/address.hpp +++ b/libraries/chain/include/graphene/chain/protocol/address.hpp @@ -27,8 +27,8 @@ #include #include +#include #include -#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/pts_address.hpp b/libraries/chain/include/graphene/chain/pts_address.hpp index c0bc80ff..faa55816 100644 --- a/libraries/chain/include/graphene/chain/pts_address.hpp +++ b/libraries/chain/include/graphene/chain/pts_address.hpp @@ -23,10 +23,13 @@ */ #pragma once -#include +#include +#include +#include + #include #include -#include +#include namespace fc { namespace ecc { class public_key; } } @@ -46,7 +49,7 @@ namespace graphene { namespace chain { operator std::string()const; ///< converts to base58 + checksum - fc::array addr; ///< binary representation of address + std::array addr; ///< binary representation of address }; inline bool operator == ( const pts_address& a, const pts_address& b ) { return a.addr == b.addr; } @@ -64,7 +67,7 @@ namespace std size_t operator()(const graphene::chain::pts_address &a) const { size_t s; - memcpy( (char*)&s, &a.addr.data[sizeof(a)-sizeof(s)], sizeof(s) ); + std::memcpy( (char*)&s, a.addr.data() + a.addr.size() - sizeof(s), sizeof(s) ); return s; } }; diff --git a/libraries/chain/protocol/address.cpp b/libraries/chain/protocol/address.cpp index f0edbd49..3065d80b 100644 --- a/libraries/chain/protocol/address.cpp +++ b/libraries/chain/protocol/address.cpp @@ -71,7 +71,7 @@ namespace graphene { address::address( const fc::ecc::public_key& pub ) { auto dat = pub.serialize(); - addr = fc::ripemd160::hash( fc::sha512::hash( dat.data, sizeof( dat ) ) ); + addr = fc::ripemd160::hash( fc::sha512::hash( (char*) dat.data(), dat.size() ) ); } address::address( const pts_address& ptsaddr ) @@ -81,21 +81,22 @@ namespace graphene { address::address( const fc::ecc::public_key_data& pub ) { - addr = fc::ripemd160::hash( fc::sha512::hash( pub.data, sizeof( pub ) ) ); + addr = fc::ripemd160::hash( fc::sha512::hash( (char*) pub.data(), pub.size() ) ); } address::address( const graphene::chain::public_key_type& pub ) { - addr = fc::ripemd160::hash( fc::sha512::hash( pub.key_data.data, sizeof( pub.key_data ) ) ); + addr = fc::ripemd160::hash( fc::sha512::hash( (char*) pub.key_data.data(), pub.key_data.size() ) ); } address::operator std::string()const { - fc::array bin_addr; - memcpy( (char*)&bin_addr, (char*)&addr, sizeof( addr ) ); - auto checksum = fc::ripemd160::hash( (char*)&addr, sizeof( addr ) ); - memcpy( ((char*)&bin_addr)+20, (char*)&checksum._hash[0], 4 ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( bin_addr.data, sizeof( bin_addr ) ); + std::array bin_addr; + static_assert( bin_addr.size() >= sizeof(addr) + 4 ); + memcpy( bin_addr.data(), addr.data(), sizeof(addr) ); + auto checksum = fc::ripemd160::hash( addr.data(), sizeof(addr) ); + memcpy( bin_addr.data() + 20, (char*)&checksum._hash[0], 4 ); + return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( bin_addr.data(), bin_addr.size() ); } } } // namespace graphene::chain diff --git a/libraries/chain/pts_address.cpp b/libraries/chain/pts_address.cpp index c6d74f58..e30f71dc 100644 --- a/libraries/chain/pts_address.cpp +++ b/libraries/chain/pts_address.cpp @@ -34,14 +34,14 @@ namespace graphene { namespace chain { pts_address::pts_address() { - memset( addr.data, 0, sizeof(addr.data) ); + memset( addr.data(), 0, addr.size() ); } pts_address::pts_address( const std::string& base58str ) { std::vector v = fc::from_base58( fc::string(base58str) ); if( v.size() ) - memcpy( addr.data, v.data(), std::min( v.size(), sizeof(addr) ) ); + memcpy( addr.data(), v.data(), std::min( v.size(), addr.size() ) ); if( !is_valid() ) { @@ -55,19 +55,19 @@ namespace graphene { namespace chain { if( compressed ) { auto dat = pub.serialize(); - sha2 = fc::sha256::hash(dat.data, sizeof(dat) ); + sha2 = fc::sha256::hash((char*) dat.data(), dat.size() ); } else { auto dat = pub.serialize_ecc_point(); - sha2 = fc::sha256::hash(dat.data, sizeof(dat) ); + sha2 = fc::sha256::hash((char*) dat.data(), dat.size() ); } auto rep = fc::ripemd160::hash((char*)&sha2,sizeof(sha2)); - addr.data[0] = version; - memcpy( addr.data+1, (char*)&rep, sizeof(rep) ); - auto check = fc::sha256::hash( addr.data, sizeof(rep)+1 ); + addr[0] = version; + memcpy( addr.data() + 1, (char*)&rep, sizeof(rep) ); + auto check = fc::sha256::hash( addr.data(), sizeof(rep)+1 ); check = fc::sha256::hash(check); - memcpy( addr.data+1+sizeof(rep), (char*)&check, 4 ); + memcpy( addr.data() + 1 + sizeof(rep), (char*)&check, 4 ); } /** @@ -76,14 +76,14 @@ namespace graphene { namespace chain { */ bool pts_address::is_valid()const { - auto check = fc::sha256::hash( addr.data, sizeof(fc::ripemd160)+1 ); + auto check = fc::sha256::hash( addr.data(), sizeof(fc::ripemd160)+1 ); check = fc::sha256::hash(check); - return memcmp( addr.data+1+sizeof(fc::ripemd160), (char*)&check, 4 ) == 0; + return memcmp( addr.data() + 1 + sizeof(fc::ripemd160), (char*)&check, 4 ) == 0; } pts_address::operator std::string()const { - return fc::to_base58( addr.data, sizeof(addr) ); + return fc::to_base58( addr.data(), addr.size() ); } } } // namespace graphene diff --git a/libraries/net/include/graphene/net/stcp_socket.hpp b/libraries/net/include/graphene/net/stcp_socket.hpp index ff0ea337..fb4bfbc7 100644 --- a/libraries/net/include/graphene/net/stcp_socket.hpp +++ b/libraries/net/include/graphene/net/stcp_socket.hpp @@ -26,6 +26,8 @@ #include #include +#include + namespace graphene { namespace net { /** diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index 14e32306..9923fa8f 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -827,7 +827,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_bytes(&_node_id.data[0], (int)_node_id.size()); + fc::rand_bytes((char*) _node_id.data(), (int)_node_id.size()); } node_impl::~node_impl() diff --git a/programs/js_operation_serializer/main.cpp b/programs/js_operation_serializer/main.cpp index f68b0554..d7c5c2f9 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -113,12 +113,13 @@ bool register_serializer( const string& name, std::function sr ) template struct js_name { static std::string name(){ return remove_namespace(fc::get_typename::name()); }; }; template -struct js_name> +struct js_name> { - static std::string name(){ return "fixed_array "+ fc::to_string(N) + ", " + remove_namespace(fc::get_typename::name()); }; + static std::string name(){ return "fixed_array "+ fc::to_string(N) + ", " + + remove_namespace(fc::get_typename::name()); }; }; -template struct js_name> { static std::string name(){ return "bytes "+ fc::to_string(N); }; }; -template struct js_name> { static std::string name(){ return "bytes "+ fc::to_string(N); }; }; +template struct js_name> { static std::string name(){ return "bytes "+ fc::to_string(N); }; }; +template struct js_name>{ static std::string name(){ return "bytes "+ fc::to_string(N); }; }; template struct js_name< fc::optional > { static std::string name(){ return "optional " + js_name::name(); } }; template<> struct js_name< object_id_type > { static std::string name(){ return "object_id_type"; } }; template struct js_name< fc::flat_set > { static std::string name(){ return "set " + js_name::name(); } }; @@ -235,7 +236,7 @@ struct serializer }; template -struct serializer,false> +struct serializer,false> { static void init() { serializer::init(); } static void generate() {} From 784221986a72aadb0a929db2aedf98b953084343 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 20 May 2019 21:38:21 +0200 Subject: [PATCH 07/77] Separate exception declaration and implementation --- libraries/chain/CMakeLists.txt | 1 + libraries/chain/exceptions.cpp | 138 +++++++++++++++ .../include/graphene/chain/exceptions.hpp | 158 ++++++------------ .../graphene/chain/internal_exceptions.hpp | 10 +- libraries/chain/protocol/small_ops.cpp | 24 ++- libraries/net/CMakeLists.txt | 1 + libraries/net/exceptions.cpp | 41 +++++ .../net/include/graphene/net/exceptions.hpp | 14 +- 8 files changed, 268 insertions(+), 119 deletions(-) create mode 100644 libraries/chain/exceptions.cpp create mode 100644 libraries/net/exceptions.cpp diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 01a4a8eb..f0b0e9e1 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -68,6 +68,7 @@ add_library( graphene_chain genesis_state.cpp get_config.cpp + exceptions.cpp pts_address.cpp diff --git a/libraries/chain/exceptions.cpp b/libraries/chain/exceptions.cpp new file mode 100644 index 00000000..68606a91 --- /dev/null +++ b/libraries/chain/exceptions.cpp @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2019 BitShares Blockchain Foundation, and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +namespace graphene { namespace chain { + + // Internal exceptions + + FC_IMPLEMENT_DERIVED_EXCEPTION( internal_exception, graphene::chain::chain_exception, 3990000, "internal exception" ) + + GRAPHENE_IMPLEMENT_INTERNAL_EXCEPTION( verify_auth_max_auth_exceeded, 1, "Exceeds max authority fan-out" ) + GRAPHENE_IMPLEMENT_INTERNAL_EXCEPTION( verify_auth_account_not_found, 2, "Auth account not found" ) + + + // Public exceptions + + FC_IMPLEMENT_EXCEPTION( chain_exception, 3000000, "blockchain exception" ) + + FC_IMPLEMENT_DERIVED_EXCEPTION( database_query_exception, chain_exception, 3010000, "database query exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( block_validate_exception, chain_exception, 3020000, "block validation exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( operation_validate_exception, chain_exception, 3040000, "operation validation exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( operation_evaluate_exception, chain_exception, 3050000, "operation evaluation exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( utility_exception, chain_exception, 3060000, "utility method exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( undo_database_exception, chain_exception, 3070000, "undo database exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( unlinkable_block_exception, chain_exception, 3080000, "unlinkable block" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( black_swan_exception, chain_exception, 3090000, "black swan" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( plugin_exception, chain_exception, 3100000, "plugin exception" ) + + FC_IMPLEMENT_DERIVED_EXCEPTION( insufficient_feeds, chain_exception, 37006, "insufficient feeds" ) + + FC_IMPLEMENT_DERIVED_EXCEPTION( pop_empty_chain, undo_database_exception, 3070001, "there are no blocks to pop" ) + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( transfer ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( from_account_not_whitelisted, transfer, 1, "owner mismatch" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( to_account_not_whitelisted, transfer, 2, "owner mismatch" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( restricted_transfer_asset, transfer, 3, "restricted transfer asset" ) + + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( limit_order_create ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( limit_order_cancel ); + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( call_order_update ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( unfilled_margin_call, call_order_update, 1, "Updating call order would trigger a margin call that cannot be fully filled" ) + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_create ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( max_auth_exceeded, account_create, 1, "Exceeds max authority fan-out" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( auth_account_not_found, account_create, 2, "Auth account not found" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( buyback_incorrect_issuer, account_create, 3, "Incorrect issuer specified for account" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( buyback_already_exists, account_create, 4, "Cannot create buyback for asset which already has buyback" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( buyback_too_many_markets, account_create, 5, "Too many buyback markets" ) + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_update ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( max_auth_exceeded, account_update, 1, "Exceeds max authority fan-out" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( auth_account_not_found, account_update, 2, "Auth account not found" ) + + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_whitelist ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_upgrade ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( account_transfer ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_create ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update_bitasset ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update_feed_producers ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_issue ); + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_reserve ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( invalid_on_mia, asset_reserve, 1, "invalid on mia" ) + + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_fund_fee_pool ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_settle ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_global_settle ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_publish_feed ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( committee_member_create ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( witness_create ); + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( proposal_create ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( review_period_required, proposal_create, 1, "review_period required" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( review_period_insufficient, proposal_create, 2, "review_period insufficient" ) + + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( proposal_update ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( proposal_delete ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_create ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_update ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_claim ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( withdraw_permission_delete ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( fill_order ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( global_parameters_update ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( vesting_balance_create ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( vesting_balance_withdraw ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( worker_create ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( custom ); + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( assert ); + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( balance_claim ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( claimed_too_often, balance_claim, 1, "balance claimed too often" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( invalid_claim_amount, balance_claim, 2, "invalid claim amount" ) + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( owner_mismatch, balance_claim, 3, "owner mismatch" ) + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( override_transfer ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( not_permitted, override_transfer, 1, "not permitted" ) + + GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( blind_transfer ); + GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( unknown_commitment, blind_transfer, 1, "Attempting to claim an unknown prior commitment" ); + + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( transfer_from_blind_operation ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_claim_fees_operation ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( bid_collateral_operation ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_claim_pool_operation ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update_issuer_operation ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( htlc_create_operation ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( htlc_redeem_operation ) + //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( htlc_extend_operation ) + + #define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \ + catch( const cause_type& e ) \ + { throw( effect_type( e.what(), e.get_log() ) ); } + +} } // graphene::chain diff --git a/libraries/chain/include/graphene/chain/exceptions.hpp b/libraries/chain/include/graphene/chain/exceptions.hpp index ee264029..d89626ad 100644 --- a/libraries/chain/include/graphene/chain/exceptions.hpp +++ b/libraries/chain/include/graphene/chain/exceptions.hpp @@ -35,12 +35,24 @@ #define GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( op_name ) \ FC_DECLARE_DERIVED_EXCEPTION( \ + op_name ## _validate_exception, \ + graphene::chain::operation_validate_exception, \ + 3040000 + 100 * operation::tag< op_name ## _operation >::value \ + ) \ + FC_DECLARE_DERIVED_EXCEPTION( \ + op_name ## _evaluate_exception, \ + graphene::chain::operation_evaluate_exception, \ + 3050000 + 100 * operation::tag< op_name ## _operation >::value \ + ) + +#define GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( op_name ) \ + FC_IMPLEMENT_DERIVED_EXCEPTION( \ op_name ## _validate_exception, \ graphene::chain::operation_validate_exception, \ 3040000 + 100 * operation::tag< op_name ## _operation >::value, \ #op_name "_operation validation exception" \ ) \ - FC_DECLARE_DERIVED_EXCEPTION( \ + FC_IMPLEMENT_DERIVED_EXCEPTION( \ op_name ## _evaluate_exception, \ graphene::chain::operation_evaluate_exception, \ 3050000 + 100 * operation::tag< op_name ## _operation >::value, \ @@ -49,6 +61,14 @@ #define GRAPHENE_DECLARE_OP_VALIDATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \ FC_DECLARE_DERIVED_EXCEPTION( \ + op_name ## _ ## exc_name, \ + graphene::chain::op_name ## _validate_exception, \ + 3040000 + 100 * operation::tag< op_name ## _operation >::value \ + + seqnum \ + ) + +#define GRAPHENE_IMPLEMENT_OP_VALIDATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \ + FC_IMPLEMENT_DERIVED_EXCEPTION( \ op_name ## _ ## exc_name, \ graphene::chain::op_name ## _validate_exception, \ 3040000 + 100 * operation::tag< op_name ## _operation >::value \ @@ -58,6 +78,14 @@ #define GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \ FC_DECLARE_DERIVED_EXCEPTION( \ + op_name ## _ ## exc_name, \ + graphene::chain::op_name ## _evaluate_exception, \ + 3050000 + 100 * operation::tag< op_name ## _operation >::value \ + + seqnum \ + ) + +#define GRAPHENE_IMPLEMENT_OP_EVALUATE_EXCEPTION( exc_name, op_name, seqnum, msg ) \ + FC_IMPLEMENT_DERIVED_EXCEPTION( \ op_name ## _ ## exc_name, \ graphene::chain::op_name ## _evaluate_exception, \ 3050000 + 100 * operation::tag< op_name ## _operation >::value \ @@ -82,30 +110,21 @@ namespace graphene { namespace chain { - FC_DECLARE_EXCEPTION( chain_exception, 3000000, "blockchain exception" ) - FC_DECLARE_DERIVED_EXCEPTION( database_query_exception, graphene::chain::chain_exception, 3010000, "database query exception" ) - FC_DECLARE_DERIVED_EXCEPTION( block_validate_exception, graphene::chain::chain_exception, 3020000, "block validation exception" ) - FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, graphene::chain::chain_exception, 3030000, "transaction validation exception" ) - FC_DECLARE_DERIVED_EXCEPTION( operation_validate_exception, graphene::chain::chain_exception, 3040000, "operation validation exception" ) - FC_DECLARE_DERIVED_EXCEPTION( operation_evaluate_exception, graphene::chain::chain_exception, 3050000, "operation evaluation exception" ) - FC_DECLARE_DERIVED_EXCEPTION( utility_exception, graphene::chain::chain_exception, 3060000, "utility method exception" ) - FC_DECLARE_DERIVED_EXCEPTION( undo_database_exception, graphene::chain::chain_exception, 3070000, "undo database exception" ) - FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, graphene::chain::chain_exception, 3080000, "unlinkable block" ) - FC_DECLARE_DERIVED_EXCEPTION( black_swan_exception, graphene::chain::chain_exception, 3090000, "black swan" ) - FC_DECLARE_DERIVED_EXCEPTION( plugin_exception, graphene::chain::chain_exception, 3100000, "plugin exception" ) + FC_DECLARE_EXCEPTION( chain_exception, 3000000 ) - FC_DECLARE_DERIVED_EXCEPTION( tx_missing_active_auth, graphene::chain::transaction_exception, 3030001, "missing required active authority" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_missing_owner_auth, graphene::chain::transaction_exception, 3030002, "missing required owner authority" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_missing_other_auth, graphene::chain::transaction_exception, 3030003, "missing required other authority" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_sig, graphene::chain::transaction_exception, 3030004, "irrelevant signature included" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate_sig, graphene::chain::transaction_exception, 3030005, "duplicate signature included" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_approval, graphene::chain::transaction_exception, 3030006, "committee account cannot directly approve transaction" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::chain::transaction_exception, 3030007, "insufficient fee" ) + FC_DECLARE_DERIVED_EXCEPTION( database_query_exception, chain_exception, 3010000 ) + FC_DECLARE_DERIVED_EXCEPTION( block_validate_exception, chain_exception, 3020000 ) + FC_DECLARE_DERIVED_EXCEPTION( operation_validate_exception, chain_exception, 3040000 ) + FC_DECLARE_DERIVED_EXCEPTION( operation_evaluate_exception, chain_exception, 3050000 ) + FC_DECLARE_DERIVED_EXCEPTION( utility_exception, chain_exception, 3060000 ) + FC_DECLARE_DERIVED_EXCEPTION( undo_database_exception, chain_exception, 3070000 ) + FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, chain_exception, 3080000 ) + FC_DECLARE_DERIVED_EXCEPTION( black_swan_exception, chain_exception, 3090000 ) + FC_DECLARE_DERIVED_EXCEPTION( plugin_exception, chain_exception, 3100000 ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_pts_address, graphene::chain::utility_exception, 3060001, "invalid pts address" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, graphene::chain::chain_exception, 37006, "insufficient feeds" ) + FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, chain_exception, 37006 ) - FC_DECLARE_DERIVED_EXCEPTION( pop_empty_chain, graphene::chain::undo_database_exception, 3070001, "there are no blocks to pop" ) + FC_DECLARE_DERIVED_EXCEPTION( pop_empty_chain, undo_database_exception, 3070001 ) GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( transfer ); GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( from_account_not_whitelisted, transfer, 1, "owner mismatch" ) @@ -176,93 +195,14 @@ namespace graphene { namespace chain { GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( blind_transfer ); GRAPHENE_DECLARE_OP_EVALUATE_EXCEPTION( unknown_commitment, blind_transfer, 1, "Attempting to claim an unknown prior commitment" ); - /* - FC_DECLARE_DERIVED_EXCEPTION( addition_overflow, graphene::chain::chain_exception, 30002, "addition overflow" ) - FC_DECLARE_DERIVED_EXCEPTION( subtraction_overflow, graphene::chain::chain_exception, 30003, "subtraction overflow" ) - FC_DECLARE_DERIVED_EXCEPTION( asset_type_mismatch, graphene::chain::chain_exception, 30004, "asset/price mismatch" ) - FC_DECLARE_DERIVED_EXCEPTION( unsupported_chain_operation, graphene::chain::chain_exception, 30005, "unsupported chain operation" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_transaction, graphene::chain::chain_exception, 30006, "unknown transaction" ) - FC_DECLARE_DERIVED_EXCEPTION( duplicate_transaction, graphene::chain::chain_exception, 30007, "duplicate transaction" ) - FC_DECLARE_DERIVED_EXCEPTION( zero_amount, graphene::chain::chain_exception, 30008, "zero amount" ) - FC_DECLARE_DERIVED_EXCEPTION( zero_price, graphene::chain::chain_exception, 30009, "zero price" ) - FC_DECLARE_DERIVED_EXCEPTION( asset_divide_by_self, graphene::chain::chain_exception, 30010, "asset divide by self" ) - FC_DECLARE_DERIVED_EXCEPTION( asset_divide_by_zero, graphene::chain::chain_exception, 30011, "asset divide by zero" ) - FC_DECLARE_DERIVED_EXCEPTION( new_database_version, graphene::chain::chain_exception, 30012, "new database version" ) - FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block, graphene::chain::chain_exception, 30013, "unlinkable block" ) - FC_DECLARE_DERIVED_EXCEPTION( price_out_of_range, graphene::chain::chain_exception, 30014, "price out of range" ) - - FC_DECLARE_DERIVED_EXCEPTION( block_numbers_not_sequential, graphene::chain::chain_exception, 30015, "block numbers not sequential" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_previous_block_id, graphene::chain::chain_exception, 30016, "invalid previous block" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_block_time, graphene::chain::chain_exception, 30017, "invalid block time" ) - FC_DECLARE_DERIVED_EXCEPTION( time_in_past, graphene::chain::chain_exception, 30018, "time is in the past" ) - FC_DECLARE_DERIVED_EXCEPTION( time_in_future, graphene::chain::chain_exception, 30019, "time is in the future" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_block_digest, graphene::chain::chain_exception, 30020, "invalid block digest" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_member_signee, graphene::chain::chain_exception, 30021, "invalid committee_member signee" ) - FC_DECLARE_DERIVED_EXCEPTION( failed_checkpoint_verification, graphene::chain::chain_exception, 30022, "failed checkpoint verification" ) - FC_DECLARE_DERIVED_EXCEPTION( wrong_chain_id, graphene::chain::chain_exception, 30023, "wrong chain id" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_block, graphene::chain::chain_exception, 30024, "unknown block" ) - FC_DECLARE_DERIVED_EXCEPTION( block_older_than_undo_history, graphene::chain::chain_exception, 30025, "block is older than our undo history allows us to process" ) - - FC_DECLARE_EXCEPTION( evaluation_error, 31000, "Evaluation Error" ) - FC_DECLARE_DERIVED_EXCEPTION( negative_deposit, graphene::chain::evaluation_error, 31001, "negative deposit" ) - FC_DECLARE_DERIVED_EXCEPTION( not_a_committee_member, graphene::chain::evaluation_error, 31002, "not a committee_member" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_balance_record, graphene::chain::evaluation_error, 31003, "unknown balance record" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_funds, graphene::chain::evaluation_error, 31004, "insufficient funds" ) - FC_DECLARE_DERIVED_EXCEPTION( missing_signature, graphene::chain::evaluation_error, 31005, "missing signature" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_claim_password, graphene::chain::evaluation_error, 31006, "invalid claim password" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_withdraw_condition, graphene::chain::evaluation_error, 31007, "invalid withdraw condition" ) - FC_DECLARE_DERIVED_EXCEPTION( negative_withdraw, graphene::chain::evaluation_error, 31008, "negative withdraw" ) - FC_DECLARE_DERIVED_EXCEPTION( not_an_active_committee_member, graphene::chain::evaluation_error, 31009, "not an active committee_member" ) - FC_DECLARE_DERIVED_EXCEPTION( expired_transaction, graphene::chain::evaluation_error, 31010, "expired transaction" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_transaction_expiration, graphene::chain::evaluation_error, 31011, "invalid transaction expiration" ) - FC_DECLARE_DERIVED_EXCEPTION( oversized_transaction, graphene::chain::evaluation_error, 31012, "transaction exceeded the maximum transaction size" ) - - FC_DECLARE_DERIVED_EXCEPTION( invalid_account_name, graphene::chain::evaluation_error, 32001, "invalid account name" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_account_id, graphene::chain::evaluation_error, 32002, "unknown account id" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_account_name, graphene::chain::evaluation_error, 32003, "unknown account name" ) - FC_DECLARE_DERIVED_EXCEPTION( missing_parent_account_signature, graphene::chain::evaluation_error, 32004, "missing parent account signature" ) - FC_DECLARE_DERIVED_EXCEPTION( parent_account_retracted, graphene::chain::evaluation_error, 32005, "parent account retracted" ) - FC_DECLARE_DERIVED_EXCEPTION( account_expired, graphene::chain::evaluation_error, 32006, "account expired" ) - FC_DECLARE_DERIVED_EXCEPTION( account_already_registered, graphene::chain::evaluation_error, 32007, "account already registered" ) - FC_DECLARE_DERIVED_EXCEPTION( account_key_in_use, graphene::chain::evaluation_error, 32008, "account key already in use" ) - FC_DECLARE_DERIVED_EXCEPTION( account_retracted, graphene::chain::evaluation_error, 32009, "account retracted" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_parent_account_name, graphene::chain::evaluation_error, 32010, "unknown parent account name" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_committee_member_slate, graphene::chain::evaluation_error, 32011, "unknown committee_member slate" ) - FC_DECLARE_DERIVED_EXCEPTION( too_may_committee_members_in_slate, graphene::chain::evaluation_error, 32012, "too many committee_members in slate" ) - FC_DECLARE_DERIVED_EXCEPTION( pay_balance_remaining, graphene::chain::evaluation_error, 32013, "pay balance remaining" ) - - FC_DECLARE_DERIVED_EXCEPTION( not_a_committee_member_signature, graphene::chain::evaluation_error, 33002, "not committee_members signature" ) - - FC_DECLARE_DERIVED_EXCEPTION( invalid_precision, graphene::chain::evaluation_error, 35001, "invalid precision" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_symbol, graphene::chain::evaluation_error, 35002, "invalid asset symbol" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_asset_id, graphene::chain::evaluation_error, 35003, "unknown asset id" ) - FC_DECLARE_DERIVED_EXCEPTION( asset_symbol_in_use, graphene::chain::evaluation_error, 35004, "asset symbol in use" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_amount, graphene::chain::evaluation_error, 35005, "invalid asset amount" ) - FC_DECLARE_DERIVED_EXCEPTION( negative_issue, graphene::chain::evaluation_error, 35006, "negative issue" ) - FC_DECLARE_DERIVED_EXCEPTION( over_issue, graphene::chain::evaluation_error, 35007, "over issue" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_asset_symbol, graphene::chain::evaluation_error, 35008, "unknown asset symbol" ) - FC_DECLARE_DERIVED_EXCEPTION( asset_id_in_use, graphene::chain::evaluation_error, 35009, "asset id in use" ) - FC_DECLARE_DERIVED_EXCEPTION( not_user_issued, graphene::chain::evaluation_error, 35010, "not user issued" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_asset_name, graphene::chain::evaluation_error, 35011, "invalid asset name" ) - - FC_DECLARE_DERIVED_EXCEPTION( committee_member_vote_limit, graphene::chain::evaluation_error, 36001, "committee_member_vote_limit" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::chain::evaluation_error, 36002, "insufficient fee" ) - FC_DECLARE_DERIVED_EXCEPTION( negative_fee, graphene::chain::evaluation_error, 36003, "negative fee" ) - FC_DECLARE_DERIVED_EXCEPTION( missing_deposit, graphene::chain::evaluation_error, 36004, "missing deposit" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_relay_fee, graphene::chain::evaluation_error, 36005, "insufficient relay fee" ) - - FC_DECLARE_DERIVED_EXCEPTION( invalid_market, graphene::chain::evaluation_error, 37001, "invalid market" ) - FC_DECLARE_DERIVED_EXCEPTION( unknown_market_order, graphene::chain::evaluation_error, 37002, "unknown market order" ) - FC_DECLARE_DERIVED_EXCEPTION( shorting_base_shares, graphene::chain::evaluation_error, 37003, "shorting base shares" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_collateral, graphene::chain::evaluation_error, 37004, "insufficient collateral" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_depth, graphene::chain::evaluation_error, 37005, "insufficient depth" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_feeds, graphene::chain::evaluation_error, 37006, "insufficient feeds" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_feed_price, graphene::chain::evaluation_error, 37007, "invalid feed price" ) - - FC_DECLARE_DERIVED_EXCEPTION( price_multiplication_overflow, graphene::chain::evaluation_error, 38001, "price multiplication overflow" ) - FC_DECLARE_DERIVED_EXCEPTION( price_multiplication_underflow, graphene::chain::evaluation_error, 38002, "price multiplication underflow" ) - FC_DECLARE_DERIVED_EXCEPTION( price_multiplication_undefined, graphene::chain::evaluation_error, 38003, "price multiplication undefined product 0*inf" ) - */ + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( transfer_from_blind_operation ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_claim_fees_operation ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( bid_collateral_operation ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_claim_pool_operation ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_update_issuer_operation ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_create_operation ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_redeem_operation ) + //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_extend_operation ) #define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \ catch( const cause_type& e ) \ diff --git a/libraries/chain/include/graphene/chain/internal_exceptions.hpp b/libraries/chain/include/graphene/chain/internal_exceptions.hpp index 8a57ae23..4381c6de 100644 --- a/libraries/chain/include/graphene/chain/internal_exceptions.hpp +++ b/libraries/chain/include/graphene/chain/internal_exceptions.hpp @@ -23,11 +23,17 @@ */ #pragma once -#include #include #define GRAPHENE_DECLARE_INTERNAL_EXCEPTION( exc_name, seqnum, msg ) \ FC_DECLARE_DERIVED_EXCEPTION( \ + internal_ ## exc_name, \ + graphene::chain::internal_exception, \ + 3990000 + seqnum \ + ) + +#define GRAPHENE_IMPLEMENT_INTERNAL_EXCEPTION( exc_name, seqnum, msg ) \ + FC_IMPLEMENT_DERIVED_EXCEPTION( \ internal_ ## exc_name, \ graphene::chain::internal_exception, \ 3990000 + seqnum, \ @@ -36,7 +42,7 @@ namespace graphene { namespace chain { -FC_DECLARE_DERIVED_EXCEPTION( internal_exception, graphene::chain::chain_exception, 3990000, "internal exception" ) +FC_DECLARE_DERIVED_EXCEPTION( internal_exception, graphene::chain::chain_exception, 3990000 ) GRAPHENE_DECLARE_INTERNAL_EXCEPTION( verify_auth_max_auth_exceeded, 1, "Exceeds max authority fan-out" ) GRAPHENE_DECLARE_INTERNAL_EXCEPTION( verify_auth_account_not_found, 2, "Auth account not found" ) diff --git a/libraries/chain/protocol/small_ops.cpp b/libraries/chain/protocol/small_ops.cpp index 8ab7cf43..60464968 100644 --- a/libraries/chain/protocol/small_ops.cpp +++ b/libraries/chain/protocol/small_ops.cpp @@ -22,7 +22,6 @@ * THE SOFTWARE. */ -#include #include #include #include @@ -32,6 +31,29 @@ #include +namespace graphene { namespace protocol { + +FC_IMPLEMENT_EXCEPTION( protocol_exception, 4000000, "protocol exception" ) + +FC_IMPLEMENT_DERIVED_EXCEPTION( transaction_exception, protocol_exception, 4010000, + "transaction validation exception" ) + +FC_IMPLEMENT_DERIVED_EXCEPTION( tx_missing_active_auth, transaction_exception, 4010001, + "missing required active authority" ) +FC_IMPLEMENT_DERIVED_EXCEPTION( tx_missing_owner_auth, transaction_exception, 4010002, + "missing required owner authority" ) +FC_IMPLEMENT_DERIVED_EXCEPTION( tx_missing_other_auth, transaction_exception, 4010003, + "missing required other authority" ) +FC_IMPLEMENT_DERIVED_EXCEPTION( tx_irrelevant_sig, transaction_exception, 4010004, + "irrelevant signature included" ) +FC_IMPLEMENT_DERIVED_EXCEPTION( tx_duplicate_sig, transaction_exception, 4010005, + "duplicate signature included" ) +FC_IMPLEMENT_DERIVED_EXCEPTION( invalid_committee_approval, transaction_exception, 4010006, + "committee account cannot directly approve transaction" ) +FC_IMPLEMENT_DERIVED_EXCEPTION( insufficient_fee, transaction_exception, 4010007, "insufficient fee" ) + +} } // graphene::protocol + GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::balance_claim_operation ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::buyback_account_options ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::fba_distribute_operation ) diff --git a/libraries/net/CMakeLists.txt b/libraries/net/CMakeLists.txt index 955012e4..2594b053 100644 --- a/libraries/net/CMakeLists.txt +++ b/libraries/net/CMakeLists.txt @@ -3,6 +3,7 @@ file(GLOB HEADERS "include/graphene/net/*.hpp") set(SOURCES node.cpp stcp_socket.cpp core_messages.cpp + exceptions.cpp peer_database.cpp peer_connection.cpp message.cpp diff --git a/libraries/net/exceptions.cpp b/libraries/net/exceptions.cpp new file mode 100644 index 00000000..7b6e23dc --- /dev/null +++ b/libraries/net/exceptions.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019 BitShares Blockchain Foundation, and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include + +namespace graphene { namespace net { + + FC_IMPLEMENT_EXCEPTION( net_exception, 90000, "P2P Networking Exception" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( send_queue_overflow, net_exception, 90001, + "send queue for this peer exceeded maximum size" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( insufficient_relay_fee, net_exception, 90002, + "insufficient relay fee" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( already_connected_to_requested_peer, net_exception, 90003, + "already connected to requested peer" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( block_older_than_undo_history, net_exception, 90004, + "block is older than our undo history allows us to process" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( peer_is_on_an_unreachable_fork, net_exception, 90005, + "peer is on another fork" ) + FC_IMPLEMENT_DERIVED_EXCEPTION( unlinkable_block_exception, net_exception, 90006, "unlinkable block" ) + +} } diff --git a/libraries/net/include/graphene/net/exceptions.hpp b/libraries/net/include/graphene/net/exceptions.hpp index 59da8ccb..e95eea87 100644 --- a/libraries/net/include/graphene/net/exceptions.hpp +++ b/libraries/net/include/graphene/net/exceptions.hpp @@ -27,12 +27,12 @@ namespace graphene { namespace net { // registered in node.cpp - FC_DECLARE_EXCEPTION( net_exception, 90000, "P2P Networking Exception" ); - FC_DECLARE_DERIVED_EXCEPTION( send_queue_overflow, graphene::net::net_exception, 90001, "send queue for this peer exceeded maximum size" ); - FC_DECLARE_DERIVED_EXCEPTION( insufficient_relay_fee, graphene::net::net_exception, 90002, "insufficient relay fee" ); - FC_DECLARE_DERIVED_EXCEPTION( already_connected_to_requested_peer, graphene::net::net_exception, 90003, "already connected to requested peer" ); - FC_DECLARE_DERIVED_EXCEPTION( block_older_than_undo_history, graphene::net::net_exception, 90004, "block is older than our undo history allows us to process" ); - FC_DECLARE_DERIVED_EXCEPTION( peer_is_on_an_unreachable_fork, graphene::net::net_exception, 90005, "peer is on another fork" ); - FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, graphene::net::net_exception, 90006, "unlinkable block" ) + FC_DECLARE_EXCEPTION( net_exception, 90000 ) + FC_DECLARE_DERIVED_EXCEPTION( send_queue_overflow, net_exception, 90001 ) + FC_DECLARE_DERIVED_EXCEPTION( insufficient_relay_fee, net_exception, 90002 ) + FC_DECLARE_DERIVED_EXCEPTION( already_connected_to_requested_peer, net_exception, 90003 ) + FC_DECLARE_DERIVED_EXCEPTION( block_older_than_undo_history, net_exception, 90004 ) + FC_DECLARE_DERIVED_EXCEPTION( peer_is_on_an_unreachable_fork, net_exception, 90005 ) + FC_DECLARE_DERIVED_EXCEPTION( unlinkable_block_exception, net_exception, 90006 ) } } From 7eb3729cc0ddf6856c784c4fca9fc505fd3b4ffd Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sat, 27 Apr 2019 22:01:49 +0200 Subject: [PATCH 08/77] Adapted to fc promise changes --- libraries/app/api.cpp | 4 ++-- libraries/net/node.cpp | 8 ++++---- programs/cli_wallet/main.cpp | 2 +- programs/delayed_node/main.cpp | 2 +- programs/size_checker/main.cpp | 1 + programs/witness_node/main.cpp | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 8832ac9d..a80c4726 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -192,8 +192,8 @@ namespace graphene { namespace app { { _app.chain_database()->check_tansaction_for_duplicated_operations(trx); - fc::promise::ptr prom( new fc::promise() ); - broadcast_transaction_with_callback( [=]( const fc::variant& v ){ + fc::promise::ptr prom = fc::promise::create(); + broadcast_transaction_with_callback( [prom]( const fc::variant& v ){ prom->set_value(v); }, trx ); diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index 9923fa8f..c15b0e08 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -948,7 +948,7 @@ namespace graphene { namespace net { namespace detail { #if 0 try { - _retrigger_connect_loop_promise = fc::promise::ptr( new fc::promise("graphene::net::retrigger_connect_loop") ); + _retrigger_connect_loop_promise = fc::promise::create("graphene::net::retrigger_connect_loop"); if( is_wanting_new_connections() || !_add_once_node_list.empty() ) { if( is_wanting_new_connections() ) @@ -1078,7 +1078,7 @@ namespace graphene { namespace net { namespace detail { if( !_sync_items_to_fetch_updated ) { dlog( "no sync items to fetch right now, going to sleep" ); - _retrigger_fetch_sync_items_loop_promise = fc::promise::ptr( new fc::promise("graphene::net::retrigger_fetch_sync_items_loop") ); + _retrigger_fetch_sync_items_loop_promise = fc::promise::create("graphene::net::retrigger_fetch_sync_items_loop"); _retrigger_fetch_sync_items_loop_promise->wait(); _retrigger_fetch_sync_items_loop_promise.reset(); } @@ -1205,7 +1205,7 @@ namespace graphene { namespace net { namespace detail { if (!_items_to_fetch_updated) { - _retrigger_fetch_item_loop_promise = fc::promise::ptr(new fc::promise("graphene::net::retrigger_fetch_item_loop")); + _retrigger_fetch_item_loop_promise = fc::promise::create("graphene::net::retrigger_fetch_item_loop"); fc::microseconds time_until_retrigger = fc::microseconds::maximum(); if (next_peer_unblocked_time != fc::time_point::maximum()) time_until_retrigger = next_peer_unblocked_time - fc::time_point::now(); @@ -1297,7 +1297,7 @@ namespace graphene { namespace net { namespace detail { if (_new_inventory.empty()) { - _retrigger_advertise_inventory_loop_promise = fc::promise::ptr(new fc::promise("graphene::net::retrigger_advertise_inventory_loop")); + _retrigger_advertise_inventory_loop_promise = fc::promise::create("graphene::net::retrigger_advertise_inventory_loop"); _retrigger_advertise_inventory_loop_promise->wait(); _retrigger_advertise_inventory_loop_promise.reset(); } diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 3fd1051b..98c68835 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -266,7 +266,7 @@ int main( int argc, char** argv ) } else { - fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); + fc::promise::ptr exit_promise = fc::promise::create("UNIX Signal Handler"); fc::set_signal_handler([&exit_promise](int signal) { exit_promise->set_value(signal); }, SIGINT); diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index 112b7dee..23f9b08b 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -166,7 +166,7 @@ int main(int argc, char** argv) { node.startup(); node.startup_plugins(); - fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); + fc::promise::ptr exit_promise = fc::promise::create("UNIX Signal Handler"); fc::set_signal_handler([&exit_promise](int signal) { exit_promise->set_value(signal); }, SIGINT); diff --git a/programs/size_checker/main.cpp b/programs/size_checker/main.cpp index 188e88e4..3015e1cd 100644 --- a/programs/size_checker/main.cpp +++ b/programs/size_checker/main.cpp @@ -23,6 +23,7 @@ */ #include +#include #include #include diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 4d49d96f..f62119d2 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -136,7 +136,7 @@ int main(int argc, char** argv) { node->startup(); node->startup_plugins(); - fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); + fc::promise::ptr exit_promise = fc::promise::create("UNIX Signal Handler"); fc::set_signal_handler([&exit_promise](int signal) { elog( "Caught SIGINT attempting to exit cleanly" ); From cc77a088915d0a22160347ea21b285ee3093f31b Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 18 Aug 2020 19:07:16 -0500 Subject: [PATCH 09/77] Fixes Add back in some of Peter's fixes that got lost in the cherry pick --- libraries/chain/protocol/types.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/chain/protocol/types.cpp b/libraries/chain/protocol/types.cpp index b7cac207..74ab01f3 100644 --- a/libraries/chain/protocol/types.cpp +++ b/libraries/chain/protocol/types.cpp @@ -70,7 +70,7 @@ namespace graphene { namespace chain { auto bin = fc::from_base58( base58str.substr( prefix_len ) ); auto bin_key = fc::raw::unpack(bin); key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check ); + FC_ASSERT( fc::ripemd160::hash( (char*)key_data.data(), key_data.size() )._hash[0] == bin_key.check ); }; bool public_key_type::is_valid_muse( const std::string& base58str ) @@ -83,7 +83,7 @@ namespace graphene { namespace chain { auto bin = fc::from_base58( base58str.substr( prefix_len ) ); auto bin_key = fc::raw::unpack(bin); key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check ); + FC_ASSERT( fc::ripemd160::hash( (char*)key_data.data(), key_data.size() )._hash[0] == bin_key.check ); return true; } @@ -97,7 +97,7 @@ namespace graphene { namespace chain { auto bin = fc::from_base58( base58str.substr( prefix_len ) ); auto bin_key = fc::raw::unpack(bin); fc::ecc::public_key_data key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check ); + FC_ASSERT( fc::ripemd160::hash( (char*)key_data.data(), key_data.size() )._hash[0] == bin_key.check ); return true; } @@ -115,7 +115,7 @@ namespace graphene { namespace chain { { binary_key k; k.data = key_data; - k.check = fc::ripemd160::hash( k.data.data, k.data.size() )._hash[0]; + k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0]; auto data = fc::raw::pack( k ); return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); } @@ -156,7 +156,7 @@ namespace graphene { namespace chain { FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); auto bin = fc::from_base58( base58str.substr( prefix_len ) ); auto bin_key = fc::raw::unpack(bin); - FC_ASSERT( fc::ripemd160::hash( bin_key.data.data, bin_key.data.size() )._hash[0] == bin_key.check ); + FC_ASSERT( fc::ripemd160::hash( (char*)bin_key.data.data(), bin_key.data.size() )._hash[0] == bin_key.check ); key_data = bin_key.data; } @@ -169,7 +169,7 @@ namespace graphene { namespace chain { { binary_key k; k.data = key_data; - k.check = fc::ripemd160::hash( k.data.data, k.data.size() )._hash[0]; + k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0]; auto data = fc::raw::pack( k ); return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); } @@ -210,7 +210,7 @@ namespace graphene { namespace chain { FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); auto bin = fc::from_base58( base58str.substr( prefix_len ) ); auto bin_key = fc::raw::unpack(bin); - FC_ASSERT( fc::ripemd160::hash( bin_key.data.data, bin_key.data.size() )._hash[0] == bin_key.check ); + FC_ASSERT( fc::ripemd160::hash( (char*)bin_key.data.data(), bin_key.data.size() )._hash[0] == bin_key.check ); key_data = bin_key.data; } @@ -223,7 +223,7 @@ namespace graphene { namespace chain { { binary_key k; k.data = key_data; - k.check = fc::ripemd160::hash( k.data.data, k.data.size() )._hash[0]; + k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0]; auto data = fc::raw::pack( k ); return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); } From 68c57a741430b26687cdbe9c93a585b978ffcdc7 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Mon, 18 Mar 2019 15:10:03 +0100 Subject: [PATCH 10/77] _hash endianness fixes --- libraries/chain/db_block.cpp | 2 +- libraries/chain/protocol/block.cpp | 4 ++-- libraries/chain/protocol/memo.cpp | 11 ++++++----- libraries/chain/protocol/transaction.cpp | 4 ++-- libraries/chain/protocol/types.cpp | 16 ++++++++-------- libraries/wallet/wallet.cpp | 8 ++++---- tests/generate_empty_blocks/main.cpp | 4 ++-- 7 files changed, 25 insertions(+), 24 deletions(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index e667413d..11134759 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -804,7 +804,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx const auto& tapos_block_summary = block_summary_id_type( trx.ref_block_num )(*this); //Verify TaPoS block summary has correct ID prefix, and that this block's time is not past the expiration - FC_ASSERT( trx.ref_block_prefix == tapos_block_summary.block_id._hash[1] ); + FC_ASSERT( trx.ref_block_prefix == tapos_block_summary.block_id._hash[1].value() ); } fc::time_point_sec now = head_block_time(); diff --git a/libraries/chain/protocol/block.cpp b/libraries/chain/protocol/block.cpp index 725ea3a7..11680bb5 100644 --- a/libraries/chain/protocol/block.cpp +++ b/libraries/chain/protocol/block.cpp @@ -35,13 +35,13 @@ namespace graphene { namespace chain { uint32_t block_header::num_from_id(const block_id_type& id) { - return fc::endian_reverse_u32(id._hash[0]); + return boost::endian::endian_reverse(id._hash[0].value()); } 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 + tmp._hash[0] = boost::endian::endian_reverse(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))); diff --git a/libraries/chain/protocol/memo.cpp b/libraries/chain/protocol/memo.cpp index afa0b486..387c095f 100644 --- a/libraries/chain/protocol/memo.cpp +++ b/libraries/chain/protocol/memo.cpp @@ -22,6 +22,7 @@ * THE SOFTWARE. */ #include +#include #include #include @@ -36,7 +37,7 @@ void memo_data::set_message(const fc::ecc::private_key& priv, const fc::ecc::pub to = pub; if( custom_nonce == 0 ) { - uint64_t entropy = fc::sha224::hash(fc::ecc::private_key::generate())._hash[0]; + uint64_t entropy = fc::sha224::hash(fc::ecc::private_key::generate())._hash[0].value(); entropy <<= 32; entropy &= 0xff00000000000000; nonce = (fc::time_point::now().time_since_epoch().count() & 0x00ffffffffffffff) | entropy; @@ -44,7 +45,7 @@ void memo_data::set_message(const fc::ecc::private_key& priv, const fc::ecc::pub nonce = custom_nonce; auto secret = priv.get_shared_secret(pub); auto nonce_plus_secret = fc::sha512::hash(fc::to_string(nonce) + secret.str()); - string text = memo_message(digest_type::hash(msg)._hash[0], msg).serialize(); + string text = memo_message(digest_type::hash(msg)._hash[0].value(), msg).serialize(); message = fc::aes_encrypt( nonce_plus_secret, vector(text.begin(), text.end()) ); } else @@ -63,7 +64,7 @@ string memo_data::get_message(const fc::ecc::private_key& priv, auto nonce_plus_secret = fc::sha512::hash(fc::to_string(nonce) + secret.str()); auto plain_text = fc::aes_decrypt( nonce_plus_secret, message ); auto result = memo_message::deserialize(string(plain_text.begin(), plain_text.end())); - FC_ASSERT( result.checksum == uint32_t(digest_type::hash(result.text)._hash[0]) ); + FC_ASSERT( result.checksum == (uint32_t)digest_type::hash(result.text)._hash[0].value() ); return result.text; } else @@ -75,7 +76,7 @@ string memo_data::get_message(const fc::ecc::private_key& priv, string memo_message::serialize() const { auto serial_checksum = string(sizeof(checksum), ' '); - (uint32_t&)(*serial_checksum.data()) = checksum; + (uint32_t&)(*serial_checksum.data()) = boost::endian::native_to_little(checksum); return serial_checksum + text; } @@ -83,7 +84,7 @@ memo_message memo_message::deserialize(const string& serial) { memo_message result; FC_ASSERT( serial.size() >= sizeof(result.checksum) ); - result.checksum = ((uint32_t&)(*serial.data())); + result.checksum = boost::endian::little_to_native((uint32_t&)(*serial.data())); result.text = serial.substr(sizeof(result.checksum)); return result; } diff --git a/libraries/chain/protocol/transaction.cpp b/libraries/chain/protocol/transaction.cpp index 6d6e526c..94c6ded9 100644 --- a/libraries/chain/protocol/transaction.cpp +++ b/libraries/chain/protocol/transaction.cpp @@ -90,8 +90,8 @@ void transaction::set_expiration( fc::time_point_sec expiration_time ) void transaction::set_reference_block( const block_id_type& reference_block ) { - ref_block_num = fc::endian_reverse_u32(reference_block._hash[0]); - ref_block_prefix = reference_block._hash[1]; + ref_block_num = boost::endian::endian_reverse(reference_block._hash[0].value()); + ref_block_prefix = reference_block._hash[1].value(); } void transaction::get_required_authorities( flat_set& active, flat_set& owner, vector& other )const diff --git a/libraries/chain/protocol/types.cpp b/libraries/chain/protocol/types.cpp index 74ab01f3..d5c04992 100644 --- a/libraries/chain/protocol/types.cpp +++ b/libraries/chain/protocol/types.cpp @@ -70,7 +70,7 @@ namespace graphene { namespace chain { auto bin = fc::from_base58( base58str.substr( prefix_len ) ); auto bin_key = fc::raw::unpack(bin); key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( (char*)key_data.data(), key_data.size() )._hash[0] == bin_key.check ); + FC_ASSERT( fc::ripemd160::hash( (char*)key_data.data(), key_data.size() )._hash[0].value() == bin_key.check ); }; bool public_key_type::is_valid_muse( const std::string& base58str ) @@ -83,7 +83,7 @@ namespace graphene { namespace chain { auto bin = fc::from_base58( base58str.substr( prefix_len ) ); auto bin_key = fc::raw::unpack(bin); key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( (char*)key_data.data(), key_data.size() )._hash[0] == bin_key.check ); + FC_ASSERT( fc::ripemd160::hash( (char*)key_data.data(), key_data.size() )._hash[0].value() == bin_key.check ); return true; } @@ -97,7 +97,7 @@ namespace graphene { namespace chain { auto bin = fc::from_base58( base58str.substr( prefix_len ) ); auto bin_key = fc::raw::unpack(bin); fc::ecc::public_key_data key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( (char*)key_data.data(), key_data.size() )._hash[0] == bin_key.check ); + FC_ASSERT( fc::ripemd160::hash( (char*)key_data.data(), key_data.size() )._hash[0].value() == bin_key.check ); return true; } @@ -115,7 +115,7 @@ namespace graphene { namespace chain { { binary_key k; k.data = key_data; - k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0]; + k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0].value(); auto data = fc::raw::pack( k ); return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); } @@ -156,7 +156,7 @@ namespace graphene { namespace chain { FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); auto bin = fc::from_base58( base58str.substr( prefix_len ) ); auto bin_key = fc::raw::unpack(bin); - FC_ASSERT( fc::ripemd160::hash( (char*)bin_key.data.data(), bin_key.data.size() )._hash[0] == bin_key.check ); + FC_ASSERT( fc::ripemd160::hash( (char*)bin_key.data.data(), bin_key.data.size() )._hash[0].value() == bin_key.check ); key_data = bin_key.data; } @@ -169,7 +169,7 @@ namespace graphene { namespace chain { { binary_key k; k.data = key_data; - k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0]; + k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0].value(); auto data = fc::raw::pack( k ); return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); } @@ -210,7 +210,7 @@ namespace graphene { namespace chain { FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); auto bin = fc::from_base58( base58str.substr( prefix_len ) ); auto bin_key = fc::raw::unpack(bin); - FC_ASSERT( fc::ripemd160::hash( (char*)bin_key.data.data(), bin_key.data.size() )._hash[0] == bin_key.check ); + FC_ASSERT( fc::ripemd160::hash( (char*)bin_key.data.data(), bin_key.data.size() )._hash[0].value() == bin_key.check ); key_data = bin_key.data; } @@ -223,7 +223,7 @@ namespace graphene { namespace chain { { binary_key k; k.data = key_data; - k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0]; + k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0].value(); auto data = fc::raw::pack( k ); return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); } diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 47230d3c..f3bdec4a 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -170,7 +170,7 @@ optional maybe_id( const string& name_or_id ) string address_to_shorthash( const address& addr ) { - uint32_t x = addr.addr._hash[0]; + uint32_t x = addr.addr._hash[0].value(); static const char hd[] = "0123456789abcdef"; string result; @@ -5391,7 +5391,7 @@ blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label, conf_output.decrypted_memo.amount = change; conf_output.decrypted_memo.blinding_factor = change_blind_factor; conf_output.decrypted_memo.commitment = change_out.commitment; - conf_output.decrypted_memo.check = from_secret._hash[0]; + conf_output.decrypted_memo.check = from_secret._hash[0].value(); conf_output.confirmation.one_time_key = one_time_key.get_public_key(); conf_output.confirmation.to = from_key; conf_output.confirmation.encrypted_memo = fc::aes_encrypt( from_secret, fc::raw::pack( conf_output.decrypted_memo ) ); @@ -5409,7 +5409,7 @@ blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label, conf_output.decrypted_memo.amount = amount; conf_output.decrypted_memo.blinding_factor = blind_factor; conf_output.decrypted_memo.commitment = to_out.commitment; - conf_output.decrypted_memo.check = secret._hash[0]; + conf_output.decrypted_memo.check = secret._hash[0].value(); conf_output.confirmation.one_time_key = one_time_key.get_public_key(); conf_output.confirmation.to = to_key; conf_output.confirmation.encrypted_memo = fc::aes_encrypt( secret, fc::raw::pack( conf_output.decrypted_memo ) ); @@ -5497,7 +5497,7 @@ blind_confirmation wallet_api::transfer_to_blind( string from_account_id_or_name conf_output.decrypted_memo.amount = amount; conf_output.decrypted_memo.blinding_factor = blind_factor; conf_output.decrypted_memo.commitment = out.commitment; - conf_output.decrypted_memo.check = secret._hash[0]; + conf_output.decrypted_memo.check = secret._hash[0].value(); conf_output.confirmation.one_time_key = one_time_key.get_public_key(); conf_output.confirmation.to = to_key; conf_output.confirmation.encrypted_memo = fc::aes_encrypt( secret, fc::raw::pack( conf_output.decrypted_memo ) ); diff --git a/tests/generate_empty_blocks/main.cpp b/tests/generate_empty_blocks/main.cpp index 298b03cd..6e40e2cb 100644 --- a/tests/generate_empty_blocks/main.cpp +++ b/tests/generate_empty_blocks/main.cpp @@ -132,14 +132,14 @@ int main( int argc, char** argv ) signed_block b = db.generate_block(db.get_slot_time(slot), db.get_scheduled_witness(slot), nathan_priv_key, database::skip_nothing); FC_ASSERT( db.head_block_id() == b.id() ); fc::sha256 h = b.digest(); - uint64_t rand = h._hash[0]; + uint64_t rand = h._hash[0].value(); slot = 1; while(true) { if( (rand % 100) < miss_rate ) { slot++; - rand = (rand/100) ^ h._hash[slot&3]; + rand = (rand/100) ^ h._hash[slot&3].value(); missed++; } else From 54ce371a4a034419a747b43adcbda42a091a9a30 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 18 Aug 2020 19:26:53 -0500 Subject: [PATCH 11/77] Remove all uses of fc/smart_ref It's gone, can't use it anymore --- libraries/chain/betting_market_evaluator.cpp | 1 - .../chain/include/graphene/chain/protocol/fee_schedule.hpp | 1 - libraries/chain/protocol/committee_member.cpp | 1 - libraries/chain/protocol/operations.cpp | 1 - libraries/chain/small_objects.cpp | 1 - libraries/plugins/accounts_list/accounts_list_plugin.cpp | 1 - libraries/plugins/affiliate_stats/affiliate_stats_api.cpp | 1 - libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp | 1 - libraries/plugins/bookie/bookie_api.cpp | 1 - libraries/plugins/bookie/bookie_plugin.cpp | 1 - libraries/plugins/generate_genesis/generate_genesis.cpp | 1 - .../generate_uia_sharedrop_genesis.cpp | 1 - tests/cli/main.cpp | 2 -- tests/tests/history_api_tests.cpp | 1 - 14 files changed, 15 deletions(-) diff --git a/libraries/chain/betting_market_evaluator.cpp b/libraries/chain/betting_market_evaluator.cpp index b40f276a..1670ef78 100644 --- a/libraries/chain/betting_market_evaluator.cpp +++ b/libraries/chain/betting_market_evaluator.cpp @@ -22,7 +22,6 @@ * THE SOFTWARE. */ #define DEFAULT_LOGGER "betting" -#include #include #include diff --git a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp index b650ab4c..0dd8ca6f 100644 --- a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp +++ b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp @@ -22,7 +22,6 @@ * THE SOFTWARE. */ #pragma once -#include #include namespace graphene { namespace chain { diff --git a/libraries/chain/protocol/committee_member.cpp b/libraries/chain/protocol/committee_member.cpp index 1824870a..3ce62783 100644 --- a/libraries/chain/protocol/committee_member.cpp +++ b/libraries/chain/protocol/committee_member.cpp @@ -21,7 +21,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include #include #include diff --git a/libraries/chain/protocol/operations.cpp b/libraries/chain/protocol/operations.cpp index 7ec951f2..e513028c 100644 --- a/libraries/chain/protocol/operations.cpp +++ b/libraries/chain/protocol/operations.cpp @@ -21,7 +21,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include #include #include #include diff --git a/libraries/chain/small_objects.cpp b/libraries/chain/small_objects.cpp index a74fa116..6b8af3d9 100644 --- a/libraries/chain/small_objects.cpp +++ b/libraries/chain/small_objects.cpp @@ -44,7 +44,6 @@ #include #include -#include GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::balance_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::block_summary_object ) diff --git a/libraries/plugins/accounts_list/accounts_list_plugin.cpp b/libraries/plugins/accounts_list/accounts_list_plugin.cpp index 757891ea..5a57cc63 100644 --- a/libraries/plugins/accounts_list/accounts_list_plugin.cpp +++ b/libraries/plugins/accounts_list/accounts_list_plugin.cpp @@ -34,7 +34,6 @@ #include #include -#include #include namespace graphene { namespace accounts_list { diff --git a/libraries/plugins/affiliate_stats/affiliate_stats_api.cpp b/libraries/plugins/affiliate_stats/affiliate_stats_api.cpp index d37a0360..159f6699 100644 --- a/libraries/plugins/affiliate_stats/affiliate_stats_api.cpp +++ b/libraries/plugins/affiliate_stats/affiliate_stats_api.cpp @@ -24,7 +24,6 @@ #include #include -#include #include diff --git a/libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp b/libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp index da9c8a04..03b54659 100644 --- a/libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp +++ b/libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp @@ -35,7 +35,6 @@ #include #include -#include #include namespace graphene { namespace affiliate_stats { diff --git a/libraries/plugins/bookie/bookie_api.cpp b/libraries/plugins/bookie/bookie_api.cpp index 838c038c..9caa9c62 100644 --- a/libraries/plugins/bookie/bookie_api.cpp +++ b/libraries/plugins/bookie/bookie_api.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include diff --git a/libraries/plugins/bookie/bookie_plugin.cpp b/libraries/plugins/bookie/bookie_plugin.cpp index 261de241..5bc31f14 100644 --- a/libraries/plugins/bookie/bookie_plugin.cpp +++ b/libraries/plugins/bookie/bookie_plugin.cpp @@ -36,7 +36,6 @@ #include -#include #include #include diff --git a/libraries/plugins/generate_genesis/generate_genesis.cpp b/libraries/plugins/generate_genesis/generate_genesis.cpp index 337b4255..88da427e 100644 --- a/libraries/plugins/generate_genesis/generate_genesis.cpp +++ b/libraries/plugins/generate_genesis/generate_genesis.cpp @@ -29,7 +29,6 @@ #include -#include #include #include diff --git a/libraries/plugins/generate_uia_sharedrop_genesis/generate_uia_sharedrop_genesis.cpp b/libraries/plugins/generate_uia_sharedrop_genesis/generate_uia_sharedrop_genesis.cpp index d6db850a..05f7c9b3 100644 --- a/libraries/plugins/generate_uia_sharedrop_genesis/generate_uia_sharedrop_genesis.cpp +++ b/libraries/plugins/generate_uia_sharedrop_genesis/generate_uia_sharedrop_genesis.cpp @@ -29,7 +29,6 @@ #include -#include #include #include diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 9e7a4119..9c9fcd1a 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -44,8 +44,6 @@ #include #include -#include - #ifdef _WIN32 #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0501 diff --git a/tests/tests/history_api_tests.cpp b/tests/tests/history_api_tests.cpp index 943b8265..819138c2 100644 --- a/tests/tests/history_api_tests.cpp +++ b/tests/tests/history_api_tests.cpp @@ -30,7 +30,6 @@ #include "../common/database_fixture.hpp" -#include #include using namespace graphene::app; From 13a76d25ac81358294dbbf5f96bd20bd4e5f2404 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 28 Aug 2019 15:46:33 -0500 Subject: [PATCH 12/77] Replace improper static_variant operator overloads with comparators --- libraries/chain/include/graphene/chain/protocol/base.hpp | 2 +- .../chain/include/graphene/chain/protocol/fee_schedule.hpp | 2 +- tests/common/database_fixture.cpp | 2 +- tests/common/database_fixture.hpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/chain/include/graphene/chain/protocol/base.hpp b/libraries/chain/include/graphene/chain/protocol/base.hpp index 23c285d3..676d28ff 100644 --- a/libraries/chain/include/graphene/chain/protocol/base.hpp +++ b/libraries/chain/include/graphene/chain/protocol/base.hpp @@ -118,7 +118,7 @@ namespace graphene { namespace chain { * @note static_variant compares only the type tag and not the * content. */ - typedef flat_set extensions_type; + typedef future_extensions::flat_set_type extensions_type; ///@} diff --git a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp index 0dd8ca6f..1587d1ba 100644 --- a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp +++ b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp @@ -75,7 +75,7 @@ namespace graphene { namespace chain { /** * @note must be sorted by fee_parameters.which() and have no duplicates */ - flat_set parameters; + fee_parameters::flat_set_type parameters; uint32_t scale = GRAPHENE_100_PERCENT; ///< fee * scale / GRAPHENE_100_PERCENT }; diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index be095092..2ffddd90 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -669,7 +669,7 @@ void database_fixture::issue_uia( account_id_type recipient_id, asset amount ) } void database_fixture::change_fees( - const flat_set< fee_parameters >& new_params, + const fee_parameters::flat_set_type& new_params, uint32_t new_scale /* = 0 */ ) { diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index 25a87855..487b66dc 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -281,7 +281,7 @@ struct database_fixture { void transfer( const account_object& from, const account_object& to, const asset& amount, const asset& fee = asset() ); void fund_fee_pool( const account_object& from, const asset_object& asset_to_fund, const share_type amount ); void enable_fees(); - void change_fees( const flat_set< fee_parameters >& new_params, uint32_t new_scale = 0 ); + void change_fees( const fee_parameters::flat_set_type& new_params, uint32_t new_scale = 0 ); void upgrade_to_lifetime_member( account_id_type account ); void upgrade_to_lifetime_member( const account_object& account ); void upgrade_to_annual_member( account_id_type account ); From 9ac63ce0b364e2e29667a009565e7b46b005c8d2 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 18 Aug 2020 19:37:41 -0500 Subject: [PATCH 13/77] Fixes Remove boost::signals from build system; it's header-only so it's not listed in cmake anymore. Also remove some unused hashing code --- CMakeLists.txt | 6 +++--- .../include/graphene/chain/protocol/address.hpp | 13 ------------- libraries/db/include/graphene/db/flat_index.hpp | 8 -------- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd539a9c..671cfed3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ set( CLI_CLIENT_EXECUTABLE_NAME graphene_client ) set( GUI_CLIENT_EXECUTABLE_NAME BitShares ) set( CUSTOM_URL_SCHEME "gcs" ) set( INSTALLER_APP_ID "68ad7005-8eee-49c9-95ce-9eed97e5b347" ) +set( CMAKE_CXX_VERSION 14 ) # http://stackoverflow.com/a/18369825 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") @@ -46,7 +47,6 @@ LIST(APPEND BOOST_COMPONENTS thread system filesystem program_options - signals serialization chrono unit_test_framework @@ -113,11 +113,11 @@ else( WIN32 ) # Apple AND Linux if( APPLE ) # Apple Specific Options Here message( STATUS "Configuring BitShares on OS X" ) - set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -stdlib=libc++ -Wall" ) + set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -stdlib=libc++ -Wall" ) 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} -Wall" ) set( rt_library rt ) #set( pthread_library pthread) set(CMAKE_LINKER_FLAGS "-pthread" CACHE STRING "Linker Flags" FORCE) diff --git a/libraries/chain/include/graphene/chain/protocol/address.hpp b/libraries/chain/include/graphene/chain/protocol/address.hpp index 564bab53..39e3bf36 100644 --- a/libraries/chain/include/graphene/chain/protocol/address.hpp +++ b/libraries/chain/include/graphene/chain/protocol/address.hpp @@ -78,19 +78,6 @@ namespace fc void from_variant( const fc::variant& var, graphene::chain::address& vo, uint32_t max_depth = 1 ); } -namespace std -{ - template<> - struct hash - { - public: - size_t operator()(const graphene::chain::address &a) const - { - return (uint64_t(a.addr._hash[0])<<32) | uint64_t( a.addr._hash[0] ); - } - }; -} - #include FC_REFLECT( graphene::chain::address, (addr) ) diff --git a/libraries/db/include/graphene/db/flat_index.hpp b/libraries/db/include/graphene/db/flat_index.hpp index f1b7912e..0d17cbfa 100644 --- a/libraries/db/include/graphene/db/flat_index.hpp +++ b/libraries/db/include/graphene/db/flat_index.hpp @@ -93,14 +93,6 @@ namespace graphene { namespace db { } FC_CAPTURE_AND_RETHROW() } - virtual fc::uint128 hash()const override { - fc::uint128 result; - for( const auto& ptr : _objects ) - result += ptr.hash(); - - return result; - } - class const_iterator { public: From d54cc47a4f874a4cf434fec3a9317b52cf61fdf5 Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 14 Mar 2018 18:21:57 -0400 Subject: [PATCH 14/77] Impl. pack/unpack functions for extension class --- .../include/graphene/chain/protocol/ext.hpp | 72 ++++++++++++------- .../include/graphene/chain/protocol/types.hpp | 6 +- 2 files changed, 50 insertions(+), 28 deletions(-) diff --git a/libraries/chain/include/graphene/chain/protocol/ext.hpp b/libraries/chain/include/graphene/chain/protocol/ext.hpp index 6c974630..75364525 100644 --- a/libraries/chain/include/graphene/chain/protocol/ext.hpp +++ b/libraries/chain/include/graphene/chain/protocol/ext.hpp @@ -29,6 +29,8 @@ namespace graphene { namespace chain { +using fc::unsigned_int; + template< typename T > struct extension { @@ -55,15 +57,19 @@ struct graphene_extension_pack_count_visitor template< typename Stream, typename T > struct graphene_extension_pack_read_visitor { - graphene_extension_pack_read_visitor( Stream& s, const T& v ) : stream(s), value(v) {} + graphene_extension_pack_read_visitor( Stream& s, const T& v, uint32_t _max_depth ) + : stream(s), value(v), max_depth(_max_depth - 1) + { + FC_ASSERT( _max_depth > 0 ); + } template void operator()( const char* name )const { if( (value.*member).valid() ) { - fc::raw::pack( stream, unsigned_int( which ) ); - fc::raw::pack( stream, *(value.*member) ); + fc::raw::pack( stream, unsigned_int( which ), max_depth ); + fc::raw::pack( stream, *(value.*member), max_depth ); } ++which; } @@ -71,27 +77,19 @@ struct graphene_extension_pack_read_visitor Stream& stream; const T& value; mutable uint32_t which = 0; + const uint32_t max_depth; }; -template< typename Stream, class T > -void operator<<( Stream& stream, const graphene::chain::extension& value ) -{ - graphene_extension_pack_count_visitor count_vtor( value.value ); - fc::reflector::visit( count_vtor ); - fc::raw::pack( stream, unsigned_int( count_vtor.count ) ); - graphene_extension_pack_read_visitor read_vtor( stream, value.value ); - fc::reflector::visit( read_vtor ); -} - - template< typename Stream, typename T > struct graphene_extension_unpack_visitor { - graphene_extension_unpack_visitor( Stream& s, T& v ) : stream(s), value(v) + graphene_extension_unpack_visitor( Stream& s, T& v, uint32_t _max_depth ) + : stream(s), value(v), max_depth(_max_depth - 1) { + FC_ASSERT( _max_depth > 0 ); unsigned_int c; - fc::raw::unpack( stream, c ); + fc::raw::unpack( stream, c, max_depth ); count_left = c.value; maybe_read_next_which(); } @@ -101,7 +99,7 @@ struct graphene_extension_unpack_visitor if( count_left > 0 ) { unsigned_int w; - fc::raw::unpack( stream, w ); + fc::raw::unpack( stream, w, max_depth ); next_which = w.value; } } @@ -112,7 +110,7 @@ struct graphene_extension_unpack_visitor if( (count_left > 0) && (which == next_which) ) { typename Member::value_type temp; - fc::raw::unpack( stream, temp ); + fc::raw::unpack( stream, temp, max_depth ); (value.*member) = temp; --count_left; maybe_read_next_which(); @@ -128,17 +126,9 @@ struct graphene_extension_unpack_visitor Stream& stream; T& value; + const uint32_t max_depth; }; -template< typename Stream, typename T > -void operator>>( Stream& s, graphene::chain::extension& value ) -{ - value = graphene::chain::extension(); - graphene_extension_unpack_visitor vtor( s, value.value ); - fc::reflector::visit( vtor ); - FC_ASSERT( vtor.count_left == 0 ); // unrecognized extension throws here -} - } } // graphene::chain namespace fc { @@ -212,4 +202,32 @@ void to_variant( const graphene::chain::extension& value, fc::variant& var, u var = vtor.mvo; } +namespace raw { + +template< typename Stream, typename T > +void pack( Stream& stream, const graphene::chain::extension& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ) +{ + FC_ASSERT( _max_depth > 0 ); + --_max_depth; + graphene::chain::graphene_extension_pack_count_visitor count_vtor( value.value ); + fc::reflector::visit( count_vtor ); + fc::raw::pack( stream, unsigned_int( count_vtor.count ), _max_depth ); + graphene::chain::graphene_extension_pack_read_visitor read_vtor( stream, value.value, _max_depth ); + fc::reflector::visit( read_vtor ); +} + + +template< typename Stream, typename T > +void unpack( Stream& s, graphene::chain::extension& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ) +{ + FC_ASSERT( _max_depth > 0 ); + --_max_depth; + value = graphene::chain::extension(); + graphene::chain::graphene_extension_unpack_visitor vtor( s, value.value, _max_depth ); + fc::reflector::visit( vtor ); + FC_ASSERT( vtor.count_left == 0 ); // unrecognized extension throws here +} + +} // fc::raw + } // fc diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp index e617c395..47f22878 100644 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ b/libraries/chain/include/graphene/chain/protocol/types.hpp @@ -35,7 +35,11 @@ #include #include #include -#include +#include + +#include + +#include #include #include From 14f627c014ef827ccd10cb45eb5aca0137d2ca46 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 13 Apr 2019 23:38:56 -0500 Subject: [PATCH 15/77] Ref #1506: Isolate chain/protocol to its own library --- .gitignore | 2 + libraries/CMakeLists.txt | 1 + libraries/app/api.cpp | 2 +- libraries/app/application.cpp | 6 +- libraries/app/include/graphene/app/api.hpp | 4 +- .../app/include/graphene/app/database_api.hpp | 2 +- .../app/include/graphene/app/full_account.hpp | 2 + libraries/app/plugin.cpp | 2 +- libraries/chain/CMakeLists.txt | 59 +- libraries/chain/block_database.cpp | 2 +- libraries/chain/buyback.cpp | 2 +- .../chain/committee_member_evaluator.cpp | 7 +- libraries/chain/confidential_evaluator.cpp | 2 +- libraries/chain/db_block.cpp | 5 +- libraries/chain/db_init.cpp | 2 - libraries/chain/db_maint.cpp | 2 + libraries/chain/db_management.cpp | 3 +- libraries/chain/db_notify.cpp | 8 +- libraries/chain/db_update.cpp | 2 +- libraries/chain/evaluator.cpp | 4 +- libraries/chain/genesis_state.cpp | 6 +- libraries/chain/get_config.cpp | 2 +- .../include/graphene/chain/account_object.hpp | 10 +- .../graphene/chain/assert_evaluator.hpp | 2 +- .../graphene/chain/asset_evaluator.hpp | 2 +- .../include/graphene/chain/asset_object.hpp | 17 +- .../graphene/chain/balance_evaluator.hpp | 2 +- .../include/graphene/chain/balance_object.hpp | 2 + .../include/graphene/chain/block_database.hpp | 5 +- .../graphene/chain/block_summary_object.hpp | 1 + .../graphene/chain/budget_record_object.hpp | 5 +- .../chain/include/graphene/chain/buyback.hpp | 2 +- .../include/graphene/chain/buyback_object.hpp | 4 +- .../graphene/chain/chain_property_object.hpp | 2 + .../chain/committee_member_object.hpp | 4 +- .../graphene/chain/confidential_evaluator.hpp | 5 +- .../graphene/chain/confidential_object.hpp | 5 +- .../chain/include/graphene/chain/config.hpp | 4 +- .../graphene/chain/custom_evaluator.hpp | 2 +- .../chain/include/graphene/chain/database.hpp | 12 + .../include/graphene/chain/evaluator.hpp | 7 +- .../include/graphene/chain/exceptions.hpp | 6 +- .../graphene/chain/fba_accumulator_id.hpp | 2 +- .../include/graphene/chain/fba_object.hpp | 4 +- .../include/graphene/chain/fork_database.hpp | 4 +- .../include/graphene/chain/genesis_state.hpp | 5 +- .../graphene/chain/global_property_object.hpp | 7 +- .../chain/include/graphene/chain/impacted.hpp | 6 +- .../graphene/chain/market_evaluator.hpp | 6 +- .../include/graphene/chain/market_object.hpp | 10 +- .../chain/operation_history_object.hpp | 6 +- .../graphene/chain/proposal_evaluator.hpp | 2 +- .../graphene/chain/proposal_object.hpp | 4 +- .../include/graphene/chain/protocol/types.hpp | 535 ------------------ .../graphene/chain/special_authority.hpp | 3 +- .../chain/special_authority_object.hpp | 4 +- .../chain/transaction_evaluation_state.hpp | 8 +- .../graphene/chain/transaction_object.hpp | 5 +- .../graphene/chain/transfer_evaluator.hpp | 2 +- .../chain/include/graphene/chain/types.hpp | 106 ++++ .../graphene/chain/vesting_balance_object.hpp | 7 +- .../include/graphene/chain/vote_count.hpp | 2 +- .../chain/withdraw_permission_object.hpp | 4 +- .../include/graphene/chain/witness_object.hpp | 4 +- .../chain/witness_schedule_object.hpp | 3 +- .../include/graphene/chain/worker_object.hpp | 7 +- libraries/chain/market_evaluator.cpp | 2 +- libraries/chain/protocol/chain_parameters.cpp | 8 - libraries/chain/special_authority.cpp | 22 +- libraries/chain/witness_evaluator.cpp | 4 +- libraries/chain/worker_evaluator.cpp | 6 +- libraries/db/include/graphene/db/fwd.hpp | 1 + .../db/include/graphene/db/generic_index.hpp | 2 +- .../include/graphene/db/object_database.hpp | 12 +- .../db/include/graphene/db/object_id.hpp | 46 +- libraries/egenesis/egenesis_brief.cpp.tmpl | 2 +- libraries/egenesis/egenesis_full.cpp.tmpl | 2 +- libraries/egenesis/embed_genesis.cpp | 4 +- .../include/graphene/egenesis/egenesis.hpp | 2 +- libraries/net/CMakeLists.txt | 2 +- .../include/graphene/net/core_messages.hpp | 10 +- .../net/include/graphene/net/message.hpp | 2 +- libraries/net/include/graphene/net/node.hpp | 8 +- .../include/graphene/net/peer_database.hpp | 2 +- libraries/net/node.cpp | 5 +- libraries/net/peer_connection.cpp | 2 +- .../account_history_plugin.hpp | 2 +- .../graphene/debug_witness/debug_witness.hpp | 2 +- .../delayed_node/delayed_node_plugin.cpp | 2 +- .../market_history/market_history_plugin.cpp | 2 +- libraries/protocol/CMakeLists.txt | 54 ++ libraries/{chain => }/protocol/account.cpp | 32 +- libraries/{chain => }/protocol/address.cpp | 20 +- libraries/{chain => }/protocol/assert.cpp | 14 +- libraries/{chain => }/protocol/asset.cpp | 12 +- libraries/{chain => }/protocol/asset_ops.cpp | 59 +- libraries/{chain => }/protocol/authority.cpp | 9 +- .../{chain => }/protocol/betting_market.cpp | 0 libraries/{chain => }/protocol/block.cpp | 5 +- libraries/protocol/chain_parameters.cpp | 8 + .../{chain => }/protocol/committee_member.cpp | 21 +- libraries/{chain => }/protocol/competitor.cpp | 0 .../{chain => }/protocol/confidential.cpp | 22 +- libraries/{chain => }/protocol/custom.cpp | 6 +- .../protocol/custom_account_authority.cpp | 0 .../protocol/custom_permission.cpp | 0 libraries/{chain => }/protocol/event.cpp | 0 .../{chain => }/protocol/event_group.cpp | 0 .../{chain => }/protocol/fee_schedule.cpp | 8 +- .../include/graphene}/protocol/README.md | 0 .../include/graphene}/protocol/account.hpp | 75 +-- .../include/graphene}/protocol/address.hpp | 30 +- .../include/graphene}/protocol/affiliate.hpp | 0 .../include/graphene}/protocol/assert.hpp | 19 +- .../include/graphene}/protocol/asset.hpp | 18 +- .../include/graphene}/protocol/asset_ops.hpp | 141 ++--- .../include/graphene}/protocol/authority.hpp | 14 +- .../include/graphene}/protocol/balance.hpp | 14 +- .../include/graphene}/protocol/base.hpp | 16 +- .../graphene}/protocol/betting_market.hpp | 0 .../include/graphene}/protocol/block.hpp | 18 +- .../include/graphene}/protocol/buyback.hpp | 8 +- .../graphene}/protocol/chain_parameters.hpp | 17 +- .../graphene}/protocol/committee_member.hpp | 32 +- .../graphene}/protocol/confidential.hpp | 39 +- .../include/graphene/protocol/config.hpp | 134 +++++ .../include/graphene}/protocol/custom.hpp | 14 +- .../protocol/custom_account_authority.hpp | 0 .../graphene}/protocol/custom_permission.hpp | 0 .../include/graphene}/protocol/event.hpp | 0 .../graphene}/protocol/event_group.hpp | 0 .../include/graphene/protocol/exceptions.hpp | 48 ++ .../include/graphene}/protocol/ext.hpp | 33 +- .../include/graphene}/protocol/fba.hpp | 14 +- .../graphene}/protocol/fee_schedule.hpp | 14 +- .../graphene}/protocol/lottery_ops.hpp | 0 .../include/graphene}/protocol/market.hpp | 40 +- .../include/graphene}/protocol/memo.hpp | 14 +- .../include/graphene}/protocol/nft_ops.hpp | 0 .../include/graphene}/protocol/offer.hpp | 0 .../include/graphene}/protocol/operations.hpp | 64 +-- .../include/graphene}/protocol/proposal.hpp | 31 +- .../include/graphene}/protocol/protocol.hpp | 0 .../graphene/protocol}/pts_address.hpp | 21 +- .../protocol/rock_paper_scissors.hpp | 0 .../graphene}/protocol/special_authority.hpp | 14 +- .../include/graphene}/protocol/sport.hpp | 0 .../include/graphene}/protocol/tournament.hpp | 0 .../graphene}/protocol/transaction.hpp | 20 +- .../include/graphene}/protocol/transfer.hpp | 25 +- .../include/graphene/protocol/types.hpp | 369 ++++++++++++ .../include/graphene}/protocol/vesting.hpp | 33 +- .../include/graphene}/protocol/vote.hpp | 20 +- .../protocol/withdraw_permission.hpp | 25 +- .../include/graphene}/protocol/witness.hpp | 23 +- .../include/graphene}/protocol/worker.hpp | 17 +- .../{chain => }/protocol/lottery_ops.cpp | 0 libraries/{chain => }/protocol/market.cpp | 20 +- libraries/{chain => }/protocol/memo.cpp | 15 +- libraries/{chain => }/protocol/nft.cpp | 0 libraries/{chain => }/protocol/offer.cpp | 0 libraries/{chain => }/protocol/operations.cpp | 9 +- libraries/{chain => }/protocol/proposal.cpp | 20 +- libraries/{chain => protocol}/pts_address.cpp | 16 +- libraries/{chain => }/protocol/small_ops.cpp | 0 .../special_authority.cpp} | 42 +- libraries/{chain => }/protocol/sport.cpp | 0 libraries/{chain => }/protocol/tournament.cpp | 0 .../{chain => }/protocol/transaction.cpp | 25 +- libraries/{chain => }/protocol/transfer.cpp | 14 +- libraries/{chain => }/protocol/types.cpp | 39 +- .../protocol/config.hpp => protocol/vote.cpp} | 21 +- .../protocol/withdraw_permission.cpp | 22 +- libraries/{chain => }/protocol/witness.cpp | 14 +- libraries/{chain => }/protocol/worker.cpp | 4 +- libraries/wallet/wallet.cpp | 28 +- programs/build_helpers/member_enumerator.cpp | 4 +- programs/genesis_util/convert_address.cpp | 6 +- programs/genesis_util/genesis_update.cpp | 3 +- programs/genesis_util/get_dev_key.cpp | 8 +- programs/js_operation_serializer/main.cpp | 18 +- programs/size_checker/main.cpp | 7 +- tests/common/database_fixture.hpp | 11 +- 183 files changed, 1686 insertions(+), 1468 deletions(-) delete mode 100644 libraries/chain/include/graphene/chain/protocol/types.hpp create mode 100644 libraries/chain/include/graphene/chain/types.hpp delete mode 100644 libraries/chain/protocol/chain_parameters.cpp create mode 100644 libraries/protocol/CMakeLists.txt rename libraries/{chain => }/protocol/account.cpp (89%) rename libraries/{chain => }/protocol/address.cpp (87%) rename libraries/{chain => }/protocol/assert.cpp (81%) rename libraries/{chain => }/protocol/asset.cpp (96%) rename libraries/{chain => }/protocol/asset_ops.cpp (75%) rename libraries/{chain => }/protocol/authority.cpp (86%) rename libraries/{chain => }/protocol/betting_market.cpp (100%) rename libraries/{chain => }/protocol/block.cpp (96%) create mode 100644 libraries/protocol/chain_parameters.cpp rename libraries/{chain => }/protocol/committee_member.cpp (64%) rename libraries/{chain => }/protocol/competitor.cpp (100%) rename libraries/{chain => }/protocol/confidential.cpp (86%) rename libraries/{chain => }/protocol/custom.cpp (93%) rename libraries/{chain => }/protocol/custom_account_authority.cpp (100%) rename libraries/{chain => }/protocol/custom_permission.cpp (100%) rename libraries/{chain => }/protocol/event.cpp (100%) rename libraries/{chain => }/protocol/event_group.cpp (100%) rename libraries/{chain => }/protocol/fee_schedule.cpp (97%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/README.md (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/account.hpp (79%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/address.hpp (79%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/affiliate.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/assert.hpp (85%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/asset.hpp (94%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/asset_ops.hpp (83%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/authority.hpp (89%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/balance.hpp (85%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/base.hpp (93%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/betting_market.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/block.hpp (80%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/buyback.hpp (85%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/chain_parameters.hpp (97%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/committee_member.hpp (74%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/confidential.hpp (87%) create mode 100644 libraries/protocol/include/graphene/protocol/config.hpp rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/custom.hpp (80%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/custom_account_authority.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/custom_permission.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/event.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/event_group.hpp (100%) create mode 100644 libraries/protocol/include/graphene/protocol/exceptions.hpp rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/ext.hpp (82%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/fba.hpp (78%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/fee_schedule.hpp (87%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/lottery_ops.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/market.hpp (79%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/memo.hpp (89%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/nft_ops.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/offer.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/operations.hpp (80%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/proposal.hpp (87%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/protocol.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene/protocol}/pts_address.hpp (84%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/rock_paper_scissors.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/special_authority.hpp (78%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/sport.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/tournament.hpp (100%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/transaction.hpp (93%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/transfer.hpp (78%) create mode 100644 libraries/protocol/include/graphene/protocol/types.hpp rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/vesting.hpp (76%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/vote.hpp (86%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/withdraw_permission.hpp (89%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/witness.hpp (75%) rename libraries/{chain/include/graphene/chain => protocol/include/graphene}/protocol/worker.hpp (88%) rename libraries/{chain => }/protocol/lottery_ops.cpp (100%) rename libraries/{chain => }/protocol/market.cpp (67%) rename libraries/{chain => }/protocol/memo.cpp (93%) rename libraries/{chain => }/protocol/nft.cpp (100%) rename libraries/{chain => }/protocol/offer.cpp (100%) rename libraries/{chain => }/protocol/operations.cpp (91%) rename libraries/{chain => }/protocol/proposal.cpp (83%) rename libraries/{chain => protocol}/pts_address.cpp (86%) rename libraries/{chain => }/protocol/small_ops.cpp (100%) rename libraries/{chain/protocol/vote.cpp => protocol/special_authority.cpp} (62%) rename libraries/{chain => }/protocol/sport.cpp (100%) rename libraries/{chain => }/protocol/tournament.cpp (100%) rename libraries/{chain => }/protocol/transaction.cpp (94%) rename libraries/{chain => }/protocol/transfer.cpp (79%) rename libraries/{chain => }/protocol/types.cpp (83%) rename libraries/{chain/include/graphene/chain/protocol/config.hpp => protocol/vote.cpp} (74%) rename libraries/{chain => }/protocol/withdraw_permission.cpp (69%) rename libraries/{chain => }/protocol/witness.cpp (73%) rename libraries/{chain => }/protocol/worker.cpp (95%) diff --git a/.gitignore b/.gitignore index 90311de0..a640668b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +build*/ + *.a *.sw* diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 04ad3781..d2ae5c82 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -8,3 +8,4 @@ add_subdirectory( utilities ) add_subdirectory( app ) add_subdirectory( plugins ) add_subdirectory( wallet ) +add_subdirectory( protocol ) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index a80c4726..949f93d2 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 2a299625..4c83fe96 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -26,8 +26,10 @@ #include #include -#include -#include +#include +#include +#include +#include #include diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 4adf73a3..a1ba96fe 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -25,8 +25,8 @@ #include -#include -#include +#include +#include #include #include diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 0b141125..a3218a5b 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -25,7 +25,7 @@ #include -#include +#include #include diff --git a/libraries/app/include/graphene/app/full_account.hpp b/libraries/app/include/graphene/app/full_account.hpp index 955857b7..7de9daf6 100644 --- a/libraries/app/include/graphene/app/full_account.hpp +++ b/libraries/app/include/graphene/app/full_account.hpp @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include namespace graphene { namespace app { diff --git a/libraries/app/plugin.cpp b/libraries/app/plugin.cpp index cae488a6..02d1fdb8 100644 --- a/libraries/app/plugin.cpp +++ b/libraries/app/plugin.cpp @@ -23,7 +23,7 @@ */ #include -#include +#include namespace graphene { namespace app { diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index f0b0e9e1..2c94b538 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -6,7 +6,6 @@ set_source_files_properties( "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain add_dependencies( build_hardfork_hpp cat-parts ) file(GLOB HEADERS "include/graphene/chain/*.hpp") -file(GLOB PROTOCOL_HEADERS "include/graphene/chain/protocol/*.hpp") if( GRAPHENE_DISABLE_UNITY_BUILD ) set( GRAPHENE_DB_FILES @@ -36,42 +35,10 @@ add_library( graphene_chain ${GRAPHENE_DB_FILES} fork_database.cpp - protocol/types.cpp - protocol/address.cpp - protocol/authority.cpp - protocol/asset.cpp - protocol/assert.cpp - protocol/account.cpp - protocol/transfer.cpp - protocol/chain_parameters.cpp - protocol/committee_member.cpp - protocol/witness.cpp - protocol/market.cpp - protocol/proposal.cpp - protocol/withdraw_permission.cpp - protocol/asset_ops.cpp - protocol/lottery_ops.cpp - protocol/memo.cpp - protocol/worker.cpp - protocol/custom.cpp - protocol/operations.cpp - protocol/transaction.cpp - protocol/block.cpp - protocol/fee_schedule.cpp - protocol/confidential.cpp - protocol/vote.cpp - protocol/tournament.cpp - protocol/small_ops.cpp - protocol/custom_permission.cpp - protocol/custom_account_authority.cpp - protocol/offer.cpp - genesis_state.cpp get_config.cpp exceptions.cpp - pts_address.cpp - evaluator.cpp balance_evaluator.cpp account_evaluator.cpp @@ -105,35 +72,12 @@ add_library( graphene_chain is_authorized_asset.cpp - protocol/sport.cpp - sport_evaluator.cpp - protocol/event_group.cpp - event_group_evaluator.cpp - event_group_object.cpp - protocol/event.cpp - event_evaluator.cpp - event_object.cpp - protocol/betting_market.cpp - betting_market_evaluator.cpp - betting_market_object.cpp - betting_market_group_object.cpp - custom_permission_evaluator.cpp - custom_account_authority_evaluator.cpp - - affiliate_payout.cpp - - offer_object.cpp - offer_evaluator.cpp - nft_evaluator.cpp - protocol/nft.cpp - ${HEADERS} - ${PROTOCOL_HEADERS} "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp" ) add_dependencies( graphene_chain build_hardfork_hpp ) -target_link_libraries( graphene_chain fc graphene_db ) +target_link_libraries( graphene_chain fc graphene_db graphene_protocol ) target_include_directories( graphene_chain PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include" ) @@ -149,4 +93,3 @@ INSTALL( TARGETS ARCHIVE DESTINATION lib ) INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/chain" ) -INSTALL( FILES ${PROTOCOL_HEADERS} DESTINATION "include/graphene/chain/protocol" ) diff --git a/libraries/chain/block_database.cpp b/libraries/chain/block_database.cpp index 2dd9b7a2..d86a5d25 100644 --- a/libraries/chain/block_database.cpp +++ b/libraries/chain/block_database.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include -#include +#include #include namespace graphene { namespace chain { diff --git a/libraries/chain/buyback.cpp b/libraries/chain/buyback.cpp index 09341fe7..152fc7bb 100644 --- a/libraries/chain/buyback.cpp +++ b/libraries/chain/buyback.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include +#include #include #include #include diff --git a/libraries/chain/committee_member_evaluator.cpp b/libraries/chain/committee_member_evaluator.cpp index 01614f99..439285b4 100644 --- a/libraries/chain/committee_member_evaluator.cpp +++ b/libraries/chain/committee_member_evaluator.cpp @@ -25,9 +25,8 @@ #include #include #include -#include -#include -#include +#include +#include #include namespace graphene { namespace chain { @@ -42,7 +41,7 @@ object_id_type committee_member_create_evaluator::do_apply( const committee_memb { try { vote_id_type vote_id; db().modify(db().get_global_properties(), [&vote_id](global_property_object& p) { - vote_id = get_next_vote_id(p, vote_id_type::committee); + vote_id = vote_id_type(vote_id_type::committee, p.next_available_vote_id++); }); const auto& new_del_object = db().create( [&]( committee_member_object& obj ){ diff --git a/libraries/chain/confidential_evaluator.cpp b/libraries/chain/confidential_evaluator.cpp index 9946b492..4be4d0e1 100644 --- a/libraries/chain/confidential_evaluator.cpp +++ b/libraries/chain/confidential_evaluator.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include -#include +#include #include #include #include diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 11134759..4e1cf289 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -36,11 +36,10 @@ #include #include #include -#include #include #include -#include -#include + +#include namespace { diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 9c3102fe..5d67bd8e 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -86,8 +86,6 @@ #include #include -#include - #include #include diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index b222b0de..dacb7c5c 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -24,6 +24,8 @@ #include +#include + #include #include #include diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index c6380b8c..30a38301 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -28,7 +28,8 @@ #include #include #include -#include + +#include #include diff --git a/libraries/chain/db_notify.cpp b/libraries/chain/db_notify.cpp index f56e3d8b..ad4d92c0 100644 --- a/libraries/chain/db_notify.cpp +++ b/libraries/chain/db_notify.cpp @@ -24,10 +24,10 @@ #include -#include -#include -#include -#include +#include +#include +#include + #include #include #include diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index 5703d04a..1e9a0c51 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -37,7 +37,7 @@ #include #include -#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/evaluator.cpp b/libraries/chain/evaluator.cpp index d92564e9..ed32f5ef 100644 --- a/libraries/chain/evaluator.cpp +++ b/libraries/chain/evaluator.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include namespace graphene { namespace chain { database& generic_evaluator::db()const { return trx_state->db(); } @@ -56,7 +56,7 @@ database& generic_evaluator::db()const { return trx_state->db(); } fee_paying_account = &account_id(d); fee_paying_account_statistics = &fee_paying_account->statistics(d); - fee_asset = &fee.asset_id(d); + fee_asset = &asset_id_type(fee.asset_id)(d); fee_asset_dyn_data = &fee_asset->dynamic_asset_data_id(d); if( d.head_block_time() > HARDFORK_419_TIME ) diff --git a/libraries/chain/genesis_state.cpp b/libraries/chain/genesis_state.cpp index 3ad0ec46..a8ab549c 100644 --- a/libraries/chain/genesis_state.cpp +++ b/libraries/chain/genesis_state.cpp @@ -24,10 +24,8 @@ #include -// these are required to serialize a genesis_state -#include - -#include +// this is required to serialize a genesis_state +#include namespace graphene { namespace chain { diff --git a/libraries/chain/get_config.cpp b/libraries/chain/get_config.cpp index c961b950..6c30a534 100644 --- a/libraries/chain/get_config.cpp +++ b/libraries/chain/get_config.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index 5f24adeb..c547af22 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -22,13 +22,15 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include -#include +#include #include namespace graphene { namespace chain { class database; + class account_object; + class vesting_balance_object; /** * @class account_statistics_object @@ -541,6 +543,10 @@ namespace graphene { namespace chain { }} +MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_balance_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_statistics_object) + FC_REFLECT_DERIVED( graphene::chain::account_object, (graphene::db::object), (membership_expiration_date)(registrar)(referrer)(lifetime_referrer) diff --git a/libraries/chain/include/graphene/chain/assert_evaluator.hpp b/libraries/chain/include/graphene/chain/assert_evaluator.hpp index b985a849..e4bfdd00 100644 --- a/libraries/chain/include/graphene/chain/assert_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/assert_evaluator.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/asset_evaluator.hpp b/libraries/chain/include/graphene/chain/asset_evaluator.hpp index d65d37fc..360d1cd0 100644 --- a/libraries/chain/include/graphene/chain/asset_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/asset_evaluator.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index d8c65e89..5e149447 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -22,11 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -#include +#include #include +#include +#include /** * @defgroup prediction_market Prediction Market @@ -39,6 +38,8 @@ */ namespace graphene { namespace chain { + class account_object; + class asset_bitasset_data_object; class database; class transaction_evaluation_state; using namespace graphene::db; @@ -111,13 +112,13 @@ namespace graphene { namespace chain { string amount_to_string(share_type amount)const; /// Convert an asset to a textual representation, i.e. "123.45" string amount_to_string(const asset& amount)const - { FC_ASSERT(amount.asset_id == id); return amount_to_string(amount.amount); } + { FC_ASSERT(amount.asset_id == get_id()); return amount_to_string(amount.amount); } /// Convert an asset to a textual representation with symbol, i.e. "123.45 USD" string amount_to_pretty_string(share_type amount)const { return amount_to_string(amount) + " " + symbol; } /// Convert an asset to a textual representation with symbol, i.e. "123.45 USD" string amount_to_pretty_string(const asset &amount)const - { FC_ASSERT(amount.asset_id == id); return amount_to_pretty_string(amount.amount); } + { FC_ASSERT(amount.asset_id == get_id()); return amount_to_pretty_string(amount.amount); } uint32_t get_issuer_num()const { return issuer.instance.value; } @@ -513,6 +514,10 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_dynamic_data_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_bitasset_data_object) + FC_REFLECT_DERIVED( graphene::chain::asset_dynamic_data_object, (graphene::db::object), (current_supply)(sweeps_tickets_sold)(confidential_supply)(accumulated_fees)(fee_pool) ) diff --git a/libraries/chain/include/graphene/chain/balance_evaluator.hpp b/libraries/chain/include/graphene/chain/balance_evaluator.hpp index 9458b173..ef1491b9 100644 --- a/libraries/chain/include/graphene/chain/balance_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/balance_evaluator.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include #include diff --git a/libraries/chain/include/graphene/chain/balance_object.hpp b/libraries/chain/include/graphene/chain/balance_object.hpp index 38a1a649..a0f6ff23 100644 --- a/libraries/chain/include/graphene/chain/balance_object.hpp +++ b/libraries/chain/include/graphene/chain/balance_object.hpp @@ -71,6 +71,8 @@ namespace graphene { namespace chain { using balance_index = generic_index; } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::balance_object) + FC_REFLECT_DERIVED( graphene::chain::balance_object, (graphene::db::object), (owner)(balance)(vesting_policy)(last_claim_date) ) diff --git a/libraries/chain/include/graphene/chain/block_database.hpp b/libraries/chain/include/graphene/chain/block_database.hpp index c5cf5df9..2580e326 100644 --- a/libraries/chain/include/graphene/chain/block_database.hpp +++ b/libraries/chain/include/graphene/chain/block_database.hpp @@ -23,12 +23,13 @@ */ #pragma once #include -#include +#include #include namespace graphene { namespace chain { - class index_entry; + struct index_entry; + using namespace graphene::protocol; class block_database { diff --git a/libraries/chain/include/graphene/chain/block_summary_object.hpp b/libraries/chain/include/graphene/chain/block_summary_object.hpp index 9f79d43e..62be251d 100644 --- a/libraries/chain/include/graphene/chain/block_summary_object.hpp +++ b/libraries/chain/include/graphene/chain/block_summary_object.hpp @@ -48,6 +48,7 @@ namespace graphene { namespace chain { } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::block_summary_object) FC_REFLECT_DERIVED( graphene::chain::block_summary_object, (graphene::db::object), (block_id) ) diff --git a/libraries/chain/include/graphene/chain/budget_record_object.hpp b/libraries/chain/include/graphene/chain/budget_record_object.hpp index e3f6d06e..82cd8c76 100644 --- a/libraries/chain/include/graphene/chain/budget_record_object.hpp +++ b/libraries/chain/include/graphene/chain/budget_record_object.hpp @@ -22,7 +22,8 @@ * THE SOFTWARE. */ #pragma once -#include +#include +#include #include namespace graphene { namespace chain { @@ -65,6 +66,8 @@ class budget_record_object : public graphene::db::abstract_object +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/buyback_object.hpp b/libraries/chain/include/graphene/chain/buyback_object.hpp index 3d58429b..3de8b039 100644 --- a/libraries/chain/include/graphene/chain/buyback_object.hpp +++ b/libraries/chain/include/graphene/chain/buyback_object.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include @@ -64,6 +64,8 @@ typedef generic_index< buyback_object, buyback_multi_index_type > buyback_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::buyback_object) + FC_REFLECT_DERIVED( graphene::chain::buyback_object, (graphene::db::object), (asset_to_buy) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::buyback_object ) diff --git a/libraries/chain/include/graphene/chain/chain_property_object.hpp b/libraries/chain/include/graphene/chain/chain_property_object.hpp index 3c7a77ff..d0c9e28d 100644 --- a/libraries/chain/include/graphene/chain/chain_property_object.hpp +++ b/libraries/chain/include/graphene/chain/chain_property_object.hpp @@ -42,6 +42,8 @@ class chain_property_object : public abstract_object } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::chain_property_object) + FC_REFLECT_DERIVED( graphene::chain::chain_property_object, (graphene::db::object), (chain_id) (immutable_parameters) diff --git a/libraries/chain/include/graphene/chain/committee_member_object.hpp b/libraries/chain/include/graphene/chain/committee_member_object.hpp index fe7968d3..dfbbe979 100644 --- a/libraries/chain/include/graphene/chain/committee_member_object.hpp +++ b/libraries/chain/include/graphene/chain/committee_member_object.hpp @@ -22,9 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include #include #include +#include +#include namespace graphene { namespace chain { using namespace graphene::db; @@ -71,6 +72,7 @@ namespace graphene { namespace chain { using committee_member_index = generic_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::committee_member_object) FC_REFLECT_DERIVED( graphene::chain::committee_member_object, (graphene::db::object), (committee_member_account)(vote_id)(total_votes)(url) ) diff --git a/libraries/chain/include/graphene/chain/confidential_evaluator.hpp b/libraries/chain/include/graphene/chain/confidential_evaluator.hpp index bc877faf..136519c7 100644 --- a/libraries/chain/include/graphene/chain/confidential_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/confidential_evaluator.hpp @@ -23,13 +23,10 @@ */ #pragma once #include +#include namespace graphene { namespace chain { -struct transfer_to_blind_operation; -struct transfer_from_blind_operation; -struct blind_transfer_operation; - class transfer_to_blind_evaluator : public evaluator { public: diff --git a/libraries/chain/include/graphene/chain/confidential_object.hpp b/libraries/chain/include/graphene/chain/confidential_object.hpp index acdb0ba5..90df90de 100644 --- a/libraries/chain/include/graphene/chain/confidential_object.hpp +++ b/libraries/chain/include/graphene/chain/confidential_object.hpp @@ -23,8 +23,8 @@ */ #pragma once -#include -#include +#include +#include #include @@ -65,6 +65,7 @@ typedef generic_index + #define GRAPHENE_SYMBOL "TEST" #define GRAPHENE_ADDRESS_PREFIX "TEST" @@ -243,4 +245,4 @@ #define NFT_TOKEN_MIN_LENGTH 3 #define NFT_TOKEN_MAX_LENGTH 15 -#define NFT_URI_MAX_LENGTH GRAPHENE_MAX_URL_LENGTH \ No newline at end of file +#define NFT_URI_MAX_LENGTH GRAPHENE_MAX_URL_LENGTH diff --git a/libraries/chain/include/graphene/chain/custom_evaluator.hpp b/libraries/chain/include/graphene/chain/custom_evaluator.hpp index 968f6e48..f9efe76e 100644 --- a/libraries/chain/include/graphene/chain/custom_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/custom_evaluator.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index 8ecb4b91..7807f479 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -22,6 +22,9 @@ * THE SOFTWARE. */ #pragma once + +#include + #include #include #include @@ -49,6 +52,15 @@ namespace graphene { namespace chain { using graphene::db::object; class op_evaluator; class transaction_evaluation_state; + class proposal_object; + class operation_history_object; + class chain_property_object; + class witness_schedule_object; + class witness_object; + class force_settlement_object; + class limit_order_object; + class collateral_bid_object; + class call_order_object; struct budget_record; diff --git a/libraries/chain/include/graphene/chain/evaluator.hpp b/libraries/chain/include/graphene/chain/evaluator.hpp index af90517e..0a1cc986 100644 --- a/libraries/chain/include/graphene/chain/evaluator.hpp +++ b/libraries/chain/include/graphene/chain/evaluator.hpp @@ -24,14 +24,17 @@ #pragma once #include #include -#include +#include namespace graphene { namespace chain { class database; - struct signed_transaction; class generic_evaluator; class transaction_evaluation_state; + class account_object; + class account_statistics_object; + class asset_object; + class asset_dynamic_data_object; class generic_evaluator { diff --git a/libraries/chain/include/graphene/chain/exceptions.hpp b/libraries/chain/include/graphene/chain/exceptions.hpp index d89626ad..8ae9edff 100644 --- a/libraries/chain/include/graphene/chain/exceptions.hpp +++ b/libraries/chain/include/graphene/chain/exceptions.hpp @@ -24,7 +24,10 @@ #pragma once #include -#include +#include +#include +#include +#include #define GRAPHENE_ASSERT( expr, exc_type, FORMAT, ... ) \ FC_MULTILINE_MACRO_BEGIN \ @@ -32,7 +35,6 @@ FC_THROW_EXCEPTION( exc_type, FORMAT, __VA_ARGS__ ); \ FC_MULTILINE_MACRO_END - #define GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( op_name ) \ FC_DECLARE_DERIVED_EXCEPTION( \ op_name ## _validate_exception, \ diff --git a/libraries/chain/include/graphene/chain/fba_accumulator_id.hpp b/libraries/chain/include/graphene/chain/fba_accumulator_id.hpp index 9bc0cf23..f0eefdbe 100644 --- a/libraries/chain/include/graphene/chain/fba_accumulator_id.hpp +++ b/libraries/chain/include/graphene/chain/fba_accumulator_id.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/fba_object.hpp b/libraries/chain/include/graphene/chain/fba_object.hpp index 3d1e1be0..0927b235 100644 --- a/libraries/chain/include/graphene/chain/fba_object.hpp +++ b/libraries/chain/include/graphene/chain/fba_object.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include @@ -49,6 +49,8 @@ class fba_accumulator_object : public graphene::db::abstract_object< fba_accumul } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::fba_accumulator_object) + FC_REFLECT_DERIVED( graphene::chain::fba_accumulator_object, (graphene::db::object), (accumulated_fba_fees)(designated_asset) ) diff --git a/libraries/chain/include/graphene/chain/fork_database.hpp b/libraries/chain/include/graphene/chain/fork_database.hpp index 4007ca09..5e811e3d 100644 --- a/libraries/chain/include/graphene/chain/fork_database.hpp +++ b/libraries/chain/include/graphene/chain/fork_database.hpp @@ -22,7 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include + +#include #include #include diff --git a/libraries/chain/include/graphene/chain/genesis_state.hpp b/libraries/chain/include/graphene/chain/genesis_state.hpp index b2f76118..2eadba2f 100644 --- a/libraries/chain/include/graphene/chain/genesis_state.hpp +++ b/libraries/chain/include/graphene/chain/genesis_state.hpp @@ -23,9 +23,8 @@ */ #pragma once -#include -#include -#include +#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/global_property_object.hpp b/libraries/chain/include/graphene/chain/global_property_object.hpp index 789b1bd1..e53837ae 100644 --- a/libraries/chain/include/graphene/chain/global_property_object.hpp +++ b/libraries/chain/include/graphene/chain/global_property_object.hpp @@ -24,8 +24,8 @@ #pragma once #include -#include -#include +#include +#include #include #include @@ -123,6 +123,9 @@ namespace graphene { namespace chain { }; }} +MAP_OBJECT_ID_TO_TYPE(graphene::chain::dynamic_global_property_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::global_property_object) + FC_REFLECT_DERIVED( graphene::chain::dynamic_global_property_object, (graphene::db::object), (head_block_number) (head_block_id) diff --git a/libraries/chain/include/graphene/chain/impacted.hpp b/libraries/chain/include/graphene/chain/impacted.hpp index 2a22cbd1..9d986cb8 100644 --- a/libraries/chain/include/graphene/chain/impacted.hpp +++ b/libraries/chain/include/graphene/chain/impacted.hpp @@ -24,9 +24,9 @@ #pragma once #include -#include -#include -#include +#include +#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/market_evaluator.hpp b/libraries/chain/include/graphene/chain/market_evaluator.hpp index 9d653c07..778f012c 100644 --- a/libraries/chain/include/graphene/chain/market_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/market_evaluator.hpp @@ -23,7 +23,7 @@ */ #pragma once #include -#include +#include namespace graphene { namespace chain { @@ -31,9 +31,7 @@ namespace graphene { namespace chain { class asset_object; class asset_bitasset_data_object; class call_order_object; - struct call_order_update_operation; - struct limit_order_cancel_operation; - struct limit_order_create_operation; + class limit_order_object; class limit_order_create_evaluator : public evaluator { diff --git a/libraries/chain/include/graphene/chain/market_object.hpp b/libraries/chain/include/graphene/chain/market_object.hpp index 4bd3e048..9d058638 100644 --- a/libraries/chain/include/graphene/chain/market_object.hpp +++ b/libraries/chain/include/graphene/chain/market_object.hpp @@ -23,10 +23,10 @@ */ #pragma once -#include -#include #include #include +#include +#include #include @@ -65,7 +65,6 @@ class limit_order_object : public abstract_object asset amount_to_receive()const { return amount_for_sale() * sell_price; } }; -struct by_id; struct by_price; struct by_expiration; struct by_account; @@ -205,6 +204,11 @@ typedef generic_index +#include #include #include @@ -139,6 +138,9 @@ typedef generic_index +#include #include #include #include diff --git a/libraries/chain/include/graphene/chain/proposal_object.hpp b/libraries/chain/include/graphene/chain/proposal_object.hpp index d17d2c40..b05e9e44 100644 --- a/libraries/chain/include/graphene/chain/proposal_object.hpp +++ b/libraries/chain/include/graphene/chain/proposal_object.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include @@ -94,6 +94,8 @@ typedef generic_index proposal_ } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::proposal_object) + FC_REFLECT_DERIVED( graphene::chain::proposal_object, (graphene::chain::object), (expiration_time)(review_period_time)(proposed_transaction)(required_active_approvals) (available_active_approvals)(required_owner_approvals)(available_owner_approvals) diff --git a/libraries/chain/include/graphene/chain/protocol/types.hpp b/libraries/chain/include/graphene/chain/protocol/types.hpp deleted file mode 100644 index 47f22878..00000000 --- a/libraries/chain/include/graphene/chain/protocol/types.hpp +++ /dev/null @@ -1,535 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#define GRAPHENE_EXTERNAL_SERIALIZATION(ext, type) \ -namespace fc { \ - ext template void from_variant( const variant& v, type& vo, uint32_t max_depth ); \ - ext template void to_variant( const type& v, variant& vo, uint32_t max_depth ); \ -namespace raw { \ - ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ - ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ - ext template void unpack< datastream, type >( datastream& s, type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ -} } // fc::raw - -namespace graphene { namespace chain { - using namespace graphene::db; - - using std::map; - using std::vector; - using std::unordered_map; - using std::string; - using std::deque; - using std::shared_ptr; - using std::weak_ptr; - using std::unique_ptr; - using std::set; - using std::pair; - using std::enable_shared_from_this; - using std::tie; - using std::make_pair; - - using fc::variant_object; - using fc::variant; - using fc::enum_type; - using fc::optional; - using fc::unsigned_int; - using fc::time_point_sec; - using fc::time_point; - using fc::safe; - using fc::flat_map; - using fc::flat_set; - using fc::static_variant; - using fc::ecc::range_proof_type; - using fc::ecc::range_proof_info; - using fc::ecc::commitment_type; - struct void_t{}; - - typedef fc::ecc::private_key private_key_type; - typedef fc::sha256 chain_id_type; - - enum asset_issuer_permission_flags - { - charge_market_fee = 0x01, /**< an issuer-specified percentage of all market trades in this asset is paid to the issuer */ - white_list = 0x02, /**< accounts must be whitelisted in order to hold this asset */ - override_authority = 0x04, /**< issuer may transfer asset back to himself */ - transfer_restricted = 0x08, /**< require the issuer to be one party to every transfer */ - disable_force_settle = 0x10, /**< disable force settling */ - global_settle = 0x20, /**< allow the bitasset issuer to force a global settling -- this may be set in permissions, but not flags */ - disable_confidential = 0x40, /**< allow the asset to be used with confidential transactions */ - witness_fed_asset = 0x80, /**< allow the asset to be fed by witnesses */ - committee_fed_asset = 0x100 /**< allow the asset to be fed by the committee */ - }; - const static uint32_t ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_force_settle|global_settle|disable_confidential - |witness_fed_asset|committee_fed_asset; - const static uint32_t UIA_ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_confidential; - - enum reserved_spaces - { - relative_protocol_ids = 0, - protocol_ids = 1, - implementation_ids = 2 - }; - - inline bool is_relative( object_id_type o ){ return o.space() == 0; } - - /** - * List all object types from all namespaces here so they can - * be easily reflected and displayed in debug output. If a 3rd party - * wants to extend the core code then they will have to change the - * packed_object::type field from enum_type to uint16 to avoid - * warnings when converting packed_objects to/from json. - */ - enum object_type - { - null_object_type, - base_object_type, - account_object_type, - asset_object_type, - force_settlement_object_type, - committee_member_object_type, - witness_object_type, - limit_order_object_type, - call_order_object_type, - custom_object_type, - proposal_object_type, - operation_history_object_type, - withdraw_permission_object_type, - vesting_balance_object_type, - worker_object_type, - balance_object_type, - tournament_object_type, - tournament_details_object_type, - match_object_type, - game_object_type, - sport_object_type, - event_group_object_type, - event_object_type, - betting_market_rules_object_type, - betting_market_group_object_type, - betting_market_object_type, - bet_object_type, - custom_permission_object_type, - custom_account_authority_object_type, - offer_object_type, - nft_metadata_type, - nft_object_type, - OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types - }; - - enum impl_object_type - { - impl_global_property_object_type, - impl_dynamic_global_property_object_type, - impl_reserved0_object_type, // formerly index_meta_object_type, TODO: delete me - impl_asset_dynamic_data_type, - impl_asset_bitasset_data_type, - impl_account_balance_object_type, - impl_account_statistics_object_type, - impl_transaction_object_type, - impl_block_summary_object_type, - impl_account_transaction_history_object_type, - impl_blinded_balance_object_type, - impl_chain_property_object_type, - impl_witness_schedule_object_type, - impl_budget_record_object_type, - impl_special_authority_object_type, - impl_buyback_object_type, - impl_fba_accumulator_object_type, - impl_asset_dividend_data_type, - impl_pending_dividend_payout_balance_for_holder_object_type, - impl_distributed_dividend_balance_data_type, - impl_betting_market_position_object_type, - impl_global_betting_statistics_object_type, - impl_lottery_balance_object_type, - impl_sweeps_vesting_balance_object_type, - impl_offer_history_object_type - }; - - //typedef fc::unsigned_int object_id_type; - //typedef uint64_t object_id_type; - class account_object; - class committee_member_object; - class witness_object; - class asset_object; - class force_settlement_object; - class limit_order_object; - class call_order_object; - class custom_object; - class proposal_object; - class operation_history_object; - class withdraw_permission_object; - class vesting_balance_object; - class worker_object; - class balance_object; - class blinded_balance_object; - class tournament_object; - class tournament_details_object; - class match_object; - class game_object; - class sport_object; - class event_group_object; - class event_object; - class betting_market_rules_object; - class betting_market_group_object; - class betting_market_object; - class bet_object; - class custom_permission_object; - class custom_account_authority_object; - class offer_object; - class nft_metadata_object; - class nft_object; - - typedef object_id< protocol_ids, account_object_type, account_object> account_id_type; - typedef object_id< protocol_ids, asset_object_type, asset_object> asset_id_type; - typedef object_id< protocol_ids, force_settlement_object_type, force_settlement_object> force_settlement_id_type; - typedef object_id< protocol_ids, committee_member_object_type, committee_member_object> committee_member_id_type; - typedef object_id< protocol_ids, witness_object_type, witness_object> witness_id_type; - typedef object_id< protocol_ids, limit_order_object_type, limit_order_object> limit_order_id_type; - typedef object_id< protocol_ids, call_order_object_type, call_order_object> call_order_id_type; - typedef object_id< protocol_ids, custom_object_type, custom_object> custom_id_type; - typedef object_id< protocol_ids, proposal_object_type, proposal_object> proposal_id_type; - typedef object_id< protocol_ids, operation_history_object_type, operation_history_object> operation_history_id_type; - typedef object_id< protocol_ids, withdraw_permission_object_type,withdraw_permission_object> withdraw_permission_id_type; - typedef object_id< protocol_ids, vesting_balance_object_type, vesting_balance_object> vesting_balance_id_type; - typedef object_id< protocol_ids, worker_object_type, worker_object> worker_id_type; - typedef object_id< protocol_ids, balance_object_type, balance_object> balance_id_type; - typedef object_id< protocol_ids, tournament_object_type, tournament_object> tournament_id_type; - typedef object_id< protocol_ids, tournament_details_object_type, tournament_details_object> tournament_details_id_type; - typedef object_id< protocol_ids, match_object_type, match_object> match_id_type; - typedef object_id< protocol_ids, game_object_type, game_object> game_id_type; - typedef object_id< protocol_ids, sport_object_type, sport_object> sport_id_type; - typedef object_id< protocol_ids, event_group_object_type, event_group_object> event_group_id_type; - typedef object_id< protocol_ids, event_object_type, event_object> event_id_type; - typedef object_id< protocol_ids, betting_market_rules_object_type, betting_market_rules_object> betting_market_rules_id_type; - typedef object_id< protocol_ids, betting_market_group_object_type, betting_market_group_object> betting_market_group_id_type; - typedef object_id< protocol_ids, betting_market_object_type, betting_market_object> betting_market_id_type; - typedef object_id< protocol_ids, bet_object_type, bet_object> bet_id_type; - typedef object_id< protocol_ids, custom_permission_object_type, custom_permission_object> custom_permission_id_type; - typedef object_id< protocol_ids, custom_account_authority_object_type, custom_account_authority_object> custom_account_authority_id_type; - typedef object_id< protocol_ids, offer_object_type, offer_object> offer_id_type; - typedef object_id< protocol_ids, nft_metadata_type, nft_metadata_object> nft_metadata_id_type; - typedef object_id< protocol_ids, nft_object_type, nft_object> nft_id_type; - - // implementation types - class global_property_object; - class dynamic_global_property_object; - class asset_dynamic_data_object; - class asset_bitasset_data_object; - class account_balance_object; - class account_statistics_object; - class transaction_object; - class block_summary_object; - class account_transaction_history_object; - class chain_property_object; - class witness_schedule_object; - class budget_record_object; - class special_authority_object; - class buyback_object; - class fba_accumulator_object; - class asset_dividend_data_object; - class pending_dividend_payout_balance_for_holder_object; - class betting_market_position_object; - class global_betting_statistics_object; - class lottery_balance_object; - class sweeps_vesting_balance_object; - class offer_history_object; - - typedef object_id< implementation_ids, impl_global_property_object_type, global_property_object> global_property_id_type; - typedef object_id< implementation_ids, impl_dynamic_global_property_object_type, dynamic_global_property_object> dynamic_global_property_id_type; - typedef object_id< implementation_ids, impl_asset_dynamic_data_type, asset_dynamic_data_object> asset_dynamic_data_id_type; - typedef object_id< implementation_ids, impl_asset_bitasset_data_type, asset_bitasset_data_object> asset_bitasset_data_id_type; - typedef object_id< implementation_ids, impl_asset_dividend_data_type, asset_dividend_data_object> asset_dividend_data_id_type; - typedef object_id< implementation_ids, - impl_pending_dividend_payout_balance_for_holder_object_type, - pending_dividend_payout_balance_for_holder_object> pending_dividend_payout_balance_for_holder_object_type; - typedef object_id< implementation_ids, impl_account_balance_object_type, account_balance_object> account_balance_id_type; - typedef object_id< implementation_ids, impl_account_statistics_object_type, account_statistics_object> account_statistics_id_type; - typedef object_id< implementation_ids, impl_transaction_object_type, transaction_object> transaction_obj_id_type; - typedef object_id< implementation_ids, impl_block_summary_object_type, block_summary_object> block_summary_id_type; - - typedef object_id< implementation_ids, - impl_account_transaction_history_object_type, - account_transaction_history_object> account_transaction_history_id_type; - typedef object_id< implementation_ids, impl_chain_property_object_type, chain_property_object> chain_property_id_type; - typedef object_id< implementation_ids, impl_witness_schedule_object_type, witness_schedule_object> witness_schedule_id_type; - typedef object_id< implementation_ids, impl_budget_record_object_type, budget_record_object > budget_record_id_type; - typedef object_id< implementation_ids, impl_blinded_balance_object_type, blinded_balance_object > blinded_balance_id_type; - typedef object_id< implementation_ids, impl_special_authority_object_type, special_authority_object > special_authority_id_type; - typedef object_id< implementation_ids, impl_buyback_object_type, buyback_object > buyback_id_type; - typedef object_id< implementation_ids, impl_fba_accumulator_object_type, fba_accumulator_object > fba_accumulator_id_type; - typedef object_id< implementation_ids, impl_betting_market_position_object_type, betting_market_position_object > betting_market_position_id_type; - typedef object_id< implementation_ids, impl_global_betting_statistics_object_type, global_betting_statistics_object > global_betting_statistics_id_type; - typedef object_id< implementation_ids, impl_lottery_balance_object_type, lottery_balance_object > lottery_balance_id_type; - typedef object_id< implementation_ids, impl_sweeps_vesting_balance_object_type, sweeps_vesting_balance_object> sweeps_vesting_balance_id_type; - typedef object_id< implementation_ids, impl_offer_history_object_type, offer_history_object> offer_history_id_type; - - typedef fc::ripemd160 block_id_type; - typedef fc::ripemd160 checksum_type; - typedef fc::ripemd160 transaction_id_type; - typedef fc::sha256 digest_type; - typedef fc::ecc::compact_signature signature_type; - typedef safe share_type; - typedef fc::ripemd160 secret_hash_type; - typedef uint16_t weight_type; - - struct public_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::public_key_data data; - }; - fc::ecc::public_key_data key_data; - public_key_type(); - public_key_type( const fc::ecc::public_key_data& data ); - public_key_type( const fc::ecc::public_key& pubkey ); - explicit public_key_type( const std::string& base58str ); - operator fc::ecc::public_key_data() const; - operator fc::ecc::public_key() const; - explicit operator std::string() const; - friend bool operator == ( const public_key_type& p1, const fc::ecc::public_key& p2); - friend bool operator == ( const public_key_type& p1, const public_key_type& p2); - friend bool operator != ( const public_key_type& p1, const public_key_type& p2); - // TODO: This is temporary for testing - bool is_valid_v1( const std::string& base58str ); - bool is_valid_muse( const std::string& base58str ); - }; - - struct extended_public_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::extended_key_data data; - }; - - fc::ecc::extended_key_data key_data; - - extended_public_key_type(); - extended_public_key_type( const fc::ecc::extended_key_data& data ); - extended_public_key_type( const fc::ecc::extended_public_key& extpubkey ); - explicit extended_public_key_type( const std::string& base58str ); - operator fc::ecc::extended_public_key() const; - explicit operator std::string() const; - friend bool operator == ( const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2); - friend bool operator == ( const extended_public_key_type& p1, const extended_public_key_type& p2); - friend bool operator != ( const extended_public_key_type& p1, const extended_public_key_type& p2); - }; - - struct extended_private_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::extended_key_data data; - }; - - fc::ecc::extended_key_data key_data; - - extended_private_key_type(); - extended_private_key_type( const fc::ecc::extended_key_data& data ); - extended_private_key_type( const fc::ecc::extended_private_key& extprivkey ); - explicit extended_private_key_type( const std::string& base58str ); - operator fc::ecc::extended_private_key() const; - explicit operator std::string() const; - friend bool operator == ( const extended_private_key_type& p1, const fc::ecc::extended_private_key& p2); - friend bool operator == ( const extended_private_key_type& p1, const extended_private_key_type& p2); - friend bool operator != ( const extended_private_key_type& p1, const extended_private_key_type& p2); - }; - - typedef flat_map internationalized_string_type; - - typedef uint32_t bet_multiplier_type; -} } // graphene::chain - -namespace fc -{ - void to_variant( const graphene::chain::public_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::public_key_type& vo, uint32_t max_depth = 2 ); - void to_variant( const graphene::chain::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::extended_public_key_type& vo, uint32_t max_depth = 2 ); - void to_variant( const graphene::chain::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::extended_private_key_type& vo, uint32_t max_depth = 2 ); -} - -FC_REFLECT( graphene::chain::public_key_type, (key_data) ) -FC_REFLECT( graphene::chain::public_key_type::binary_key, (data)(check) ) -FC_REFLECT( graphene::chain::extended_public_key_type, (key_data) ) -FC_REFLECT( graphene::chain::extended_public_key_type::binary_key, (check)(data) ) -FC_REFLECT( graphene::chain::extended_private_key_type, (key_data) ) -FC_REFLECT( graphene::chain::extended_private_key_type::binary_key, (check)(data) ) - -FC_REFLECT_ENUM( graphene::chain::object_type, - (null_object_type) - (base_object_type) - (account_object_type) - (force_settlement_object_type) - (asset_object_type) - (committee_member_object_type) - (witness_object_type) - (limit_order_object_type) - (call_order_object_type) - (custom_object_type) - (proposal_object_type) - (operation_history_object_type) - (withdraw_permission_object_type) - (vesting_balance_object_type) - (worker_object_type) - (balance_object_type) - (tournament_object_type) - (tournament_details_object_type) - (match_object_type) - (game_object_type) - (sport_object_type) - (event_group_object_type) - (event_object_type) - (betting_market_rules_object_type) - (betting_market_group_object_type) - (betting_market_object_type) - (bet_object_type) - (custom_permission_object_type) - (custom_account_authority_object_type) - (offer_object_type) - (nft_metadata_type) - (nft_object_type) - (OBJECT_TYPE_COUNT) - ) -FC_REFLECT_ENUM( graphene::chain::impl_object_type, - (impl_global_property_object_type) - (impl_dynamic_global_property_object_type) - (impl_reserved0_object_type) - (impl_asset_dynamic_data_type) - (impl_asset_bitasset_data_type) - (impl_account_balance_object_type) - (impl_account_statistics_object_type) - (impl_transaction_object_type) - (impl_block_summary_object_type) - (impl_account_transaction_history_object_type) - (impl_blinded_balance_object_type) - (impl_chain_property_object_type) - (impl_witness_schedule_object_type) - (impl_budget_record_object_type) - (impl_special_authority_object_type) - (impl_buyback_object_type) - (impl_fba_accumulator_object_type) - (impl_asset_dividend_data_type) - (impl_pending_dividend_payout_balance_for_holder_object_type) - (impl_distributed_dividend_balance_data_type) - (impl_betting_market_position_object_type) - (impl_global_betting_statistics_object_type) - (impl_lottery_balance_object_type) - (impl_sweeps_vesting_balance_object_type) - (impl_offer_history_object_type) - ) - -FC_REFLECT_TYPENAME( graphene::chain::share_type ) - -FC_REFLECT_TYPENAME( graphene::chain::account_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::force_settlement_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::committee_member_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::witness_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::limit_order_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::call_order_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::proposal_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::operation_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::withdraw_permission_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::vesting_balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::worker_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::sport_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::event_group_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::event_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_rules_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_group_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::bet_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::tournament_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::offer_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::global_property_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::dynamic_global_property_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_dynamic_data_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_bitasset_data_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_statistics_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::transaction_obj_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::block_summary_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_transaction_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::budget_record_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::special_authority_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::buyback_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::fba_accumulator_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_position_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::global_betting_statistics_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::tournament_details_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_permission_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_account_authority_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::offer_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::nft_metadata_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::nft_id_type ) - -FC_REFLECT( graphene::chain::void_t, ) - -FC_REFLECT_ENUM( graphene::chain::asset_issuer_permission_flags, - (charge_market_fee) - (white_list) - (transfer_restricted) - (override_authority) - (disable_force_settle) - (global_settle) - (disable_confidential) - (witness_fed_asset) - (committee_fed_asset) - ) diff --git a/libraries/chain/include/graphene/chain/special_authority.hpp b/libraries/chain/include/graphene/chain/special_authority.hpp index f091f736..931b35a7 100644 --- a/libraries/chain/include/graphene/chain/special_authority.hpp +++ b/libraries/chain/include/graphene/chain/special_authority.hpp @@ -23,11 +23,12 @@ */ #pragma once -#include +#include namespace graphene { namespace chain { class database; +using namespace protocol; void evaluate_special_authority( const database& db, const special_authority& auth ); diff --git a/libraries/chain/include/graphene/chain/special_authority_object.hpp b/libraries/chain/include/graphene/chain/special_authority_object.hpp index 75093f3a..d1d999ee 100644 --- a/libraries/chain/include/graphene/chain/special_authority_object.hpp +++ b/libraries/chain/include/graphene/chain/special_authority_object.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include @@ -63,6 +63,8 @@ typedef generic_index< special_authority_object, special_authority_multi_index_t } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::special_authority_object) + FC_REFLECT_DERIVED( graphene::chain::special_authority_object, (graphene::db::object), diff --git a/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp b/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp index 5ffb4bb7..53c6f3eb 100644 --- a/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp +++ b/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp @@ -22,11 +22,13 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { +namespace protocol { class signed_transaction; } +namespace chain { class database; - struct signed_transaction; + using protocol::signed_transaction; /** * Place holder for state tracked while processing a transaction. This class provides helper methods that are diff --git a/libraries/chain/include/graphene/chain/transaction_object.hpp b/libraries/chain/include/graphene/chain/transaction_object.hpp index aaaa31f1..a613e07c 100644 --- a/libraries/chain/include/graphene/chain/transaction_object.hpp +++ b/libraries/chain/include/graphene/chain/transaction_object.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include @@ -55,7 +55,6 @@ namespace graphene { namespace chain { }; struct by_expiration; - struct by_id; struct by_trx_id; typedef multi_index_container< transaction_object, @@ -69,6 +68,8 @@ namespace graphene { namespace chain { typedef generic_index transaction_index; } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::transaction_object) + FC_REFLECT_DERIVED( graphene::chain::transaction_object, (graphene::db::object), (trx)(trx_id) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transaction_object ) diff --git a/libraries/chain/include/graphene/chain/transfer_evaluator.hpp b/libraries/chain/include/graphene/chain/transfer_evaluator.hpp index 900ab074..6c2bc7ee 100644 --- a/libraries/chain/include/graphene/chain/transfer_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/transfer_evaluator.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/types.hpp b/libraries/chain/include/graphene/chain/types.hpp new file mode 100644 index 00000000..c84608a2 --- /dev/null +++ b/libraries/chain/include/graphene/chain/types.hpp @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#pragma once + +#include + +namespace graphene { namespace chain { + +using namespace graphene::protocol; + +enum impl_object_type { + impl_global_property_object_type, + impl_dynamic_global_property_object_type, + impl_reserved0_object_type, // formerly index_meta_object_type, TODO: delete me + impl_asset_dynamic_data_type, + impl_asset_bitasset_data_type, + impl_account_balance_object_type, + impl_account_statistics_object_type, + impl_transaction_object_type, + impl_block_summary_object_type, + impl_account_transaction_history_object_type, + impl_blinded_balance_object_type, + impl_chain_property_object_type, + impl_witness_schedule_object_type, + impl_budget_record_object_type, + impl_special_authority_object_type, + impl_buyback_object_type, + impl_fba_accumulator_object_type, + impl_collateral_bid_object_type +}; + +using global_property_id_type = object_id; +using dynamic_global_property_id_type = object_id; +using asset_dynamic_data_id_type = object_id; +using asset_bitasset_data_id_type = object_id; +using account_balance_id_type = object_id; +using account_statistics_id_type = object_id; +using transaction_obj_id_type = object_id; +using block_summary_id_type = object_id; +using account_transaction_history_id_type = object_id; +using chain_property_id_type = object_id; +using witness_schedule_id_type = object_id; +using budget_record_id_type = object_id; +using blinded_balance_id_type = object_id; +using special_authority_id_type = object_id; +using buyback_id_type = object_id; +using fba_accumulator_id_type = object_id; +using collateral_bid_id_type = object_id; + +} } + +FC_REFLECT_ENUM(graphene::chain::impl_object_type, + (impl_global_property_object_type) + (impl_dynamic_global_property_object_type) + (impl_reserved0_object_type) + (impl_asset_dynamic_data_type) + (impl_asset_bitasset_data_type) + (impl_account_balance_object_type) + (impl_account_statistics_object_type) + (impl_transaction_object_type) + (impl_block_summary_object_type) + (impl_account_transaction_history_object_type) + (impl_blinded_balance_object_type) + (impl_chain_property_object_type) + (impl_witness_schedule_object_type) + (impl_budget_record_object_type) + (impl_special_authority_object_type) + (impl_buyback_object_type) + (impl_fba_accumulator_object_type) + (impl_collateral_bid_object_type)) + +FC_REFLECT_TYPENAME(graphene::chain::global_property_id_type) +FC_REFLECT_TYPENAME(graphene::chain::dynamic_global_property_id_type) +FC_REFLECT_TYPENAME(graphene::chain::asset_dynamic_data_id_type) +FC_REFLECT_TYPENAME(graphene::chain::asset_bitasset_data_id_type) +FC_REFLECT_TYPENAME(graphene::chain::account_balance_id_type) +FC_REFLECT_TYPENAME(graphene::chain::account_statistics_id_type) +FC_REFLECT_TYPENAME(graphene::chain::transaction_obj_id_type) +FC_REFLECT_TYPENAME(graphene::chain::block_summary_id_type) +FC_REFLECT_TYPENAME(graphene::chain::account_transaction_history_id_type) +FC_REFLECT_TYPENAME(graphene::chain::budget_record_id_type) +FC_REFLECT_TYPENAME(graphene::chain::special_authority_id_type) +FC_REFLECT_TYPENAME(graphene::chain::buyback_id_type) +FC_REFLECT_TYPENAME(graphene::chain::fba_accumulator_id_type) +FC_REFLECT_TYPENAME(graphene::chain::collateral_bid_id_type) diff --git a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp index 19acc0e7..11b689df 100644 --- a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp +++ b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp @@ -23,9 +23,7 @@ */ #pragma once -#include -#include - +#include #include #include @@ -37,6 +35,7 @@ namespace graphene { namespace chain { using namespace graphene::db; + using namespace graphene::protocol; struct vesting_policy_context { @@ -210,6 +209,8 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::vesting_balance_object) + FC_REFLECT(graphene::chain::linear_vesting_policy, (begin_timestamp) (vesting_cliff_seconds) diff --git a/libraries/chain/include/graphene/chain/vote_count.hpp b/libraries/chain/include/graphene/chain/vote_count.hpp index f76a784d..ed8ed130 100644 --- a/libraries/chain/include/graphene/chain/vote_count.hpp +++ b/libraries/chain/include/graphene/chain/vote_count.hpp @@ -24,7 +24,7 @@ #pragma once -#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp index a6fee0c5..5b723113 100644 --- a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp +++ b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include @@ -105,6 +105,8 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::withdraw_permission_object) + FC_REFLECT_DERIVED( graphene::chain::withdraw_permission_object, (graphene::db::object), (withdraw_from_account) (authorized_account) diff --git a/libraries/chain/include/graphene/chain/witness_object.hpp b/libraries/chain/include/graphene/chain/witness_object.hpp index 7928b46e..2647dcd8 100644 --- a/libraries/chain/include/graphene/chain/witness_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_object.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include @@ -70,6 +70,8 @@ namespace graphene { namespace chain { using witness_index = generic_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::witness_object) + FC_REFLECT_DERIVED( graphene::chain::witness_object, (graphene::db::object), (witness_account) (last_aslot) diff --git a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp index 1702212d..2415f82f 100644 --- a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include #include @@ -73,6 +73,7 @@ class witness_schedule_object : public graphene::db::abstract_object #include -#include +#include +#include namespace graphene { namespace chain { +class database; /** * @defgroup worker_types Implementations of the various worker types in the system @@ -159,6 +160,8 @@ using worker_index = generic_index #include -#include +#include #include diff --git a/libraries/chain/protocol/chain_parameters.cpp b/libraries/chain/protocol/chain_parameters.cpp deleted file mode 100644 index 2bfa624f..00000000 --- a/libraries/chain/protocol/chain_parameters.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include - -namespace graphene { namespace chain { - chain_parameters::chain_parameters() { - current_fees = std::make_shared(); - } -}} \ No newline at end of file diff --git a/libraries/chain/special_authority.cpp b/libraries/chain/special_authority.cpp index 74889f80..a92cc5e9 100644 --- a/libraries/chain/special_authority.cpp +++ b/libraries/chain/special_authority.cpp @@ -22,31 +22,13 @@ * THE SOFTWARE. */ -#include +#include #include #include namespace graphene { namespace chain { -struct special_authority_validate_visitor -{ - typedef void result_type; - - void operator()( const no_special_authority& a ) {} - - void operator()( const top_holders_special_authority& a ) - { - FC_ASSERT( a.num_top_holders > 0 ); - } -}; - -void validate_special_authority( const special_authority& a ) -{ - special_authority_validate_visitor vtor; - a.visit( vtor ); -} - struct special_authority_evaluate_visitor { typedef void result_type; @@ -57,7 +39,7 @@ struct special_authority_evaluate_visitor void operator()( const top_holders_special_authority& a ) { - a.asset(db); // require asset to exist + db.get(a.asset); // require asset to exist } const database& db; diff --git a/libraries/chain/witness_evaluator.cpp b/libraries/chain/witness_evaluator.cpp index 7bd261bb..dd45e743 100644 --- a/libraries/chain/witness_evaluator.cpp +++ b/libraries/chain/witness_evaluator.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include namespace graphene { namespace chain { @@ -40,7 +40,7 @@ object_id_type witness_create_evaluator::do_apply( const witness_create_operatio { try { vote_id_type vote_id; db().modify(db().get_global_properties(), [&vote_id](global_property_object& p) { - vote_id = get_next_vote_id(p, vote_id_type::witness); + vote_id = vote_id_type(vote_id_type::witness, p.next_available_vote_id++); }); const auto& new_witness_object = db().create( [&]( witness_object& obj ) { diff --git a/libraries/chain/worker_evaluator.cpp b/libraries/chain/worker_evaluator.cpp index b5aea8f3..b57396cf 100644 --- a/libraries/chain/worker_evaluator.cpp +++ b/libraries/chain/worker_evaluator.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include namespace graphene { namespace chain { @@ -84,8 +84,8 @@ object_id_type worker_create_evaluator::do_apply(const worker_create_evaluator:: database& d = db(); vote_id_type for_id, against_id; d.modify(d.get_global_properties(), [&for_id, &against_id](global_property_object& p) { - for_id = get_next_vote_id(p, vote_id_type::worker); - against_id = get_next_vote_id(p, vote_id_type::worker); + for_id = vote_id_type(vote_id_type::worker, p.next_available_vote_id++); + against_id = vote_id_type(vote_id_type::worker, p.next_available_vote_id++); }); return d.create([&](worker_object& w) { diff --git a/libraries/db/include/graphene/db/fwd.hpp b/libraries/db/include/graphene/db/fwd.hpp index 36b4e713..76c514dd 100644 --- a/libraries/db/include/graphene/db/fwd.hpp +++ b/libraries/db/include/graphene/db/fwd.hpp @@ -33,3 +33,4 @@ namespace graphene { namespace db { typedef std::shared_ptr peer_ram_ptr; }} // namespace graphene::db + diff --git a/libraries/db/include/graphene/db/generic_index.hpp b/libraries/db/include/graphene/db/generic_index.hpp index 2f760ee2..c272ec5b 100644 --- a/libraries/db/include/graphene/db/generic_index.hpp +++ b/libraries/db/include/graphene/db/generic_index.hpp @@ -28,7 +28,7 @@ #include #include -namespace graphene { namespace chain { +namespace graphene { namespace db { using boost::multi_index_container; using namespace boost::multi_index; diff --git a/libraries/db/include/graphene/db/object_database.hpp b/libraries/db/include/graphene/db/object_database.hpp index fa2109aa..8e91dbf4 100644 --- a/libraries/db/include/graphene/db/object_database.hpp +++ b/libraries/db/include/graphene/db/object_database.hpp @@ -121,11 +121,15 @@ namespace graphene { namespace db { return static_cast(obj); } - template - const T* find( object_id id )const { return find(id); } + template + auto find( object_id id )const -> const typename object_downcast::type* { + return find::type>(id); + } - template - const T& get( object_id id )const { return get(id); } + template + auto get( object_id id )const -> const typename object_downcast::type& { + return get::type>(id); + } template IndexType* add_index() diff --git a/libraries/db/include/graphene/db/object_id.hpp b/libraries/db/include/graphene/db/object_id.hpp index 255ef048..2d351181 100644 --- a/libraries/db/include/graphene/db/object_id.hpp +++ b/libraries/db/include/graphene/db/object_id.hpp @@ -93,14 +93,23 @@ namespace graphene { namespace db { class object; class object_database; - template + /// This template is used to downcast a generic object type to a specific xyz_object type. + template + struct object_downcast { using type = object; }; + // This macro specializes the above template for a specific xyz_object type +#define MAP_OBJECT_ID_TO_TYPE(OBJECT) \ + namespace graphene { namespace db { \ + template<> \ + struct object_downcast> { using type = OBJECT; }; \ + } } + + template struct object_id { - typedef T type; static const uint8_t space_id = SpaceID; static const uint8_t type_id = TypeID; - object_id(){} + object_id() = default; object_id( unsigned_int i ):instance(i){} explicit object_id( uint64_t i ):instance(i) { @@ -117,14 +126,18 @@ namespace graphene { namespace db { explicit operator uint64_t()const { return object_id_type( *this ).number; } template - const T& operator()(const DB& db)const { return db.get(*this); } + auto operator()(const DB& db)const -> const decltype(db.get(*this))& { return db.get(*this); } friend bool operator == ( const object_id& a, const object_id& b ) { return a.instance == b.instance; } friend bool operator != ( const object_id& a, const object_id& b ) { return a.instance != b.instance; } friend bool operator == ( const object_id_type& a, const object_id& b ) { return a == object_id_type(b); } friend bool operator != ( const object_id_type& a, const object_id& b ) { return a != object_id_type(b); } - friend bool operator == ( const object_id& b, const object_id_type& a ) { return a == object_id_type(b); } - friend bool operator != ( const object_id& b, const object_id_type& a ) { return a != object_id_type(b); } + friend bool operator == ( const object_id& a, const object_id_type& b ) { return object_id_type(a) == b; } + friend bool operator != ( const object_id& a, const object_id_type& b ) { return object_id_type(a) != b; } + friend bool operator == ( const object_id& a, const fc::unsigned_int& b ) { return a.instance == b; } + friend bool operator != ( const object_id& a, const fc::unsigned_int& b ) { return a.instance != b; } + friend bool operator == ( const fc::unsigned_int& a, const object_id& b ) { return a == b.instance; } + friend bool operator != ( const fc::unsigned_int& a, const object_id& b ) { return a != b.instance; } friend bool operator < ( const object_id& a, const object_id& b ) { return a.instance.value < b.instance.value; } friend bool operator > ( const object_id& a, const object_id& b ) { return a.instance.value > b.instance.value; } @@ -140,8 +153,8 @@ FC_REFLECT( graphene::db::object_id_type, (number) ) // REFLECT object_id manually because it has 2 template params namespace fc { -template -struct get_typename> +template +struct get_typename> { static const char* name() { return typeid(get_typename).name(); @@ -150,12 +163,11 @@ struct get_typename> } }; -template -struct reflector > +template +struct reflector > { - typedef graphene::db::object_id type; - typedef fc::true_type is_defined; - typedef fc::false_type is_enum; + typedef graphene::db::object_id type; + typedef std::true_type is_defined; enum member_count_enum { local_member_count = 1, total_member_count = 1 @@ -190,13 +202,13 @@ struct reflector > FC_ASSERT( type_id <= 0xff ); vo.number |= (space_id << 56) | (type_id << 48); } FC_CAPTURE_AND_RETHROW( (var) ) } - template - void to_variant( const graphene::db::object_id& var, fc::variant& vo, uint32_t max_depth = 1 ) + template + void to_variant( const graphene::db::object_id& var, fc::variant& vo, uint32_t max_depth = 1 ) { vo = fc::to_string(SpaceID) + "." + fc::to_string(TypeID) + "." + fc::to_string(var.instance.value); } - template - void from_variant( const fc::variant& var, graphene::db::object_id& vo, uint32_t max_depth = 1 ) + template + void from_variant( const fc::variant& var, graphene::db::object_id& vo, uint32_t max_depth = 1 ) { try { const auto& s = var.get_string(); auto first_dot = s.find('.'); diff --git a/libraries/egenesis/egenesis_brief.cpp.tmpl b/libraries/egenesis/egenesis_brief.cpp.tmpl index bd590eb3..bb4a7e58 100644 --- a/libraries/egenesis/egenesis_brief.cpp.tmpl +++ b/libraries/egenesis/egenesis_brief.cpp.tmpl @@ -17,7 +17,7 @@ ${generated_file_banner} * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include namespace graphene { namespace egenesis { diff --git a/libraries/egenesis/egenesis_full.cpp.tmpl b/libraries/egenesis/egenesis_full.cpp.tmpl index 83285f11..2b172fa0 100644 --- a/libraries/egenesis/egenesis_full.cpp.tmpl +++ b/libraries/egenesis/egenesis_full.cpp.tmpl @@ -17,7 +17,7 @@ ${generated_file_banner} * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include namespace graphene { namespace egenesis { diff --git a/libraries/egenesis/embed_genesis.cpp b/libraries/egenesis/embed_genesis.cpp index c2ffd686..b4c7d91c 100644 --- a/libraries/egenesis/embed_genesis.cpp +++ b/libraries/egenesis/embed_genesis.cpp @@ -34,10 +34,10 @@ #include #include #include -#include +#include // we need to include the world in order to serialize fee_parameters -#include +#include using namespace graphene::chain; diff --git a/libraries/egenesis/include/graphene/egenesis/egenesis.hpp b/libraries/egenesis/include/graphene/egenesis/egenesis.hpp index 848a4d29..8d575301 100644 --- a/libraries/egenesis/include/graphene/egenesis/egenesis.hpp +++ b/libraries/egenesis/include/graphene/egenesis/egenesis.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include namespace graphene { namespace egenesis { diff --git a/libraries/net/CMakeLists.txt b/libraries/net/CMakeLists.txt index 2594b053..202a792d 100644 --- a/libraries/net/CMakeLists.txt +++ b/libraries/net/CMakeLists.txt @@ -12,7 +12,7 @@ set(SOURCES node.cpp add_library( graphene_net ${SOURCES} ${HEADERS} ) target_link_libraries( graphene_net - PUBLIC fc graphene_db ) + PUBLIC fc graphene_db graphene_protocol ) target_include_directories( graphene_net PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../chain/include" "${CMAKE_CURRENT_BINARY_DIR}/../chain/include" diff --git a/libraries/net/include/graphene/net/core_messages.hpp b/libraries/net/include/graphene/net/core_messages.hpp index 8af0c344..39d68fba 100644 --- a/libraries/net/include/graphene/net/core_messages.hpp +++ b/libraries/net/include/graphene/net/core_messages.hpp @@ -24,7 +24,7 @@ #pragma once #include -#include +#include #include #include @@ -40,10 +40,10 @@ #include namespace graphene { namespace net { - using graphene::chain::signed_transaction; - using graphene::chain::block_id_type; - using graphene::chain::transaction_id_type; - using graphene::chain::signed_block; + using graphene::protocol::signed_transaction; + using graphene::protocol::block_id_type; + using graphene::protocol::transaction_id_type; + using graphene::protocol::signed_block; typedef fc::ecc::public_key_data node_id_t; typedef fc::ripemd160 item_hash_t; diff --git a/libraries/net/include/graphene/net/message.hpp b/libraries/net/include/graphene/net/message.hpp index 8f6d2b6e..1807eb16 100644 --- a/libraries/net/include/graphene/net/message.hpp +++ b/libraries/net/include/graphene/net/message.hpp @@ -24,7 +24,7 @@ #pragma once #include -#include +#include #include #include diff --git a/libraries/net/include/graphene/net/node.hpp b/libraries/net/include/graphene/net/node.hpp index e17af148..f68f3574 100644 --- a/libraries/net/include/graphene/net/node.hpp +++ b/libraries/net/include/graphene/net/node.hpp @@ -27,14 +27,14 @@ #include #include -#include +#include #include namespace graphene { namespace net { using fc::variant_object; - using graphene::chain::chain_id_type; + using graphene::protocol::chain_id_type; namespace detail { @@ -272,8 +272,8 @@ namespace graphene { namespace net { void set_advanced_node_parameters(const fc::variant_object& params); fc::variant_object get_advanced_node_parameters(); - message_propagation_data get_transaction_propagation_data(const graphene::chain::transaction_id_type& transaction_id); - message_propagation_data get_block_propagation_data(const graphene::chain::block_id_type& block_id); + message_propagation_data get_transaction_propagation_data(const graphene::protocol::transaction_id_type& transaction_id); + message_propagation_data get_block_propagation_data(const graphene::protocol::block_id_type& block_id); node_id_t get_node_id() const; void set_allowed_peers(const std::vector& allowed_peers); diff --git a/libraries/net/include/graphene/net/peer_database.hpp b/libraries/net/include/graphene/net/peer_database.hpp index ff7f4036..931f6e33 100644 --- a/libraries/net/include/graphene/net/peer_database.hpp +++ b/libraries/net/include/graphene/net/peer_database.hpp @@ -24,7 +24,7 @@ #pragma once #include -#include +#include #include #include diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index c15b0e08..c7177251 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -79,7 +79,10 @@ #include #include -#include +// Nasty hack: A circular dependency around fee_schedule is resolved by fwd-declaring it and using a shared_ptr +// to it in chain_parameters, which is used in an operation and thus must be serialized by the net library. +// Resolving that forward declaration doesn't happen until now: +#include #include diff --git a/libraries/net/peer_connection.cpp b/libraries/net/peer_connection.cpp index 9b753e6c..e5099e79 100644 --- a/libraries/net/peer_connection.cpp +++ b/libraries/net/peer_connection.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include diff --git a/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp b/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp index 784c7e45..986869ff 100644 --- a/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp +++ b/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp @@ -94,7 +94,7 @@ class affiliate_reward_index : public secondary_index } } //graphene::account_history -/*struct by_id; +/* struct by_seq; struct by_op; typedef boost::multi_index_container< 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 907d26ae..0965345e 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 @@ -25,7 +25,7 @@ #include #include -#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 599fc65c..413f6b9d 100644 --- a/libraries/plugins/delayed_node/delayed_node_plugin.cpp +++ b/libraries/plugins/delayed_node/delayed_node_plugin.cpp @@ -23,7 +23,7 @@ */ #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 48c215f0..baa6c3c2 100644 --- a/libraries/plugins/market_history/market_history_plugin.cpp +++ b/libraries/plugins/market_history/market_history_plugin.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include diff --git a/libraries/protocol/CMakeLists.txt b/libraries/protocol/CMakeLists.txt new file mode 100644 index 00000000..51932639 --- /dev/null +++ b/libraries/protocol/CMakeLists.txt @@ -0,0 +1,54 @@ +file(GLOB HEADERS "include/graphene/protocol/*.hpp") + +list(APPEND SOURCES account.cpp + assert.cpp + asset_ops.cpp + block.cpp + confidential.cpp + chain_parameters.cpp + fee_schedule.cpp + memo.cpp + proposal.cpp + transfer.cpp + vote.cpp + witness.cpp + address.cpp + asset.cpp + authority.cpp + special_authority.cpp + committee_member.cpp + custom.cpp + market.cpp + operations.cpp + pts_address.cpp + transaction.cpp + types.cpp + withdraw_permission.cpp + worker.cpp + betting_market.cpp + competitor.cpp + event.cpp + event_group.cpp + lottery_ops.cpp + small_ops.cpp + sport.cpp + tournament.cpp + small_ops.cpp + custom_permission.cpp + custom_account_authority.cpp + offer.cpp + ) + + +add_library( graphene_protocol ${SOURCES} ${HEADERS} ) +target_link_libraries( graphene_protocol graphene_db fc ) +target_include_directories( graphene_protocol PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) + +install( TARGETS + graphene_protocol + + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) +install( FILES ${HEADERS} DESTINATION "include/graphene/protocol" ) diff --git a/libraries/chain/protocol/account.cpp b/libraries/protocol/account.cpp similarity index 89% rename from libraries/chain/protocol/account.cpp rename to libraries/protocol/account.cpp index c79811b9..b5180978 100644 --- a/libraries/chain/protocol/account.cpp +++ b/libraries/protocol/account.cpp @@ -21,13 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include -#include +#include -#include - -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * Names must comply with the following grammar (RFC 1035): @@ -322,16 +318,16 @@ void account_transfer_operation::validate()const } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_whitelist_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_upgrade_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_whitelist_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_upgrade_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_whitelist_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_upgrade_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_whitelist_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_upgrade_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::account_transfer_operation ) diff --git a/libraries/chain/protocol/address.cpp b/libraries/protocol/address.cpp similarity index 87% rename from libraries/chain/protocol/address.cpp rename to libraries/protocol/address.cpp index 3065d80b..7f1fb301 100644 --- a/libraries/chain/protocol/address.cpp +++ b/libraries/protocol/address.cpp @@ -21,17 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include +#include #include #include #include -#include - -namespace graphene { - namespace chain { - +namespace graphene { namespace protocol { address::address( const std::string& base58str ) { std::string prefix( GRAPHENE_ADDRESS_PREFIX ); @@ -84,7 +80,7 @@ namespace graphene { addr = fc::ripemd160::hash( fc::sha512::hash( (char*) pub.data(), pub.size() ) ); } - address::address( const graphene::chain::public_key_type& pub ) + address::address( const graphene::protocol::public_key_type& pub ) { addr = fc::ripemd160::hash( fc::sha512::hash( (char*) pub.key_data.data(), pub.key_data.size() ) ); } @@ -99,17 +95,17 @@ namespace graphene { return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( bin_addr.data(), bin_addr.size() ); } -} } // namespace graphene::chain +} } // namespace graphene::protocol namespace fc { - void to_variant( const graphene::chain::address& var, variant& vo, uint32_t max_depth ) + void to_variant( const graphene::protocol::address& var, variant& vo, uint32_t max_depth ) { vo = std::string(var); } - void from_variant( const variant& var, graphene::chain::address& vo, uint32_t max_depth ) + void from_variant( const variant& var, graphene::protocol::address& vo, uint32_t max_depth ) { - vo = graphene::chain::address( var.as_string() ); + vo = graphene::protocol::address( var.as_string() ); } } diff --git a/libraries/chain/protocol/assert.cpp b/libraries/protocol/assert.cpp similarity index 81% rename from libraries/chain/protocol/assert.cpp rename to libraries/protocol/assert.cpp index 5ce61e45..6ab539a8 100644 --- a/libraries/chain/protocol/assert.cpp +++ b/libraries/protocol/assert.cpp @@ -21,13 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include -#include +#include -#include - -namespace graphene { namespace chain { +namespace graphene { namespace protocol { bool account_name_eq_lit_predicate::validate()const { @@ -66,7 +62,7 @@ share_type assert_operation::calculate_fee(const fee_parameters_type& k)const return k.fee * predicates.size(); } -} } // namespace graphene::chain +} } // namespace graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::assert_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::assert_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::assert_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::assert_operation ) diff --git a/libraries/chain/protocol/asset.cpp b/libraries/protocol/asset.cpp similarity index 96% rename from libraries/chain/protocol/asset.cpp rename to libraries/protocol/asset.cpp index ebff3518..d7f52813 100644 --- a/libraries/chain/protocol/asset.cpp +++ b/libraries/protocol/asset.cpp @@ -21,13 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include #include #include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { typedef boost::multiprecision::uint128_t uint128_t; typedef boost::multiprecision::int128_t int128_t; @@ -207,8 +207,8 @@ const int64_t scaled_precision_lut[19] = p10< 16 >::v, p10< 17 >::v, p10< 18 >::v }; -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::price ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::price_feed ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::price ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::price_feed ) diff --git a/libraries/chain/protocol/asset_ops.cpp b/libraries/protocol/asset_ops.cpp similarity index 75% rename from libraries/chain/protocol/asset_ops.cpp rename to libraries/protocol/asset_ops.cpp index 5dfd09ee..614d54b2 100644 --- a/libraries/chain/protocol/asset_ops.cpp +++ b/libraries/protocol/asset_ops.cpp @@ -21,12 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * Valid symbols can contain [A-Z0-9], and '.' @@ -289,31 +288,31 @@ void lottery_asset_options::validate() const FC_ASSERT( total == GRAPHENE_100_PERCENT, "distribution amount not equals GRAPHENE_100_PERCENT" ); } -} } // namespace graphene::chain +} } // namespace graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::bitasset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_global_settle_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_settle_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_fund_fee_pool_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_claim_fees_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_bitasset_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_feed_producers_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_publish_feed_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_issue_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_reserve_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_global_settle_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_settle_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_settle_cancel_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_fund_fee_pool_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_claim_fees_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_dividend_distribution_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_bitasset_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_update_feed_producers_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_publish_feed_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_issue_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::asset_reserve_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::bitasset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_global_settle_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_settle_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_fund_fee_pool_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_claim_fees_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_bitasset_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_feed_producers_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_publish_feed_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_issue_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_reserve_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_global_settle_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_settle_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_settle_cancel_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_fund_fee_pool_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_claim_fees_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_dividend_distribution_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_bitasset_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_update_feed_producers_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_publish_feed_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_issue_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::asset_reserve_operation ) diff --git a/libraries/chain/protocol/authority.cpp b/libraries/protocol/authority.cpp similarity index 86% rename from libraries/chain/protocol/authority.cpp rename to libraries/protocol/authority.cpp index 6cfed2ec..241942fc 100644 --- a/libraries/chain/protocol/authority.cpp +++ b/libraries/protocol/authority.cpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void add_authority_accounts( flat_set& result, @@ -36,6 +35,6 @@ void add_authority_accounts( result.insert( item.first ); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::authority ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::authority ) diff --git a/libraries/chain/protocol/betting_market.cpp b/libraries/protocol/betting_market.cpp similarity index 100% rename from libraries/chain/protocol/betting_market.cpp rename to libraries/protocol/betting_market.cpp diff --git a/libraries/chain/protocol/block.cpp b/libraries/protocol/block.cpp similarity index 96% rename from libraries/chain/protocol/block.cpp rename to libraries/protocol/block.cpp index 11680bb5..ddf6ae6d 100644 --- a/libraries/chain/protocol/block.cpp +++ b/libraries/protocol/block.cpp @@ -21,13 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include #include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { digest_type block_header::digest()const { return digest_type::hash(*this); diff --git a/libraries/protocol/chain_parameters.cpp b/libraries/protocol/chain_parameters.cpp new file mode 100644 index 00000000..7203d76e --- /dev/null +++ b/libraries/protocol/chain_parameters.cpp @@ -0,0 +1,8 @@ +#include +#include + +namespace graphene { namespace protocol { + chain_parameters::chain_parameters() { + current_fees = std::make_shared(); + } +}} \ No newline at end of file diff --git a/libraries/chain/protocol/committee_member.cpp b/libraries/protocol/committee_member.cpp similarity index 64% rename from libraries/chain/protocol/committee_member.cpp rename to libraries/protocol/committee_member.cpp index 3ce62783..12d32a71 100644 --- a/libraries/chain/protocol/committee_member.cpp +++ b/libraries/protocol/committee_member.cpp @@ -21,12 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include -#include - -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void committee_member_create_operation::validate()const { @@ -47,11 +44,11 @@ void committee_member_update_global_parameters_operation::validate() const new_parameters.validate(); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_update_global_parameters_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::committee_member_update_global_parameters_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_update_global_parameters_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::committee_member_update_global_parameters_operation ) diff --git a/libraries/chain/protocol/competitor.cpp b/libraries/protocol/competitor.cpp similarity index 100% rename from libraries/chain/protocol/competitor.cpp rename to libraries/protocol/competitor.cpp diff --git a/libraries/chain/protocol/confidential.cpp b/libraries/protocol/confidential.cpp similarity index 86% rename from libraries/chain/protocol/confidential.cpp rename to libraries/protocol/confidential.cpp index 2e8fbc68..f7d03f58 100644 --- a/libraries/chain/protocol/confidential.cpp +++ b/libraries/protocol/confidential.cpp @@ -21,14 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include -#include + +#include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void transfer_to_blind_operation::validate()const { @@ -155,11 +154,12 @@ stealth_confirmation::stealth_confirmation( const std::string& base58 ) *this = fc::raw::unpack( fc::from_base58( base58 ) ); } -} } // graphene::chain +} } // graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_to_blind_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_from_blind_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::blind_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_to_blind_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_from_blind_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::blind_transfer_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_to_blind_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_from_blind_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::blind_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_to_blind_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_from_blind_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::blind_transfer_operation ) diff --git a/libraries/chain/protocol/custom.cpp b/libraries/protocol/custom.cpp similarity index 93% rename from libraries/chain/protocol/custom.cpp rename to libraries/protocol/custom.cpp index 72f8dd44..c64e2e4c 100644 --- a/libraries/chain/protocol/custom.cpp +++ b/libraries/protocol/custom.cpp @@ -21,11 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include -#include - -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void custom_operation::validate()const { diff --git a/libraries/chain/protocol/custom_account_authority.cpp b/libraries/protocol/custom_account_authority.cpp similarity index 100% rename from libraries/chain/protocol/custom_account_authority.cpp rename to libraries/protocol/custom_account_authority.cpp diff --git a/libraries/chain/protocol/custom_permission.cpp b/libraries/protocol/custom_permission.cpp similarity index 100% rename from libraries/chain/protocol/custom_permission.cpp rename to libraries/protocol/custom_permission.cpp diff --git a/libraries/chain/protocol/event.cpp b/libraries/protocol/event.cpp similarity index 100% rename from libraries/chain/protocol/event.cpp rename to libraries/protocol/event.cpp diff --git a/libraries/chain/protocol/event_group.cpp b/libraries/protocol/event_group.cpp similarity index 100% rename from libraries/chain/protocol/event_group.cpp rename to libraries/protocol/event_group.cpp diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/protocol/fee_schedule.cpp similarity index 97% rename from libraries/chain/protocol/fee_schedule.cpp rename to libraries/protocol/fee_schedule.cpp index 7410cddf..5375637b 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/protocol/fee_schedule.cpp @@ -22,14 +22,14 @@ * THE SOFTWARE. */ #include -#include +#include #include #include #define MAX_FEE_STABILIZATION_ITERATION 4 -namespace graphene { namespace chain { +namespace graphene { namespace protocol { fee_schedule::fee_schedule() { @@ -195,6 +195,6 @@ namespace graphene { namespace chain { } } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::fee_schedule ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::fee_schedule ) diff --git a/libraries/chain/include/graphene/chain/protocol/README.md b/libraries/protocol/include/graphene/protocol/README.md similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/README.md rename to libraries/protocol/include/graphene/protocol/README.md diff --git a/libraries/chain/include/graphene/chain/protocol/account.hpp b/libraries/protocol/include/graphene/protocol/account.hpp similarity index 79% rename from libraries/chain/include/graphene/chain/protocol/account.hpp rename to libraries/protocol/include/graphene/protocol/account.hpp index 36926480..6eacf675 100644 --- a/libraries/chain/include/graphene/chain/protocol/account.hpp +++ b/libraries/protocol/include/graphene/protocol/account.hpp @@ -22,14 +22,14 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { bool is_valid_name( const string& s ); bool is_cheap_name( const string& n ); @@ -284,49 +284,50 @@ namespace graphene { namespace chain { void validate()const; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT(graphene::chain::account_options, (memo_key)(voting_account)(num_witness)(num_committee)(votes)(extensions)) -// FC_REFLECT_TYPENAME( graphene::chain::account_whitelist_operation::account_listing) -FC_REFLECT_ENUM( graphene::chain::account_whitelist_operation::account_listing, +FC_REFLECT(graphene::protocol::account_options, (memo_key)(voting_account)(num_witness)(num_committee)(votes)(extensions)) +FC_REFLECT_ENUM( graphene::protocol::account_whitelist_operation::account_listing, (no_listing)(white_listed)(black_listed)(white_and_black_listed)) -FC_REFLECT_ENUM( graphene::chain::app_tag, (bookie)(rps) ) -FC_REFLECT( graphene::chain::affiliate_reward_distribution, (_dist) ); -FC_REFLECT( graphene::chain::affiliate_reward_distributions, (_dists) ); +FC_REFLECT_ENUM( graphene::protocol::app_tag, (bookie)(rps) ) +FC_REFLECT( graphene::protocol::affiliate_reward_distribution, (_dist) ); +FC_REFLECT( graphene::protocol::affiliate_reward_distributions, (_dists) ); -FC_REFLECT(graphene::chain::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options) ) -FC_REFLECT( graphene::chain::account_create_operation, +FC_REFLECT(graphene::protocol::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options) ) +FC_REFLECT_TYPENAME(graphene::protocol::extension) +FC_REFLECT( graphene::protocol::account_create_operation, (fee)(registrar) (referrer)(referrer_percent) (name)(owner)(active)(options)(extensions) ) -FC_REFLECT(graphene::chain::account_update_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(update_last_voting_time) ) -FC_REFLECT( graphene::chain::account_update_operation, +FC_REFLECT(graphene::protocol::account_update_operation::ext, (null_ext)(owner_special_authority)(active_special_authority) ) +FC_REFLECT_TYPENAME(graphene::protocol::extension) +FC_REFLECT( graphene::protocol::account_update_operation, (fee)(account)(owner)(active)(new_options)(extensions) ) -FC_REFLECT( graphene::chain::account_upgrade_operation, +FC_REFLECT( graphene::protocol::account_upgrade_operation, (fee)(account_to_upgrade)(upgrade_to_lifetime_member)(extensions) ) -FC_REFLECT( graphene::chain::account_whitelist_operation, (fee)(authorizing_account)(account_to_list)(new_listing)(extensions)) +FC_REFLECT( graphene::protocol::account_whitelist_operation, (fee)(authorizing_account)(account_to_list)(new_listing)(extensions)) -FC_REFLECT( graphene::chain::account_create_operation::fee_parameters_type, (basic_fee)(premium_fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::account_whitelist_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::account_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::account_upgrade_operation::fee_parameters_type, (membership_annual_fee)(membership_lifetime_fee) ) -FC_REFLECT( graphene::chain::account_transfer_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::account_transfer_operation, (fee)(account_id)(new_owner)(extensions) ) +FC_REFLECT( graphene::protocol::account_create_operation::fee_parameters_type, (basic_fee)(premium_fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::account_whitelist_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::account_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::account_upgrade_operation::fee_parameters_type, (membership_annual_fee)(membership_lifetime_fee) ) +FC_REFLECT( graphene::protocol::account_transfer_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::account_transfer_operation, (fee)(account_id)(new_owner)(extensions) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_whitelist_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_upgrade_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_whitelist_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_upgrade_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::account_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_whitelist_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_upgrade_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_whitelist_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_upgrade_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::account_transfer_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/address.hpp b/libraries/protocol/include/graphene/protocol/address.hpp similarity index 79% rename from libraries/chain/include/graphene/chain/protocol/address.hpp rename to libraries/protocol/include/graphene/protocol/address.hpp index 39e3bf36..e29743ab 100644 --- a/libraries/chain/include/graphene/chain/protocol/address.hpp +++ b/libraries/protocol/include/graphene/protocol/address.hpp @@ -23,14 +23,13 @@ */ #pragma once -#include -#include -#include +#include +#include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct public_key_type; @@ -70,15 +69,28 @@ namespace graphene { namespace chain { inline bool operator != ( const address& a, const address& b ) { return a.addr != b.addr; } inline bool operator < ( const address& a, const address& b ) { return a.addr < b.addr; } -} } // namespace graphene::chain +} } // namespace graphene::protocol namespace fc { - void to_variant( const graphene::chain::address& var, fc::variant& vo, uint32_t max_depth = 1 ); - void from_variant( const fc::variant& var, graphene::chain::address& vo, uint32_t max_depth = 1 ); + void to_variant( const graphene::protocol::address& var, fc::variant& vo, uint32_t max_depth = 1 ); + void from_variant( const fc::variant& var, graphene::protocol::address& vo, uint32_t max_depth = 1 ); +} + +namespace std +{ + template<> + struct hash + { + public: + size_t operator()(const graphene::protocol::address &a) const + { + return (uint64_t(a.addr._hash[0])<<32) | uint64_t( a.addr._hash[0] ); + } + }; } #include -FC_REFLECT( graphene::chain::address, (addr) ) +FC_REFLECT( graphene::protocol::address, (addr) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::address ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::address ) diff --git a/libraries/chain/include/graphene/chain/protocol/affiliate.hpp b/libraries/protocol/include/graphene/protocol/affiliate.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/affiliate.hpp rename to libraries/protocol/include/graphene/protocol/affiliate.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/assert.hpp b/libraries/protocol/include/graphene/protocol/assert.hpp similarity index 85% rename from libraries/chain/include/graphene/chain/protocol/assert.hpp rename to libraries/protocol/include/graphene/protocol/assert.hpp index ce758862..0e780247 100644 --- a/libraries/chain/include/graphene/chain/protocol/assert.hpp +++ b/libraries/protocol/include/graphene/protocol/assert.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * Used to verify that account_id->name is equal to the given string literal. @@ -104,14 +103,14 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::assert_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::account_name_eq_lit_predicate, (account_id)(name) ) -FC_REFLECT( graphene::chain::asset_symbol_eq_lit_predicate, (asset_id)(symbol) ) -FC_REFLECT( graphene::chain::block_id_predicate, (id) ) -FC_REFLECT_TYPENAME( graphene::chain::predicate ) -FC_REFLECT( graphene::chain::assert_operation, (fee)(fee_paying_account)(predicates)(required_auths)(extensions) ) +FC_REFLECT( graphene::protocol::assert_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::account_name_eq_lit_predicate, (account_id)(name) ) +FC_REFLECT( graphene::protocol::asset_symbol_eq_lit_predicate, (asset_id)(symbol) ) +FC_REFLECT( graphene::protocol::block_id_predicate, (id) ) +FC_REFLECT_TYPENAME( graphene::protocol::predicate ) +FC_REFLECT( graphene::protocol::assert_operation, (fee)(fee_paying_account)(predicates)(required_auths)(extensions) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::assert_operation::fee_parameters_type ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::assert_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/asset.hpp b/libraries/protocol/include/graphene/protocol/asset.hpp similarity index 94% rename from libraries/chain/include/graphene/chain/protocol/asset.hpp rename to libraries/protocol/include/graphene/protocol/asset.hpp index 60bd3cd0..9798e520 100644 --- a/libraries/chain/include/graphene/chain/protocol/asset.hpp +++ b/libraries/protocol/include/graphene/protocol/asset.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { extern const int64_t scaled_precision_lut[]; @@ -211,14 +211,14 @@ namespace graphene { namespace chain { } } -FC_REFLECT( graphene::chain::asset, (amount)(asset_id) ) -FC_REFLECT( graphene::chain::price, (base)(quote) ) +FC_REFLECT( graphene::protocol::asset, (amount)(asset_id) ) +FC_REFLECT( graphene::protocol::price, (base)(quote) ) #define GRAPHENE_PRICE_FEED_FIELDS (settlement_price)(maintenance_collateral_ratio)(maximum_short_squeeze_ratio) \ (core_exchange_rate) -FC_REFLECT( graphene::chain::price_feed, GRAPHENE_PRICE_FEED_FIELDS ) +FC_REFLECT( graphene::protocol::price_feed, GRAPHENE_PRICE_FEED_FIELDS ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::price ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::price_feed ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::price ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::price_feed ) diff --git a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp b/libraries/protocol/include/graphene/protocol/asset_ops.hpp similarity index 83% rename from libraries/chain/include/graphene/chain/protocol/asset_ops.hpp rename to libraries/protocol/include/graphene/protocol/asset_ops.hpp index ae5dc211..743197ae 100644 --- a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/asset_ops.hpp @@ -22,11 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { - class database; +namespace graphene { namespace protocol { bool is_valid_symbol( const string& symbol ); @@ -646,15 +645,15 @@ namespace graphene { namespace chain { void validate()const {}; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::sweeps_vesting_claim_operation, (fee)(account)(amount_to_claim)(extensions) ) -FC_REFLECT( graphene::chain::sweeps_vesting_claim_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::sweeps_vesting_claim_operation, (fee)(account)(amount_to_claim)(extensions) ) +FC_REFLECT( graphene::protocol::sweeps_vesting_claim_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_claim_fees_operation, (fee)(issuer)(amount_to_claim)(extensions) ) -FC_REFLECT( graphene::chain::asset_claim_fees_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_claim_fees_operation, (fee)(issuer)(amount_to_claim)(extensions) ) +FC_REFLECT( graphene::protocol::asset_claim_fees_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_options, +FC_REFLECT( graphene::protocol::asset_options, (max_supply) (market_fee_percent) (max_market_fee) @@ -669,7 +668,7 @@ FC_REFLECT( graphene::chain::asset_options, (extensions) ) -FC_REFLECT( graphene::chain::dividend_asset_options, +FC_REFLECT( graphene::protocol::dividend_asset_options, (next_payout_time) (payout_interval) (minimum_fee_percentage) @@ -677,7 +676,7 @@ FC_REFLECT( graphene::chain::dividend_asset_options, (extensions) ) -FC_REFLECT( graphene::chain::bitasset_options, +FC_REFLECT( graphene::protocol::bitasset_options, (feed_lifetime_sec) (minimum_feeds) (force_settlement_delay_sec) @@ -687,27 +686,26 @@ FC_REFLECT( graphene::chain::bitasset_options, (extensions) ) -FC_REFLECT( graphene::chain::benefactor, (id)(share) ) +FC_REFLECT( graphene::protocol::benefactor, (id)(share) ) -FC_REFLECT( graphene::chain::lottery_asset_options, (benefactors)(owner)(winning_tickets)(ticket_price)(end_date)(ending_on_soldout)(is_active) ) +FC_REFLECT( graphene::protocol::lottery_asset_options, (benefactors)(owner)(winning_tickets)(ticket_price)(end_date)(ending_on_soldout)(is_active) ) +FC_REFLECT( graphene::protocol::asset_create_operation::fee_parameters_type, (symbol3)(symbol4)(long_symbol)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::lottery_asset_create_operation::fee_parameters_type, (lottery_asset)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::asset_global_settle_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_settle_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_settle_cancel_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::asset_fund_fee_pool_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::asset_update_bitasset_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_update_dividend_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_update_feed_producers_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_publish_feed_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_issue_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::asset_reserve_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::asset_dividend_distribution_operation::fee_parameters_type, (distribution_base_fee)(distribution_fee_per_holder)) -FC_REFLECT( graphene::chain::asset_create_operation::fee_parameters_type, (symbol3)(symbol4)(long_symbol)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::lottery_asset_create_operation::fee_parameters_type, (lottery_asset)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::asset_global_settle_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_settle_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_settle_cancel_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::asset_fund_fee_pool_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::asset_update_bitasset_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_update_dividend_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_update_feed_producers_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_publish_feed_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_issue_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::asset_reserve_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::asset_dividend_distribution_operation::fee_parameters_type, (distribution_base_fee)(distribution_fee_per_holder)) - -FC_REFLECT( graphene::chain::asset_create_operation, +FC_REFLECT( graphene::protocol::asset_create_operation, (fee) (issuer) (symbol) @@ -717,7 +715,7 @@ FC_REFLECT( graphene::chain::asset_create_operation, (is_prediction_market) (extensions) ) -FC_REFLECT( graphene::chain::lottery_asset_create_operation, +FC_REFLECT( graphene::protocol::lottery_asset_create_operation, (fee) (issuer) (symbol) @@ -727,7 +725,7 @@ FC_REFLECT( graphene::chain::lottery_asset_create_operation, (is_prediction_market) (extensions) ) -FC_REFLECT( graphene::chain::asset_update_operation, +FC_REFLECT( graphene::protocol::asset_update_operation, (fee) (issuer) (asset_to_update) @@ -735,7 +733,7 @@ FC_REFLECT( graphene::chain::asset_update_operation, (new_options) (extensions) ) -FC_REFLECT( graphene::chain::asset_update_bitasset_operation, +FC_REFLECT( graphene::protocol::asset_update_issuer_operation, (fee) (issuer) (asset_to_update) @@ -749,45 +747,52 @@ FC_REFLECT( graphene::chain::asset_update_dividend_operation, (new_options) (extensions) ) -FC_REFLECT( graphene::chain::asset_update_feed_producers_operation, +FC_REFLECT( graphene::protocol::asset_update_bitasset_operation, + (fee) + (issuer) + (asset_to_update) + (new_options) + (extensions) + ) +FC_REFLECT( graphene::protocol::asset_update_feed_producers_operation, (fee)(issuer)(asset_to_update)(new_feed_producers)(extensions) ) -FC_REFLECT( graphene::chain::asset_publish_feed_operation, +FC_REFLECT( graphene::protocol::asset_publish_feed_operation, (fee)(publisher)(asset_id)(feed)(extensions) ) -FC_REFLECT( graphene::chain::asset_settle_operation, (fee)(account)(amount)(extensions) ) -FC_REFLECT( graphene::chain::asset_settle_cancel_operation, (fee)(settlement)(account)(amount)(extensions) ) -FC_REFLECT( graphene::chain::asset_global_settle_operation, (fee)(issuer)(asset_to_settle)(settle_price)(extensions) ) -FC_REFLECT( graphene::chain::asset_issue_operation, +FC_REFLECT( graphene::protocol::asset_settle_operation, (fee)(account)(amount)(extensions) ) +FC_REFLECT( graphene::protocol::asset_settle_cancel_operation, (fee)(settlement)(account)(amount)(extensions) ) +FC_REFLECT( graphene::protocol::asset_global_settle_operation, (fee)(issuer)(asset_to_settle)(settle_price)(extensions) ) +FC_REFLECT( graphene::protocol::asset_issue_operation, (fee)(issuer)(asset_to_issue)(issue_to_account)(memo)(extensions) ) -FC_REFLECT( graphene::chain::asset_reserve_operation, +FC_REFLECT( graphene::protocol::asset_reserve_operation, (fee)(payer)(amount_to_reserve)(extensions) ) -FC_REFLECT( graphene::chain::asset_fund_fee_pool_operation, (fee)(from_account)(asset_id)(amount)(extensions) ); -FC_REFLECT( graphene::chain::asset_dividend_distribution_operation, (fee)(dividend_asset_id)(account_id)(amounts)(extensions) ); +FC_REFLECT( graphene::protocol::asset_fund_fee_pool_operation, (fee)(from_account)(asset_id)(amount)(extensions) ); +FC_REFLECT( graphene::protocol::asset_dividend_distribution_operation, (fee)(dividend_asset_id)(account_id)(amounts)(extensions) ); -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::bitasset_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_global_settle_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_settle_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_fund_fee_pool_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_dividend_distribution_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_claim_fees_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_bitasset_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_feed_producers_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_publish_feed_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_issue_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_reserve_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_global_settle_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_settle_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_settle_cancel_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_fund_fee_pool_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_claim_fees_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_bitasset_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_update_feed_producers_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_publish_feed_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_issue_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::asset_reserve_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::bitasset_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_global_settle_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_settle_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_fund_fee_pool_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_dividend_distribution_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_claim_fees_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_bitasset_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_feed_producers_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_publish_feed_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_issue_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_reserve_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_global_settle_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_settle_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_settle_cancel_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_fund_fee_pool_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_claim_fees_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_bitasset_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_update_feed_producers_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_publish_feed_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_issue_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::asset_reserve_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/authority.hpp b/libraries/protocol/include/graphene/protocol/authority.hpp similarity index 89% rename from libraries/chain/include/graphene/chain/protocol/authority.hpp rename to libraries/protocol/include/graphene/protocol/authority.hpp index d279402d..944f7a79 100644 --- a/libraries/chain/include/graphene/chain/protocol/authority.hpp +++ b/libraries/protocol/include/graphene/protocol/authority.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @class authority @@ -130,10 +129,9 @@ void add_authority_accounts( const authority& a ); -} } // namespace graphene::chain +} } // namespace graphene::protocol -FC_REFLECT( graphene::chain::authority, (weight_threshold)(account_auths)(key_auths)(address_auths) ) -// FC_REFLECT_TYPENAME( graphene::chain::authority::classification ) -FC_REFLECT_ENUM( graphene::chain::authority::classification, (owner)(active)(key) ) +FC_REFLECT( graphene::protocol::authority, (weight_threshold)(account_auths)(key_auths)(address_auths) ) +FC_REFLECT_ENUM( graphene::protocol::authority::classification, (owner)(active)(key) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::authority ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::authority ) diff --git a/libraries/chain/include/graphene/chain/protocol/balance.hpp b/libraries/protocol/include/graphene/protocol/balance.hpp similarity index 85% rename from libraries/chain/include/graphene/chain/protocol/balance.hpp rename to libraries/protocol/include/graphene/protocol/balance.hpp index 9d0b252f..076697d9 100644 --- a/libraries/chain/include/graphene/chain/protocol/balance.hpp +++ b/libraries/protocol/include/graphene/protocol/balance.hpp @@ -22,14 +22,12 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** - * @brief Claim a balance in a @ref balanc_object + * @brief Claim a balance in a @ref balance_object * * This operation is used to claim the balance in a given @ref balance_object. If the balance object contains a * vesting balance, @ref total_claimed must not exceed @ref balance_object::available at the time of evaluation. If @@ -54,10 +52,10 @@ namespace graphene { namespace chain { } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::balance_claim_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::balance_claim_operation, +FC_REFLECT( graphene::protocol::balance_claim_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::balance_claim_operation, (fee)(deposit_to_account)(balance_to_claim)(balance_owner_key)(total_claimed) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::balance_claim_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/base.hpp b/libraries/protocol/include/graphene/protocol/base.hpp similarity index 93% rename from libraries/chain/include/graphene/chain/protocol/base.hpp rename to libraries/protocol/include/graphene/protocol/base.hpp index 676d28ff..29d2b237 100644 --- a/libraries/chain/include/graphene/chain/protocol/base.hpp +++ b/libraries/protocol/include/graphene/protocol/base.hpp @@ -23,13 +23,13 @@ */ #pragma once -#include -#include -#include +#include +#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct asset; struct authority; @@ -122,8 +122,8 @@ namespace graphene { namespace chain { ///@} -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT_TYPENAME( graphene::chain::operation_result ) -FC_REFLECT_TYPENAME( graphene::chain::future_extensions ) -FC_REFLECT( graphene::chain::void_result, ) +FC_REFLECT_TYPENAME( graphene::protocol::operation_result ) +FC_REFLECT_TYPENAME( graphene::protocol::future_extensions ) +FC_REFLECT( graphene::protocol::void_result, ) diff --git a/libraries/chain/include/graphene/chain/protocol/betting_market.hpp b/libraries/protocol/include/graphene/protocol/betting_market.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/betting_market.hpp rename to libraries/protocol/include/graphene/protocol/betting_market.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/block.hpp b/libraries/protocol/include/graphene/protocol/block.hpp similarity index 80% rename from libraries/chain/include/graphene/chain/protocol/block.hpp rename to libraries/protocol/include/graphene/protocol/block.hpp index ad5b0327..67c633ed 100644 --- a/libraries/chain/include/graphene/chain/protocol/block.hpp +++ b/libraries/protocol/include/graphene/protocol/block.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct block_header { @@ -57,9 +57,9 @@ namespace graphene { namespace chain { vector transactions; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::block_header, +FC_REFLECT( graphene::protocol::block_header, (previous) (timestamp) (witness) @@ -67,10 +67,10 @@ FC_REFLECT( graphene::chain::block_header, (previous_secret) (transaction_merkle_root) (extensions) ) -FC_REFLECT_DERIVED( graphene::chain::signed_block_header, (graphene::chain::block_header), (witness_signature) ) -FC_REFLECT_DERIVED( graphene::chain::signed_block, (graphene::chain::signed_block_header), (transactions) ) +FC_REFLECT_DERIVED( graphene::protocol::signed_block_header, (graphene::protocol::block_header), (witness_signature) ) +FC_REFLECT_DERIVED( graphene::protocol::signed_block, (graphene::protocol::signed_block_header), (transactions) ) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::block_header) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::signed_block_header) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::signed_block) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::block_header) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_block_header) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_block) diff --git a/libraries/chain/include/graphene/chain/protocol/buyback.hpp b/libraries/protocol/include/graphene/protocol/buyback.hpp similarity index 85% rename from libraries/chain/include/graphene/chain/protocol/buyback.hpp rename to libraries/protocol/include/graphene/protocol/buyback.hpp index 4a51e8c7..9f58beca 100644 --- a/libraries/chain/include/graphene/chain/protocol/buyback.hpp +++ b/libraries/protocol/include/graphene/protocol/buyback.hpp @@ -23,9 +23,9 @@ */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct buyback_account_options { @@ -49,6 +49,6 @@ struct buyback_account_options } } -FC_REFLECT( graphene::chain::buyback_account_options, (asset_to_buy)(asset_to_buy_issuer)(markets) ); +FC_REFLECT( graphene::protocol::buyback_account_options, (asset_to_buy)(asset_to_buy_issuer)(markets) ); -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::buyback_account_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::buyback_account_options ) diff --git a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp similarity index 97% rename from libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp rename to libraries/protocol/include/graphene/protocol/chain_parameters.hpp index d07f613b..2121dca2 100644 --- a/libraries/chain/include/graphene/chain/protocol/chain_parameters.hpp +++ b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp @@ -22,17 +22,16 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -#include +#include #include <../hardfork.d/GPOS.hf> #include +#include +#include -namespace graphene { namespace chain { struct fee_schedule; } } +namespace graphene { namespace protocol { + struct fee_schedule; -namespace graphene { namespace chain { struct parameter_extension { optional< bet_multiplier_type > min_bet_multiplier; @@ -153,9 +152,9 @@ namespace graphene { namespace chain { } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::parameter_extension, +FC_REFLECT( graphene::protocol::parameter_extension, (min_bet_multiplier) (max_bet_multiplier) (betting_rake_fee_percentage) @@ -173,7 +172,7 @@ FC_REFLECT( graphene::chain::parameter_extension, (rbac_max_authorities_per_permission) ) -FC_REFLECT( graphene::chain::chain_parameters, +FC_REFLECT( graphene::protocol::chain_parameters, (current_fees) (block_interval) (maintenance_interval) diff --git a/libraries/chain/include/graphene/chain/protocol/committee_member.hpp b/libraries/protocol/include/graphene/protocol/committee_member.hpp similarity index 74% rename from libraries/chain/include/graphene/chain/protocol/committee_member.hpp rename to libraries/protocol/include/graphene/protocol/committee_member.hpp index 8aaed748..748994dd 100644 --- a/libraries/chain/include/graphene/chain/protocol/committee_member.hpp +++ b/libraries/protocol/include/graphene/protocol/committee_member.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief Create a committee_member object, as a bid to hold a committee_member seat on the network. @@ -93,21 +93,21 @@ namespace graphene { namespace chain { /// TODO: committee_member_resign_operation : public base_operation -} } // graphene::chain -FC_REFLECT( graphene::chain::committee_member_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::committee_member_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::committee_member_update_global_parameters_operation::fee_parameters_type, (fee) ) +} } // graphene::protocol +FC_REFLECT( graphene::protocol::committee_member_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::committee_member_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::committee_member_update_global_parameters_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::committee_member_create_operation, +FC_REFLECT( graphene::protocol::committee_member_create_operation, (fee)(committee_member_account)(url) ) -FC_REFLECT( graphene::chain::committee_member_update_operation, +FC_REFLECT( graphene::protocol::committee_member_update_operation, (fee)(committee_member)(committee_member_account)(new_url) ) -FC_REFLECT( graphene::chain::committee_member_update_global_parameters_operation, (fee)(new_parameters) ); +FC_REFLECT( graphene::protocol::committee_member_update_global_parameters_operation, (fee)(new_parameters) ); -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_update_global_parameters_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::committee_member_update_global_parameters_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_update_global_parameters_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::committee_member_update_global_parameters_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/confidential.hpp b/libraries/protocol/include/graphene/protocol/confidential.hpp similarity index 87% rename from libraries/chain/include/graphene/chain/protocol/confidential.hpp rename to libraries/protocol/include/graphene/protocol/confidential.hpp index 697ef35b..5d407420 100644 --- a/libraries/chain/include/graphene/chain/protocol/confidential.hpp +++ b/libraries/protocol/include/graphene/protocol/confidential.hpp @@ -23,9 +23,9 @@ */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { using fc::ecc::blind_factor_type; @@ -258,33 +258,34 @@ struct blind_transfer_operation : public base_operation ///@} endgroup stealth -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::stealth_confirmation, +FC_REFLECT( graphene::protocol::stealth_confirmation, (one_time_key)(to)(encrypted_memo) ) -FC_REFLECT( graphene::chain::stealth_confirmation::memo_data, +FC_REFLECT( graphene::protocol::stealth_confirmation::memo_data, (from)(amount)(blinding_factor)(commitment)(check) ); -FC_REFLECT( graphene::chain::blind_memo, +FC_REFLECT( graphene::protocol::blind_memo, (from)(amount)(message)(check) ) -FC_REFLECT( graphene::chain::blind_input, +FC_REFLECT( graphene::protocol::blind_input, (commitment)(owner) ) -FC_REFLECT( graphene::chain::blind_output, +FC_REFLECT( graphene::protocol::blind_output, (commitment)(range_proof)(owner)(stealth_memo) ) -FC_REFLECT( graphene::chain::transfer_to_blind_operation, +FC_REFLECT( graphene::protocol::transfer_to_blind_operation, (fee)(amount)(from)(blinding_factor)(outputs) ) -FC_REFLECT( graphene::chain::transfer_from_blind_operation, +FC_REFLECT( graphene::protocol::transfer_from_blind_operation, (fee)(amount)(to)(blinding_factor)(inputs) ) -FC_REFLECT( graphene::chain::blind_transfer_operation, +FC_REFLECT( graphene::protocol::blind_transfer_operation, (fee)(inputs)(outputs) ) -FC_REFLECT( graphene::chain::transfer_to_blind_operation::fee_parameters_type, (fee)(price_per_output) ) -FC_REFLECT( graphene::chain::transfer_from_blind_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::transfer_to_blind_operation::fee_parameters_type, (fee)(price_per_output) ) +FC_REFLECT( graphene::protocol::transfer_from_blind_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::blind_transfer_operation::fee_parameters_type, (fee)(price_per_output) ) FC_REFLECT( graphene::chain::blind_transfer_operation::fee_parameters_type, (fee)(price_per_output) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_to_blind_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_from_blind_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::blind_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_to_blind_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_from_blind_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::blind_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_to_blind_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_from_blind_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::blind_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_to_blind_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_from_blind_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::blind_transfer_operation ) diff --git a/libraries/protocol/include/graphene/protocol/config.hpp b/libraries/protocol/include/graphene/protocol/config.hpp new file mode 100644 index 00000000..6f1f6da4 --- /dev/null +++ b/libraries/protocol/include/graphene/protocol/config.hpp @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#pragma once + +#define GRAPHENE_SYMBOL "BTS" +#define GRAPHENE_ADDRESS_PREFIX "BTS" + +#define GRAPHENE_BLOCKCHAIN_PRECISION uint64_t( 100000 ) +#define GRAPHENE_BLOCKCHAIN_PRECISION_DIGITS 5 + +#define GRAPHENE_MIN_ACCOUNT_NAME_LENGTH 1 +#define GRAPHENE_MAX_ACCOUNT_NAME_LENGTH 63 + +#define GRAPHENE_MIN_ASSET_SYMBOL_LENGTH 3 +#define GRAPHENE_MAX_ASSET_SYMBOL_LENGTH 16 + +#define GRAPHENE_MAX_SHARE_SUPPLY int64_t(1000000000000000ll) + +#define GRAPHENE_MAX_WORKER_NAME_LENGTH 63 +#define GRAPHENE_MAX_URL_LENGTH 127 + +#define GRAPHENE_MAX_SIG_CHECK_DEPTH 2 + +#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT) + +/** + * Don't allow the committee_members to publish a limit that would + * make the network unable to operate. + */ +#define GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT 1024 +#define GRAPHENE_MIN_BLOCK_INTERVAL 1 /* seconds */ +#define GRAPHENE_MAX_BLOCK_INTERVAL 30 /* seconds */ + +#define GRAPHENE_DEFAULT_BLOCK_INTERVAL 5 /* seconds */ +#define GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE 2048 +#define GRAPHENE_DEFAULT_MAX_BLOCK_SIZE (2*1000*1000) /* < 2 MiB (less than MAX_MESSAGE_SIZE in graphene/net/config.hpp) */ +#define GRAPHENE_DEFAULT_MAX_TIME_UNTIL_EXPIRATION (60*60*24) // seconds, aka: 1 day +#define GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL (60*60*24) // seconds, aka: 1 day +#define GRAPHENE_DEFAULT_MAINTENANCE_SKIP_SLOTS 3 // number of slots to skip for maintenance interval + +#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_DELAY (60*60*24) ///< 1 day +#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_OFFSET 0 ///< 1% +#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_MAX_VOLUME (20* GRAPHENE_1_PERCENT) ///< 20% +#define GRAPHENE_DEFAULT_PRICE_FEED_LIFETIME (60*60*24) ///< 1 day +#define GRAPHENE_DEFAULT_MAX_AUTHORITY_MEMBERSHIP 10 +#define GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES 10 +#define GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS 10 + +#define GRAPHENE_DEFAULT_MIN_WITNESS_COUNT (11) +#define GRAPHENE_DEFAULT_MIN_COMMITTEE_MEMBER_COUNT (11) +#define GRAPHENE_DEFAULT_MAX_WITNESSES (1001) // SHOULD BE ODD +#define GRAPHENE_DEFAULT_MAX_COMMITTEE (1001) // SHOULD BE ODD +#define GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC (60*60*24*7*4) // Four weeks +#define GRAPHENE_DEFAULT_COMMITTEE_PROPOSAL_REVIEW_PERIOD_SEC (60*60*24*7*2) // Two weeks +#define GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT) +#define GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE (30*GRAPHENE_1_PERCENT) +#define GRAPHENE_DEFAULT_CASHBACK_VESTING_PERIOD_SEC (60*60*24*365) ///< 1 year +#define GRAPHENE_DEFAULT_CASHBACK_VESTING_THRESHOLD (GRAPHENE_BLOCKCHAIN_PRECISION*int64_t(100)) +#define GRAPHENE_DEFAULT_BURN_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT) +#define GRAPHENE_DEFAULT_MAX_ASSERT_OPCODE 1 +#define GRAPHENE_DEFAULT_FEE_LIQUIDATION_THRESHOLD GRAPHENE_BLOCKCHAIN_PRECISION * 100; +#define GRAPHENE_DEFAULT_ACCOUNTS_PER_FEE_SCALE 1000 +#define GRAPHENE_DEFAULT_ACCOUNT_FEE_SCALE_BITSHIFTS 4 +#define GRAPHENE_DEFAULT_MAX_BUYBACK_MARKETS 4 + +#define GRAPHENE_DEFAULT_WITNESS_PAY_PER_BLOCK (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t( 10) ) +#define GRAPHENE_DEFAULT_WITNESS_PAY_VESTING_SECONDS (60*60*24) +#define GRAPHENE_DEFAULT_WORKER_BUDGET_PER_DAY (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t(500) * 1000 ) +#define GRAPHENE_DEFAULT_MINIMUM_FEEDS 7 + +#define GRAPHENE_MIN_BLOCK_SIZE_LIMIT (GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT*5) // 5 transactions per block + +/** percentage fields are fixed point with a denominator of 10,000 */ +#define GRAPHENE_100_PERCENT 10000 +#define GRAPHENE_1_PERCENT (GRAPHENE_100_PERCENT/100) +/** NOTE: making this a power of 2 (say 2^15) would greatly accelerate fee calcs */ + +#define GRAPHENE_MAX_MARKET_FEE_PERCENT GRAPHENE_100_PERCENT +/** + * These ratios are fixed point numbers with a denominator of GRAPHENE_COLLATERAL_RATIO_DENOM, the + * minimum maitenance collateral is therefore 1.001x and the default + * maintenance ratio is 1.75x + */ +///@{ +#define GRAPHENE_COLLATERAL_RATIO_DENOM 1000 +#define GRAPHENE_MIN_COLLATERAL_RATIO 1001 ///< lower than this could result in divide by 0 +#define GRAPHENE_MAX_COLLATERAL_RATIO 32000 ///< higher than this is unnecessary and may exceed int16 storage +#define GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO 1750 ///< Call when collateral only pays off 175% the debt +#define GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO 1500 ///< Stop calling when collateral only pays off 150% of the debt +///@} +#define GRAPHENE_DEFAULT_MARGIN_PERIOD_SEC (30*60*60*24) + +/** + * Reserved Account IDs with special meaning + */ +///@{ +/// Represents the current committee members, two-week review period +#define GRAPHENE_COMMITTEE_ACCOUNT (graphene::protocol::account_id_type(0)) +/// Represents the current witnesses +#define GRAPHENE_WITNESS_ACCOUNT (graphene::protocol::account_id_type(1)) +/// Represents the current committee members +#define GRAPHENE_RELAXED_COMMITTEE_ACCOUNT (graphene::protocol::account_id_type(2)) +/// Represents the canonical account with NO authority (nobody can access funds in null account) +#define GRAPHENE_NULL_ACCOUNT (graphene::protocol::account_id_type(3)) +/// Represents the canonical account with WILDCARD authority (anybody can access funds in temp account) +#define GRAPHENE_TEMP_ACCOUNT (graphene::protocol::account_id_type(4)) +/// Represents the canonical account for specifying you will vote directly (as opposed to a proxy) +#define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::protocol::account_id_type(5)) +/// Sentinel value used in the scheduler. +#define GRAPHENE_NULL_WITNESS (graphene::protocol::witness_id_type(0)) +///@} + +#define GRAPHENE_FBA_STEALTH_DESIGNATED_ASSET (asset_id_type(743)) diff --git a/libraries/chain/include/graphene/chain/protocol/custom.hpp b/libraries/protocol/include/graphene/protocol/custom.hpp similarity index 80% rename from libraries/chain/include/graphene/chain/protocol/custom.hpp rename to libraries/protocol/include/graphene/protocol/custom.hpp index 5596aaad..dc31168e 100644 --- a/libraries/chain/include/graphene/chain/protocol/custom.hpp +++ b/libraries/protocol/include/graphene/protocol/custom.hpp @@ -23,9 +23,9 @@ */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief provides a generic way to add higher level protocols on top of witness consensus @@ -52,10 +52,10 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const; }; -} } // namespace graphene::chain +} } // namespace graphene::protocol -FC_REFLECT( graphene::chain::custom_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::custom_operation, (fee)(payer)(required_auths)(id)(data) ) +FC_REFLECT( graphene::protocol::custom_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::custom_operation, (fee)(payer)(required_auths)(id)(data) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::custom_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::custom_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::custom_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::custom_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/custom_account_authority.hpp b/libraries/protocol/include/graphene/protocol/custom_account_authority.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/custom_account_authority.hpp rename to libraries/protocol/include/graphene/protocol/custom_account_authority.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/custom_permission.hpp b/libraries/protocol/include/graphene/protocol/custom_permission.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/custom_permission.hpp rename to libraries/protocol/include/graphene/protocol/custom_permission.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/event.hpp b/libraries/protocol/include/graphene/protocol/event.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/event.hpp rename to libraries/protocol/include/graphene/protocol/event.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/event_group.hpp b/libraries/protocol/include/graphene/protocol/event_group.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/event_group.hpp rename to libraries/protocol/include/graphene/protocol/event_group.hpp diff --git a/libraries/protocol/include/graphene/protocol/exceptions.hpp b/libraries/protocol/include/graphene/protocol/exceptions.hpp new file mode 100644 index 00000000..5141151d --- /dev/null +++ b/libraries/protocol/include/graphene/protocol/exceptions.hpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#pragma once + +#include + +#define GRAPHENE_ASSERT( expr, exc_type, FORMAT, ... ) \ + FC_MULTILINE_MACRO_BEGIN \ + if( !(expr) ) \ + FC_THROW_EXCEPTION( exc_type, FORMAT, __VA_ARGS__ ); \ + FC_MULTILINE_MACRO_END + +namespace graphene { namespace protocol { + + FC_DECLARE_EXCEPTION( protocol_exception, 4000000, "protocol exception" ) + + FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, graphene::protocol::protocol_exception, 4010000, "transaction validation exception" ) + + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_active_auth, graphene::protocol::transaction_exception, 4010001, "missing required active authority" ) + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_owner_auth, graphene::protocol::transaction_exception, 4010002, "missing required owner authority" ) + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_other_auth, graphene::protocol::transaction_exception, 4010003, "missing required other authority" ) + FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_sig, graphene::protocol::transaction_exception, 4010004, "irrelevant signature included" ) + FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate_sig, graphene::protocol::transaction_exception, 4010005, "duplicate signature included" ) + FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_approval, graphene::protocol::transaction_exception, 4010006, "committee account cannot directly approve transaction" ) + FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::protocol::transaction_exception, 4010007, "insufficient fee" ) + +} } // graphene::protocol diff --git a/libraries/chain/include/graphene/chain/protocol/ext.hpp b/libraries/protocol/include/graphene/protocol/ext.hpp similarity index 82% rename from libraries/chain/include/graphene/chain/protocol/ext.hpp rename to libraries/protocol/include/graphene/protocol/ext.hpp index 75364525..7cb47cfc 100644 --- a/libraries/chain/include/graphene/chain/protocol/ext.hpp +++ b/libraries/protocol/include/graphene/protocol/ext.hpp @@ -26,8 +26,9 @@ #include #include #include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { using fc::unsigned_int; @@ -129,7 +130,7 @@ struct graphene_extension_unpack_visitor const uint32_t max_depth; }; -} } // graphene::chain +} } // graphene::protocol namespace fc { @@ -162,9 +163,9 @@ struct graphene_extension_from_variant_visitor }; template< typename T > -void from_variant( const fc::variant& var, graphene::chain::extension& value, uint32_t max_depth ) +void from_variant( const fc::variant& var, graphene::protocol::extension& value, uint32_t max_depth ) { - value = graphene::chain::extension(); + value = graphene::protocol::extension(); if( var.is_null() ) return; if( var.is_array() ) @@ -195,7 +196,7 @@ struct graphene_extension_to_variant_visitor }; template< typename T > -void to_variant( const graphene::chain::extension& value, fc::variant& var, uint32_t max_depth ) +void to_variant( const graphene::protocol::extension& value, fc::variant& var, uint32_t max_depth ) { graphene_extension_to_variant_visitor vtor( value.value, max_depth ); fc::reflector::visit( vtor ); @@ -205,29 +206,39 @@ void to_variant( const graphene::chain::extension& value, fc::variant& var, u namespace raw { template< typename Stream, typename T > -void pack( Stream& stream, const graphene::chain::extension& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ) +void pack( Stream& stream, const graphene::protocol::extension& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ) { FC_ASSERT( _max_depth > 0 ); --_max_depth; - graphene::chain::graphene_extension_pack_count_visitor count_vtor( value.value ); + graphene::protocol::graphene_extension_pack_count_visitor count_vtor( value.value ); fc::reflector::visit( count_vtor ); fc::raw::pack( stream, unsigned_int( count_vtor.count ), _max_depth ); - graphene::chain::graphene_extension_pack_read_visitor read_vtor( stream, value.value, _max_depth ); + graphene::protocol::graphene_extension_pack_read_visitor read_vtor( stream, value.value, _max_depth ); fc::reflector::visit( read_vtor ); } template< typename Stream, typename T > -void unpack( Stream& s, graphene::chain::extension& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ) +void unpack( Stream& s, graphene::protocol::extension& value, uint32_t _max_depth=FC_PACK_MAX_DEPTH ) { FC_ASSERT( _max_depth > 0 ); --_max_depth; - value = graphene::chain::extension(); - graphene::chain::graphene_extension_unpack_visitor vtor( s, value.value, _max_depth ); + value = graphene::protocol::extension(); + graphene::protocol::graphene_extension_unpack_visitor vtor( s, value.value, _max_depth ); fc::reflector::visit( vtor ); FC_ASSERT( vtor.count_left == 0 ); // unrecognized extension throws here } } // fc::raw +template struct get_typename< graphene::protocol::extension > +{ + static const char* name() + { + static std::string n = std::string("graphene::protocol::extension<") + + fc::get_typename::name() + std::string(">"); + return n.c_str(); + } +}; + } // fc diff --git a/libraries/chain/include/graphene/chain/protocol/fba.hpp b/libraries/protocol/include/graphene/protocol/fba.hpp similarity index 78% rename from libraries/chain/include/graphene/chain/protocol/fba.hpp rename to libraries/protocol/include/graphene/protocol/fba.hpp index dc672436..0f5425bf 100644 --- a/libraries/chain/include/graphene/chain/protocol/fba.hpp +++ b/libraries/protocol/include/graphene/protocol/fba.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct fba_distribute_operation : public base_operation { @@ -33,7 +32,7 @@ struct fba_distribute_operation : public base_operation asset fee; // always zero account_id_type account_id; - fba_accumulator_id_type fba_id; + object_id_type fba_id; share_type amount; account_id_type fee_payer()const { return account_id; } @@ -43,8 +42,7 @@ struct fba_distribute_operation : public base_operation } } -FC_REFLECT( graphene::chain::fba_distribute_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::fba_distribute_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::fba_distribute_operation, (fee)(account_id)(fba_id)(amount) ) -FC_REFLECT( graphene::chain::fba_distribute_operation, (fee)(account_id)(fba_id)(amount) ) - -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::fba_distribute_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fba_distribute_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp b/libraries/protocol/include/graphene/protocol/fee_schedule.hpp similarity index 87% rename from libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp rename to libraries/protocol/include/graphene/protocol/fee_schedule.hpp index 1587d1ba..deb5a087 100644 --- a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp +++ b/libraries/protocol/include/graphene/protocol/fee_schedule.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { template struct transform_to_fee_parameters; template @@ -81,13 +81,13 @@ namespace graphene { namespace chain { typedef fee_schedule fee_schedule_type; -} } // graphene::chain +} } // graphene::protocol namespace fc { - template<> struct get_typename> { static const char* name() { return "shared_ptr"; } }; + template<> struct get_typename> { static const char* name() { return "shared_ptr"; } }; } -FC_REFLECT_TYPENAME( graphene::chain::fee_parameters ) -FC_REFLECT( graphene::chain::fee_schedule, (parameters)(scale) ) +FC_REFLECT_TYPENAME( graphene::protocol::fee_parameters ) +FC_REFLECT( graphene::protocol::fee_schedule, (parameters)(scale) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::fee_schedule ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fee_schedule ) diff --git a/libraries/chain/include/graphene/chain/protocol/lottery_ops.hpp b/libraries/protocol/include/graphene/protocol/lottery_ops.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/lottery_ops.hpp rename to libraries/protocol/include/graphene/protocol/lottery_ops.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/market.hpp b/libraries/protocol/include/graphene/protocol/market.hpp similarity index 79% rename from libraries/chain/include/graphene/chain/protocol/market.hpp rename to libraries/protocol/include/graphene/protocol/market.hpp index 2bff8c56..4dee59f0 100644 --- a/libraries/chain/include/graphene/chain/protocol/market.hpp +++ b/libraries/protocol/include/graphene/protocol/market.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @class limit_order_create_operation @@ -73,7 +73,6 @@ namespace graphene { namespace chain { price get_price()const { return amount_to_sell / min_to_receive; } }; - /** * @ingroup operations * Used to cancel an existing limit order. Both fee_pay_account and the @@ -159,22 +158,23 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const { return 0; } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::limit_order_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::limit_order_cancel_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::call_order_update_operation::fee_parameters_type, (fee) ) -/// THIS IS THE ONLY VIRTUAL OPERATION THUS FAR... -FC_REFLECT( graphene::chain::fill_order_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::limit_order_create_operation,(fee)(seller)(amount_to_sell)(min_to_receive)(expiration)(fill_or_kill)(extensions)) -FC_REFLECT( graphene::chain::limit_order_cancel_operation,(fee)(fee_paying_account)(order)(extensions) ) -FC_REFLECT( graphene::chain::call_order_update_operation, (fee)(funding_account)(delta_collateral)(delta_debt)(extensions) ) +FC_REFLECT( graphene::protocol::limit_order_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::limit_order_cancel_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::call_order_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::fill_order_operation::fee_parameters_type, ) // VIRTUAL +FC_REFLECT( graphene::protocol::limit_order_create_operation,(fee)(seller)(amount_to_sell)(min_to_receive)(expiration)(fill_or_kill)(extensions)) +FC_REFLECT( graphene::protocol::limit_order_cancel_operation,(fee)(fee_paying_account)(order)(extensions) ) +FC_REFLECT( graphene::protocol::call_order_update_operation, (fee)(funding_account)(delta_collateral)(delta_debt)(extensions) ) +FC_REFLECT( graphene::protocol::fill_order_operation, (fee)(order_id)(account_id)(pays)(receives)(fill_price)(is_maker) ) FC_REFLECT( graphene::chain::fill_order_operation, (fee)(order_id)(account_id)(pays)(receives) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_cancel_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::call_order_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::limit_order_cancel_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::call_order_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::fill_order_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_cancel_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::call_order_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_cancel_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::call_order_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fill_order_operation ) + diff --git a/libraries/chain/include/graphene/chain/protocol/memo.hpp b/libraries/protocol/include/graphene/protocol/memo.hpp similarity index 89% rename from libraries/chain/include/graphene/chain/protocol/memo.hpp rename to libraries/protocol/include/graphene/protocol/memo.hpp index 6c5b69fb..d0ef2115 100644 --- a/libraries/chain/include/graphene/chain/protocol/memo.hpp +++ b/libraries/protocol/include/graphene/protocol/memo.hpp @@ -22,9 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief defines the keys used to derive the shared secret @@ -85,10 +85,10 @@ namespace graphene { namespace chain { static memo_message deserialize(const string& serial); }; -} } // namespace graphene::chain +} } // namespace graphene::protocol -FC_REFLECT( graphene::chain::memo_message, (checksum)(text) ) -FC_REFLECT( graphene::chain::memo_data, (from)(to)(nonce)(message) ) +FC_REFLECT( graphene::protocol::memo_message, (checksum)(text) ) +FC_REFLECT( graphene::protocol::memo_data, (from)(to)(nonce)(message) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::memo_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::memo_data ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::memo_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::memo_data ) diff --git a/libraries/chain/include/graphene/chain/protocol/nft_ops.hpp b/libraries/protocol/include/graphene/protocol/nft_ops.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/nft_ops.hpp rename to libraries/protocol/include/graphene/protocol/nft_ops.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/offer.hpp b/libraries/protocol/include/graphene/protocol/offer.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/offer.hpp rename to libraries/protocol/include/graphene/protocol/offer.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/operations.hpp b/libraries/protocol/include/graphene/protocol/operations.hpp similarity index 80% rename from libraries/chain/include/graphene/chain/protocol/operations.hpp rename to libraries/protocol/include/graphene/protocol/operations.hpp index 1285d353..ae61643c 100644 --- a/libraries/chain/include/graphene/chain/protocol/operations.hpp +++ b/libraries/protocol/include/graphene/protocol/operations.hpp @@ -22,35 +22,35 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @ingroup operations @@ -183,9 +183,9 @@ namespace graphene { namespace chain { operation op; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT_TYPENAME( graphene::chain::operation ) -FC_REFLECT( graphene::chain::op_wrapper, (op) ) +FC_REFLECT_TYPENAME( graphene::protocol::operation ) +FC_REFLECT( graphene::protocol::op_wrapper, (op) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::op_wrapper ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::op_wrapper ) diff --git a/libraries/chain/include/graphene/chain/protocol/proposal.hpp b/libraries/protocol/include/graphene/protocol/proposal.hpp similarity index 87% rename from libraries/chain/include/graphene/chain/protocol/proposal.hpp rename to libraries/protocol/include/graphene/protocol/proposal.hpp index 141ec35f..c18a06b3 100644 --- a/libraries/chain/include/graphene/chain/protocol/proposal.hpp +++ b/libraries/protocol/include/graphene/protocol/proposal.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @defgroup proposed_transactions The Graphene Transaction Proposal Protocol * @ingroup operations @@ -168,22 +167,22 @@ namespace graphene { namespace chain { }; ///@} -}} // graphene::chain +}} // graphene::protocol -FC_REFLECT( graphene::chain::proposal_create_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::proposal_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::proposal_delete_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::proposal_create_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::proposal_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::proposal_delete_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::proposal_create_operation, (fee)(fee_paying_account)(expiration_time) +FC_REFLECT( graphene::protocol::proposal_create_operation, (fee)(fee_paying_account)(expiration_time) (proposed_ops)(review_period_seconds)(extensions) ) -FC_REFLECT( graphene::chain::proposal_update_operation, (fee)(fee_paying_account)(proposal) +FC_REFLECT( graphene::protocol::proposal_update_operation, (fee)(fee_paying_account)(proposal) (active_approvals_to_add)(active_approvals_to_remove)(owner_approvals_to_add)(owner_approvals_to_remove) (key_approvals_to_add)(key_approvals_to_remove)(extensions) ) -FC_REFLECT( graphene::chain::proposal_delete_operation, (fee)(fee_paying_account)(using_owner_authority)(proposal)(extensions) ) +FC_REFLECT( graphene::protocol::proposal_delete_operation, (fee)(fee_paying_account)(using_owner_authority)(proposal)(extensions) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_delete_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::proposal_delete_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_delete_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::proposal_delete_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/protocol.hpp b/libraries/protocol/include/graphene/protocol/protocol.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/protocol.hpp rename to libraries/protocol/include/graphene/protocol/protocol.hpp diff --git a/libraries/chain/include/graphene/chain/pts_address.hpp b/libraries/protocol/include/graphene/protocol/pts_address.hpp similarity index 84% rename from libraries/chain/include/graphene/chain/pts_address.hpp rename to libraries/protocol/include/graphene/protocol/pts_address.hpp index faa55816..7544d98a 100644 --- a/libraries/chain/include/graphene/chain/pts_address.hpp +++ b/libraries/protocol/include/graphene/protocol/pts_address.hpp @@ -33,7 +33,7 @@ namespace fc { namespace ecc { class public_key; } } -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * Implements address stringification and validation from PTS @@ -56,15 +56,15 @@ namespace graphene { namespace chain { inline bool operator != ( const pts_address& a, const pts_address& b ) { return a.addr != b.addr; } inline bool operator < ( const pts_address& a, const pts_address& b ) { return a.addr < b.addr; } -} } // namespace graphene::chain +} } // namespace graphene::protocol namespace std { template<> - struct hash + struct hash { public: - size_t operator()(const graphene::chain::pts_address &a) const + size_t operator()(const graphene::protocol::pts_address &a) const { size_t s; std::memcpy( (char*)&s, a.addr.data() + a.addr.size() - sizeof(s), sizeof(s) ); @@ -74,17 +74,18 @@ namespace std } #include -FC_REFLECT( graphene::chain::pts_address, (addr) ) +FC_REFLECT( graphene::protocol::pts_address, (addr) ) namespace fc { - void to_variant( const graphene::chain::pts_address& var, fc::variant& vo, uint32_t max_depth = 1 ); - void from_variant( const fc::variant& var, graphene::chain::pts_address& vo, uint32_t max_depth = 1 ); + void to_variant( const graphene::protocol::pts_address& var, fc::variant& vo, uint32_t max_depth = 1 ); + void from_variant( const fc::variant& var, graphene::protocol::pts_address& vo, uint32_t max_depth = 1 ); namespace raw { - extern template void pack( datastream& s, const graphene::chain::pts_address& tx, + extern template void pack( datastream& s, const graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - extern template void pack( datastream& s, const graphene::chain::pts_address& tx, + extern template void pack( datastream& s, const graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - extern template void unpack( datastream& s, graphene::chain::pts_address& tx, + extern template void unpack( datastream& s, graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); } } // fc::raw + diff --git a/libraries/chain/include/graphene/chain/protocol/rock_paper_scissors.hpp b/libraries/protocol/include/graphene/protocol/rock_paper_scissors.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/rock_paper_scissors.hpp rename to libraries/protocol/include/graphene/protocol/rock_paper_scissors.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/special_authority.hpp b/libraries/protocol/include/graphene/protocol/special_authority.hpp similarity index 78% rename from libraries/chain/include/graphene/chain/protocol/special_authority.hpp rename to libraries/protocol/include/graphene/protocol/special_authority.hpp index 05a80719..f6e925cb 100644 --- a/libraries/chain/include/graphene/chain/protocol/special_authority.hpp +++ b/libraries/protocol/include/graphene/protocol/special_authority.hpp @@ -23,10 +23,10 @@ */ #pragma once -#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct no_special_authority {}; @@ -43,10 +43,10 @@ typedef static_variant< void validate_special_authority( const special_authority& auth ); -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::no_special_authority, ) -FC_REFLECT( graphene::chain::top_holders_special_authority, (asset)(num_top_holders) ) -FC_REFLECT_TYPENAME( graphene::chain::special_authority ) +FC_REFLECT( graphene::protocol::no_special_authority, ) +FC_REFLECT( graphene::protocol::top_holders_special_authority, (asset)(num_top_holders) ) +FC_REFLECT_TYPENAME( graphene::protocol::special_authority ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::top_holders_special_authority ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::top_holders_special_authority ) diff --git a/libraries/chain/include/graphene/chain/protocol/sport.hpp b/libraries/protocol/include/graphene/protocol/sport.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/sport.hpp rename to libraries/protocol/include/graphene/protocol/sport.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/tournament.hpp b/libraries/protocol/include/graphene/protocol/tournament.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/protocol/tournament.hpp rename to libraries/protocol/include/graphene/protocol/tournament.hpp diff --git a/libraries/chain/include/graphene/chain/protocol/transaction.hpp b/libraries/protocol/include/graphene/protocol/transaction.hpp similarity index 93% rename from libraries/chain/include/graphene/chain/protocol/transaction.hpp rename to libraries/protocol/include/graphene/protocol/transaction.hpp index ec8f3f53..8bb689ec 100644 --- a/libraries/chain/include/graphene/chain/protocol/transaction.hpp +++ b/libraries/protocol/include/graphene/protocol/transaction.hpp @@ -22,12 +22,12 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @defgroup transactions Transactions @@ -228,14 +228,14 @@ namespace graphene { namespace chain { /// @} transactions group -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::transaction, (ref_block_num)(ref_block_prefix)(expiration)(operations)(extensions) ) +FC_REFLECT( graphene::protocol::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::protocol::signed_transaction, (graphene::protocol::transaction), (signatures) ) +FC_REFLECT_DERIVED( graphene::protocol::processed_transaction, (graphene::protocol::precomputable_transaction), (operation_results) ) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::signed_transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::chain::processed_transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::processed_transaction) diff --git a/libraries/chain/include/graphene/chain/protocol/transfer.hpp b/libraries/protocol/include/graphene/protocol/transfer.hpp similarity index 78% rename from libraries/chain/include/graphene/chain/protocol/transfer.hpp rename to libraries/protocol/include/graphene/protocol/transfer.hpp index 5366a7ab..76fc6bb4 100644 --- a/libraries/chain/include/graphene/chain/protocol/transfer.hpp +++ b/libraries/protocol/include/graphene/protocol/transfer.hpp @@ -22,11 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @ingroup operations @@ -99,15 +98,15 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type& k)const; }; -}} // graphene::chain +}} // graphene::protocol -FC_REFLECT( graphene::chain::transfer_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::override_transfer_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::transfer_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::override_transfer_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::override_transfer_operation, (fee)(issuer)(from)(to)(amount)(memo)(extensions) ) -FC_REFLECT( graphene::chain::transfer_operation, (fee)(from)(to)(amount)(memo)(extensions) ) +FC_REFLECT( graphene::protocol::override_transfer_operation, (fee)(issuer)(from)(to)(amount)(memo)(extensions) ) +FC_REFLECT( graphene::protocol::transfer_operation, (fee)(from)(to)(amount)(memo)(extensions) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::override_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transfer_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::override_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::override_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::override_transfer_operation ) diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp new file mode 100644 index 00000000..2ef4f290 --- /dev/null +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -0,0 +1,369 @@ +/* + * Copyright (c) 2015 Cryptonomex, Inc., and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace graphene { namespace protocol { +using namespace graphene::db; + +using std::map; +using std::vector; +using std::unordered_map; +using std::string; +using std::deque; +using std::shared_ptr; +using std::weak_ptr; +using std::unique_ptr; +using std::set; +using std::pair; +using std::enable_shared_from_this; +using std::tie; +using std::make_pair; + +using fc::variant_object; +using fc::variant; +using fc::enum_type; +using fc::optional; +using fc::unsigned_int; +using fc::time_point_sec; +using fc::time_point; +using fc::safe; +using fc::flat_map; +using fc::flat_set; +using fc::static_variant; +using fc::ecc::range_proof_type; +using fc::ecc::range_proof_info; +using fc::ecc::commitment_type; +struct void_t{}; + +using private_key_type = fc::ecc::private_key; +using chain_id_type = fc::sha256; +using ratio_type = boost::rational; + +enum asset_issuer_permission_flags { + charge_market_fee = 0x01, /**< an issuer-specified percentage of all market trades in this asset is paid to the issuer */ + white_list = 0x02, /**< accounts must be whitelisted in order to hold this asset */ + override_authority = 0x04, /**< issuer may transfer asset back to himself */ + transfer_restricted = 0x08, /**< require the issuer to be one party to every transfer */ + disable_force_settle = 0x10, /**< disable force settling */ + global_settle = 0x20, /**< allow the bitasset issuer to force a global settling -- this may be set in permissions, but not flags */ + disable_confidential = 0x40, /**< allow the asset to be used with confidential transactions */ + witness_fed_asset = 0x80, /**< allow the asset to be fed by witnesses */ + committee_fed_asset = 0x100 /**< allow the asset to be fed by the committee */ +}; +const static uint32_t ASSET_ISSUER_PERMISSION_MASK = + charge_market_fee + | white_list + | override_authority + | transfer_restricted + | disable_force_settle + | global_settle + | disable_confidential + | witness_fed_asset + | committee_fed_asset; +const static uint32_t UIA_ASSET_ISSUER_PERMISSION_MASK = + charge_market_fee + | white_list + | override_authority + | transfer_restricted + | disable_confidential; + +enum reserved_spaces { + relative_protocol_ids = 0, + protocol_ids = 1, + implementation_ids = 2 +}; + +inline bool is_relative(object_id_type o) { return o.space() == 0; } + +/** + * List all object types from all namespaces here so they can + * be easily reflected and displayed in debug output. If a 3rd party + * wants to extend the core code then they will have to change the + * packed_object::type field from enum_type to uint16 to avoid + * warnings when converting packed_objects to/from json. + */ +enum object_type { + null_object_type, + base_object_type, + account_object_type, + asset_object_type, + force_settlement_object_type, + committee_member_object_type, + witness_object_type, + limit_order_object_type, + call_order_object_type, + custom_object_type, + proposal_object_type, + operation_history_object_type, + withdraw_permission_object_type, + vesting_balance_object_type, + worker_object_type, + balance_object_type, + tournament_object_type, + tournament_details_object_type, + match_object_type, + game_object_type, + sport_object_type, + event_group_object_type, + event_object_type, + betting_market_rules_object_type, + betting_market_group_object_type, + betting_market_object_type, + bet_object_type, + custom_permission_object_type, + custom_account_authority_object_type, + offer_object_type, + nft_metadata_type, + nft_object_type, +OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types +}; + +using account_id_type = object_id; +using asset_id_type = object_id; +using force_settlement_id_type = object_id; +using committee_member_id_type = object_id; +using witness_id_type = object_id; +using limit_order_id_type = object_id; +using call_order_id_type = object_id; +using custom_id_type = object_id; +using proposal_id_type = object_id; +using operation_history_id_type = object_id; +using withdraw_permission_id_type = object_id; +using vesting_balance_id_type = object_id; +using worker_id_type = object_id; +using balance_id_type = object_id; +using htlc_id_type = object_id; + +using block_id_type = fc::ripemd160; +using checksum_type = fc::ripemd160; +using transaction_id_type = fc::ripemd160; +using digest_type = fc::sha256; +using signature_type = fc::ecc::compact_signature; +using share_type = safe; +using weight_type = uint16_t; + +struct public_key_type { + struct binary_key { + binary_key() = default; + uint32_t check = 0; + fc::ecc::public_key_data data; + }; + fc::ecc::public_key_data key_data; + public_key_type(); + public_key_type(const fc::ecc::public_key_data& data); + public_key_type(const fc::ecc::public_key& pubkey); + explicit public_key_type(const std::string& base58str); + operator fc::ecc::public_key_data() const; + operator fc::ecc::public_key() const; + explicit operator std::string() const; + friend bool operator == (const public_key_type& p1, const fc::ecc::public_key& p2); + friend bool operator == (const public_key_type& p1, const public_key_type& p2); + 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 { + binary_key() = default; + uint32_t check = 0; + fc::ecc::extended_key_data data; + }; + + fc::ecc::extended_key_data key_data; + + extended_public_key_type(); + extended_public_key_type(const fc::ecc::extended_key_data& data); + extended_public_key_type(const fc::ecc::extended_public_key& extpubkey); + explicit extended_public_key_type(const std::string& base58str); + operator fc::ecc::extended_public_key() const; + explicit operator std::string() const; + friend bool operator == (const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2); + friend bool operator == (const extended_public_key_type& p1, const extended_public_key_type& p2); + friend bool operator != (const extended_public_key_type& p1, const extended_public_key_type& p2); +}; + +struct extended_private_key_type { + struct binary_key { + binary_key() = default; + uint32_t check = 0; + fc::ecc::extended_key_data data; + }; + + fc::ecc::extended_key_data key_data; + + extended_private_key_type(); + extended_private_key_type(const fc::ecc::extended_key_data& data); + extended_private_key_type(const fc::ecc::extended_private_key& extprivkey); + explicit extended_private_key_type(const std::string& base58str); + operator fc::ecc::extended_private_key() const; + explicit operator std::string() const; + friend bool operator == (const extended_private_key_type& p1, const fc::ecc::extended_private_key& p); + friend bool operator == (const extended_private_key_type& p1, const extended_private_key_type& p); + friend bool operator != (const extended_private_key_type& p1, const extended_private_key_type& p); +}; + +struct fee_schedule; +} } // graphene::protocol + +namespace fc { +void to_variant(const graphene::protocol::public_key_type& var, fc::variant& vo, uint32_t max_depth = 2); +void from_variant(const fc::variant& var, graphene::protocol::public_key_type& vo, uint32_t max_depth = 2); +void to_variant(const graphene::protocol::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth = 2); +void from_variant(const fc::variant& var, graphene::protocol::extended_public_key_type& vo, uint32_t max_depth = 2); +void to_variant(const graphene::protocol::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth = 2); +void from_variant(const fc::variant& var, graphene::protocol::extended_private_key_type& vo, uint32_t max_depth = 2); + + +template<> +struct get_typename> { static const char* name() { + return "shared_ptr"; +} }; +template<> +struct get_typename> { static const char* name() { + return "shared_ptr"; +} }; +void from_variant( const fc::variant& var, std::shared_ptr& vo, + uint32_t max_depth = 2 ); +} + +FC_REFLECT_ENUM(graphene::protocol::object_type, + (null_object_type) + (base_object_type) + (account_object_type) + (force_settlement_object_type) + (asset_object_type) + (committee_member_object_type) + (witness_object_type) + (limit_order_object_type) + (call_order_object_type) + (custom_object_type) + (proposal_object_type) + (operation_history_object_type) + (withdraw_permission_object_type) + (vesting_balance_object_type) + (worker_object_type) + (balance_object_type) + (tournament_object_type) + (tournament_details_object_type) + (match_object_type) + (game_object_type) + (sport_object_type) + (event_group_object_type) + (event_object_type) + (betting_market_rules_object_type) + (betting_market_group_object_type) + (betting_market_object_type) + (bet_object_type) + (custom_permission_object_type) + (custom_account_authority_object_type) + (offer_object_type) + (nft_metadata_type) + (nft_object_type) + (OBJECT_TYPE_COUNT)) + +FC_REFLECT_TYPENAME(graphene::protocol::account_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::asset_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::force_settlement_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::committee_member_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::witness_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::limit_order_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::call_order_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::custom_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::proposal_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::operation_history_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::withdraw_permission_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::vesting_balance_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::worker_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::balance_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::tournament_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::tournament_details_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::match_id_type)) +FC_REFLECT_TYPENAME(graphene::protocol::game_id_type)) +FC_REFLECT_TYPENAME(graphene::protocol::sport_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::event_group_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::event_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::betting_market_rules_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::betting_market_group_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::betting_market_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::bet_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::custom_permission_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::custom_account_authority_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::offer_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::nft_metadata_id_type) +FC_REFLECT_TYPENAME(graphene::protocol::nft_id_type) + +FC_REFLECT(graphene::protocol::public_key_type, (key_data)) +FC_REFLECT(graphene::protocol::public_key_type::binary_key, (data)(check)) +FC_REFLECT(graphene::protocol::extended_public_key_type, (key_data)) +FC_REFLECT(graphene::protocol::extended_public_key_type::binary_key, (check)(data)) +FC_REFLECT(graphene::protocol::extended_private_key_type, (key_data)) +FC_REFLECT(graphene::protocol::extended_private_key_type::binary_key, (check)(data)) + +FC_REFLECT_TYPENAME(graphene::protocol::share_type) +FC_REFLECT(graphene::protocol::void_t,) + +FC_REFLECT_ENUM(graphene::protocol::asset_issuer_permission_flags, + (charge_market_fee) + (white_list) + (transfer_restricted) + (override_authority) + (disable_force_settle) + (global_settle) + (disable_confidential) + (witness_fed_asset) + (committee_fed_asset)) diff --git a/libraries/chain/include/graphene/chain/protocol/vesting.hpp b/libraries/protocol/include/graphene/protocol/vesting.hpp similarity index 76% rename from libraries/chain/include/graphene/chain/protocol/vesting.hpp rename to libraries/protocol/include/graphene/protocol/vesting.hpp index 4dffb253..1f5779be 100644 --- a/libraries/chain/include/graphene/chain/protocol/vesting.hpp +++ b/libraries/protocol/include/graphene/protocol/vesting.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include -namespace graphene { namespace chain { +#include + +namespace graphene { namespace protocol { enum class vesting_balance_type { normal, gpos }; @@ -121,21 +121,22 @@ namespace graphene { namespace chain { } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::vesting_balance_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::vesting_balance_withdraw_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::vesting_balance_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::vesting_balance_withdraw_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::vesting_balance_create_operation, (fee)(creator)(owner)(amount)(policy)(balance_type) ) -FC_REFLECT( graphene::chain::vesting_balance_withdraw_operation, (fee)(vesting_balance)(owner)(amount)) +FC_REFLECT( graphene::protocol::vesting_balance_create_operation, (fee)(creator)(owner)(amount)(policy) ) +FC_REFLECT( graphene::protocol::vesting_balance_withdraw_operation, (fee)(vesting_balance)(owner)(amount) ) -FC_REFLECT(graphene::chain::linear_vesting_policy_initializer, (begin_timestamp)(vesting_cliff_seconds)(vesting_duration_seconds) ) -FC_REFLECT(graphene::chain::cdd_vesting_policy_initializer, (start_claim)(vesting_seconds) ) -FC_REFLECT_TYPENAME( graphene::chain::vesting_policy_initializer ) +FC_REFLECT(graphene::protocol::linear_vesting_policy_initializer, (begin_timestamp)(vesting_cliff_seconds)(vesting_duration_seconds) ) +FC_REFLECT(graphene::protocol::cdd_vesting_policy_initializer, (start_claim)(vesting_seconds) ) +FC_REFLECT_EMPTY( graphene::protocol::instant_vesting_policy_initializer ) +FC_REFLECT_TYPENAME( graphene::protocol::vesting_policy_initializer ) -FC_REFLECT_ENUM( graphene::chain::vesting_balance_type, (normal)(gpos) ) +FC_REFLECT_ENUM( graphene::protocol::vesting_balance_type, (normal)(gpos) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_withdraw_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vesting_balance_withdraw_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vesting_balance_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vesting_balance_withdraw_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vesting_balance_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vesting_balance_withdraw_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/vote.hpp b/libraries/protocol/include/graphene/protocol/vote.hpp similarity index 86% rename from libraries/chain/include/graphene/chain/protocol/vote.hpp rename to libraries/protocol/include/graphene/protocol/vote.hpp index 7d733e45..0c69dddd 100644 --- a/libraries/chain/include/graphene/chain/protocol/vote.hpp +++ b/libraries/protocol/include/graphene/protocol/vote.hpp @@ -26,7 +26,7 @@ #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief An ID for some votable object @@ -125,25 +125,21 @@ struct vote_id_type } }; -class global_property_object; - -vote_id_type get_next_vote_id( global_property_object& gpo, vote_id_type::vote_type type ); - -} } // graphene::chain +} } // graphene::protocol namespace fc { class variant; -void to_variant( const graphene::chain::vote_id_type& var, fc::variant& vo, uint32_t max_depth = 1 ); -void from_variant( const fc::variant& var, graphene::chain::vote_id_type& vo, uint32_t max_depth = 1 ); +void to_variant( const graphene::protocol::vote_id_type& var, fc::variant& vo, uint32_t max_depth = 1 ); +void from_variant( const fc::variant& var, graphene::protocol::vote_id_type& vo, uint32_t max_depth = 1 ); } // fc -FC_REFLECT_TYPENAME( fc::flat_set ) +FC_REFLECT_TYPENAME( fc::flat_set ) -FC_REFLECT_ENUM( graphene::chain::vote_id_type::vote_type, (witness)(committee)(worker)(VOTE_TYPE_COUNT) ) -FC_REFLECT( graphene::chain::vote_id_type, (content) ) +FC_REFLECT_ENUM( graphene::protocol::vote_id_type::vote_type, (witness)(committee)(worker)(VOTE_TYPE_COUNT) ) +FC_REFLECT( graphene::protocol::vote_id_type, (content) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::vote_id_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::vote_id_type ) diff --git a/libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp similarity index 89% rename from libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp rename to libraries/protocol/include/graphene/protocol/withdraw_permission.hpp index 7963e99f..0041379c 100644 --- a/libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp +++ b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp @@ -22,11 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief Create a new withdrawal permission @@ -166,19 +165,19 @@ namespace graphene { namespace chain { void validate()const; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::withdraw_permission_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::withdraw_permission_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::withdraw_permission_claim_operation::fee_parameters_type, (fee)(price_per_kbyte) ) -FC_REFLECT( graphene::chain::withdraw_permission_delete_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::withdraw_permission_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::withdraw_permission_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::withdraw_permission_claim_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::protocol::withdraw_permission_delete_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::withdraw_permission_create_operation, (fee)(withdraw_from_account)(authorized_account) +FC_REFLECT( graphene::protocol::withdraw_permission_create_operation, (fee)(withdraw_from_account)(authorized_account) (withdrawal_limit)(withdrawal_period_sec)(periods_until_expiration)(period_start_time) ) -FC_REFLECT( graphene::chain::withdraw_permission_update_operation, (fee)(withdraw_from_account)(authorized_account) +FC_REFLECT( graphene::protocol::withdraw_permission_update_operation, (fee)(withdraw_from_account)(authorized_account) (permission_to_update)(withdrawal_limit)(withdrawal_period_sec)(period_start_time)(periods_until_expiration) ) -FC_REFLECT( graphene::chain::withdraw_permission_claim_operation, (fee)(withdraw_permission)(withdraw_from_account)(withdraw_to_account)(amount_to_withdraw)(memo) ); -FC_REFLECT( graphene::chain::withdraw_permission_delete_operation, (fee)(withdraw_from_account)(authorized_account) +FC_REFLECT( graphene::protocol::withdraw_permission_claim_operation, (fee)(withdraw_permission)(withdraw_from_account)(withdraw_to_account)(amount_to_withdraw)(memo) ); +FC_REFLECT( graphene::protocol::withdraw_permission_delete_operation, (fee)(withdraw_from_account)(authorized_account) (withdrawal_permission) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_create_operation::fee_parameters_type ) diff --git a/libraries/chain/include/graphene/chain/protocol/witness.hpp b/libraries/protocol/include/graphene/protocol/witness.hpp similarity index 75% rename from libraries/chain/include/graphene/chain/protocol/witness.hpp rename to libraries/protocol/include/graphene/protocol/witness.hpp index 2b5e88b0..33472a3f 100644 --- a/libraries/chain/include/graphene/chain/protocol/witness.hpp +++ b/libraries/protocol/include/graphene/protocol/witness.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @brief Create a witness object, as a bid to hold a witness position on the network. @@ -78,15 +77,15 @@ namespace graphene { namespace chain { /// TODO: witness_resign_operation : public base_operation -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::witness_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::witness_create_operation, (fee)(witness_account)(url)(block_signing_key)(initial_secret) ) +FC_REFLECT( graphene::protocol::witness_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::witness_create_operation, (fee)(witness_account)(url)(block_signing_key) ) -FC_REFLECT( graphene::chain::witness_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::witness_update_operation, (fee)(witness)(witness_account)(new_url)(new_signing_key)(new_initial_secret) ) +FC_REFLECT( graphene::protocol::witness_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::witness_update_operation, (fee)(witness)(witness_account)(new_url)(new_signing_key) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::witness_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::witness_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::witness_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::witness_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::witness_update_operation ) diff --git a/libraries/chain/include/graphene/chain/protocol/worker.hpp b/libraries/protocol/include/graphene/protocol/worker.hpp similarity index 88% rename from libraries/chain/include/graphene/chain/protocol/worker.hpp rename to libraries/protocol/include/graphene/protocol/worker.hpp index 11e0aa05..ccc59e8d 100644 --- a/libraries/chain/include/graphene/chain/protocol/worker.hpp +++ b/libraries/protocol/include/graphene/protocol/worker.hpp @@ -22,10 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @defgroup workers The Blockchain Worker System @@ -96,13 +95,13 @@ namespace graphene { namespace chain { } } -FC_REFLECT( graphene::chain::vesting_balance_worker_initializer, (pay_vesting_period_days) ) -FC_REFLECT( graphene::chain::burn_worker_initializer, ) -FC_REFLECT( graphene::chain::refund_worker_initializer, ) -FC_REFLECT_TYPENAME( graphene::chain::worker_initializer ) +FC_REFLECT( graphene::protocol::vesting_balance_worker_initializer, (pay_vesting_period_days) ) +FC_REFLECT( graphene::protocol::burn_worker_initializer, ) +FC_REFLECT( graphene::protocol::refund_worker_initializer, ) +FC_REFLECT_TYPENAME( graphene::protocol::worker_initializer ) -FC_REFLECT( graphene::chain::worker_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::worker_create_operation, +FC_REFLECT( graphene::protocol::worker_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::worker_create_operation, (fee)(owner)(work_begin_date)(work_end_date)(daily_pay)(name)(url)(initializer) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::worker_create_operation::fee_parameters_type ) diff --git a/libraries/chain/protocol/lottery_ops.cpp b/libraries/protocol/lottery_ops.cpp similarity index 100% rename from libraries/chain/protocol/lottery_ops.cpp rename to libraries/protocol/lottery_ops.cpp diff --git a/libraries/chain/protocol/market.cpp b/libraries/protocol/market.cpp similarity index 67% rename from libraries/chain/protocol/market.cpp rename to libraries/protocol/market.cpp index ae0a3a68..5c72baea 100644 --- a/libraries/chain/protocol/market.cpp +++ b/libraries/protocol/market.cpp @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include #include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void limit_order_create_operation::validate()const { @@ -46,12 +46,12 @@ void call_order_update_operation::validate()const FC_ASSERT( delta_collateral.amount != 0 || delta_debt.amount != 0 ); } FC_CAPTURE_AND_RETHROW((*this)) } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_cancel_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::call_order_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::limit_order_cancel_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::call_order_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::fill_order_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order_cancel_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::call_order_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order_cancel_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::call_order_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::fill_order_operation ) diff --git a/libraries/chain/protocol/memo.cpp b/libraries/protocol/memo.cpp similarity index 93% rename from libraries/chain/protocol/memo.cpp rename to libraries/protocol/memo.cpp index 387c095f..6780cadd 100644 --- a/libraries/chain/protocol/memo.cpp +++ b/libraries/protocol/memo.cpp @@ -21,12 +21,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include + +#include + #include #include -namespace graphene { namespace chain { +#include + +namespace graphene { namespace protocol { void memo_data::set_message(const fc::ecc::private_key& priv, const fc::ecc::public_key& pub, const string& msg, uint64_t custom_nonce) @@ -89,7 +92,7 @@ memo_message memo_message::deserialize(const string& serial) return result; } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::memo_message ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::memo_data ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::memo_message ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::memo_data ) diff --git a/libraries/chain/protocol/nft.cpp b/libraries/protocol/nft.cpp similarity index 100% rename from libraries/chain/protocol/nft.cpp rename to libraries/protocol/nft.cpp diff --git a/libraries/chain/protocol/offer.cpp b/libraries/protocol/offer.cpp similarity index 100% rename from libraries/chain/protocol/offer.cpp rename to libraries/protocol/offer.cpp diff --git a/libraries/chain/protocol/operations.cpp b/libraries/protocol/operations.cpp similarity index 91% rename from libraries/chain/protocol/operations.cpp rename to libraries/protocol/operations.cpp index e513028c..335abc36 100644 --- a/libraries/chain/protocol/operations.cpp +++ b/libraries/protocol/operations.cpp @@ -21,12 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include #include #include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { uint64_t base_operation::calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte ) { @@ -87,6 +86,6 @@ void operation_get_required_authorities( const operation& op, op.visit( operation_get_required_auth( active, owner, other ) ); } -} } // namespace graphene::chain +} } // namespace graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::op_wrapper ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::op_wrapper ) diff --git a/libraries/chain/protocol/proposal.cpp b/libraries/protocol/proposal.cpp similarity index 83% rename from libraries/chain/protocol/proposal.cpp rename to libraries/protocol/proposal.cpp index f14f057a..a1a40187 100644 --- a/libraries/chain/protocol/proposal.cpp +++ b/libraries/protocol/proposal.cpp @@ -21,12 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { proposal_create_operation proposal_create_operation::committee_proposal(const chain_parameters& global_params, fc::time_point_sec head_block_time ) { @@ -105,11 +105,11 @@ void proposal_update_operation::get_required_owner_authorities( flat_set -#include +#include #include #include @@ -30,7 +29,7 @@ #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { pts_address::pts_address() { @@ -43,10 +42,7 @@ namespace graphene { namespace chain { if( v.size() ) memcpy( addr.data(), v.data(), std::min( v.size(), addr.size() ) ); - if( !is_valid() ) - { - FC_THROW_EXCEPTION( invalid_pts_address, "invalid pts_address ${a}", ("a", base58str) ); - } + FC_ASSERT(is_valid(), "invalid pts_address ${a}", ("a", base58str)); } pts_address::pts_address( const fc::ecc::public_key& pub, bool compressed, uint8_t version ) @@ -90,13 +86,13 @@ namespace graphene { namespace chain { namespace fc { - void to_variant( const graphene::chain::pts_address& var, variant& vo, uint32_t max_depth ) + void to_variant( const graphene::protocol::pts_address& var, variant& vo, uint32_t max_depth ) { vo = std::string(var); } - void from_variant( const variant& var, graphene::chain::pts_address& vo, uint32_t max_depth ) + void from_variant( const variant& var, graphene::protocol::pts_address& vo, uint32_t max_depth ) { - vo = graphene::chain::pts_address( var.as_string() ); + vo = graphene::protocol::pts_address( var.as_string() ); } namespace raw { diff --git a/libraries/chain/protocol/small_ops.cpp b/libraries/protocol/small_ops.cpp similarity index 100% rename from libraries/chain/protocol/small_ops.cpp rename to libraries/protocol/small_ops.cpp diff --git a/libraries/chain/protocol/vote.cpp b/libraries/protocol/special_authority.cpp similarity index 62% rename from libraries/chain/protocol/vote.cpp rename to libraries/protocol/special_authority.cpp index 68f476f5..2f7b4f91 100644 --- a/libraries/chain/protocol/vote.cpp +++ b/libraries/protocol/special_authority.cpp @@ -22,32 +22,26 @@ * THE SOFTWARE. */ -#include -#include -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { -vote_id_type get_next_vote_id( global_property_object& gpo, vote_id_type::vote_type type ) +struct special_authority_validate_visitor { - return vote_id_type( type, gpo.next_available_vote_id++ ); + typedef void result_type; + + void operator()( const no_special_authority& a ) {} + + void operator()( const top_holders_special_authority& a ) + { + FC_ASSERT( a.num_top_holders > 0 ); + } +}; + +void validate_special_authority( const special_authority& a ) +{ + special_authority_validate_visitor vtor; + a.visit( vtor ); } -} } // graphene::chain - -namespace fc -{ - -void to_variant( const graphene::chain::vote_id_type& var, variant& vo, uint32_t max_depth ) -{ - vo = string(var); -} - -void from_variant( const variant& var, graphene::chain::vote_id_type& vo, uint32_t max_depth ) -{ - vo = graphene::chain::vote_id_type(var.as_string()); -} - -} // fc - -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vote_id_type ) +} } // graphene::protocol diff --git a/libraries/chain/protocol/sport.cpp b/libraries/protocol/sport.cpp similarity index 100% rename from libraries/chain/protocol/sport.cpp rename to libraries/protocol/sport.cpp diff --git a/libraries/chain/protocol/tournament.cpp b/libraries/protocol/tournament.cpp similarity index 100% rename from libraries/chain/protocol/tournament.cpp rename to libraries/protocol/tournament.cpp diff --git a/libraries/chain/protocol/transaction.cpp b/libraries/protocol/transaction.cpp similarity index 94% rename from libraries/chain/protocol/transaction.cpp rename to libraries/protocol/transaction.cpp index 94c6ded9..8fe191ca 100644 --- a/libraries/chain/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -21,14 +21,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include + +#include +#include +#include #include #include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { digest_type processed_transaction::merkle_digest()const { @@ -67,7 +69,7 @@ graphene::chain::transaction_id_type graphene::chain::transaction::id() const return result; } -const signature_type& graphene::chain::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id) +const signature_type& graphene::protocol::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)); @@ -75,7 +77,7 @@ const signature_type& graphene::chain::signed_transaction::sign(const private_ke return signatures.back(); } -signature_type graphene::chain::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id)const +signature_type graphene::protocol::signed_transaction::sign(const private_key_type& key, const chain_id_type& chain_id)const { digest_type::encoder enc; fc::raw::pack( enc, chain_id ); @@ -417,7 +419,7 @@ set signed_transaction::minimize_required_signatures( result.erase( k ); try { - graphene::chain::verify_authority( operations, result, get_active, get_owner, get_custom, max_recursion ); + graphene::protocol::verify_authority( operations, result, get_active, get_owner, get_custom, max_recursion ); continue; // element stays erased if verify_authority is ok } catch( const tx_missing_owner_auth& e ) {} @@ -435,11 +437,12 @@ void signed_transaction::verify_authority( const std::function(account_id_type, const operation&)>& get_custom, uint32_t max_recursion )const { try { - graphene::chain::verify_authority( operations, get_signature_keys( chain_id ), get_active, get_owner, get_custom, max_recursion ); + graphene::protocol::verify_authority( operations, get_signature_keys( chain_id ), get_active, get_owner, get_custom, max_recursion ); } FC_CAPTURE_AND_RETHROW( (*this) ) } -} } // graphene::chain +} } // graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::signed_transaction) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::processed_transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::signed_transaction) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::processed_transaction) diff --git a/libraries/chain/protocol/transfer.cpp b/libraries/protocol/transfer.cpp similarity index 79% rename from libraries/chain/protocol/transfer.cpp rename to libraries/protocol/transfer.cpp index 0fb0aefa..cc63146b 100644 --- a/libraries/chain/protocol/transfer.cpp +++ b/libraries/protocol/transfer.cpp @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { share_type transfer_operation::calculate_fee( const fee_parameters_type& schedule )const { @@ -62,9 +62,9 @@ void override_transfer_operation::validate()const FC_ASSERT( issuer != from ); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::override_transfer_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transfer_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::override_transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::override_transfer_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::override_transfer_operation ) diff --git a/libraries/chain/protocol/types.cpp b/libraries/protocol/types.cpp similarity index 83% rename from libraries/chain/protocol/types.cpp rename to libraries/protocol/types.cpp index d5c04992..e07f7c64 100644 --- a/libraries/chain/protocol/types.cpp +++ b/libraries/protocol/types.cpp @@ -21,15 +21,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include +#include +#include +#include #include #include #include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { public_key_type::public_key_type():key_data(){}; @@ -191,7 +192,7 @@ namespace graphene { namespace chain { // extended_private_key_type - extended_private_key_type::extended_private_key_type():key_data(){}; + extended_private_key_type::extended_private_key_type() = default; extended_private_key_type::extended_private_key_type( const fc::ecc::extended_key_data& data ) :key_data( data ){}; @@ -243,38 +244,48 @@ namespace graphene { namespace chain { return p1.key_data != p2.key_data; } -} } // graphene::chain +} } // graphene::protocol namespace fc { using namespace std; - void to_variant( const graphene::chain::public_key_type& var, fc::variant& vo, uint32_t max_depth ) + void to_variant( const graphene::protocol::public_key_type& var, fc::variant& vo, uint32_t max_depth ) { vo = std::string( var ); } - void from_variant( const fc::variant& var, graphene::chain::public_key_type& vo, uint32_t max_depth ) + void from_variant( const fc::variant& var, graphene::protocol::public_key_type& vo, uint32_t max_depth ) { - vo = graphene::chain::public_key_type( var.as_string() ); + vo = graphene::protocol::public_key_type( var.as_string() ); } - void to_variant( const graphene::chain::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth ) + void to_variant( const graphene::protocol::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth ) { vo = std::string( var ); } - void from_variant( const fc::variant& var, graphene::chain::extended_public_key_type& vo, uint32_t max_depth ) + void from_variant( const fc::variant& var, graphene::protocol::extended_public_key_type& vo, uint32_t max_depth ) { - vo = graphene::chain::extended_public_key_type( var.as_string() ); + vo = graphene::protocol::extended_public_key_type( var.as_string() ); } - void to_variant( const graphene::chain::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth ) + void to_variant( const graphene::protocol::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth ) { vo = std::string( var ); } - void from_variant( const fc::variant& var, graphene::chain::extended_private_key_type& vo, uint32_t max_depth ) + void from_variant( const fc::variant& var, graphene::protocol::extended_private_key_type& vo, uint32_t max_depth ) { - vo = graphene::chain::extended_private_key_type( var.as_string() ); + vo = graphene::protocol::extended_private_key_type( var.as_string() ); } + + void from_variant( const fc::variant& var, std::shared_ptr& vo, + uint32_t max_depth ) { + // If it's null, just make a new one + if (!vo) vo = std::make_shared(); + // Convert the non-const shared_ptr to a non-const fee_schedule& so we can write it + // Don't decrement max_depth since we're not actually deserializing at this step + from_variant(var, const_cast(*vo), max_depth); + } + } // fc diff --git a/libraries/chain/include/graphene/chain/protocol/config.hpp b/libraries/protocol/vote.cpp similarity index 74% rename from libraries/chain/include/graphene/chain/protocol/config.hpp rename to libraries/protocol/vote.cpp index 870b08fe..ae1755c1 100644 --- a/libraries/chain/include/graphene/chain/protocol/config.hpp +++ b/libraries/protocol/vote.cpp @@ -21,5 +21,22 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#pragma once -#include + +#include +#include +#include + +namespace fc +{ + +void to_variant( const graphene::protocol::vote_id_type& var, variant& vo, uint32_t max_depth ) +{ + vo = string(var); +} + +void from_variant( const variant& var, graphene::protocol::vote_id_type& vo, uint32_t max_depth ) +{ + vo = graphene::protocol::vote_id_type(var.as_string()); +} + +} // fc diff --git a/libraries/chain/protocol/withdraw_permission.cpp b/libraries/protocol/withdraw_permission.cpp similarity index 69% rename from libraries/chain/protocol/withdraw_permission.cpp rename to libraries/protocol/withdraw_permission.cpp index b36c378d..1155e3d5 100644 --- a/libraries/chain/protocol/withdraw_permission.cpp +++ b/libraries/protocol/withdraw_permission.cpp @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void withdraw_permission_update_operation::validate()const { @@ -67,13 +67,13 @@ void withdraw_permission_delete_operation::validate() const FC_ASSERT( withdraw_from_account != authorized_account ); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_claim_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_delete_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_claim_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_delete_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_claim_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_delete_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_claim_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::withdraw_permission_delete_operation ) diff --git a/libraries/chain/protocol/witness.cpp b/libraries/protocol/witness.cpp similarity index 73% rename from libraries/chain/protocol/witness.cpp rename to libraries/protocol/witness.cpp index 90583cd8..eb8d4661 100644 --- a/libraries/chain/protocol/witness.cpp +++ b/libraries/protocol/witness.cpp @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include #include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void witness_create_operation::validate() const { @@ -39,9 +39,9 @@ void witness_update_operation::validate() const FC_ASSERT(new_url->size() < GRAPHENE_MAX_URL_LENGTH ); } -} } // graphene::chain +} } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::witness_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::witness_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::witness_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::witness_update_operation ) diff --git a/libraries/chain/protocol/worker.cpp b/libraries/protocol/worker.cpp similarity index 95% rename from libraries/chain/protocol/worker.cpp rename to libraries/protocol/worker.cpp index 932148ec..86de8bc4 100644 --- a/libraries/chain/protocol/worker.cpp +++ b/libraries/protocol/worker.cpp @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include #include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void worker_create_operation::validate() const { diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index f3bdec4a..1b7a57b9 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -62,16 +62,14 @@ #include #include #include -<<<<<<< HEAD #include -======= #include #include #include ->>>>>>> 8f1eca14... Replace fc::uint128 with boost::multiprecision::uint128_t #include #include +#include #include #include @@ -81,7 +79,8 @@ #include -#include +#include +#include #include #include #include @@ -659,11 +658,11 @@ public: return _checksum == fc::sha512(); } - template - T get_object(object_id id)const + template + typename graphene::db::object_downcast::type get_object(ID id)const { auto ob = _remote_db->get_objects({id}).front(); - return ob.template as( GRAPHENE_MAX_NESTED_OBJECTS ); + return ob.template as::type>( GRAPHENE_MAX_NESTED_OBJECTS ); } void set_operation_fees( signed_transaction& tx, const std::shared_ptr s ) @@ -685,13 +684,9 @@ public: " old"); result["next_maintenance_time"] = fc::get_approximate_relative_time_string(dynamic_props.next_maintenance_time); result["chain_id"] = chain_props.chain_id; -<<<<<<< HEAD - result["participation"] = (100*dynamic_props.recent_slots_filled.popcount()) / 128.0; -======= stringstream participation; participation << fixed << std::setprecision(2) << (100.0*fc::popcount(dynamic_props.recent_slots_filled)) / 128.0; result["participation"] = participation.str(); ->>>>>>> 8f1eca14... Replace fc::uint128 with boost::multiprecision::uint128_t result["active_witnesses"] = fc::variant(global_props.active_witnesses, GRAPHENE_MAX_NESTED_OBJECTS); result["active_committee_members"] = fc::variant(global_props.active_committee_members, GRAPHENE_MAX_NESTED_OBJECTS); result["entropy"] = fc::variant(dynamic_props.random, GRAPHENE_MAX_NESTED_OBJECTS); @@ -1195,7 +1190,7 @@ public: total_fee += gprops.current_fees->set_fee( op, fee_asset_obj.options.core_exchange_rate ); FC_ASSERT((total_fee * fee_asset_obj.options.core_exchange_rate).amount <= - get_object(fee_asset_obj.dynamic_asset_data_id).fee_pool, + get_object(fee_asset_obj.dynamic_asset_data_id).fee_pool, "Cannot pay fees in ${asset}, as this asset's fee pool is insufficiently funded.", ("asset", fee_asset_obj.symbol)); } else { @@ -2087,7 +2082,7 @@ public: if( vbid ) { - result.emplace_back( get_object(*vbid), now ); + result.emplace_back( get_object(*vbid), now ); return result; } @@ -2606,14 +2601,13 @@ public: return sign_transaction(trx, broadcast); } - signed_transaction cancel_order(object_id_type order_id, bool broadcast = false) + signed_transaction cancel_order(limit_order_id_type order_id, bool broadcast = false) { try { FC_ASSERT(!is_locked()); - FC_ASSERT(order_id.space() == protocol_ids, "Invalid order ID ${id}", ("id", order_id)); signed_transaction trx; limit_order_cancel_operation op; - op.fee_paying_account = get_object(order_id).seller; + op.fee_paying_account = get_object(order_id).seller; op.order = order_id; trx.operations = {op}; set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees); @@ -4130,7 +4124,7 @@ asset_bitasset_data_object wallet_api::get_bitasset_data(string asset_name_or_id { auto asset = get_asset(asset_name_or_id); FC_ASSERT(asset.is_market_issued() && asset.bitasset_data_id); - return my->get_object(*asset.bitasset_data_id); + return my->get_object(*asset.bitasset_data_id); } account_id_type wallet_api::get_account_id(string account_name_or_id) const diff --git a/programs/build_helpers/member_enumerator.cpp b/programs/build_helpers/member_enumerator.cpp index d956af38..44e8cfac 100644 --- a/programs/build_helpers/member_enumerator.cpp +++ b/programs/build_helpers/member_enumerator.cpp @@ -18,8 +18,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -#include -#include +#include +#include #include #include #include diff --git a/programs/genesis_util/convert_address.cpp b/programs/genesis_util/convert_address.cpp index 7f73acdb..f8224cc8 100644 --- a/programs/genesis_util/convert_address.cpp +++ b/programs/genesis_util/convert_address.cpp @@ -26,13 +26,13 @@ * Convert BTC / PTS addresses to a Graphene address. */ -#include -#include +#include +#include #include #include -using namespace graphene::chain; +using namespace graphene::protocol; int main(int argc, char** argv) { diff --git a/programs/genesis_util/genesis_update.cpp b/programs/genesis_util/genesis_update.cpp index 4df7091f..136603a4 100644 --- a/programs/genesis_util/genesis_update.cpp +++ b/programs/genesis_util/genesis_update.cpp @@ -32,8 +32,7 @@ #include #include -#include -#include +#include #include #include diff --git a/programs/genesis_util/get_dev_key.cpp b/programs/genesis_util/get_dev_key.cpp index ea7cdf9f..4fc6a42f 100644 --- a/programs/genesis_util/get_dev_key.cpp +++ b/programs/genesis_util/get_dev_key.cpp @@ -28,8 +28,8 @@ #include #include -#include -#include +#include +#include #include #ifndef WIN32 @@ -73,10 +73,10 @@ int main( int argc, char** argv ) auto show_key = [&comma]( const fc::ecc::private_key& priv_key ) { fc::limited_mutable_variant_object mvo(5); - graphene::chain::public_key_type pub_key = priv_key.get_public_key(); + graphene::protocol::public_key_type pub_key = priv_key.get_public_key(); mvo( "private_key", graphene::utilities::key_to_wif( priv_key ) ) ( "public_key", std::string( pub_key ) ) - ( "address", graphene::chain::address( pub_key ) ) + ( "address", graphene::protocol::address( pub_key ) ) ; if( comma ) std::cout << ",\n"; diff --git a/programs/js_operation_serializer/main.cpp b/programs/js_operation_serializer/main.cpp index d7c5c2f9..9ce86cfa 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -21,8 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include + +#include +#include #include #include @@ -136,11 +137,16 @@ template<> struct js_name { static std::string name(){ retu template<> struct js_name< vote_id_type > { static std::string name(){ return "vote_id"; } }; template<> struct js_name< time_point_sec > { static std::string name(){ return "time_point_sec"; } }; -template -struct js_name > +template +struct js_name > { static std::string name(){ +<<<<<<< HEAD return "protocol_id_type \"" + remove_namespace(fc::get_typename::name()) + "\""; +======= + return "protocol_id_type(\"" + + remove_namespace(fc::get_typename>>::name()) + "\")"; +>>>>>>> eec1da5b... Ref #1506: Isolate chain/protocol to its own library }; }; @@ -283,8 +289,8 @@ struct serializer,false> static void generate(){} }; -template -struct serializer< graphene::db::object_id ,true> +template +struct serializer< graphene::db::object_id ,true> { static void init() {} static void generate() {} diff --git a/programs/size_checker/main.cpp b/programs/size_checker/main.cpp index 3015e1cd..a7c09308 100644 --- a/programs/size_checker/main.cpp +++ b/programs/size_checker/main.cpp @@ -27,7 +27,8 @@ #include #include -#include +#include +#include #include #include @@ -35,7 +36,7 @@ #include #include -using namespace graphene::chain; +using namespace graphene::protocol; vector< fc::variant_object > g_op_types; @@ -68,7 +69,7 @@ int main( int argc, char** argv ) { try { - graphene::chain::operation op; + graphene::protocol::operation op; vector witnesses; witnesses.resize(50); diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index 487b66dc..5f1ebc16 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -23,12 +23,19 @@ */ #pragma once -#include -#include #include +#include +#include + +#include +#include #include +#include +#include +#include + #include #include From 9bada137355eead7815442038e7aa0962ddf23d8 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sun, 14 Apr 2019 15:41:42 -0500 Subject: [PATCH 16/77] Ref #1506: Add object_downcast_t Allows the more concise expression `object_downcast_t` instead of the old `typename object_downcast::type` --- libraries/db/include/graphene/db/object_database.hpp | 8 ++++---- libraries/db/include/graphene/db/object_id.hpp | 2 ++ libraries/wallet/wallet.cpp | 4 ++-- programs/js_operation_serializer/main.cpp | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libraries/db/include/graphene/db/object_database.hpp b/libraries/db/include/graphene/db/object_database.hpp index 8e91dbf4..3a4315c1 100644 --- a/libraries/db/include/graphene/db/object_database.hpp +++ b/libraries/db/include/graphene/db/object_database.hpp @@ -122,13 +122,13 @@ namespace graphene { namespace db { } template - auto find( object_id id )const -> const typename object_downcast::type* { - return find::type>(id); + auto find( object_id id )const -> const object_downcast_t* { + return find>(id); } template - auto get( object_id id )const -> const typename object_downcast::type& { - return get::type>(id); + auto get( object_id id )const -> const object_downcast_t& { + return get>(id); } template diff --git a/libraries/db/include/graphene/db/object_id.hpp b/libraries/db/include/graphene/db/object_id.hpp index 2d351181..c44dcc17 100644 --- a/libraries/db/include/graphene/db/object_id.hpp +++ b/libraries/db/include/graphene/db/object_id.hpp @@ -102,6 +102,8 @@ namespace graphene { namespace db { template<> \ struct object_downcast> { using type = OBJECT; }; \ } } + template + using object_downcast_t = typename object_downcast::type; template struct object_id diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 1b7a57b9..86db6176 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -659,10 +659,10 @@ public: } template - typename graphene::db::object_downcast::type get_object(ID id)const + typename graphene::db::object_downcast_tget_object(ID id)const { auto ob = _remote_db->get_objects({id}).front(); - return ob.template as::type>( GRAPHENE_MAX_NESTED_OBJECTS ); + return ob.template as>( GRAPHENE_MAX_NESTED_OBJECTS ); } void set_operation_fees( signed_transaction& tx, const std::shared_ptr s ) diff --git a/programs/js_operation_serializer/main.cpp b/programs/js_operation_serializer/main.cpp index 9ce86cfa..63a6d604 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -138,7 +138,7 @@ template<> struct js_name< vote_id_type > { static std::string name(){ retu template<> struct js_name< time_point_sec > { static std::string name(){ return "time_point_sec"; } }; template -struct js_name > +struct js_name > { static std::string name(){ <<<<<<< HEAD From f076bb258692b7659644df19306525ce959a1d31 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 19 Apr 2019 17:11:28 -0500 Subject: [PATCH 17/77] Ref #1506: Move ID types from db to protocol The ID types, object_id and object_id_type, were defined in the db library, and the protocol library depends on db to get these types. Technically, the ID types are defined by the protocol and used by the database, and not vice versa. Therefore these types should be in the protocol library, and db should depend on protocol to get them. This commit makes it so. --- libraries/db/CMakeLists.txt | 2 +- libraries/db/include/graphene/db/object.hpp | 4 ++-- libraries/protocol/CMakeLists.txt | 2 +- .../db => protocol/include/graphene/protocol}/object_id.hpp | 0 libraries/protocol/include/graphene/protocol/types.hpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename libraries/{db/include/graphene/db => protocol/include/graphene/protocol}/object_id.hpp (100%) diff --git a/libraries/db/CMakeLists.txt b/libraries/db/CMakeLists.txt index 6feb985c..b0899d86 100644 --- a/libraries/db/CMakeLists.txt +++ b/libraries/db/CMakeLists.txt @@ -1,6 +1,6 @@ file(GLOB HEADERS "include/graphene/db/*.hpp") add_library( graphene_db undo_database.cpp index.cpp object_database.cpp ${HEADERS} ) -target_link_libraries( graphene_db fc ) +target_link_libraries( graphene_db graphene_protocol fc ) target_include_directories( graphene_db PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) install( TARGETS diff --git a/libraries/db/include/graphene/db/object.hpp b/libraries/db/include/graphene/db/object.hpp index 09734d5f..2c0f2adc 100644 --- a/libraries/db/include/graphene/db/object.hpp +++ b/libraries/db/include/graphene/db/object.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include #include #include +#include #define MAX_NESTING (200) diff --git a/libraries/protocol/CMakeLists.txt b/libraries/protocol/CMakeLists.txt index 51932639..9c7e4805 100644 --- a/libraries/protocol/CMakeLists.txt +++ b/libraries/protocol/CMakeLists.txt @@ -41,7 +41,7 @@ list(APPEND SOURCES account.cpp add_library( graphene_protocol ${SOURCES} ${HEADERS} ) -target_link_libraries( graphene_protocol graphene_db fc ) +target_link_libraries( graphene_protocol fc ) target_include_directories( graphene_protocol PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) install( TARGETS diff --git a/libraries/db/include/graphene/db/object_id.hpp b/libraries/protocol/include/graphene/protocol/object_id.hpp similarity index 100% rename from libraries/db/include/graphene/db/object_id.hpp rename to libraries/protocol/include/graphene/protocol/object_id.hpp diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index 2ef4f290..020bebf0 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include From 9c71579d6ec7576c4b570018b1ea46a32284276a Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 13 Apr 2019 23:38:56 -0500 Subject: [PATCH 18/77] Ref #1506: Isolate chain/protocol to its own library --- libraries/wallet/wallet.cpp | 2 +- tests/benchmarks/main.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 86db6176..c379b845 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -659,7 +659,7 @@ public: } template - typename graphene::db::object_downcast_tget_object(ID id)const + graphene::db::object_downcast_t get_object(ID id)const { auto ob = _remote_db->get_objects({id}).front(); return ob.template as>( GRAPHENE_MAX_NESTED_OBJECTS ); diff --git a/tests/benchmarks/main.cpp b/tests/benchmarks/main.cpp index 706318d6..479fb337 100644 --- a/tests/benchmarks/main.cpp +++ b/tests/benchmarks/main.cpp @@ -23,3 +23,4 @@ */ #define BOOST_TEST_MODULE "C++ Benchmarks for Graphene Blockchain Database" #include + From 9a52c29023bf32859657f0c74125c78cf76842cc Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 1 May 2019 12:45:22 -0500 Subject: [PATCH 19/77] Remove commented-out index code --- .../account_history_plugin.hpp | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp b/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp index 986869ff..84315013 100644 --- a/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp +++ b/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp @@ -93,28 +93,3 @@ class affiliate_reward_index : public secondary_index }; } } //graphene::account_history - -/* -struct by_seq; -struct by_op; -typedef boost::multi_index_container< - graphene::chain::account_transaction_history_object, - boost::multi_index::indexed_by< - boost::multi_index::ordered_unique< tag, member< object, object_id_type, &object::id > >, - boost::multi_index::ordered_unique< tag, - composite_key< account_transaction_history_object, - member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>, - member< account_transaction_history_object, uint32_t, &account_transaction_history_object::sequence> - > - >, - boost::multi_index::ordered_unique< tag, - composite_key< account_transaction_history_object, - member< account_transaction_history_object, account_id_type, &account_transaction_history_object::account>, - member< account_transaction_history_object, operation_history_id_type, &account_transaction_history_object::operation_id> - > - > - > -> account_transaction_history_multi_index_type; - -typedef graphene::account_history::generic_index account_transaction_history_index; -*/ From 3a155776176eac1f75dbd6f06d033b36ed14ea4b Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 1 May 2019 12:47:49 -0500 Subject: [PATCH 20/77] Wrap overlength line --- libraries/protocol/include/graphene/protocol/object_id.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/protocol/include/graphene/protocol/object_id.hpp b/libraries/protocol/include/graphene/protocol/object_id.hpp index c44dcc17..7471ff6a 100644 --- a/libraries/protocol/include/graphene/protocol/object_id.hpp +++ b/libraries/protocol/include/graphene/protocol/object_id.hpp @@ -100,7 +100,8 @@ namespace graphene { namespace db { #define MAP_OBJECT_ID_TO_TYPE(OBJECT) \ namespace graphene { namespace db { \ template<> \ - struct object_downcast> { using type = OBJECT; }; \ + struct object_downcast> { using type = OBJECT; }; \ } } template using object_downcast_t = typename object_downcast::type; From 35d864e269c5b8a856308f535fa390f64741cd34 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 1 May 2019 12:50:00 -0500 Subject: [PATCH 21/77] Remove unused key types --- .../include/graphene/protocol/types.hpp | 48 ------- libraries/protocol/types.cpp | 128 ------------------ tests/tests/serialization_tests.cpp | 36 ----- 3 files changed, 212 deletions(-) diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index 020bebf0..260b904c 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -217,56 +217,12 @@ public: } }; -struct extended_public_key_type { - struct binary_key { - binary_key() = default; - uint32_t check = 0; - fc::ecc::extended_key_data data; - }; - - fc::ecc::extended_key_data key_data; - - extended_public_key_type(); - extended_public_key_type(const fc::ecc::extended_key_data& data); - extended_public_key_type(const fc::ecc::extended_public_key& extpubkey); - explicit extended_public_key_type(const std::string& base58str); - operator fc::ecc::extended_public_key() const; - explicit operator std::string() const; - friend bool operator == (const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2); - friend bool operator == (const extended_public_key_type& p1, const extended_public_key_type& p2); - friend bool operator != (const extended_public_key_type& p1, const extended_public_key_type& p2); -}; - -struct extended_private_key_type { - struct binary_key { - binary_key() = default; - uint32_t check = 0; - fc::ecc::extended_key_data data; - }; - - fc::ecc::extended_key_data key_data; - - extended_private_key_type(); - extended_private_key_type(const fc::ecc::extended_key_data& data); - extended_private_key_type(const fc::ecc::extended_private_key& extprivkey); - explicit extended_private_key_type(const std::string& base58str); - operator fc::ecc::extended_private_key() const; - explicit operator std::string() const; - friend bool operator == (const extended_private_key_type& p1, const fc::ecc::extended_private_key& p); - friend bool operator == (const extended_private_key_type& p1, const extended_private_key_type& p); - friend bool operator != (const extended_private_key_type& p1, const extended_private_key_type& p); -}; - struct fee_schedule; } } // graphene::protocol namespace fc { void to_variant(const graphene::protocol::public_key_type& var, fc::variant& vo, uint32_t max_depth = 2); void from_variant(const fc::variant& var, graphene::protocol::public_key_type& vo, uint32_t max_depth = 2); -void to_variant(const graphene::protocol::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth = 2); -void from_variant(const fc::variant& var, graphene::protocol::extended_public_key_type& vo, uint32_t max_depth = 2); -void to_variant(const graphene::protocol::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth = 2); -void from_variant(const fc::variant& var, graphene::protocol::extended_private_key_type& vo, uint32_t max_depth = 2); template<> @@ -349,10 +305,6 @@ FC_REFLECT_TYPENAME(graphene::protocol::nft_id_type) FC_REFLECT(graphene::protocol::public_key_type, (key_data)) FC_REFLECT(graphene::protocol::public_key_type::binary_key, (data)(check)) -FC_REFLECT(graphene::protocol::extended_public_key_type, (key_data)) -FC_REFLECT(graphene::protocol::extended_public_key_type::binary_key, (check)(data)) -FC_REFLECT(graphene::protocol::extended_private_key_type, (key_data)) -FC_REFLECT(graphene::protocol::extended_private_key_type::binary_key, (check)(data)) FC_REFLECT_TYPENAME(graphene::protocol::share_type) FC_REFLECT(graphene::protocol::void_t,) diff --git a/libraries/protocol/types.cpp b/libraries/protocol/types.cpp index e07f7c64..355b7339 100644 --- a/libraries/protocol/types.cpp +++ b/libraries/protocol/types.cpp @@ -136,114 +136,6 @@ namespace graphene { namespace protocol { return p1.key_data != p2.key_data; } - // extended_public_key_type - - extended_public_key_type::extended_public_key_type():key_data(){}; - - extended_public_key_type::extended_public_key_type( const fc::ecc::extended_key_data& data ) - :key_data( data ){}; - - extended_public_key_type::extended_public_key_type( const fc::ecc::extended_public_key& extpubkey ) - { - key_data = extpubkey.serialize_extended(); - }; - - extended_public_key_type::extended_public_key_type( const std::string& base58str ) - { - std::string prefix( GRAPHENE_ADDRESS_PREFIX ); - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - FC_ASSERT( fc::ripemd160::hash( (char*)bin_key.data.data(), bin_key.data.size() )._hash[0].value() == bin_key.check ); - key_data = bin_key.data; - } - - extended_public_key_type::operator fc::ecc::extended_public_key() const - { - return fc::ecc::extended_public_key::deserialize( key_data ); - } - - extended_public_key_type::operator std::string() const - { - binary_key k; - k.data = key_data; - k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0].value(); - auto data = fc::raw::pack( k ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); - } - - bool operator == ( const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2) - { - return p1.key_data == p2.serialize_extended(); - } - - bool operator == ( const extended_public_key_type& p1, const extended_public_key_type& p2) - { - return p1.key_data == p2.key_data; - } - - bool operator != ( const extended_public_key_type& p1, const extended_public_key_type& p2) - { - return p1.key_data != p2.key_data; - } - - // extended_private_key_type - - extended_private_key_type::extended_private_key_type() = default; - - extended_private_key_type::extended_private_key_type( const fc::ecc::extended_key_data& data ) - :key_data( data ){}; - - extended_private_key_type::extended_private_key_type( const fc::ecc::extended_private_key& extprivkey ) - { - key_data = extprivkey.serialize_extended(); - }; - - extended_private_key_type::extended_private_key_type( const std::string& base58str ) - { - std::string prefix( GRAPHENE_ADDRESS_PREFIX ); - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - FC_ASSERT( fc::ripemd160::hash( (char*)bin_key.data.data(), bin_key.data.size() )._hash[0].value() == bin_key.check ); - key_data = bin_key.data; - } - - extended_private_key_type::operator fc::ecc::extended_private_key() const - { - return fc::ecc::extended_private_key::deserialize( key_data ); - } - - extended_private_key_type::operator std::string() const - { - binary_key k; - k.data = key_data; - k.check = fc::ripemd160::hash( (char*)k.data.data(), k.data.size() )._hash[0].value(); - auto data = fc::raw::pack( k ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); - } - - bool operator == ( const extended_private_key_type& p1, const fc::ecc::extended_public_key& p2) - { - return p1.key_data == p2.serialize_extended(); - } - - bool operator == ( const extended_private_key_type& p1, const extended_private_key_type& p2) - { - return p1.key_data == p2.key_data; - } - - bool operator != ( const extended_private_key_type& p1, const extended_private_key_type& p2) - { - return p1.key_data != p2.key_data; - } - } } // graphene::protocol namespace fc @@ -259,26 +151,6 @@ namespace fc vo = graphene::protocol::public_key_type( var.as_string() ); } - void to_variant( const graphene::protocol::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth ) - { - vo = std::string( var ); - } - - void from_variant( const fc::variant& var, graphene::protocol::extended_public_key_type& vo, uint32_t max_depth ) - { - vo = graphene::protocol::extended_public_key_type( var.as_string() ); - } - - void to_variant( const graphene::protocol::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth ) - { - vo = std::string( var ); - } - - void from_variant( const fc::variant& var, graphene::protocol::extended_private_key_type& vo, uint32_t max_depth ) - { - vo = graphene::protocol::extended_private_key_type( var.as_string() ); - } - void from_variant( const fc::variant& var, std::shared_ptr& vo, uint32_t max_depth ) { // If it's null, just make a new one diff --git a/tests/tests/serialization_tests.cpp b/tests/tests/serialization_tests.cpp index 59e16f01..91085af4 100644 --- a/tests/tests/serialization_tests.cpp +++ b/tests/tests/serialization_tests.cpp @@ -86,42 +86,6 @@ BOOST_AUTO_TEST_CASE( json_tests ) } } -BOOST_AUTO_TEST_CASE( extended_private_key_type_test ) -{ - try - { - fc::ecc::extended_private_key key = fc::ecc::extended_private_key( fc::ecc::private_key::generate(), - fc::sha256(), - 0, 0, 0 ); - extended_private_key_type type = extended_private_key_type( key ); - std::string packed = std::string( type ); - extended_private_key_type unpacked = extended_private_key_type( packed ); - BOOST_CHECK( type == unpacked ); - } catch ( const fc::exception& e ) - { - edump((e.to_detail_string())); - throw; - } -} - -BOOST_AUTO_TEST_CASE( extended_public_key_type_test ) -{ - try - { - fc::ecc::extended_public_key key = fc::ecc::extended_public_key( fc::ecc::private_key::generate().get_public_key(), - fc::sha256(), - 0, 0, 0 ); - extended_public_key_type type = extended_public_key_type( key ); - std::string packed = std::string( type ); - extended_public_key_type unpacked = extended_public_key_type( packed ); - BOOST_CHECK( type == unpacked ); - } catch ( const fc::exception& e ) - { - edump((e.to_detail_string())); - throw; - } -} - BOOST_AUTO_TEST_CASE( extension_serialization_test ) { try From f57dc27f554c7786ea8648a8da619e075eda72af Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 1 May 2019 13:56:54 -0500 Subject: [PATCH 22/77] Probably fix Docker build --- .../chain/include/graphene/chain/withdraw_permission_object.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp index 5b723113..824d2f94 100644 --- a/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp +++ b/libraries/chain/include/graphene/chain/withdraw_permission_object.hpp @@ -24,6 +24,7 @@ #pragma once #include #include +#include #include namespace graphene { namespace chain { From ad670ecde17c4a898429856588620fb9f9700be0 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 1 May 2019 17:04:29 -0500 Subject: [PATCH 23/77] Fix build after rebase --- libraries/app/include/graphene/app/full_account.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/app/include/graphene/app/full_account.hpp b/libraries/app/include/graphene/app/full_account.hpp index 7de9daf6..d35c2b5c 100644 --- a/libraries/app/include/graphene/app/full_account.hpp +++ b/libraries/app/include/graphene/app/full_account.hpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace graphene { namespace app { using namespace graphene::chain; From 6074749813331a610001f93f8633b9b6032f9129 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 4 May 2019 12:33:25 -0500 Subject: [PATCH 24/77] Ref #1506/#1737: Some requested changes --- libraries/chain/CMakeLists.txt | 2 +- libraries/chain/account_evaluator.cpp | 2 +- libraries/chain/evaluator.cpp | 2 +- libraries/chain/get_config.cpp | 1 - libraries/chain/include/graphene/chain/config.hpp | 2 +- ...ial_authority.hpp => special_authority_evaluation.hpp} | 0 ...ial_authority.cpp => special_authority_evaluation.cpp} | 2 +- libraries/protocol/include/graphene/protocol/config.hpp | 8 +++++++- libraries/wallet/wallet.cpp | 2 +- 9 files changed, 13 insertions(+), 8 deletions(-) rename libraries/chain/include/graphene/chain/{special_authority.hpp => special_authority_evaluation.hpp} (100%) rename libraries/chain/{special_authority.cpp => special_authority_evaluation.cpp} (96%) diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 2c94b538..388fa5a9 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -58,7 +58,7 @@ add_library( graphene_chain withdraw_permission_evaluator.cpp worker_evaluator.cpp confidential_evaluator.cpp - special_authority.cpp + special_authority_evaluation.cpp buyback.cpp account_object.cpp diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index 515108ec..91e6f623 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include diff --git a/libraries/chain/evaluator.cpp b/libraries/chain/evaluator.cpp index ed32f5ef..638df2bd 100644 --- a/libraries/chain/evaluator.cpp +++ b/libraries/chain/evaluator.cpp @@ -56,7 +56,7 @@ database& generic_evaluator::db()const { return trx_state->db(); } fee_paying_account = &account_id(d); fee_paying_account_statistics = &fee_paying_account->statistics(d); - fee_asset = &asset_id_type(fee.asset_id)(d); + fee_asset = &fee.asset_id(d); fee_asset_dyn_data = &fee_asset->dynamic_asset_data_id(d); if( d.head_block_time() > HARDFORK_419_TIME ) diff --git a/libraries/chain/get_config.cpp b/libraries/chain/get_config.cpp index 6c30a534..285bcb37 100644 --- a/libraries/chain/get_config.cpp +++ b/libraries/chain/get_config.cpp @@ -74,7 +74,6 @@ fc::variant_object get_config() result[ "GRAPHENE_MAX_COLLATERAL_RATIO" ] = GRAPHENE_MAX_COLLATERAL_RATIO; result[ "GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO" ] = GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO; result[ "GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO" ] = GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO; - result[ "GRAPHENE_DEFAULT_MARGIN_PERIOD_SEC" ] = GRAPHENE_DEFAULT_MARGIN_PERIOD_SEC; result[ "GRAPHENE_DEFAULT_MAX_WITNESSES" ] = GRAPHENE_DEFAULT_MAX_WITNESSES; result[ "GRAPHENE_DEFAULT_MAX_COMMITTEE" ] = GRAPHENE_DEFAULT_MAX_COMMITTEE; result[ "GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC" ] = GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC; diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index 2a13a162..9b9b6dce 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -153,7 +153,7 @@ #define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4 #define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3 -#define GRAPHENE_CURRENT_DB_VERSION "PPY2.3" +#define GRAPHENE_CURRENT_DB_VERSION "PPY2.5" #define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT) diff --git a/libraries/chain/include/graphene/chain/special_authority.hpp b/libraries/chain/include/graphene/chain/special_authority_evaluation.hpp similarity index 100% rename from libraries/chain/include/graphene/chain/special_authority.hpp rename to libraries/chain/include/graphene/chain/special_authority_evaluation.hpp diff --git a/libraries/chain/special_authority.cpp b/libraries/chain/special_authority_evaluation.cpp similarity index 96% rename from libraries/chain/special_authority.cpp rename to libraries/chain/special_authority_evaluation.cpp index a92cc5e9..3c007f25 100644 --- a/libraries/chain/special_authority.cpp +++ b/libraries/chain/special_authority_evaluation.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include +#include #include #include diff --git a/libraries/protocol/include/graphene/protocol/config.hpp b/libraries/protocol/include/graphene/protocol/config.hpp index 6f1f6da4..8ea4bcc5 100644 --- a/libraries/protocol/include/graphene/protocol/config.hpp +++ b/libraries/protocol/include/graphene/protocol/config.hpp @@ -44,6 +44,13 @@ #define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT) +/** + * every second, the fraction of burned core asset which cycles is + * GRAPHENE_CORE_ASSET_CYCLE_RATE / (1 << GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS) + */ +#define GRAPHENE_CORE_ASSET_CYCLE_RATE 17 +#define GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS 32 + /** * Don't allow the committee_members to publish a limit that would * make the network unable to operate. @@ -109,7 +116,6 @@ #define GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO 1750 ///< Call when collateral only pays off 175% the debt #define GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO 1500 ///< Stop calling when collateral only pays off 150% of the debt ///@} -#define GRAPHENE_DEFAULT_MARGIN_PERIOD_SEC (30*60*60*24) /** * Reserved Account IDs with special meaning diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index c379b845..55530ecb 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -80,7 +80,7 @@ #include #include -#include +#include #include #include #include From c94e46f451b8e7659be34ee1b0816affd810d3e7 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 4 May 2019 16:14:01 -0500 Subject: [PATCH 25/77] Ref #1506/#1737: Macro-fy ID type definitions Define macros to fully de-boilerplate ID type definitions. Externalities: - Rename transaction_object -> transaction_history_object - Rename impl_asset_dynamic_data_type -> impl_asset_dynamic_data_object_type - Rename impl_asset_bitasset_data_type -> impl_asset_bitasset_data_object_type The first is to avoid a naming collision on transaction_id_type, and the other two are to maintain consistency with the naming of the other types. --- libraries/app/api.cpp | 2 +- libraries/chain/CMakeLists.txt | 1 + libraries/chain/db_block.cpp | 6 +- libraries/chain/db_init.cpp | 6 +- libraries/chain/db_notify.cpp | 13 +- libraries/chain/db_update.cpp | 5 +- .../include/graphene/chain/asset_object.hpp | 4 +- ...ect.hpp => transaction_history_object.hpp} | 24 +-- .../chain/include/graphene/chain/types.hpp | 105 +++------- ...ect.cpp => transaction_history_object.cpp} | 26 +-- .../include/graphene/protocol/types.hpp | 187 ++++++------------ 11 files changed, 135 insertions(+), 244 deletions(-) rename libraries/chain/include/graphene/chain/{transaction_object.hpp => transaction_history_object.hpp} (70%) rename libraries/chain/{transaction_object.cpp => transaction_history_object.cpp} (71%) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 949f93d2..0c78eb55 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 388fa5a9..5eed3f73 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -66,6 +66,7 @@ add_library( graphene_chain fba_object.cpp proposal_object.cpp vesting_balance_object.cpp + transaction_history_object.cpp small_objects.cpp block_database.cpp diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 4e1cf289..8360149f 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include #include @@ -816,8 +816,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_history_object& transaction) { + transaction.trx_id = trx.id(); transaction.trx = trx; }); } diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 5d67bd8e..0de70a0b 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include @@ -132,8 +132,8 @@ const uint8_t operation_history_object::type_id; const uint8_t proposal_object::space_id; const uint8_t proposal_object::type_id; -const uint8_t transaction_object::space_id; -const uint8_t transaction_object::type_id; +const uint8_t transaction_history_object::space_id; +const uint8_t transaction_history_object::type_id; const uint8_t vesting_balance_object::space_id; const uint8_t vesting_balance_object::type_id; diff --git a/libraries/chain/db_notify.cpp b/libraries/chain/db_notify.cpp index ad4d92c0..c1873ccd 100644 --- a/libraries/chain/db_notify.cpp +++ b/libraries/chain/db_notify.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include @@ -366,7 +366,6 @@ void get_relevant_accounts( const object* obj, flat_set& accoun { case null_object_type: case base_object_type: - case OBJECT_TYPE_COUNT: return; case account_object_type:{ accounts.insert( obj->id ); @@ -445,9 +444,9 @@ void get_relevant_accounts( const object* obj, flat_set& accoun break; case impl_reserved0_object_type: break; - case impl_asset_dynamic_data_type: + case impl_asset_dynamic_data_object_type: break; - case impl_asset_bitasset_data_type: + case impl_asset_bitasset_data_object_type: break; case impl_account_balance_object_type:{ const auto& aobj = dynamic_cast(obj); @@ -459,9 +458,9 @@ void get_relevant_accounts( const object* obj, flat_set& accoun assert( aobj != nullptr ); accounts.insert( aobj->owner ); break; - } case impl_transaction_object_type:{ - const auto& aobj = dynamic_cast(obj); - assert( aobj != nullptr ); + } case impl_transaction_history_object_type:{ + const auto& aobj = dynamic_cast(obj); + FC_ASSERT( aobj != nullptr ); transaction_get_impacted_accounts( aobj->trx, accounts ); break; } case impl_blinded_balance_object_type:{ diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index 1e9a0c51..acac1b91 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -153,7 +153,8 @@ void database::clear_expired_transactions() { try { //Look for expired transactions in the deduplication list, and remove them. //Transactions must have expired by at least two forking windows in order to be removed. - auto& transaction_idx = static_cast(get_mutable_index(implementation_ids, impl_transaction_object_type)); + auto& transaction_idx = static_cast(get_mutable_index(implementation_ids, + impl_transaction_history_object_type)); const auto& dedupe_index = transaction_idx.indices().get(); while( (!dedupe_index.empty()) && (head_block_time() > dedupe_index.begin()->trx.expiration) ) transaction_idx.remove(*dedupe_index.begin()); diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index 5e149447..02a25db5 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -60,7 +60,7 @@ namespace graphene { namespace chain { { public: static const uint8_t space_id = implementation_ids; - static const uint8_t type_id = impl_asset_dynamic_data_type; + static const uint8_t type_id = impl_asset_dynamic_data_object_type; /// The number of shares currently in existence share_type current_supply; @@ -193,7 +193,7 @@ namespace graphene { namespace chain { { public: static const uint8_t space_id = implementation_ids; - static const uint8_t type_id = impl_asset_bitasset_data_type; + static const uint8_t type_id = impl_asset_bitasset_data_object_type; /// The asset this object belong to asset_id_type asset_id; diff --git a/libraries/chain/include/graphene/chain/transaction_object.hpp b/libraries/chain/include/graphene/chain/transaction_history_object.hpp similarity index 70% rename from libraries/chain/include/graphene/chain/transaction_object.hpp rename to libraries/chain/include/graphene/chain/transaction_history_object.hpp index a613e07c..6bed7920 100644 --- a/libraries/chain/include/graphene/chain/transaction_object.hpp +++ b/libraries/chain/include/graphene/chain/transaction_history_object.hpp @@ -39,14 +39,14 @@ namespace graphene { namespace chain { using namespace boost::multi_index; /** * The purpose of this object is to enable the detection of duplicate transactions. When a transaction is included - * in a block a transaction_object is added. At the end of block processing all transaction_objects that have - * expired can be removed from the index. + * in a block a transaction_history_object is added. At the end of block processing all transaction_history_objects that + * have expired can be removed from the index. */ - class transaction_object : public abstract_object + class transaction_history_object : public abstract_object { public: static const uint8_t space_id = implementation_ids; - static const uint8_t type_id = impl_transaction_object_type; + static const uint8_t type_id = impl_transaction_history_object_type; signed_transaction trx; transaction_id_type trx_id; @@ -57,19 +57,21 @@ namespace graphene { namespace chain { struct by_expiration; struct by_trx_id; typedef multi_index_container< - transaction_object, + transaction_history_object, indexed_by< ordered_unique< tag, member< object, object_id_type, &object::id > >, - hashed_unique< tag, BOOST_MULTI_INDEX_MEMBER(transaction_object, transaction_id_type, trx_id), std::hash >, - ordered_non_unique< tag, const_mem_fun > + hashed_unique< tag, BOOST_MULTI_INDEX_MEMBER(transaction_history_object, transaction_id_type, trx_id), + std::hash >, + ordered_non_unique< tag, const_mem_fun< transaction_history_object, time_point_sec, + &transaction_history_object::get_expiration > > > > transaction_multi_index_type; - typedef generic_index transaction_index; + typedef generic_index transaction_index; } } -MAP_OBJECT_ID_TO_TYPE(graphene::chain::transaction_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::transaction_history_object) -FC_REFLECT_DERIVED( graphene::chain::transaction_object, (graphene::db::object), (trx)(trx_id) ) +FC_REFLECT_DERIVED( graphene::chain::transaction_history_object, (graphene::db::object), (trx)(trx_id) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transaction_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transaction_history_object ) diff --git a/libraries/chain/include/graphene/chain/types.hpp b/libraries/chain/include/graphene/chain/types.hpp index c84608a2..050672ad 100644 --- a/libraries/chain/include/graphene/chain/types.hpp +++ b/libraries/chain/include/graphene/chain/types.hpp @@ -25,82 +25,31 @@ #include -namespace graphene { namespace chain { +namespace graphene { namespace chain { using namespace protocol; } } -using namespace graphene::protocol; - -enum impl_object_type { - impl_global_property_object_type, - impl_dynamic_global_property_object_type, - impl_reserved0_object_type, // formerly index_meta_object_type, TODO: delete me - impl_asset_dynamic_data_type, - impl_asset_bitasset_data_type, - impl_account_balance_object_type, - impl_account_statistics_object_type, - impl_transaction_object_type, - impl_block_summary_object_type, - impl_account_transaction_history_object_type, - impl_blinded_balance_object_type, - impl_chain_property_object_type, - impl_witness_schedule_object_type, - impl_budget_record_object_type, - impl_special_authority_object_type, - impl_buyback_object_type, - impl_fba_accumulator_object_type, - impl_collateral_bid_object_type -}; - -using global_property_id_type = object_id; -using dynamic_global_property_id_type = object_id; -using asset_dynamic_data_id_type = object_id; -using asset_bitasset_data_id_type = object_id; -using account_balance_id_type = object_id; -using account_statistics_id_type = object_id; -using transaction_obj_id_type = object_id; -using block_summary_id_type = object_id; -using account_transaction_history_id_type = object_id; -using chain_property_id_type = object_id; -using witness_schedule_id_type = object_id; -using budget_record_id_type = object_id; -using blinded_balance_id_type = object_id; -using special_authority_id_type = object_id; -using buyback_id_type = object_id; -using fba_accumulator_id_type = object_id; -using collateral_bid_id_type = object_id; - -} } - -FC_REFLECT_ENUM(graphene::chain::impl_object_type, - (impl_global_property_object_type) - (impl_dynamic_global_property_object_type) - (impl_reserved0_object_type) - (impl_asset_dynamic_data_type) - (impl_asset_bitasset_data_type) - (impl_account_balance_object_type) - (impl_account_statistics_object_type) - (impl_transaction_object_type) - (impl_block_summary_object_type) - (impl_account_transaction_history_object_type) - (impl_blinded_balance_object_type) - (impl_chain_property_object_type) - (impl_witness_schedule_object_type) - (impl_budget_record_object_type) - (impl_special_authority_object_type) - (impl_buyback_object_type) - (impl_fba_accumulator_object_type) - (impl_collateral_bid_object_type)) - -FC_REFLECT_TYPENAME(graphene::chain::global_property_id_type) -FC_REFLECT_TYPENAME(graphene::chain::dynamic_global_property_id_type) -FC_REFLECT_TYPENAME(graphene::chain::asset_dynamic_data_id_type) -FC_REFLECT_TYPENAME(graphene::chain::asset_bitasset_data_id_type) -FC_REFLECT_TYPENAME(graphene::chain::account_balance_id_type) -FC_REFLECT_TYPENAME(graphene::chain::account_statistics_id_type) -FC_REFLECT_TYPENAME(graphene::chain::transaction_obj_id_type) -FC_REFLECT_TYPENAME(graphene::chain::block_summary_id_type) -FC_REFLECT_TYPENAME(graphene::chain::account_transaction_history_id_type) -FC_REFLECT_TYPENAME(graphene::chain::budget_record_id_type) -FC_REFLECT_TYPENAME(graphene::chain::special_authority_id_type) -FC_REFLECT_TYPENAME(graphene::chain::buyback_id_type) -FC_REFLECT_TYPENAME(graphene::chain::fba_accumulator_id_type) -FC_REFLECT_TYPENAME(graphene::chain::collateral_bid_id_type) +GRAPHENE_DEFINE_IDS(chain, implementation_ids, impl_, + (global_property) + (dynamic_global_property) + (reserved0) + (asset_dynamic_data) + (asset_bitasset_data) + (account_balance) + (account_statistics) + (transaction_history) + (block_summary) + (account_transaction_history) + (blinded_balance) + (chain_property) + (witness_schedule) + (budget_record) + (special_authority) + (buyback) + (fba_accumulator) + (asset_dividend_data) + (pending_dividend_payout_balance_for_holder_object) + (distributed_dividend_balance_data) + (betting_market_position_object) + (global_betting_statistics_object) + (lottery_balance_object) + (sweeps_vesting_balance_object) + (offer_history_object)) diff --git a/libraries/chain/transaction_object.cpp b/libraries/chain/transaction_history_object.cpp similarity index 71% rename from libraries/chain/transaction_object.cpp rename to libraries/chain/transaction_history_object.cpp index fb4f75df..e242b6c3 100644 --- a/libraries/chain/transaction_object.cpp +++ b/libraries/chain/transaction_history_object.cpp @@ -21,19 +21,19 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include namespace graphene { namespace chain { const object* transaction_index::create(const std::function& constructor, object_id_type) { - transaction_object obj; + transaction_history_object obj; obj.id = get_next_available_id(); constructor(&obj); auto result = _index.insert(std::move(obj)); - FC_ASSERT(result.second, "Could not create transaction_object! Most likely a uniqueness constraint is violated."); + FC_ASSERT(result.second, "Could not create transaction_history_object! Most likely a uniqueness constraint is violated."); return &*result.first; } @@ -43,28 +43,28 @@ void transaction_index::modify(const object* obj, assert(obj != nullptr); FC_ASSERT(obj->id < _index.size()); - const transaction_object* t = dynamic_cast(obj); + const transaction_history_object* t = dynamic_cast(obj); assert(t != nullptr); auto itr = _index.find(obj->id.instance()); assert(itr != _index.end()); - _index.modify(itr, [&m](transaction_object& o) { m(&o); }); + _index.modify(itr, [&m](transaction_history_object& o) { m(&o); }); } void transaction_index::add(unique_ptr o) { assert(o); object_id_type id = o->id; - assert(id.space() == transaction_object::space_id); - assert(id.type() == transaction_object::type_id); + assert(id.space() == transaction_history_object::space_id); + assert(id.type() == transaction_history_object::type_id); assert(id.instance() == size()); - auto trx = dynamic_cast(o.get()); + auto trx = dynamic_cast(o.get()); assert(trx != nullptr); o.release(); auto result = _index.insert(std::move(*trx)); - FC_ASSERT(result.second, "Could not insert transaction_object! Most likely a uniqueness constraint is violated."); + FC_ASSERT(result.second, "Could not insert transaction_history_object! Most likely a uniqueness constraint is violated."); } void transaction_index::remove(object_id_type id) @@ -74,16 +74,16 @@ void transaction_index::remove(object_id_type id) if( itr == index.end() ) return; - assert(id.space() == transaction_object::space_id); - assert(id.type() == transaction_object::type_id); + assert(id.space() == transaction_history_object::space_id); + assert(id.type() == transaction_history_object::type_id); index.erase(itr); } const object*transaction_index::get(object_id_type id) const { - if( id.type() != transaction_object::type_id || - id.space() != transaction_object::space_id ) + if( id.type() != transaction_history_object::type_id || + id.space() != transaction_history_object::space_id ) return nullptr; auto itr = _index.find(id.instance()); diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index 260b904c..c3a63db3 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -22,6 +22,14 @@ * THE SOFTWARE. */ #pragma once + +#include +#include +#include +#include +#include +#include + #include #include #include @@ -51,6 +59,28 @@ #include +#define GRAPHENE_NAME_TO_OBJECT_TYPE(x, prefix, name) BOOST_PP_CAT(prefix, BOOST_PP_CAT(name, _object_type)) +#define GRAPHENE_NAME_TO_ID_TYPE(x, y, name) BOOST_PP_CAT(name, _id_type) +#define GRAPHENE_DECLARE_ID(x, space_prefix_seq, name) \ + using BOOST_PP_CAT(name, _id_type) = object_id; +#define GRAPHENE_REFLECT_ID(x, id_namespace, name) FC_REFLECT_TYPENAME(graphene::id_namespace::name) + +#define GRAPHENE_DEFINE_IDS(id_namespace, object_space, object_type_prefix, names_seq) \ + namespace graphene { namespace id_namespace { \ + \ + enum BOOST_PP_CAT(object_type_prefix, object_type) { \ + BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TRANSFORM(GRAPHENE_NAME_TO_OBJECT_TYPE, object_type_prefix, names_seq)) \ + }; \ + \ + BOOST_PP_SEQ_FOR_EACH(GRAPHENE_DECLARE_ID, (object_space, object_type_prefix), names_seq) \ + \ + } } \ + \ + FC_REFLECT_ENUM(graphene::id_namespace::BOOST_PP_CAT(object_type_prefix, object_type), \ + BOOST_PP_SEQ_TRANSFORM(GRAPHENE_NAME_TO_OBJECT_TYPE, object_type_prefix, names_seq)) \ + BOOST_PP_SEQ_FOR_EACH(GRAPHENE_REFLECT_ID, id_namespace, BOOST_PP_SEQ_TRANSFORM(GRAPHENE_NAME_TO_ID_TYPE, , names_seq)) + namespace graphene { namespace protocol { using namespace graphene::db; @@ -124,65 +154,6 @@ enum reserved_spaces { inline bool is_relative(object_id_type o) { return o.space() == 0; } -/** - * List all object types from all namespaces here so they can - * be easily reflected and displayed in debug output. If a 3rd party - * wants to extend the core code then they will have to change the - * packed_object::type field from enum_type to uint16 to avoid - * warnings when converting packed_objects to/from json. - */ -enum object_type { - null_object_type, - base_object_type, - account_object_type, - asset_object_type, - force_settlement_object_type, - committee_member_object_type, - witness_object_type, - limit_order_object_type, - call_order_object_type, - custom_object_type, - proposal_object_type, - operation_history_object_type, - withdraw_permission_object_type, - vesting_balance_object_type, - worker_object_type, - balance_object_type, - tournament_object_type, - tournament_details_object_type, - match_object_type, - game_object_type, - sport_object_type, - event_group_object_type, - event_object_type, - betting_market_rules_object_type, - betting_market_group_object_type, - betting_market_object_type, - bet_object_type, - custom_permission_object_type, - custom_account_authority_object_type, - offer_object_type, - nft_metadata_type, - nft_object_type, -OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types -}; - -using account_id_type = object_id; -using asset_id_type = object_id; -using force_settlement_id_type = object_id; -using committee_member_id_type = object_id; -using witness_id_type = object_id; -using limit_order_id_type = object_id; -using call_order_id_type = object_id; -using custom_id_type = object_id; -using proposal_id_type = object_id; -using operation_history_id_type = object_id; -using withdraw_permission_id_type = object_id; -using vesting_balance_id_type = object_id; -using worker_id_type = object_id; -using balance_id_type = object_id; -using htlc_id_type = object_id; - using block_id_type = fc::ripemd160; using checksum_type = fc::ripemd160; using transaction_id_type = fc::ripemd160; @@ -237,71 +208,39 @@ void from_variant( const fc::variant& var, std::shared_ptr Date: Sat, 4 May 2019 18:20:13 -0500 Subject: [PATCH 26/77] Ref #1506/#1737: Fix clean_name() --- libraries/wallet/include/graphene/wallet/reflect_util.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/reflect_util.hpp b/libraries/wallet/include/graphene/wallet/reflect_util.hpp index 44c0f412..28473391 100644 --- a/libraries/wallet/include/graphene/wallet/reflect_util.hpp +++ b/libraries/wallet/include/graphene/wallet/reflect_util.hpp @@ -39,9 +39,9 @@ namespace impl { std::string clean_name( const std::string& name ) { - const static std::string prefix = "graphene::chain::"; + const static std::string prefix = "graphene::protocol::"; const static std::string suffix = "_operation"; - // graphene::chain::.*_operation + // graphene::protocol::.*_operation if( (name.size() >= prefix.size() + suffix.size()) && (name.substr( 0, prefix.size() ) == prefix) && (name.substr( name.size()-suffix.size(), suffix.size() ) == suffix ) From d02bea9ef0add2a82f8c19943027af9f8e02a65e Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 4 May 2019 19:17:46 -0500 Subject: [PATCH 27/77] Ref #1506/#1737: Oops --- libraries/protocol/include/graphene/protocol/types.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index c3a63db3..5239766f 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -212,8 +212,8 @@ GRAPHENE_DEFINE_IDS(protocol, protocol_ids, /*protocol objects are not prefixed* (null) (base) (account) - (force_settlement) (asset) + (force_settlement) (committee_member) (witness) (limit_order) From 841c6319f97160078c6f490b89dfdaca303fdcf0 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Mon, 6 May 2019 11:34:44 -0500 Subject: [PATCH 28/77] Fix .gitignore --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index a640668b..90311de0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -build*/ - *.a *.sw* From 9ae796c0a211840e7df0a2f2ea2249d1751aa97c Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Sun, 19 May 2019 11:38:40 +0200 Subject: [PATCH 29/77] Externalized serialization in protocol library --- libraries/app/database_api.cpp | 4 +- libraries/chain/balance_evaluator.cpp | 2 +- .../include/graphene/chain/genesis_state.hpp | 1 + libraries/protocol/CMakeLists.txt | 1 + libraries/protocol/address.cpp | 7 ++-- libraries/protocol/assert.cpp | 6 ++- libraries/protocol/asset.cpp | 2 + libraries/protocol/authority.cpp | 2 + libraries/protocol/chain_parameters.cpp | 5 ++- libraries/protocol/committee_member.cpp | 3 ++ libraries/protocol/confidential.cpp | 1 - libraries/protocol/custom.cpp | 4 +- .../include/graphene/protocol/account.hpp | 5 ++- .../include/graphene/protocol/address.hpp | 21 ++-------- .../include/graphene/protocol/assert.hpp | 6 ++- .../include/graphene/protocol/asset.hpp | 1 - .../include/graphene/protocol/asset_ops.hpp | 1 + .../include/graphene/protocol/authority.hpp | 1 + .../include/graphene/protocol/balance.hpp | 4 +- .../include/graphene/protocol/base.hpp | 5 ++- .../graphene/protocol/chain_parameters.hpp | 3 +- .../graphene/protocol/committee_member.hpp | 3 +- .../graphene/protocol/confidential.hpp | 3 +- .../include/graphene/protocol/custom.hpp | 1 + .../include/graphene/protocol/fba.hpp | 1 + .../include/graphene/protocol/market.hpp | 3 +- .../include/graphene/protocol/proposal.hpp | 1 + .../include/graphene/protocol/pts_address.hpp | 3 ++ .../graphene/protocol/special_authority.hpp | 1 - .../include/graphene/protocol/transaction.hpp | 3 -- .../include/graphene/protocol/transfer.hpp | 1 + .../include/graphene/protocol/types.hpp | 38 ++++++++++++++++--- .../include/graphene/protocol/vesting.hpp | 1 + .../include/graphene/protocol/vote.hpp | 2 +- .../graphene/protocol/withdraw_permission.hpp | 17 +++++---- .../include/graphene/protocol/witness.hpp | 1 + .../include/graphene/protocol/worker.hpp | 5 ++- libraries/protocol/market.cpp | 3 ++ libraries/protocol/operations.cpp | 2 + libraries/protocol/pts_address.cpp | 6 +-- libraries/protocol/small_ops.cpp | 29 +++++++------- libraries/protocol/special_authority.cpp | 4 ++ libraries/protocol/transaction.cpp | 5 ++- libraries/protocol/types.cpp | 11 +++++- libraries/protocol/vote.cpp | 4 +- libraries/protocol/witness.cpp | 2 + libraries/protocol/worker.cpp | 6 ++- libraries/wallet/wallet.cpp | 1 + 48 files changed, 154 insertions(+), 88 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 1af19618..5cc6da24 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -26,8 +26,8 @@ #include #include #include -#include -#include +#include +#include #include diff --git a/libraries/chain/balance_evaluator.cpp b/libraries/chain/balance_evaluator.cpp index 817d736f..8cc11b85 100644 --- a/libraries/chain/balance_evaluator.cpp +++ b/libraries/chain/balance_evaluator.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include -#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/genesis_state.hpp b/libraries/chain/include/graphene/chain/genesis_state.hpp index 2eadba2f..046f5e06 100644 --- a/libraries/chain/include/graphene/chain/genesis_state.hpp +++ b/libraries/chain/include/graphene/chain/genesis_state.hpp @@ -23,6 +23,7 @@ */ #pragma once +#include #include #include #include diff --git a/libraries/protocol/CMakeLists.txt b/libraries/protocol/CMakeLists.txt index 9c7e4805..aa5cbb1d 100644 --- a/libraries/protocol/CMakeLists.txt +++ b/libraries/protocol/CMakeLists.txt @@ -21,6 +21,7 @@ list(APPEND SOURCES account.cpp market.cpp operations.cpp pts_address.cpp + small_ops.cpp transaction.cpp types.cpp withdraw_permission.cpp diff --git a/libraries/protocol/address.cpp b/libraries/protocol/address.cpp index 7f1fb301..502960ac 100644 --- a/libraries/protocol/address.cpp +++ b/libraries/protocol/address.cpp @@ -21,12 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include #include -#include +#include #include #include +#include + namespace graphene { namespace protocol { address::address( const std::string& base58str ) { @@ -109,4 +110,4 @@ namespace fc } } -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::address ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::address ) diff --git a/libraries/protocol/assert.cpp b/libraries/protocol/assert.cpp index 6ab539a8..2d5454e0 100644 --- a/libraries/protocol/assert.cpp +++ b/libraries/protocol/assert.cpp @@ -21,7 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include +#include +#include + +#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/asset.cpp b/libraries/protocol/asset.cpp index d7f52813..b3998f7b 100644 --- a/libraries/protocol/asset.cpp +++ b/libraries/protocol/asset.cpp @@ -27,6 +27,8 @@ #include #include +#include + namespace graphene { namespace protocol { typedef boost::multiprecision::uint128_t uint128_t; typedef boost::multiprecision::int128_t int128_t; diff --git a/libraries/protocol/authority.cpp b/libraries/protocol/authority.cpp index 241942fc..c3fd44dd 100644 --- a/libraries/protocol/authority.cpp +++ b/libraries/protocol/authority.cpp @@ -24,6 +24,8 @@ #include +#include + namespace graphene { namespace protocol { void add_authority_accounts( diff --git a/libraries/protocol/chain_parameters.cpp b/libraries/protocol/chain_parameters.cpp index 7203d76e..a1bc209e 100644 --- a/libraries/protocol/chain_parameters.cpp +++ b/libraries/protocol/chain_parameters.cpp @@ -1,8 +1,11 @@ #include #include +#include + namespace graphene { namespace protocol { chain_parameters::chain_parameters() { current_fees = std::make_shared(); } -}} \ No newline at end of file +}} + diff --git a/libraries/protocol/committee_member.cpp b/libraries/protocol/committee_member.cpp index 12d32a71..3972a44a 100644 --- a/libraries/protocol/committee_member.cpp +++ b/libraries/protocol/committee_member.cpp @@ -22,6 +22,9 @@ * THE SOFTWARE. */ #include +#include + +#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/confidential.cpp b/libraries/protocol/confidential.cpp index f7d03f58..ce81b43b 100644 --- a/libraries/protocol/confidential.cpp +++ b/libraries/protocol/confidential.cpp @@ -162,4 +162,3 @@ GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::blind_trans GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_to_blind_operation ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::transfer_from_blind_operation ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::blind_transfer_operation ) - diff --git a/libraries/protocol/custom.cpp b/libraries/protocol/custom.cpp index c64e2e4c..d4355014 100644 --- a/libraries/protocol/custom.cpp +++ b/libraries/protocol/custom.cpp @@ -36,5 +36,5 @@ share_type custom_operation::calculate_fee(const fee_parameters_type& k)const } } -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::custom_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::custom_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::custom_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::custom_operation ) diff --git a/libraries/protocol/include/graphene/protocol/account.hpp b/libraries/protocol/include/graphene/protocol/account.hpp index 6eacf675..b7191943 100644 --- a/libraries/protocol/include/graphene/protocol/account.hpp +++ b/libraries/protocol/include/graphene/protocol/account.hpp @@ -22,11 +22,12 @@ * THE SOFTWARE. */ #pragma once + #include +#include +#include #include -#include #include -#include #include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/address.hpp b/libraries/protocol/include/graphene/protocol/address.hpp index e29743ab..48a3cc53 100644 --- a/libraries/protocol/include/graphene/protocol/address.hpp +++ b/libraries/protocol/include/graphene/protocol/address.hpp @@ -23,15 +23,14 @@ */ #pragma once -#include -#include +#include #include #include +#include namespace graphene { namespace protocol { - - struct public_key_type; + struct pts_address; /** * @brief a 160 bit hash of a public key @@ -77,20 +76,6 @@ namespace fc void from_variant( const fc::variant& var, graphene::protocol::address& vo, uint32_t max_depth = 1 ); } -namespace std -{ - template<> - struct hash - { - public: - size_t operator()(const graphene::protocol::address &a) const - { - return (uint64_t(a.addr._hash[0])<<32) | uint64_t( a.addr._hash[0] ); - } - }; -} - -#include FC_REFLECT( graphene::protocol::address, (addr) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::address ) diff --git a/libraries/protocol/include/graphene/protocol/assert.hpp b/libraries/protocol/include/graphene/protocol/assert.hpp index 0e780247..e12de038 100644 --- a/libraries/protocol/include/graphene/protocol/assert.hpp +++ b/libraries/protocol/include/graphene/protocol/assert.hpp @@ -22,7 +22,9 @@ * THE SOFTWARE. */ #pragma once + #include +#include namespace graphene { namespace protocol { @@ -112,5 +114,5 @@ FC_REFLECT( graphene::protocol::block_id_predicate, (id) ) FC_REFLECT_TYPENAME( graphene::protocol::predicate ) FC_REFLECT( graphene::protocol::assert_operation, (fee)(fee_paying_account)(predicates)(required_auths)(extensions) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::assert_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::assert_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::assert_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::assert_operation ) diff --git a/libraries/protocol/include/graphene/protocol/asset.hpp b/libraries/protocol/include/graphene/protocol/asset.hpp index 9798e520..72631021 100644 --- a/libraries/protocol/include/graphene/protocol/asset.hpp +++ b/libraries/protocol/include/graphene/protocol/asset.hpp @@ -22,7 +22,6 @@ * THE SOFTWARE. */ #pragma once -#include #include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/asset_ops.hpp b/libraries/protocol/include/graphene/protocol/asset_ops.hpp index 743197ae..7aa798c0 100644 --- a/libraries/protocol/include/graphene/protocol/asset_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/asset_ops.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include #include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/authority.hpp b/libraries/protocol/include/graphene/protocol/authority.hpp index 944f7a79..e3fb741e 100644 --- a/libraries/protocol/include/graphene/protocol/authority.hpp +++ b/libraries/protocol/include/graphene/protocol/authority.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/balance.hpp b/libraries/protocol/include/graphene/protocol/balance.hpp index 076697d9..1ab1453a 100644 --- a/libraries/protocol/include/graphene/protocol/balance.hpp +++ b/libraries/protocol/include/graphene/protocol/balance.hpp @@ -23,6 +23,8 @@ */ #pragma once #include +#include +#include namespace graphene { namespace protocol { @@ -58,4 +60,4 @@ FC_REFLECT( graphene::protocol::balance_claim_operation::fee_parameters_type, ) FC_REFLECT( graphene::protocol::balance_claim_operation, (fee)(deposit_to_account)(balance_to_claim)(balance_owner_key)(total_claimed) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::balance_claim_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::balance_claim_operation ) diff --git a/libraries/protocol/include/graphene/protocol/base.hpp b/libraries/protocol/include/graphene/protocol/base.hpp index 29d2b237..faef9b09 100644 --- a/libraries/protocol/include/graphene/protocol/base.hpp +++ b/libraries/protocol/include/graphene/protocol/base.hpp @@ -23,13 +23,14 @@ */ #pragma once +#include #include -#include -#include #include namespace graphene { namespace protocol { + struct asset; + struct authority; struct asset; struct authority; diff --git a/libraries/protocol/include/graphene/protocol/chain_parameters.hpp b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp index 2121dca2..8685349f 100644 --- a/libraries/protocol/include/graphene/protocol/chain_parameters.hpp +++ b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp @@ -27,7 +27,6 @@ #include <../hardfork.d/GPOS.hf> #include #include -#include namespace graphene { namespace protocol { struct fee_schedule; @@ -218,4 +217,4 @@ FC_REFLECT( graphene::protocol::chain_parameters, (extensions) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::chain_parameters ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::chain_parameters ) diff --git a/libraries/protocol/include/graphene/protocol/committee_member.hpp b/libraries/protocol/include/graphene/protocol/committee_member.hpp index 748994dd..5e63e963 100644 --- a/libraries/protocol/include/graphene/protocol/committee_member.hpp +++ b/libraries/protocol/include/graphene/protocol/committee_member.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include #include namespace graphene { namespace protocol { @@ -94,11 +95,11 @@ namespace graphene { namespace protocol { /// TODO: committee_member_resign_operation : public base_operation } } // graphene::protocol + FC_REFLECT( graphene::protocol::committee_member_create_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::protocol::committee_member_update_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::protocol::committee_member_update_global_parameters_operation::fee_parameters_type, (fee) ) - FC_REFLECT( graphene::protocol::committee_member_create_operation, (fee)(committee_member_account)(url) ) FC_REFLECT( graphene::protocol::committee_member_update_operation, diff --git a/libraries/protocol/include/graphene/protocol/confidential.hpp b/libraries/protocol/include/graphene/protocol/confidential.hpp index 5d407420..fbb0a5b2 100644 --- a/libraries/protocol/include/graphene/protocol/confidential.hpp +++ b/libraries/protocol/include/graphene/protocol/confidential.hpp @@ -24,6 +24,8 @@ #pragma once #include +#include +#include namespace graphene { namespace protocol { @@ -281,7 +283,6 @@ FC_REFLECT( graphene::protocol::blind_transfer_operation, FC_REFLECT( graphene::protocol::transfer_to_blind_operation::fee_parameters_type, (fee)(price_per_output) ) FC_REFLECT( graphene::protocol::transfer_from_blind_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::protocol::blind_transfer_operation::fee_parameters_type, (fee)(price_per_output) ) -FC_REFLECT( graphene::chain::blind_transfer_operation::fee_parameters_type, (fee)(price_per_output) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_to_blind_operation::fee_parameters_type ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::transfer_from_blind_operation::fee_parameters_type ) diff --git a/libraries/protocol/include/graphene/protocol/custom.hpp b/libraries/protocol/include/graphene/protocol/custom.hpp index dc31168e..2fc63f59 100644 --- a/libraries/protocol/include/graphene/protocol/custom.hpp +++ b/libraries/protocol/include/graphene/protocol/custom.hpp @@ -24,6 +24,7 @@ #pragma once #include +#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/fba.hpp b/libraries/protocol/include/graphene/protocol/fba.hpp index 0f5425bf..1b48e77e 100644 --- a/libraries/protocol/include/graphene/protocol/fba.hpp +++ b/libraries/protocol/include/graphene/protocol/fba.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/market.hpp b/libraries/protocol/include/graphene/protocol/market.hpp index 4dee59f0..4c38b6fa 100644 --- a/libraries/protocol/include/graphene/protocol/market.hpp +++ b/libraries/protocol/include/graphene/protocol/market.hpp @@ -23,7 +23,7 @@ */ #pragma once #include -#include +#include namespace graphene { namespace protocol { @@ -177,4 +177,3 @@ GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_create_ GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_cancel_operation ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::call_order_update_operation ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::fill_order_operation ) - diff --git a/libraries/protocol/include/graphene/protocol/proposal.hpp b/libraries/protocol/include/graphene/protocol/proposal.hpp index c18a06b3..43d37722 100644 --- a/libraries/protocol/include/graphene/protocol/proposal.hpp +++ b/libraries/protocol/include/graphene/protocol/proposal.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include namespace graphene { namespace protocol { /** diff --git a/libraries/protocol/include/graphene/protocol/pts_address.hpp b/libraries/protocol/include/graphene/protocol/pts_address.hpp index 7544d98a..403f086a 100644 --- a/libraries/protocol/include/graphene/protocol/pts_address.hpp +++ b/libraries/protocol/include/graphene/protocol/pts_address.hpp @@ -25,6 +25,8 @@ #include #include +#include +#include #include #include @@ -80,6 +82,7 @@ namespace fc { void to_variant( const graphene::protocol::pts_address& var, fc::variant& vo, uint32_t max_depth = 1 ); void from_variant( const fc::variant& var, graphene::protocol::pts_address& vo, uint32_t max_depth = 1 ); + namespace raw { extern template void pack( datastream& s, const graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); diff --git a/libraries/protocol/include/graphene/protocol/special_authority.hpp b/libraries/protocol/include/graphene/protocol/special_authority.hpp index f6e925cb..4ac6e34f 100644 --- a/libraries/protocol/include/graphene/protocol/special_authority.hpp +++ b/libraries/protocol/include/graphene/protocol/special_authority.hpp @@ -24,7 +24,6 @@ #pragma once #include -#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/transaction.hpp b/libraries/protocol/include/graphene/protocol/transaction.hpp index 8bb689ec..c75ca522 100644 --- a/libraries/protocol/include/graphene/protocol/transaction.hpp +++ b/libraries/protocol/include/graphene/protocol/transaction.hpp @@ -23,9 +23,6 @@ */ #pragma once #include -#include - -#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/transfer.hpp b/libraries/protocol/include/graphene/protocol/transfer.hpp index 76fc6bb4..bd8a0353 100644 --- a/libraries/protocol/include/graphene/protocol/transfer.hpp +++ b/libraries/protocol/include/graphene/protocol/transfer.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include #include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index 5239766f..122bc27a 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -23,6 +23,11 @@ */ #pragma once +#include +#include +#include +#include + #include #include #include @@ -30,11 +35,15 @@ #include #include +#include + #include #include #include +#include #include #include +#include #include #include #include @@ -46,19 +55,26 @@ #include #include +#include #include #include -#include -#include -#include -#include -#include #include #include #include +#define GRAPHENE_EXTERNAL_SERIALIZATION(ext, type) \ +namespace fc { \ + ext template void from_variant( const variant& v, type& vo, uint32_t max_depth ); \ + ext template void to_variant( const type& v, variant& vo, uint32_t max_depth ); \ +namespace raw { \ + ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ + ext template void pack< sha256::encoder, type >( sha256::encoder& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ + ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ + ext template void unpack< datastream, type >( datastream& s, type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ +} } // fc::raw + #define GRAPHENE_NAME_TO_OBJECT_TYPE(x, prefix, name) BOOST_PP_CAT(prefix, BOOST_PP_CAT(name, _object_type)) #define GRAPHENE_NAME_TO_ID_TYPE(x, y, name) BOOST_PP_CAT(name, _id_type) #define GRAPHENE_DECLARE_ID(x, space_prefix_seq, name) \ @@ -206,7 +222,8 @@ struct get_typename> { static } }; void from_variant( const fc::variant& var, std::shared_ptr& vo, uint32_t max_depth = 2 ); -} + +} // fc::raw GRAPHENE_DEFINE_IDS(protocol, protocol_ids, /*protocol objects are not prefixed*/, (null) @@ -258,3 +275,12 @@ FC_REFLECT_ENUM(graphene::protocol::asset_issuer_permission_flags, (disable_confidential) (witness_fed_asset) (committee_fed_asset)) + +namespace fc { namespace raw { + extern template void pack( datastream& s, const graphene::protocol::public_key_type& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + extern template void pack( datastream& s, const graphene::protocol::public_key_type& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + extern template void unpack( datastream& s, graphene::protocol::public_key_type& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); +} } // fc::raw diff --git a/libraries/protocol/include/graphene/protocol/vesting.hpp b/libraries/protocol/include/graphene/protocol/vesting.hpp index 1f5779be..98294716 100644 --- a/libraries/protocol/include/graphene/protocol/vesting.hpp +++ b/libraries/protocol/include/graphene/protocol/vesting.hpp @@ -24,6 +24,7 @@ #pragma once #include +#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/vote.hpp b/libraries/protocol/include/graphene/protocol/vote.hpp index 0c69dddd..2d62631e 100644 --- a/libraries/protocol/include/graphene/protocol/vote.hpp +++ b/libraries/protocol/include/graphene/protocol/vote.hpp @@ -24,7 +24,7 @@ #pragma once -#include +#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp index 0041379c..01b4207f 100644 --- a/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp +++ b/libraries/protocol/include/graphene/protocol/withdraw_permission.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include #include namespace graphene { namespace protocol { @@ -180,11 +181,11 @@ FC_REFLECT( graphene::protocol::withdraw_permission_claim_operation, (fee)(withd FC_REFLECT( graphene::protocol::withdraw_permission_delete_operation, (fee)(withdraw_from_account)(authorized_account) (withdrawal_permission) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_update_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_claim_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_delete_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_update_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_claim_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::withdraw_permission_delete_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_update_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_claim_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_delete_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_update_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_claim_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::withdraw_permission_delete_operation ) diff --git a/libraries/protocol/include/graphene/protocol/witness.hpp b/libraries/protocol/include/graphene/protocol/witness.hpp index 33472a3f..8483050d 100644 --- a/libraries/protocol/include/graphene/protocol/witness.hpp +++ b/libraries/protocol/include/graphene/protocol/witness.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/worker.hpp b/libraries/protocol/include/graphene/protocol/worker.hpp index ccc59e8d..eb02155d 100644 --- a/libraries/protocol/include/graphene/protocol/worker.hpp +++ b/libraries/protocol/include/graphene/protocol/worker.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include namespace graphene { namespace protocol { @@ -104,5 +105,5 @@ FC_REFLECT( graphene::protocol::worker_create_operation::fee_parameters_type, (f FC_REFLECT( graphene::protocol::worker_create_operation, (fee)(owner)(work_begin_date)(work_end_date)(daily_pay)(name)(url)(initializer) ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::worker_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::worker_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::worker_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::worker_create_operation ) diff --git a/libraries/protocol/market.cpp b/libraries/protocol/market.cpp index 5c72baea..87efa0b9 100644 --- a/libraries/protocol/market.cpp +++ b/libraries/protocol/market.cpp @@ -24,6 +24,8 @@ #include #include +#include + namespace graphene { namespace protocol { void limit_order_create_operation::validate()const @@ -55,3 +57,4 @@ GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::limit_order_cancel_operation ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::call_order_update_operation ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::fill_order_operation ) + diff --git a/libraries/protocol/operations.cpp b/libraries/protocol/operations.cpp index 335abc36..4dac9c86 100644 --- a/libraries/protocol/operations.cpp +++ b/libraries/protocol/operations.cpp @@ -25,6 +25,8 @@ #include #include +#include + namespace graphene { namespace protocol { uint64_t base_operation::calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte ) diff --git a/libraries/protocol/pts_address.cpp b/libraries/protocol/pts_address.cpp index e9844025..64d23fbc 100644 --- a/libraries/protocol/pts_address.cpp +++ b/libraries/protocol/pts_address.cpp @@ -96,10 +96,10 @@ namespace fc } namespace raw { - template void pack( datastream& s, const graphene::chain::pts_address& tx, + template void pack( datastream& s, const graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - template void pack( datastream& s, const graphene::chain::pts_address& tx, + template void pack( datastream& s, const graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); - template void unpack( datastream& s, graphene::chain::pts_address& tx, + template void unpack( datastream& s, graphene::protocol::pts_address& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); } } // fc::raw diff --git a/libraries/protocol/small_ops.cpp b/libraries/protocol/small_ops.cpp index 60464968..5dcf2ac9 100644 --- a/libraries/protocol/small_ops.cpp +++ b/libraries/protocol/small_ops.cpp @@ -22,12 +22,12 @@ * THE SOFTWARE. */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include @@ -54,13 +54,14 @@ FC_IMPLEMENT_DERIVED_EXCEPTION( insufficient_fee, transaction_exceptio } } // graphene::protocol -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::balance_claim_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::buyback_account_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::fba_distribute_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::balance_claim_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::buyback_account_options ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::fba_distribute_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_withdraw_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_withdraw_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::vesting_balance_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::vesting_balance_withdraw_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::vesting_balance_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::vesting_balance_withdraw_operation ) + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::chain_parameters ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::chain_parameters ) diff --git a/libraries/protocol/special_authority.cpp b/libraries/protocol/special_authority.cpp index 2f7b4f91..26d0c4fc 100644 --- a/libraries/protocol/special_authority.cpp +++ b/libraries/protocol/special_authority.cpp @@ -24,6 +24,8 @@ #include +#include + namespace graphene { namespace protocol { struct special_authority_validate_visitor @@ -45,3 +47,5 @@ void validate_special_authority( const special_authority& a ) } } } // graphene::protocol + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::top_holders_special_authority ) diff --git a/libraries/protocol/transaction.cpp b/libraries/protocol/transaction.cpp index 8fe191ca..c47e1e56 100644 --- a/libraries/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -22,9 +22,12 @@ * THE SOFTWARE. */ -#include +#include #include #include +#include +#include + #include #include #include diff --git a/libraries/protocol/types.cpp b/libraries/protocol/types.cpp index 355b7339..88f224e3 100644 --- a/libraries/protocol/types.cpp +++ b/libraries/protocol/types.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include + #include #include @@ -160,4 +160,11 @@ namespace fc from_variant(var, const_cast(*vo), max_depth); } -} // fc +namespace raw { + template void pack( datastream& s, const graphene::protocol::public_key_type& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + template void pack( datastream& s, const graphene::protocol::public_key_type& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); + template void unpack( datastream& s, graphene::protocol::public_key_type& tx, + uint32_t _max_depth=FC_PACK_MAX_DEPTH ); +} } // fc::raw diff --git a/libraries/protocol/vote.cpp b/libraries/protocol/vote.cpp index ae1755c1..1f94fd89 100644 --- a/libraries/protocol/vote.cpp +++ b/libraries/protocol/vote.cpp @@ -23,8 +23,6 @@ */ #include -#include -#include namespace fc { @@ -40,3 +38,5 @@ void from_variant( const variant& var, graphene::protocol::vote_id_type& vo, uin } } // fc + +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::vote_id_type ) diff --git a/libraries/protocol/witness.cpp b/libraries/protocol/witness.cpp index eb8d4661..484a1589 100644 --- a/libraries/protocol/witness.cpp +++ b/libraries/protocol/witness.cpp @@ -24,6 +24,8 @@ #include #include +#include + namespace graphene { namespace protocol { void witness_create_operation::validate() const diff --git a/libraries/protocol/worker.cpp b/libraries/protocol/worker.cpp index 86de8bc4..10ed156f 100644 --- a/libraries/protocol/worker.cpp +++ b/libraries/protocol/worker.cpp @@ -24,6 +24,8 @@ #include #include +#include + namespace graphene { namespace protocol { void worker_create_operation::validate() const @@ -38,5 +40,5 @@ void worker_create_operation::validate() const } } -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::worker_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::worker_create_operation ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::worker_create_operation::fee_parameters_type ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::worker_create_operation ) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 55530ecb..b0b41051 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -80,6 +80,7 @@ #include #include +#include #include #include #include From 2af062e7cfa43960264a296f06ec449b876ac3a6 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 21 Aug 2020 15:03:18 -0500 Subject: [PATCH 30/77] Fix compile sets Delete a couple of ghost files that were in the tree but not part of the project (I accidentally added them to CMakeLists while merging, but they're broken and not part of the Peerplays code), and add several files that got dropped from the build during merge. --- libraries/chain/CMakeLists.txt | 12 ++- .../chain/transaction_history_object.cpp | 95 ------------------- libraries/protocol/CMakeLists.txt | 1 - libraries/protocol/competitor.cpp | 35 ------- 4 files changed, 11 insertions(+), 132 deletions(-) delete mode 100644 libraries/chain/transaction_history_object.cpp delete mode 100644 libraries/protocol/competitor.cpp diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 5eed3f73..7901308b 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -66,13 +66,23 @@ add_library( graphene_chain fba_object.cpp proposal_object.cpp vesting_balance_object.cpp - transaction_history_object.cpp small_objects.cpp block_database.cpp is_authorized_asset.cpp + sport_evaluator.cpp + event_group_evaluator.cpp + event_group_object.cpp + event_evaluator.cpp + event_object.cpp + betting_market_evaluator.cpp + betting_market_object.cpp + betting_market_group_object.cpp + + affiliate_payout.cpp + ${HEADERS} "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp" ) diff --git a/libraries/chain/transaction_history_object.cpp b/libraries/chain/transaction_history_object.cpp deleted file mode 100644 index e242b6c3..00000000 --- a/libraries/chain/transaction_history_object.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#include - -namespace graphene { namespace chain { - -const object* transaction_index::create(const std::function& constructor, object_id_type) -{ - transaction_history_object obj; - - obj.id = get_next_available_id(); - constructor(&obj); - - auto result = _index.insert(std::move(obj)); - FC_ASSERT(result.second, "Could not create transaction_history_object! Most likely a uniqueness constraint is violated."); - return &*result.first; -} - -void transaction_index::modify(const object* obj, - const std::function& m) -{ - assert(obj != nullptr); - FC_ASSERT(obj->id < _index.size()); - - const transaction_history_object* t = dynamic_cast(obj); - assert(t != nullptr); - - auto itr = _index.find(obj->id.instance()); - assert(itr != _index.end()); - _index.modify(itr, [&m](transaction_history_object& o) { m(&o); }); -} - -void transaction_index::add(unique_ptr o) -{ - assert(o); - object_id_type id = o->id; - assert(id.space() == transaction_history_object::space_id); - assert(id.type() == transaction_history_object::type_id); - assert(id.instance() == size()); - - auto trx = dynamic_cast(o.get()); - assert(trx != nullptr); - o.release(); - - auto result = _index.insert(std::move(*trx)); - FC_ASSERT(result.second, "Could not insert transaction_history_object! Most likely a uniqueness constraint is violated."); -} - -void transaction_index::remove(object_id_type id) -{ - auto& index = _index.get(); - auto itr = index.find(id.instance()); - if( itr == index.end() ) - return; - - assert(id.space() == transaction_history_object::space_id); - assert(id.type() == transaction_history_object::type_id); - - index.erase(itr); -} - -const object*transaction_index::get(object_id_type id) const -{ - if( id.type() != transaction_history_object::type_id || - id.space() != transaction_history_object::space_id ) - return nullptr; - - auto itr = _index.find(id.instance()); - if( itr == _index.end() ) - return nullptr; - return &*itr; -} - -} } // graphene::chain diff --git a/libraries/protocol/CMakeLists.txt b/libraries/protocol/CMakeLists.txt index aa5cbb1d..a814ba2a 100644 --- a/libraries/protocol/CMakeLists.txt +++ b/libraries/protocol/CMakeLists.txt @@ -27,7 +27,6 @@ list(APPEND SOURCES account.cpp withdraw_permission.cpp worker.cpp betting_market.cpp - competitor.cpp event.cpp event_group.cpp lottery_ops.cpp diff --git a/libraries/protocol/competitor.cpp b/libraries/protocol/competitor.cpp deleted file mode 100644 index 1f35cf37..00000000 --- a/libraries/protocol/competitor.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2018 Peerplays Blockchain Standards Association, and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#include - -namespace graphene { namespace chain { - -void competitor_create_operation::validate() const -{ - FC_ASSERT( fee.amount >= 0 ); -} - - -} } // graphene::chain - From 1c0de74aa7d7ade30f09ba08fd7b1610bf02d866 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 21 Aug 2020 15:04:37 -0500 Subject: [PATCH 31/77] General fixes Fix warnings, build issues, unused code, etc. --- libraries/app/api.cpp | 2 +- libraries/app/application.cpp | 5 +- libraries/app/config_util.cpp | 4 +- libraries/app/database_api.cpp | 5 +- .../app/include/graphene/app/full_account.hpp | 1 - libraries/chain/account_evaluator.cpp | 2 +- libraries/chain/account_object.cpp | 2 +- libraries/chain/affiliate_payout.cpp | 10 +- libraries/chain/asset_evaluator.cpp | 1 - libraries/chain/asset_object.cpp | 2 +- libraries/chain/betting_market_object.cpp | 2 +- libraries/chain/db_bet.cpp | 12 +- libraries/chain/db_block.cpp | 6 +- libraries/chain/db_getter.cpp | 6 +- libraries/chain/db_init.cpp | 4 +- libraries/chain/db_maint.cpp | 31 +-- libraries/chain/db_market.cpp | 2 +- libraries/chain/db_update.cpp | 3 +- libraries/chain/db_witness_schedule.cpp | 6 +- libraries/chain/event_evaluator.cpp | 1 + libraries/chain/exceptions.cpp | 3 - libraries/chain/fork_database.cpp | 2 +- .../graphene/chain/affiliate_payout.hpp | 4 +- .../include/graphene/chain/asset_object.hpp | 9 +- .../chain/betting_market_evaluator.hpp | 2 +- .../graphene/chain/betting_market_object.hpp | 17 +- .../graphene/chain/block_summary_object.hpp | 3 +- .../graphene/chain/budget_record_object.hpp | 3 +- .../include/graphene/chain/buyback_object.hpp | 3 +- .../graphene/chain/chain_property_object.hpp | 1 + .../chain/committee_member_evaluator.hpp | 1 + .../chain/include/graphene/chain/config.hpp | 215 +----------------- .../chain/include/graphene/chain/database.hpp | 4 +- .../graphene/chain/event_evaluator.hpp | 4 +- .../graphene/chain/event_group_evaluator.hpp | 2 +- .../graphene/chain/event_group_object.hpp | 6 +- .../include/graphene/chain/event_object.hpp | 13 +- .../include/graphene/chain/exceptions.hpp | 3 - .../include/graphene/chain/game_object.hpp | 11 +- .../global_betting_statistics_object.hpp | 5 +- .../graphene/chain/global_property_object.hpp | 1 - .../chain/immutable_chain_parameters.hpp | 2 +- .../graphene/chain/lottery_evaluator.hpp | 2 +- .../include/graphene/chain/market_object.hpp | 1 - .../include/graphene/chain/match_object.hpp | 13 +- .../chain/operation_history_object.hpp | 136 +++++------ .../graphene/chain/rock_paper_scissors.hpp | 5 +- .../graphene/chain/sport_evaluator.hpp | 2 +- .../include/graphene/chain/sport_object.hpp | 5 +- .../graphene/chain/tournament_evaluator.hpp | 2 +- .../graphene/chain/tournament_object.hpp | 14 +- .../chain/transaction_evaluation_state.hpp | 2 +- .../chain/transaction_history_object.hpp | 3 + .../chain/include/graphene/chain/types.hpp | 14 +- .../graphene/chain/vesting_balance_object.hpp | 2 + .../chain/witness_schedule_object.hpp | 15 +- libraries/chain/proposal_evaluator.cpp | 8 +- libraries/chain/small_objects.cpp | 11 +- libraries/chain/tournament_evaluator.cpp | 5 +- libraries/chain/tournament_object.cpp | 9 +- libraries/chain/vesting_balance_evaluator.cpp | 1 + libraries/chain/vesting_balance_object.cpp | 2 +- libraries/net/include/graphene/net/node.hpp | 2 +- .../affiliate_stats/affiliate_stats_api.hpp | 4 +- .../affiliate_stats_objects.hpp | 4 +- libraries/plugins/bookie/bookie_api.cpp | 2 +- libraries/plugins/bookie/bookie_plugin.cpp | 3 +- .../include/graphene/bookie/bookie_api.hpp | 4 +- .../graphene/bookie/bookie_objects.hpp | 2 +- .../include/graphene/bookie/bookie_plugin.hpp | 4 +- .../delayed_node/delayed_node_plugin.cpp | 2 +- .../generate_genesis/generate_genesis.cpp | 10 +- .../include/graphene/witness/witness.hpp | 1 - libraries/protocol/account.cpp | 9 +- libraries/protocol/address.cpp | 2 +- libraries/protocol/betting_market.cpp | 6 +- libraries/protocol/block.cpp | 7 +- libraries/protocol/event.cpp | 6 +- libraries/protocol/event_group.cpp | 6 +- libraries/protocol/fee_schedule.cpp | 4 +- .../include/graphene/protocol/affiliate.hpp | 20 +- .../include/graphene/protocol/asset_ops.hpp | 61 +++-- .../graphene/protocol/betting_market.hpp | 71 +++--- .../graphene/protocol/chain_parameters.hpp | 10 +- .../include/graphene/protocol/config.hpp | 215 +++++++++++++----- .../include/graphene/protocol/event.hpp | 21 +- .../include/graphene/protocol/event_group.hpp | 19 +- .../include/graphene/protocol/exceptions.hpp | 18 +- .../graphene/protocol/fee_schedule.hpp | 4 - .../include/graphene/protocol/lottery_ops.hpp | 22 +- .../include/graphene/protocol/market.hpp | 3 +- .../include/graphene/protocol/protocol.hpp | 4 +- .../graphene/protocol/rock_paper_scissors.hpp | 22 +- .../include/graphene/protocol/sport.hpp | 19 +- .../include/graphene/protocol/tournament.hpp | 36 +-- .../include/graphene/protocol/transaction.hpp | 3 +- .../include/graphene/protocol/types.hpp | 36 +-- .../include/graphene/protocol/vesting.hpp | 1 - libraries/protocol/lottery_ops.cpp | 6 +- libraries/protocol/operations.cpp | 2 +- libraries/protocol/small_ops.cpp | 1 + libraries/protocol/sport.cpp | 6 +- libraries/protocol/tournament.cpp | 6 +- libraries/protocol/transaction.cpp | 4 +- libraries/protocol/witness.cpp | 1 - libraries/wallet/wallet.cpp | 2 +- programs/cli_wallet/main.cpp | 2 +- programs/js_operation_serializer/main.cpp | 17 +- tests/betting/betting_tests.cpp | 2 +- tests/common/database_fixture.hpp | 3 + tests/generate_empty_blocks/main.cpp | 2 +- tests/intense/block_tests.cpp | 2 +- tests/performance/performance_tests.cpp | 2 +- tests/tests/authority_tests.cpp | 2 +- tests/tests/basic_tests.cpp | 2 +- tests/tests/confidential_tests.cpp | 2 +- tests/tests/network_broadcast_api_tests.cpp | 5 +- tests/tournament/tournament_tests.cpp | 11 +- 118 files changed, 686 insertions(+), 730 deletions(-) diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 0c78eb55..b4855e17 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -170,7 +170,7 @@ namespace graphene { namespace app { { auto block_num = b.block_num(); auto& callback = _callbacks.find(id)->second; - fc::async( [capture_this,this,id,block_num,trx_num,trx,callback]() { + fc::async( [capture_this,id,block_num,trx_num,trx,callback]() { callback( fc::variant( transaction_confirmation{ id, block_num, trx_num, trx }, GRAPHENE_MAX_NESTED_OBJECTS ) ); } ); diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 4c83fe96..0ccb7ccb 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -226,7 +226,7 @@ namespace detail { void new_connection( const fc::http::websocket_connection_ptr& c ) { - auto wsc = std::make_shared(*c, GRAPHENE_MAX_NESTED_OBJECTS); + auto wsc = std::make_shared(c, GRAPHENE_MAX_NESTED_OBJECTS); auto login = std::make_shared( std::ref(*_self) ); login->enable_api("database_api"); @@ -380,7 +380,6 @@ namespace detail { _chain_db->enable_standby_votes_tracking( _options->at("enable-standby-votes-tracking").as() ); } - bool replay = false; std::string replay_reason = "reason not provided"; if( _options->count("replay-blockchain") ) @@ -554,7 +553,7 @@ namespace detail { _chain_db->push_transaction( transaction_message.trx ); } FC_CAPTURE_AND_RETHROW( (transaction_message) ) } - virtual void handle_message(const message& message_to_process) override + virtual void handle_message(const message&) override { // not a transaction, not a block FC_THROW( "Invalid Message Type" ); diff --git a/libraries/app/config_util.cpp b/libraries/app/config_util.cpp index f06291b7..75b73a53 100644 --- a/libraries/app/config_util.cpp +++ b/libraries/app/config_util.cpp @@ -210,7 +210,7 @@ static void load_config_file(const fc::path& config_ini_path, const bpo::options { deduplicator dedup; bpo::options_description unique_options("Graphene Witness Node"); - for( const boost::shared_ptr opt : cfg_options.options() ) + for( const boost::shared_ptr& opt : cfg_options.options() ) { const boost::shared_ptr od = dedup.next(opt); if( !od ) continue; @@ -259,7 +259,7 @@ static void create_new_config_file(const fc::path& config_ini_path, const fc::pa deduplicator dedup(modify_option_defaults); std::ofstream out_cfg(config_ini_path.preferred_string()); std::string plugin_header_surrounding( 78, '=' ); - for( const boost::shared_ptr opt : cfg_options.options() ) + for( const boost::shared_ptr& opt : cfg_options.options() ) { const boost::shared_ptr od = dedup.next(opt); if( !od ) continue; diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 5cc6da24..0eef41ef 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -26,6 +26,8 @@ #include #include #include +#include + #include #include @@ -2330,10 +2332,9 @@ graphene::app::gpos_info database_api_impl::get_gpos_info(const account_id_type #endif vector account_vbos; - const time_point_sec now = _db.head_block_time(); auto vesting_range = _db.get_index_type().indices().get().equal_range(account); std::for_each(vesting_range.first, vesting_range.second, - [&account_vbos, now](const vesting_balance_object& balance) { + [&account_vbos](const vesting_balance_object& balance) { if(balance.balance.amount > 0 && balance.balance_type == vesting_balance_type::gpos && balance.balance.asset_id == asset_id_type()) account_vbos.emplace_back(balance); diff --git a/libraries/app/include/graphene/app/full_account.hpp b/libraries/app/include/graphene/app/full_account.hpp index d35c2b5c..7de9daf6 100644 --- a/libraries/app/include/graphene/app/full_account.hpp +++ b/libraries/app/include/graphene/app/full_account.hpp @@ -29,7 +29,6 @@ #include #include #include -#include namespace graphene { namespace app { using namespace graphene::chain; diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index 91e6f623..4ae8ec58 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -212,7 +212,7 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio if( dynamic_properties.accounts_registered_this_interval % global_properties.parameters.accounts_per_fee_scale == 0 && global_properties.parameters.account_fee_scale_bitshifts != 0 ) { - d.modify(global_properties, [&dynamic_properties](global_property_object& p) { + d.modify(global_properties, [](global_property_object& p) { p.parameters.current_fees->get().basic_fee <<= p.parameters.account_fee_scale_bitshifts; }); } diff --git a/libraries/chain/account_object.cpp b/libraries/chain/account_object.cpp index 30f3be14..15a41443 100644 --- a/libraries/chain/account_object.cpp +++ b/libraries/chain/account_object.cpp @@ -39,7 +39,7 @@ share_type cut_fee(share_type a, uint16_t p) fc::uint128_t r = a.value; r *= p; r /= GRAPHENE_100_PERCENT; - return r.convert_to(); + return r; } void account_balance_object::adjust_balance(const asset& delta) diff --git a/libraries/chain/affiliate_payout.cpp b/libraries/chain/affiliate_payout.cpp index 3138117c..9375f5b1 100644 --- a/libraries/chain/affiliate_payout.cpp +++ b/libraries/chain/affiliate_payout.cpp @@ -62,15 +62,15 @@ namespace graphene { namespace chain { //ilog("Paying ${p} of ${P} for ${s} of ${r}", ("p",payout.to_uint64())("P",to_pay.value)("s",share)("r",remaining) ); remaining -= share; } - FC_ASSERT( payout.to_uint64() <= to_pay ); + FC_ASSERT( payout <= to_pay ); if( payout > 0 ) { if ( accumulator.find(affiliate) == accumulator.end() ) - accumulator[affiliate] = payout.to_uint64(); + accumulator[affiliate] = payout; else - accumulator[affiliate] += payout.to_uint64(); - to_pay -= payout.to_uint64(); - paid += payout.to_uint64(); + accumulator[affiliate] += payout; + to_pay -= payout; + paid += payout; } } FC_ASSERT( to_pay == 0 ); diff --git a/libraries/chain/asset_evaluator.cpp b/libraries/chain/asset_evaluator.cpp index 7a26a2cb..cb90a89b 100644 --- a/libraries/chain/asset_evaluator.cpp +++ b/libraries/chain/asset_evaluator.cpp @@ -593,7 +593,6 @@ void_result asset_update_dividend_evaluator::do_apply( const asset_update_divide obj.referrer = op.issuer; obj.lifetime_referrer = op.issuer(db()).lifetime_referrer; - auto& params = db().get_global_properties().parameters; obj.network_fee_percentage = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE; obj.lifetime_referrer_fee_percentage = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE; obj.referrer_rewards_percentage = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE; diff --git a/libraries/chain/asset_object.cpp b/libraries/chain/asset_object.cpp index b074775a..56a1d947 100644 --- a/libraries/chain/asset_object.cpp +++ b/libraries/chain/asset_object.cpp @@ -42,7 +42,7 @@ share_type asset_bitasset_data_object::max_force_settlement_volume(share_type cu volume += force_settled_volume.value; volume *= options.maximum_force_settlement_volume; volume /= GRAPHENE_100_PERCENT; - return volume.convert_to(); + return volume; } void asset_bitasset_data_object::update_median_feeds(time_point_sec current_time) diff --git a/libraries/chain/betting_market_object.cpp b/libraries/chain/betting_market_object.cpp index d5efd56c..75613233 100644 --- a/libraries/chain/betting_market_object.cpp +++ b/libraries/chain/betting_market_object.cpp @@ -75,7 +75,7 @@ namespace mpl = boost::mpl; amount_to_match_128 += backer_multiplier - GRAPHENE_BETTING_ODDS_PRECISION - 1; amount_to_match_128 /= backer_multiplier - GRAPHENE_BETTING_ODDS_PRECISION; } - return amount_to_match_128.to_uint64(); + return amount_to_match_128; } share_type bet_object::get_approximate_matching_amount(bool round_up /* = false */) const diff --git a/libraries/chain/db_bet.cpp b/libraries/chain/db_bet.cpp index 8c3e1357..f0557aeb 100644 --- a/libraries/chain/db_bet.cpp +++ b/libraries/chain/db_bet.cpp @@ -29,6 +29,8 @@ #include #include +#include + #include #include #include @@ -132,7 +134,7 @@ void database::resolve_betting_market_group(const betting_market_group_object& b bool group_was_canceled = resolutions.begin()->second == betting_market_resolution_type::cancel; if (group_was_canceled) - modify(betting_market_group, [group_was_canceled,this](betting_market_group_object& betting_market_group_obj) { + modify(betting_market_group, [this](betting_market_group_object& betting_market_group_obj) { betting_market_group_obj.on_canceled_event(*this, false); // this cancels the betting markets }); else { @@ -149,7 +151,7 @@ void database::resolve_betting_market_group(const betting_market_group_object& b }); } - modify(betting_market_group, [group_was_canceled,this](betting_market_group_object& betting_market_group_obj) { + modify(betting_market_group, [this](betting_market_group_object& betting_market_group_obj) { betting_market_group_obj.on_graded_event(*this); }); } @@ -263,7 +265,7 @@ void database::settle_betting_market_group(const betting_market_group_object& be share_type rake_amount; if (net_profits.value > 0 && rake_account_id) { - rake_amount = ((fc::uint128_t(net_profits.value) * rake_fee_percentage + GRAPHENE_100_PERCENT - 1) / GRAPHENE_100_PERCENT).to_uint64(); + rake_amount = ((fc::uint128_t(net_profits.value) * rake_fee_percentage + GRAPHENE_100_PERCENT - 1) / GRAPHENE_100_PERCENT); share_type affiliates_share; if (rake_amount.value) affiliates_share = payout_helper.payout( bettor_id, rake_amount ); @@ -303,7 +305,8 @@ void database::settle_betting_market_group(const betting_market_group_object& be remove(betting_market); } - const event_object& event = betting_market_group.event_id(*this); + // Fetch to check for existence + betting_market_group.event_id(*this); fc_dlog(fc::logger::get("betting"), "removing betting market group ${id}", ("id", betting_market_group.id)); remove(betting_market_group); @@ -537,7 +540,6 @@ int match_bet(database& db, const bet_object& taker_bet, const bet_object& maker // because we matched at the maker's odds and not the taker's odds, the remaining amount to match // may not be an even multiple of the taker's odds; round it down. share_type taker_remaining_factor = unrounded_taker_remaining_amount_to_match / takers_odds_maker_odds_ratio; - share_type taker_remaining_maker_amount_to_match = taker_remaining_factor * takers_odds_maker_odds_ratio; share_type taker_remaining_bet_amount = taker_remaining_factor * takers_odds_taker_odds_ratio; taker_refund_amount = taker_bet.amount_to_bet.amount - taker_amount_to_match - taker_remaining_bet_amount; diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 8360149f..41821baf 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -26,9 +26,6 @@ #include #include -#include -#include - #include #include #include @@ -38,8 +35,11 @@ #include #include #include +#include #include +#include +#include namespace { diff --git a/libraries/chain/db_getter.cpp b/libraries/chain/db_getter.cpp index ac31d437..73705a81 100644 --- a/libraries/chain/db_getter.cpp +++ b/libraries/chain/db_getter.cpp @@ -110,13 +110,15 @@ std::vector database::get_seeds(asset_id_type for_asset, uint8_t count { FC_ASSERT( count_winners <= 64 ); std::string salted_string = std::string(_random_number_generator._seed) + std::to_string(for_asset.instance.value); - uint32_t* seeds = (uint32_t*)(fc::sha256::hash(salted_string)._hash); + auto seeds_hash = fc::sha256::hash(salted_string); + uint32_t* seeds = (uint32_t*)(seeds_hash._hash); std::vector result; result.reserve(64); for( int s = 0; s < 8; ++s ) { - uint32_t* sub_seeds = ( uint32_t* ) fc::sha256::hash( std::to_string( seeds[s] ) + std::to_string( for_asset.instance.value ) )._hash; + auto sub_seeds_hash = fc::sha256::hash(std::to_string(seeds[s]) + std::to_string(for_asset.instance.value)); + uint32_t* sub_seeds = (uint32_t*) sub_seeds_hash._hash; for( int ss = 0; ss < 8; ++ss ) { result.push_back(sub_seeds[ss]); } diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 0de70a0b..5a744320 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -834,7 +834,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) for( const auto& handout : genesis_state.initial_balances ) { const auto asset_id = get_asset_id(handout.asset_symbol); - create([&handout,&get_asset_id,total_allocation,asset_id](balance_object& b) { + create([&handout,total_allocation,asset_id](balance_object& b) { b.balance = asset(handout.amount, asset_id); b.owner = handout.owner; }); @@ -986,7 +986,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) _wso.last_scheduling_block = 0; - _wso.recent_slots_filled = fc::uint128_t::max_value(); + _wso.recent_slots_filled = std::numeric_limits::max(); // for shuffled for( const witness_id_type& wid : get_global_properties().active_witnesses ) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index dacb7c5c..c7d6c32a 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -22,10 +22,6 @@ * THE SOFTWARE. */ -#include - -#include - #include #include #include @@ -48,6 +44,12 @@ #include #include +#include + +#include + +#include + #define USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX // vesting_balance_object by_asset_balance index needed namespace graphene { namespace chain { @@ -163,7 +165,7 @@ void database::pay_workers( share_type& budget ) // worker with more votes is preferred // if two workers exactly tie for votes, worker with lower ID is preferred - std::sort(active_workers.begin(), active_workers.end(), [this](const worker_object& wa, const worker_object& wb) { + std::sort(active_workers.begin(), active_workers.end(), [](const worker_object& wa, const worker_object& wb) { share_type wa_vote = wa.approving_stake(); share_type wb_vote = wb.approving_stake(); if( wa_vote != wb_vote ) @@ -186,7 +188,7 @@ void database::pay_workers( share_type& budget ) fc::uint128_t pay = requested_pay.value; pay *= passed_time_count; pay /= day_count; - requested_pay = pay.convert_to(); + requested_pay = pay; share_type actual_pay = std::min(budget, requested_pay); //ilog(" ==> Paying ${a} to worker ${w}", ("w", active_worker.id)("a", actual_pay)); @@ -435,7 +437,7 @@ void database::initialize_budget_record( fc::time_point_sec now, budget_record& budget_u128 >>= GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS; share_type budget; if( budget_u128 < reserve.value ) - rec.total_budget = share_type(budget_u128.convert_to()); + rec.total_budget = share_type(budget_u128); else rec.total_budget = reserve; @@ -490,7 +492,7 @@ void database::process_budget() if( worker_budget_u128 >= available_funds.value ) worker_budget = available_funds; else - worker_budget = worker_budget_u128.convert_to(); + worker_budget = worker_budget_u128; rec.worker_budget = worker_budget; available_funds -= worker_budget; @@ -630,12 +632,12 @@ void split_fba_balance( fc::uint128_t buyback_amount_128 = fba.accumulated_fba_fees.value; buyback_amount_128 *= designated_asset_buyback_pct; buyback_amount_128 /= GRAPHENE_100_PERCENT; - share_type buyback_amount = buyback_amount_128.convert_to(); + share_type buyback_amount = buyback_amount_128; fc::uint128_t issuer_amount_128 = fba.accumulated_fba_fees.value; issuer_amount_128 *= designated_asset_issuer_pct; issuer_amount_128 /= GRAPHENE_100_PERCENT; - share_type issuer_amount = issuer_amount_128.convert_to(); + share_type issuer_amount = issuer_amount_128; // this assert should never fail FC_ASSERT( buyback_amount + issuer_amount <= fba.accumulated_fba_fees ); @@ -1121,7 +1123,7 @@ void schedule_pending_dividend_balances(database& db, minimum_amount_to_distribute *= 100 * GRAPHENE_1_PERCENT; minimum_amount_to_distribute /= dividend_data.options.minimum_fee_percentage; wdump((total_fee_per_asset_in_payout_asset)(dividend_data.options)); - minimum_shares_to_distribute = minimum_amount_to_distribute.to_uint64(); + minimum_shares_to_distribute = minimum_amount_to_distribute; } dlog("Processing dividend payments of asset type ${payout_asset_type}, delta balance is ${delta_balance}", ("payout_asset_type", payout_asset_type(db).symbol)("delta_balance", delta_balance)); @@ -1183,7 +1185,7 @@ void schedule_pending_dividend_balances(database& db, fc::uint128_t amount_to_credit(delta_balance.value); amount_to_credit *= holder_balance.amount.value; amount_to_credit /= total_balance_of_dividend_asset.value; - share_type full_shares_to_credit((int64_t) amount_to_credit.to_uint64()); + share_type full_shares_to_credit((int64_t) amount_to_credit); share_type shares_to_credit = (uint64_t) floor(full_shares_to_credit.value * vesting_factor); if (shares_to_credit < full_shares_to_credit) { @@ -1220,7 +1222,7 @@ void schedule_pending_dividend_balances(database& db, fc::uint128_t amount_to_credit(delta_balance.value); amount_to_credit *= holder_balance.value; amount_to_credit /= total_balance_of_dividend_asset.value; - share_type shares_to_credit((int64_t) amount_to_credit.to_uint64()); + share_type shares_to_credit((int64_t) amount_to_credit); remaining_amount_to_distribute = credit_account(db, holder_balance_object.owner, @@ -1280,7 +1282,7 @@ void schedule_pending_dividend_balances(database& db, fc::uint128_t amount_to_debit(remaining_amount_to_recover.value); amount_to_debit *= pending_balance_object.pending_balance.value; amount_to_debit /= remaining_pending_balances.value; - share_type shares_to_debit((int64_t)amount_to_debit.to_uint64()); + share_type shares_to_debit((int64_t)amount_to_debit); remaining_amount_to_recover -= shares_to_debit; remaining_pending_balances -= pending_balance_object.pending_balance; @@ -1466,7 +1468,6 @@ void process_dividend_assets(database& db) { // if there was a previous payout, make our next payment one interval uint32_t current_time_sec = current_head_block_time.sec_since_epoch(); - fc::time_point_sec reference_time = *dividend_data_obj.last_scheduled_payout_time; uint32_t next_possible_time_sec = dividend_data_obj.last_scheduled_payout_time->sec_since_epoch(); do next_possible_time_sec += *dividend_data_obj.options.payout_interval; diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index 49376f98..9f614815 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -578,7 +578,7 @@ asset database::calculate_market_fee( const asset_object& trade_asset, const ass fc::uint128_t a(trade_amount.amount.value); a *= trade_asset.options.market_fee_percent; a /= GRAPHENE_100_PERCENT; - asset percent_fee = trade_asset.amount(a.to_uint64()); + asset percent_fee = trade_asset.amount(a); if( percent_fee.amount > trade_asset.options.max_market_fee ) percent_fee.amount = trade_asset.options.max_market_fee; diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index acac1b91..21fdbc15 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -44,7 +44,6 @@ namespace graphene { namespace chain { void database::update_global_dynamic_data( const signed_block& b, const uint32_t missed_blocks ) { const dynamic_global_property_object& _dgp = get_dynamic_global_properties(); - const global_property_object& gpo = get_global_properties(); // dynamic global properties updating modify( _dgp, [&b,this,missed_blocks]( dynamic_global_property_object& dgp ){ @@ -424,7 +423,7 @@ void database::clear_expired_orders() auto& pays = order.balance; auto receives = (order.balance * mia.current_feed.settlement_price); receives.amount = (fc::uint128_t(receives.amount.value) * - (GRAPHENE_100_PERCENT - mia.options.force_settlement_offset_percent) / GRAPHENE_100_PERCENT).to_uint64(); + (GRAPHENE_100_PERCENT - mia.options.force_settlement_offset_percent) / GRAPHENE_100_PERCENT); assert(receives <= order.balance * mia.current_feed.settlement_price); price settlement_price = pays / receives; diff --git a/libraries/chain/db_witness_schedule.cpp b/libraries/chain/db_witness_schedule.cpp index 804fa46c..d70ea90b 100644 --- a/libraries/chain/db_witness_schedule.cpp +++ b/libraries/chain/db_witness_schedule.cpp @@ -191,7 +191,7 @@ void database::update_witness_schedule(const signed_block& next_block) modify(wso, [&](witness_schedule_object& _wso) { _wso.slots_since_genesis += schedule_slot; - witness_scheduler_rng rng(wso.rng_seed.data, _wso.slots_since_genesis); + witness_scheduler_rng rng(wso.rng_seed.data(), _wso.slots_since_genesis); _wso.scheduler._min_token_count = std::max(int(gpo.active_witnesses.size()) / 2, 1); @@ -250,12 +250,12 @@ uint32_t database::witness_participation_rate()const if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SHUFFLED_ALGORITHM) { const dynamic_global_property_object& dpo = get_dynamic_global_properties(); - return uint64_t(GRAPHENE_100_PERCENT) * dpo.recent_slots_filled.popcount() / 128; + return uint64_t(GRAPHENE_100_PERCENT) * fc::popcount(dpo.recent_slots_filled) / 128; } if (gpo.parameters.witness_schedule_algorithm == GRAPHENE_WITNESS_SCHEDULED_ALGORITHM) { const witness_schedule_object& wso = get_witness_schedule_object(); - return uint64_t(GRAPHENE_100_PERCENT) * wso.recent_slots_filled.popcount() / 128; + return uint64_t(GRAPHENE_100_PERCENT) * fc::popcount(wso.recent_slots_filled) / 128; } return 0; } diff --git a/libraries/chain/event_evaluator.cpp b/libraries/chain/event_evaluator.cpp index 28e7476d..9c2ba9f1 100644 --- a/libraries/chain/event_evaluator.cpp +++ b/libraries/chain/event_evaluator.cpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/exceptions.cpp b/libraries/chain/exceptions.cpp index 68606a91..9009a80c 100644 --- a/libraries/chain/exceptions.cpp +++ b/libraries/chain/exceptions.cpp @@ -127,9 +127,6 @@ namespace graphene { namespace chain { //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( bid_collateral_operation ) //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_claim_pool_operation ) //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( asset_update_issuer_operation ) - //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( htlc_create_operation ) - //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( htlc_redeem_operation ) - //GRAPHENE_IMPLEMENT_OP_BASE_EXCEPTIONS( htlc_extend_operation ) #define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \ catch( const cause_type& e ) \ diff --git a/libraries/chain/fork_database.cpp b/libraries/chain/fork_database.cpp index 1cb4f77b..b6c72221 100644 --- a/libraries/chain/fork_database.cpp +++ b/libraries/chain/fork_database.cpp @@ -23,7 +23,7 @@ */ #include #include -#include +#include namespace graphene { namespace chain { fork_database::fork_database() diff --git a/libraries/chain/include/graphene/chain/affiliate_payout.hpp b/libraries/chain/include/graphene/chain/affiliate_payout.hpp index 1c0ea703..d69d398b 100644 --- a/libraries/chain/include/graphene/chain/affiliate_payout.hpp +++ b/libraries/chain/include/graphene/chain/affiliate_payout.hpp @@ -23,8 +23,8 @@ */ #pragma once -#include -#include +#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index 02a25db5..60741410 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -40,6 +40,7 @@ namespace graphene { namespace chain { class account_object; class asset_bitasset_data_object; + class asset_dividend_data_object; class database; class transaction_evaluation_state; using namespace graphene::db; @@ -371,7 +372,7 @@ namespace graphene { namespace chain { { public: static const uint8_t space_id = implementation_ids; - static const uint8_t type_id = impl_asset_dividend_data_type; + static const uint8_t type_id = impl_asset_dividend_data_object_type; /// The tunable options for Dividend-paying assets are stored in this field. dividend_asset_options options; @@ -415,7 +416,7 @@ namespace graphene { namespace chain { { public: static const uint8_t space_id = implementation_ids; - static const uint8_t type_id = impl_distributed_dividend_balance_data_type; + static const uint8_t type_id = impl_total_distributed_dividend_balance_object_type; asset_id_type dividend_holder_asset_type; asset_id_type dividend_payout_asset_type; @@ -517,6 +518,10 @@ namespace graphene { namespace chain { MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_object) MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_dynamic_data_object) MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_bitasset_data_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_dividend_data_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::total_distributed_dividend_balance_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::lottery_balance_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::sweeps_vesting_balance_object) FC_REFLECT_DERIVED( graphene::chain::asset_dynamic_data_object, (graphene::db::object), (current_supply)(sweeps_tickets_sold)(confidential_supply)(accumulated_fees)(fee_pool) ) diff --git a/libraries/chain/include/graphene/chain/betting_market_evaluator.hpp b/libraries/chain/include/graphene/chain/betting_market_evaluator.hpp index eb245c4a..36a516d7 100644 --- a/libraries/chain/include/graphene/chain/betting_market_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/betting_market_evaluator.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/betting_market_object.hpp b/libraries/chain/include/graphene/chain/betting_market_object.hpp index 36e8e664..bceb5863 100644 --- a/libraries/chain/include/graphene/chain/betting_market_object.hpp +++ b/libraries/chain/include/graphene/chain/betting_market_object.hpp @@ -23,14 +23,17 @@ */ #pragma once -#include +#include + +#include + #include #include -#include -#include #include +#include + namespace graphene { namespace chain { class betting_market_object; class betting_market_group_object; @@ -45,7 +48,7 @@ namespace fc { namespace graphene { namespace chain { -FC_DECLARE_EXCEPTION(no_transition, 100000, "Invalid state transition"); +FC_DECLARE_EXCEPTION(no_transition, 100000); class database; struct by_event_id; @@ -717,6 +720,12 @@ inline Stream& operator>>( Stream& s, betting_market_group_object& betting_marke } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::betting_market_rules_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::betting_market_group_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::betting_market_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::bet_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::betting_market_position_object) + FC_REFLECT_DERIVED( graphene::chain::betting_market_rules_object, (graphene::db::object), (name)(description) ) FC_REFLECT_DERIVED( graphene::chain::betting_market_group_object, (graphene::db::object), (description) ) FC_REFLECT_DERIVED( graphene::chain::betting_market_object, (graphene::db::object), (group_id) ) diff --git a/libraries/chain/include/graphene/chain/block_summary_object.hpp b/libraries/chain/include/graphene/chain/block_summary_object.hpp index 62be251d..70fc5262 100644 --- a/libraries/chain/include/graphene/chain/block_summary_object.hpp +++ b/libraries/chain/include/graphene/chain/block_summary_object.hpp @@ -22,7 +22,8 @@ * THE SOFTWARE. */ #pragma once -#include +#include + #include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/budget_record_object.hpp b/libraries/chain/include/graphene/chain/budget_record_object.hpp index 82cd8c76..607f589f 100644 --- a/libraries/chain/include/graphene/chain/budget_record_object.hpp +++ b/libraries/chain/include/graphene/chain/budget_record_object.hpp @@ -22,7 +22,8 @@ * THE SOFTWARE. */ #pragma once -#include +#include + #include #include diff --git a/libraries/chain/include/graphene/chain/buyback_object.hpp b/libraries/chain/include/graphene/chain/buyback_object.hpp index 3de8b039..fa673e3b 100644 --- a/libraries/chain/include/graphene/chain/buyback_object.hpp +++ b/libraries/chain/include/graphene/chain/buyback_object.hpp @@ -23,7 +23,8 @@ */ #pragma once -#include +#include + #include #include diff --git a/libraries/chain/include/graphene/chain/chain_property_object.hpp b/libraries/chain/include/graphene/chain/chain_property_object.hpp index d0c9e28d..e9b7dc8f 100644 --- a/libraries/chain/include/graphene/chain/chain_property_object.hpp +++ b/libraries/chain/include/graphene/chain/chain_property_object.hpp @@ -24,6 +24,7 @@ #pragma once #include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/committee_member_evaluator.hpp b/libraries/chain/include/graphene/chain/committee_member_evaluator.hpp index ec55b1d7..388a4364 100644 --- a/libraries/chain/include/graphene/chain/committee_member_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/committee_member_evaluator.hpp @@ -24,6 +24,7 @@ #pragma once #include #include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index 9b9b6dce..1aa5b86b 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -25,224 +25,13 @@ #include -#define GRAPHENE_SYMBOL "TEST" -#define GRAPHENE_ADDRESS_PREFIX "TEST" - -#define GRAPHENE_MIN_ACCOUNT_NAME_LENGTH 1 -#define GRAPHENE_MAX_ACCOUNT_NAME_LENGTH 63 - -#define GRAPHENE_MIN_ASSET_SYMBOL_LENGTH 3 -#define GRAPHENE_MAX_ASSET_SYMBOL_LENGTH 16 - -#define GRAPHENE_MAX_SHARE_SUPPLY int64_t(1000000000000000ll) -#define GRAPHENE_MAX_PAY_RATE 10000 /* 100% */ -#define GRAPHENE_MAX_SIG_CHECK_DEPTH 2 -/** - * Don't allow the committee_members to publish a limit that would - * make the network unable to operate. - */ -#define GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT 1024 -#define GRAPHENE_MIN_BLOCK_INTERVAL 1 /* seconds */ -#define GRAPHENE_MAX_BLOCK_INTERVAL 30 /* seconds */ - -#define GRAPHENE_DEFAULT_BLOCK_INTERVAL 3 /* seconds */ -#define GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE 2048 -#define GRAPHENE_DEFAULT_MAX_BLOCK_SIZE (GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE*GRAPHENE_DEFAULT_BLOCK_INTERVAL*200000) -#define GRAPHENE_DEFAULT_MAX_TIME_UNTIL_EXPIRATION (60*60*24) // seconds, aka: 1 day -#define GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL (60*60*24) // seconds, aka: 1 day -#define GRAPHENE_DEFAULT_MAINTENANCE_SKIP_SLOTS 3 // number of slots to skip for maintenance interval - #define GRAPHENE_MIN_UNDO_HISTORY 10 #define GRAPHENE_MAX_UNDO_HISTORY 10000 -#define GRAPHENE_MIN_BLOCK_SIZE_LIMIT (GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT*5) // 5 transactions per block -#define GRAPHENE_MIN_TRANSACTION_EXPIRATION_LIMIT (GRAPHENE_MAX_BLOCK_INTERVAL * 5) // 5 transactions per block -#define GRAPHENE_BLOCKCHAIN_PRECISION uint64_t( 100000 ) +#define GRAPHENE_MAX_NESTED_OBJECTS (200) -#define GRAPHENE_BLOCKCHAIN_PRECISION_DIGITS 5 -#define GRAPHENE_DEFAULT_TRANSFER_FEE (1*GRAPHENE_BLOCKCHAIN_PRECISION) -#define GRAPHENE_MAX_INSTANCE_ID (uint64_t(-1)>>16) -/** percentage fields are fixed point with a denominator of 10,000 */ -#define GRAPHENE_100_PERCENT 10000 -#define GRAPHENE_1_PERCENT (GRAPHENE_100_PERCENT/100) -/** NOTE: making this a power of 2 (say 2^15) would greatly accelerate fee calcs */ -#define GRAPHENE_MAX_MARKET_FEE_PERCENT GRAPHENE_100_PERCENT -#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_DELAY (60*60*24) ///< 1 day -#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_OFFSET 0 ///< 1% -#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_MAX_VOLUME (20* GRAPHENE_1_PERCENT) ///< 20% -#define GRAPHENE_DEFAULT_PRICE_FEED_LIFETIME (60*60*24) ///< 1 day -#define GRAPHENE_MAX_FEED_PRODUCERS 200 -#define GRAPHENE_DEFAULT_MAX_AUTHORITY_MEMBERSHIP 10 -#define GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES 10 -#define GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS 10 - -/** - * These ratios are fixed point numbers with a denominator of GRAPHENE_COLLATERAL_RATIO_DENOM, the - * minimum maitenance collateral is therefore 1.001x and the default - * maintenance ratio is 1.75x - */ -///@{ -#define GRAPHENE_COLLATERAL_RATIO_DENOM 1000 -#define GRAPHENE_MIN_COLLATERAL_RATIO 1001 ///< lower than this could result in divide by 0 -#define GRAPHENE_MAX_COLLATERAL_RATIO 32000 ///< higher than this is unnecessary and may exceed int16 storage -#define GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO 1750 ///< Call when collateral only pays off 175% the debt -#define GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO 1500 ///< Stop calling when collateral only pays off 150% of the debt -///@} -#define GRAPHENE_DEFAULT_MARGIN_PERIOD_SEC (30*60*60*24) - -#define GRAPHENE_DEFAULT_MIN_WITNESS_COUNT (11) -#define GRAPHENE_DEFAULT_MIN_COMMITTEE_MEMBER_COUNT (11) -#define GRAPHENE_DEFAULT_MAX_WITNESSES (1001) // SHOULD BE ODD -#define GRAPHENE_DEFAULT_MAX_COMMITTEE (1001) // SHOULD BE ODD -#define GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC (60*60*24*7*4) // Four weeks -#define GRAPHENE_DEFAULT_COMMITTEE_PROPOSAL_REVIEW_PERIOD_SEC (60*60*24*7*2) // Two weeks -#define GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT) -#define GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE (30*GRAPHENE_1_PERCENT) -#define GRAPHENE_DEFAULT_MAX_BULK_DISCOUNT_PERCENT (50*GRAPHENE_1_PERCENT) -#define GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN ( GRAPHENE_BLOCKCHAIN_PRECISION*int64_t(1000) ) -#define GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MAX ( GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN*int64_t(100) ) -#define GRAPHENE_DEFAULT_CASHBACK_VESTING_PERIOD_SEC (60*60*24*365) ///< 1 year -#define GRAPHENE_DEFAULT_CASHBACK_VESTING_THRESHOLD (GRAPHENE_BLOCKCHAIN_PRECISION*int64_t(100)) -#define GRAPHENE_DEFAULT_BURN_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT) -#define GRAPHENE_WITNESS_PAY_PERCENT_PRECISION (1000000000) -#define GRAPHENE_DEFAULT_MAX_ASSERT_OPCODE 1 -#define GRAPHENE_DEFAULT_FEE_LIQUIDATION_THRESHOLD GRAPHENE_BLOCKCHAIN_PRECISION * 100; -#define GRAPHENE_DEFAULT_ACCOUNTS_PER_FEE_SCALE 1000 -#define GRAPHENE_DEFAULT_ACCOUNT_FEE_SCALE_BITSHIFTS 4 -#define GRAPHENE_DEFAULT_MAX_BUYBACK_MARKETS 4 - -#define GRAPHENE_MAX_WORKER_NAME_LENGTH 63 - -#define GRAPHENE_MAX_URL_LENGTH 127 - -#define GRAPHENE_WITNESS_SHUFFLED_ALGORITHM 0 -#define GRAPHENE_WITNESS_SCHEDULED_ALGORITHM 1 - -// counter initialization values used to derive near and far future seeds for shuffling witnesses -// we use the fractional bits of sqrt(2) in hex -#define GRAPHENE_NEAR_SCHEDULE_CTR_IV ( (uint64_t( 0x6a09 ) << 0x30) \ - | (uint64_t( 0xe667 ) << 0x20) \ - | (uint64_t( 0xf3bc ) << 0x10) \ - | (uint64_t( 0xc908 ) ) ) - -// and the fractional bits of sqrt(3) in hex -#define GRAPHENE_FAR_SCHEDULE_CTR_IV ( (uint64_t( 0xbb67 ) << 0x30) \ - | (uint64_t( 0xae85 ) << 0x20) \ - | (uint64_t( 0x84ca ) << 0x10) \ - | (uint64_t( 0xa73b ) ) ) - -// counter used to determine bits of entropy -// must be less than or equal to secret_hash_type::data_length() -#define GRAPHENE_RNG_SEED_LENGTH (160 / 8) - -/** - * every second, the fraction of burned core asset which cycles is - * GRAPHENE_CORE_ASSET_CYCLE_RATE / (1 << GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS) - */ -#define GRAPHENE_CORE_ASSET_CYCLE_RATE 17 -#define GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS 32 - -#define GRAPHENE_DEFAULT_WITNESS_PAY_PER_BLOCK (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t( 10) ) -#define GRAPHENE_DEFAULT_WITNESS_PAY_VESTING_SECONDS (60*60*24) -#define GRAPHENE_DEFAULT_WORKER_BUDGET_PER_DAY (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t(500) * 1000 ) - -#define GRAPHENE_DEFAULT_MINIMUM_FEEDS 7 - -#define GRAPHENE_MAX_INTEREST_APR uint16_t( 10000 ) +#define GRAPHENE_CURRENT_DB_VERSION "PPY2.5" #define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4 #define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3 -#define GRAPHENE_CURRENT_DB_VERSION "PPY2.5" - -#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT) - -/** - * Reserved Account IDs with special meaning - */ -///@{ -/// Represents the current committee members, two-week review period -#define GRAPHENE_COMMITTEE_ACCOUNT (graphene::chain::account_id_type(0)) -/// Represents the current witnesses -#define GRAPHENE_WITNESS_ACCOUNT (graphene::chain::account_id_type(1)) -/// Represents the current committee members -#define GRAPHENE_RELAXED_COMMITTEE_ACCOUNT (graphene::chain::account_id_type(2)) -/// Represents the canonical account with NO authority (nobody can access funds in null account) -#define GRAPHENE_NULL_ACCOUNT (graphene::chain::account_id_type(3)) -/// Represents the canonical account with WILDCARD authority (anybody can access funds in temp account) -#define GRAPHENE_TEMP_ACCOUNT (graphene::chain::account_id_type(4)) -/// Represents the canonical account for specifying you will vote directly (as opposed to a proxy) -#define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::chain::account_id_type(5)) -/// -#define GRAPHENE_RAKE_FEE_ACCOUNT_ID (graphene::chain::account_id_type(6)) -/// Sentinel value used in the scheduler. -#define GRAPHENE_NULL_WITNESS (graphene::chain::witness_id_type(0)) -///@} - -#define GRAPHENE_FBA_STEALTH_DESIGNATED_ASSET (asset_id_type(743)) - -#define GRAPHENE_DEFAULT_RAKE_FEE_PERCENTAGE (3*GRAPHENE_1_PERCENT) - -/** - * Betting-related constants. - * - * We store bet multipliers as fixed-precision uint32_t. These values are - * the maximum power-of-ten bet we can have on a "symmetric" market: - * (decimal) 1.0001 - 10001 - * (fractional) 1:10000 - 10000:1 - */ -///@{ -/// betting odds (multipliers) are stored as fixed-precision, divide by this to get the actual multiplier -#define GRAPHENE_BETTING_ODDS_PRECISION 10000 -/// the smallest bet multiplier we will accept -#define GRAPHENE_BETTING_MIN_MULTIPLIER 10001 -/// the largest bet multiplier we will accept -#define GRAPHENE_BETTING_MAX_MULTIPLIER 100010000 -///@} -#define GRAPHENE_DEFAULT_MIN_BET_MULTIPLIER 10100 -#define GRAPHENE_DEFAULT_MAX_BET_MULTIPLIER 10000000 -#define GRAPHENE_DEFAULT_PERMITTED_BETTING_ODDS_INCREMENTS { { 20000, 100}, /* <= 2: 0.01 */ \ - { 30000, 200}, /* <= 3: 0.02 */ \ - { 40000, 500}, /* <= 4: 0.05 */ \ - { 60000, 1000}, /* <= 6: 0.10 */ \ - { 100000, 2000}, /* <= 10: 0.20 */ \ - { 200000, 5000}, /* <= 20: 0.50 */ \ - { 300000, 10000}, /* <= 30: 1.00 */ \ - { 500000, 20000}, /* <= 50: 2.00 */ \ - { 1000000, 50000}, /* <= 100: 5.00 */ \ - { 10000000, 100000} } /* <= 1000: 10.00 */ -#define GRAPHENE_DEFAULT_BETTING_PERCENT_FEE (2 * GRAPHENE_1_PERCENT) -#define GRAPHENE_DEFAULT_LIVE_BETTING_DELAY_TIME 5 // seconds -#define GRAPHENE_MAX_NESTED_OBJECTS (200) -#define TOURNAMENT_MIN_ROUND_DELAY 0 -#define TOURNAMENT_MAX_ROUND_DELAY 600 -#define TOURNAMENT_MIN_TIME_PER_COMMIT_MOVE 0 -#define TOURNAMENT_MAN_TIME_PER_COMMIT_MOVE 600 -#define TOURNAMENT_MIN_TIME_PER_REVEAL_MOVE 0 -#define TOURNAMENT_MAX_TIME_PER_REVEAL_MOVE 600 -#define TOURNAMENT_DEFAULT_RAKE_FEE_PERCENTAGE (3*GRAPHENE_1_PERCENT) -#define TOURNAMENT_MINIMAL_RAKE_FEE_PERCENTAGE (1*GRAPHENE_1_PERCENT) -#define TOURNAMENT_MAXIMAL_RAKE_FEE_PERCENTAGE (20*GRAPHENE_1_PERCENT) -#define TOURNAMENT_MAXIMAL_REGISTRATION_DEADLINE (60*60*24*30) // seconds, 30 days -#define TOURNAMENT_MAX_NUMBER_OF_WINS 100 -#define TOURNAMENT_MAX_PLAYERS_NUMBER 256 -#define TOURNAMENT_MAX_WHITELIST_LENGTH 1000 -#define TOURNAMENT_MAX_START_TIME_IN_FUTURE (60*60*24*7*4) // 1 month -#define TOURNAMENT_MAX_START_DELAY (60*60*24*7) // 1 week -#define SWEEPS_DEFAULT_DISTRIBUTION_PERCENTAGE (2*GRAPHENE_1_PERCENT) -#define SWEEPS_DEFAULT_DISTRIBUTION_ASSET (graphene::chain::asset_id_type(0)) -#define SWEEPS_VESTING_BALANCE_MULTIPLIER 100000000 -#define SWEEPS_ACCUMULATOR_ACCOUNT (graphene::chain::account_id_type(0)) -#define GPOS_PERIOD (60*60*24*30*6) // 6 months -#define GPOS_SUBPERIOD (60*60*24*30) // 1 month -#define GPOS_VESTING_LOCKIN_PERIOD (60*60*24*30) // 1 month - -#define RBAC_MIN_PERMISSION_NAME_LENGTH 3 -#define RBAC_MAX_PERMISSION_NAME_LENGTH 10 -#define RBAC_MAX_PERMISSIONS_PER_ACCOUNT 5 // 5 per account -#define RBAC_MAX_ACCOUNT_AUTHORITY_LIFETIME 180*24*60*60 // 6 months -#define RBAC_MAX_AUTHS_PER_PERMISSION 15 // 15 ops linked per permission - -#define NFT_TOKEN_MIN_LENGTH 3 -#define NFT_TOKEN_MAX_LENGTH 15 -#define NFT_URI_MAX_LENGTH GRAPHENE_MAX_URL_LENGTH diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index 7807f479..317054e3 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -41,7 +42,7 @@ #include -#include +#include #include @@ -59,7 +60,6 @@ namespace graphene { namespace chain { class witness_object; class force_settlement_object; class limit_order_object; - class collateral_bid_object; class call_order_object; struct budget_record; diff --git a/libraries/chain/include/graphene/chain/event_evaluator.hpp b/libraries/chain/include/graphene/chain/event_evaluator.hpp index 876ee94d..4dfae857 100644 --- a/libraries/chain/include/graphene/chain/event_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/event_evaluator.hpp @@ -23,9 +23,11 @@ */ #pragma once -#include #include #include +#include + +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/event_group_evaluator.hpp b/libraries/chain/include/graphene/chain/event_group_evaluator.hpp index 65ff528e..2e529f66 100644 --- a/libraries/chain/include/graphene/chain/event_group_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/event_group_evaluator.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/event_group_object.hpp b/libraries/chain/include/graphene/chain/event_group_object.hpp index 5f472e07..257cac21 100644 --- a/libraries/chain/include/graphene/chain/event_group_object.hpp +++ b/libraries/chain/include/graphene/chain/event_group_object.hpp @@ -23,9 +23,11 @@ */ #pragma once -#include +#include + #include #include + #include namespace graphene { namespace chain { @@ -58,4 +60,6 @@ typedef multi_index_container< typedef generic_index event_group_object_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::event_group_object) + FC_REFLECT_DERIVED( graphene::chain::event_group_object, (graphene::db::object), (name)(sport_id) ) diff --git a/libraries/chain/include/graphene/chain/event_object.hpp b/libraries/chain/include/graphene/chain/event_object.hpp index 4258cbb1..c00e3c6b 100644 --- a/libraries/chain/include/graphene/chain/event_object.hpp +++ b/libraries/chain/include/graphene/chain/event_object.hpp @@ -23,14 +23,17 @@ */ #pragma once -#include +#include + +#include + #include #include -#include -#include #include +#include + namespace graphene { namespace chain { class event_object; } } @@ -158,5 +161,7 @@ typedef generic_index event_object_ return s; } } } // graphene::chain -FC_REFLECT(graphene::chain::event_object, (name)) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::event_object) + +FC_REFLECT(graphene::chain::event_object, (name)(season)(start_time)(event_group_id)(at_least_one_betting_market_group_settled)(scores)) diff --git a/libraries/chain/include/graphene/chain/exceptions.hpp b/libraries/chain/include/graphene/chain/exceptions.hpp index 8ae9edff..56d964a3 100644 --- a/libraries/chain/include/graphene/chain/exceptions.hpp +++ b/libraries/chain/include/graphene/chain/exceptions.hpp @@ -202,9 +202,6 @@ namespace graphene { namespace chain { //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( bid_collateral_operation ) //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_claim_pool_operation ) //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( asset_update_issuer_operation ) - //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_create_operation ) - //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_redeem_operation ) - //GRAPHENE_DECLARE_OP_BASE_EXCEPTIONS( htlc_extend_operation ) #define GRAPHENE_RECODE_EXC( cause_type, effect_type ) \ catch( const cause_type& e ) \ diff --git a/libraries/chain/include/graphene/chain/game_object.hpp b/libraries/chain/include/graphene/chain/game_object.hpp index abef1444..2a6f0b16 100644 --- a/libraries/chain/include/graphene/chain/game_object.hpp +++ b/libraries/chain/include/graphene/chain/game_object.hpp @@ -23,12 +23,17 @@ */ #pragma once -#include #include -#include + +#include + #include #include + #include + +#include + #include namespace graphene { namespace chain { @@ -159,6 +164,8 @@ namespace graphene { namespace chain { } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::game_object) + FC_REFLECT_ENUM(graphene::chain::game_state, (game_in_progress) (expecting_commit_moves) diff --git a/libraries/chain/include/graphene/chain/global_betting_statistics_object.hpp b/libraries/chain/include/graphene/chain/global_betting_statistics_object.hpp index 7c557be5..5bc95728 100644 --- a/libraries/chain/include/graphene/chain/global_betting_statistics_object.hpp +++ b/libraries/chain/include/graphene/chain/global_betting_statistics_object.hpp @@ -23,7 +23,8 @@ */ #pragma once -#include +#include + #include #include @@ -49,4 +50,6 @@ typedef generic_index #include -#include #include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp b/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp index 6e18c079..293abe95 100644 --- a/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp +++ b/libraries/chain/include/graphene/chain/immutable_chain_parameters.hpp @@ -24,7 +24,7 @@ #pragma once #include -#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/lottery_evaluator.hpp b/libraries/chain/include/graphene/chain/lottery_evaluator.hpp index 65c97d85..663d1321 100644 --- a/libraries/chain/include/graphene/chain/lottery_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/lottery_evaluator.hpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/market_object.hpp b/libraries/chain/include/graphene/chain/market_object.hpp index 9d058638..3da60243 100644 --- a/libraries/chain/include/graphene/chain/market_object.hpp +++ b/libraries/chain/include/graphene/chain/market_object.hpp @@ -207,7 +207,6 @@ typedef generic_index + #include -#include +#include + +#include + #include #include + #include + +#include + #include namespace graphene { namespace chain { @@ -157,6 +164,8 @@ namespace graphene { namespace chain { } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::match_object) + FC_REFLECT_ENUM(graphene::chain::match_state, (waiting_on_previous_matches) (match_in_progress) diff --git a/libraries/chain/include/graphene/chain/operation_history_object.hpp b/libraries/chain/include/graphene/chain/operation_history_object.hpp index c85bf3a4..b4538c60 100644 --- a/libraries/chain/include/graphene/chain/operation_history_object.hpp +++ b/libraries/chain/include/graphene/chain/operation_history_object.hpp @@ -22,82 +22,85 @@ * THE SOFTWARE. */ #pragma once + +#include + #include + #include #include namespace graphene { namespace chain { - /** - * @brief tracks the history of all logical operations on blockchain state - * @ingroup object - * @ingroup implementation - * - * All operations and virtual operations result in the creation of an - * operation_history_object that is maintained on disk as a stack. Each - * real or virtual operation is assigned a unique ID / sequence number that - * it can be referenced by. - * - * @note by default these objects are not tracked, the account_history_plugin must - * be loaded fore these objects to be maintained. - * - * @note this object is READ ONLY it can never be modified - */ - class operation_history_object : public abstract_object - { - public: - static const uint8_t space_id = protocol_ids; - static const uint8_t type_id = operation_history_object_type; +/** + * @brief tracks the history of all logical operations on blockchain state + * @ingroup object + * @ingroup implementation + * + * All operations and virtual operations result in the creation of an + * operation_history_object that is maintained on disk as a stack. Each + * real or virtual operation is assigned a unique ID / sequence number that + * it can be referenced by. + * + * @note by default these objects are not tracked, the account_history_plugin must + * be loaded fore these objects to be maintained. + * + * @note this object is READ ONLY it can never be modified + */ +class operation_history_object : public abstract_object +{ + public: + static const uint8_t space_id = protocol_ids; + static const uint8_t type_id = operation_history_object_type; - operation_history_object( const operation& o ):op(o){} - operation_history_object(){} + operation_history_object( const operation& o ):op(o){} + operation_history_object(){} - operation op; - operation_result result; - /** the block that caused this operation */ - uint32_t block_num = 0; - /** the transaction in the block */ - uint16_t trx_in_block = 0; - /** the operation within the transaction */ - uint16_t op_in_trx = 0; - /** any virtual operations implied by operation in block */ - uint32_t virtual_op = 0; - }; + operation op; + operation_result result; + /** the block that caused this operation */ + uint32_t block_num = 0; + /** the transaction in the block */ + uint16_t trx_in_block = 0; + /** the operation within the transaction */ + uint16_t op_in_trx = 0; + /** any virtual operations implied by operation in block */ + uint32_t virtual_op = 0; +}; + +/** + * @brief a node in a linked list of operation_history_objects + * @ingroup implementation + * @ingroup object + * + * Account history is important for users and wallets even though it is + * not part of "core validation". Account history is maintained as + * a linked list stored on disk in a stack. Each account will point to the + * most recent account history object by ID. When a new operation relativent + * to that account is processed a new account history object is allcoated at + * the end of the stack and intialized to point to the prior object. + * + * This data is never accessed as part of chain validation and therefore + * can be kept on disk as a memory mapped file. Using a memory mapped file + * will help the operating system better manage / cache / page files and + * also accelerates load time. + * + * When the transaction history for a particular account is requested the + * linked list can be traversed with relatively effecient disk access because + * of the use of a memory mapped stack. + */ +class account_transaction_history_object : public abstract_object +{ + public: + static const uint8_t space_id = implementation_ids; + static const uint8_t type_id = impl_account_transaction_history_object_type; + account_id_type account; /// the account this operation applies to + operation_history_id_type operation_id; + uint32_t sequence = 0; /// the operation position within the given account + account_transaction_history_id_type next; +}; - /** - * @brief a node in a linked list of operation_history_objects - * @ingroup implementation - * @ingroup object - * - * Account history is important for users and wallets even though it is - * not part of "core validation". Account history is maintained as - * a linked list stored on disk in a stack. Each account will point to the - * most recent account history object by ID. When a new operation relativent - * to that account is processed a new account history object is allcoated at - * the end of the stack and intialized to point to the prior object. - * - * This data is never accessed as part of chain validation and therefore - * can be kept on disk as a memory mapped file. Using a memory mapped file - * will help the operating system better manage / cache / page files and - * also accelerates load time. - * - * When the transaction history for a particular account is requested the - * linked list can be traversed with relatively effecient disk access because - * of the use of a memory mapped stack. - */ - class account_transaction_history_object : public abstract_object - { - public: - static const uint8_t space_id = implementation_ids; - static const uint8_t type_id = impl_account_transaction_history_object_type; - account_id_type account; /// the account this operation applies to - operation_history_id_type operation_id; - uint32_t sequence = 0; /// the operation position within the given account - account_transaction_history_id_type next; - }; - - struct by_id; struct by_seq; struct by_op; struct by_opid; @@ -135,7 +138,6 @@ typedef multi_index_container< typedef generic_index account_transaction_history_index; - } } // graphene::chain MAP_OBJECT_ID_TO_TYPE(graphene::chain::operation_history_object) diff --git a/libraries/chain/include/graphene/chain/rock_paper_scissors.hpp b/libraries/chain/include/graphene/chain/rock_paper_scissors.hpp index 23015e3e..f2b6c382 100644 --- a/libraries/chain/include/graphene/chain/rock_paper_scissors.hpp +++ b/libraries/chain/include/graphene/chain/rock_paper_scissors.hpp @@ -26,11 +26,14 @@ #include +#include + +#include + #include #include #include #include -#include namespace graphene { namespace chain { struct rock_paper_scissors_game_details diff --git a/libraries/chain/include/graphene/chain/sport_evaluator.hpp b/libraries/chain/include/graphene/chain/sport_evaluator.hpp index 4724e795..0f91305d 100644 --- a/libraries/chain/include/graphene/chain/sport_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/sport_evaluator.hpp @@ -23,7 +23,7 @@ */ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/sport_object.hpp b/libraries/chain/include/graphene/chain/sport_object.hpp index 4f3139d8..3da135b5 100644 --- a/libraries/chain/include/graphene/chain/sport_object.hpp +++ b/libraries/chain/include/graphene/chain/sport_object.hpp @@ -23,7 +23,8 @@ */ #pragma once -#include +#include + #include #include @@ -48,4 +49,6 @@ typedef multi_index_container< typedef generic_index sport_object_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::sport_object) + FC_REFLECT_DERIVED( graphene::chain::sport_object, (graphene::db::object), (name) ) diff --git a/libraries/chain/include/graphene/chain/tournament_evaluator.hpp b/libraries/chain/include/graphene/chain/tournament_evaluator.hpp index 18a0140d..9cce918d 100644 --- a/libraries/chain/include/graphene/chain/tournament_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/tournament_evaluator.hpp @@ -1,5 +1,5 @@ #pragma once -#include +#include #include #include diff --git a/libraries/chain/include/graphene/chain/tournament_object.hpp b/libraries/chain/include/graphene/chain/tournament_object.hpp index 140770e2..b6ef883e 100644 --- a/libraries/chain/include/graphene/chain/tournament_object.hpp +++ b/libraries/chain/include/graphene/chain/tournament_object.hpp @@ -1,12 +1,19 @@ #pragma once -#include + +#include #include -#include +#include + +#include + #include #include + #include #include +#include + namespace graphene { namespace chain { class tournament_object; } } @@ -234,6 +241,9 @@ namespace graphene { namespace chain { } } +MAP_OBJECT_ID_TO_TYPE(graphene::chain::tournament_details_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::tournament_object) + FC_REFLECT_DERIVED(graphene::chain::tournament_details_object, (graphene::db::object), (tournament_id) (registered_players) diff --git a/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp b/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp index 53c6f3eb..16958f35 100644 --- a/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp +++ b/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp @@ -25,7 +25,7 @@ #include namespace graphene { -namespace protocol { class signed_transaction; } +namespace protocol { struct signed_transaction; } namespace chain { class database; using protocol::signed_transaction; diff --git a/libraries/chain/include/graphene/chain/transaction_history_object.hpp b/libraries/chain/include/graphene/chain/transaction_history_object.hpp index 6bed7920..e1f5f337 100644 --- a/libraries/chain/include/graphene/chain/transaction_history_object.hpp +++ b/libraries/chain/include/graphene/chain/transaction_history_object.hpp @@ -23,7 +23,10 @@ */ #pragma once +#include + #include + #include #include diff --git a/libraries/chain/include/graphene/chain/types.hpp b/libraries/chain/include/graphene/chain/types.hpp index 050672ad..16158b80 100644 --- a/libraries/chain/include/graphene/chain/types.hpp +++ b/libraries/chain/include/graphene/chain/types.hpp @@ -46,10 +46,10 @@ GRAPHENE_DEFINE_IDS(chain, implementation_ids, impl_, (buyback) (fba_accumulator) (asset_dividend_data) - (pending_dividend_payout_balance_for_holder_object) - (distributed_dividend_balance_data) - (betting_market_position_object) - (global_betting_statistics_object) - (lottery_balance_object) - (sweeps_vesting_balance_object) - (offer_history_object)) + (pending_dividend_payout_balance_for_holder) + (total_distributed_dividend_balance) + (betting_market_position) + (global_betting_statistics) + (lottery_balance) + (sweeps_vesting_balance) + (offer_history)) diff --git a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp index 11b689df..c6ecceb7 100644 --- a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp +++ b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp @@ -23,6 +23,8 @@ */ #pragma once +#include + #include #include #include diff --git a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp index 2415f82f..dc32e1bc 100644 --- a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp @@ -22,11 +22,16 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include #include #include +#include + +#include + +#include +#include + +#include namespace graphene { namespace chain { @@ -62,13 +67,13 @@ class witness_schedule_object : public graphene::db::abstract_object rng_seed; + std::array< char, sizeof(secret_hash_type) > rng_seed = {}; /** * Not necessary for consensus, but used for figuring out the participation rate. * The nth bit is 0 if the nth slot was unfilled, else it is 1. */ - fc::uint128 recent_slots_filled; + fc::uint128_t recent_slots_filled; }; } } diff --git a/libraries/chain/proposal_evaluator.cpp b/libraries/chain/proposal_evaluator.cpp index 70066066..fa9d5868 100644 --- a/libraries/chain/proposal_evaluator.cpp +++ b/libraries/chain/proposal_evaluator.cpp @@ -25,9 +25,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include @@ -314,7 +314,7 @@ void_result proposal_update_evaluator::do_apply(const proposal_update_operation& // Potential optimization: if _executed_proposal is true, we can skip the modify step and make push_proposal skip // signature checks. This isn't done now because I just wrote all the proposals code, and I'm not yet 100% sure the // required approvals are sufficient to authorize the transaction. - d.modify(*_proposal, [&o, &d](proposal_object& p) { + d.modify(*_proposal, [&o](proposal_object& p) { p.available_active_approvals.insert(o.active_approvals_to_add.begin(), o.active_approvals_to_add.end()); p.available_owner_approvals.insert(o.owner_approvals_to_add.begin(), o.owner_approvals_to_add.end()); for( account_id_type id : o.active_approvals_to_remove ) diff --git a/libraries/chain/small_objects.cpp b/libraries/chain/small_objects.cpp index 6b8af3d9..66812162 100644 --- a/libraries/chain/small_objects.cpp +++ b/libraries/chain/small_objects.cpp @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include +#include #include #include @@ -36,15 +36,20 @@ #include #include #include -#include +#include #include #include #include #include #include +#include #include +namespace graphene { namespace chain { +FC_IMPLEMENT_EXCEPTION(no_transition, 100000, "Invalid state transition"); +} } + GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::balance_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::block_summary_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::budget_record ) @@ -63,7 +68,7 @@ GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::global_propert GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::operation_history_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::account_transaction_history_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::special_authority_object ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transaction_object ) +GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::transaction_history_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::withdraw_permission_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_object ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::witness_scheduler ) diff --git a/libraries/chain/tournament_evaluator.cpp b/libraries/chain/tournament_evaluator.cpp index c90f5e10..d3c7acf7 100644 --- a/libraries/chain/tournament_evaluator.cpp +++ b/libraries/chain/tournament_evaluator.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -106,8 +106,7 @@ namespace graphene { namespace chain { object_id_type tournament_create_evaluator::do_apply( const tournament_create_operation& op ) { try { const tournament_details_object& tournament_details = - db().create( [&]( tournament_details_object& a ) { - }); + db().create( [&]( tournament_details_object& ) { }); const tournament_object& new_tournament = db().create( [&]( tournament_object& t ) { diff --git a/libraries/chain/tournament_object.cpp b/libraries/chain/tournament_object.cpp index ad64b34f..715ef1d3 100644 --- a/libraries/chain/tournament_object.cpp +++ b/libraries/chain/tournament_object.cpp @@ -317,7 +317,7 @@ namespace graphene { namespace chain { share_type rake_amount = 0; if (dividend_id) - rake_amount = (fc::uint128_t(tournament_obj.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64(); + rake_amount = (fc::uint128_t(tournament_obj.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100); asset won_prize(tournament_obj.prize_pool - rake_amount, tournament_obj.options.buy_in.asset_id); tournament_payout_operation op; @@ -645,13 +645,6 @@ namespace graphene { namespace chain { } } - fc::sha256 rock_paper_scissors_throw::calculate_hash() const - { - std::vector full_throw_packed(fc::raw::pack(*this)); - return fc::sha256::hash(full_throw_packed.data(), full_throw_packed.size()); - } - - vector tournament_players_index::get_registered_tournaments_for_account( const account_id_type& a )const { auto iter = account_to_joined_tournaments.find(a); diff --git a/libraries/chain/vesting_balance_evaluator.cpp b/libraries/chain/vesting_balance_evaluator.cpp index e81383b6..78a0fcdf 100644 --- a/libraries/chain/vesting_balance_evaluator.cpp +++ b/libraries/chain/vesting_balance_evaluator.cpp @@ -26,6 +26,7 @@ #include #include #include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/vesting_balance_object.cpp b/libraries/chain/vesting_balance_object.cpp index b9e99ae9..604281d0 100644 --- a/libraries/chain/vesting_balance_object.cpp +++ b/libraries/chain/vesting_balance_object.cpp @@ -59,7 +59,7 @@ asset linear_vesting_policy::get_allowed_withdraw( const vesting_policy_context& share_type total_vested = 0; if( elapsed_seconds < vesting_duration_seconds ) { - total_vested = (fc::uint128_t( begin_balance.value ) * elapsed_seconds / vesting_duration_seconds).to_uint64(); + total_vested = (fc::uint128_t( begin_balance.value ) * elapsed_seconds / vesting_duration_seconds); } else { diff --git a/libraries/net/include/graphene/net/node.hpp b/libraries/net/include/graphene/net/node.hpp index f68f3574..fe03ac0c 100644 --- a/libraries/net/include/graphene/net/node.hpp +++ b/libraries/net/include/graphene/net/node.hpp @@ -193,7 +193,7 @@ namespace graphene { namespace net { { public: node(const std::string& user_agent); - ~node(); + virtual ~node(); void close(); diff --git a/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_api.hpp b/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_api.hpp index 29c45d9f..b9f4ac64 100644 --- a/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_api.hpp +++ b/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_api.hpp @@ -27,8 +27,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_objects.hpp b/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_objects.hpp index 1dc70276..a6d3a63c 100644 --- a/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_objects.hpp +++ b/libraries/plugins/affiliate_stats/include/graphene/affiliate_stats/affiliate_stats_objects.hpp @@ -48,7 +48,7 @@ public: inline asset_id_type get_asset_id()const { return total_payout.asset_id; } }; -typedef object_id app_reward_id_type; +typedef object_id app_reward_id_type; struct by_asset; struct by_app_asset; @@ -86,7 +86,7 @@ public: inline asset_id_type get_asset_id()const { return total_payout.asset_id; } }; -typedef object_id referral_reward_id_type; +typedef object_id referral_reward_id_type; struct by_referral_asset; typedef multi_index_container< diff --git a/libraries/plugins/bookie/bookie_api.cpp b/libraries/plugins/bookie/bookie_api.cpp index 9caa9c62..4269364d 100644 --- a/libraries/plugins/bookie/bookie_api.cpp +++ b/libraries/plugins/bookie/bookie_api.cpp @@ -152,7 +152,7 @@ fc::variants bookie_api_impl::get_objects(const vector& ids) con result.reserve(ids.size()); std::transform(ids.begin(), ids.end(), std::back_inserter(result), - [this, &db](object_id_type id) -> fc::variant { + [&db](object_id_type id) -> fc::variant { switch (id.type()) { case event_id_type::type_id: diff --git a/libraries/plugins/bookie/bookie_plugin.cpp b/libraries/plugins/bookie/bookie_plugin.cpp index 5bc31f14..3dd17d1b 100644 --- a/libraries/plugins/bookie/bookie_plugin.cpp +++ b/libraries/plugins/bookie/bookie_plugin.cpp @@ -519,7 +519,8 @@ asset bookie_plugin::get_total_matched_bet_amount_for_betting_market_group(betti } std::vector bookie_plugin::get_events_containing_sub_string(const std::string& sub_string, const std::string& language) { - ilog("bookie plugin: get_events_containing_sub_string(${sub_string}, ${language})", (sub_string)(language)); + ilog("bookie plugin: get_events_containing_sub_string(${sub_string}, ${language})", + ("sub_string", sub_string)("language", language)); return my->get_events_containing_sub_string(sub_string, language); } diff --git a/libraries/plugins/bookie/include/graphene/bookie/bookie_api.hpp b/libraries/plugins/bookie/include/graphene/bookie/bookie_api.hpp index 36c8a64b..0919fc62 100644 --- a/libraries/plugins/bookie/include/graphene/bookie/bookie_api.hpp +++ b/libraries/plugins/bookie/include/graphene/bookie/bookie_api.hpp @@ -29,8 +29,8 @@ #include #include -#include -#include +#include +#include #include using namespace graphene::chain; diff --git a/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp b/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp index 1166ced3..c9e20b8e 100644 --- a/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp +++ b/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp @@ -52,7 +52,7 @@ class persistent_event_object : public graphene::db::abstract_object persistent_event_id_type; +typedef object_id persistent_event_id_type; struct by_event_id; typedef multi_index_container< diff --git a/libraries/plugins/bookie/include/graphene/bookie/bookie_plugin.hpp b/libraries/plugins/bookie/include/graphene/bookie/bookie_plugin.hpp index 333b8bab..93889cb8 100644 --- a/libraries/plugins/bookie/include/graphene/bookie/bookie_plugin.hpp +++ b/libraries/plugins/bookie/include/graphene/bookie/bookie_plugin.hpp @@ -23,8 +23,10 @@ */ #pragma once -#include #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 413f6b9d..8ad490bc 100644 --- a/libraries/plugins/delayed_node/delayed_node_plugin.cpp +++ b/libraries/plugins/delayed_node/delayed_node_plugin.cpp @@ -63,7 +63,7 @@ void delayed_node_plugin::plugin_set_program_options(bpo::options_description& c void delayed_node_plugin::connect() { - my->client_connection = std::make_shared(*my->client.connect(my->remote_endpoint), GRAPHENE_MAX_NESTED_OBJECTS); + my->client_connection = std::make_shared(my->client.connect(my->remote_endpoint), GRAPHENE_MAX_NESTED_OBJECTS); my->database_api = my->client_connection->get_remote_api(0); my->client_connection_closed = my->client_connection->closed.connect([this] { connection_failed(); diff --git a/libraries/plugins/generate_genesis/generate_genesis.cpp b/libraries/plugins/generate_genesis/generate_genesis.cpp index 88da427e..c526611f 100644 --- a/libraries/plugins/generate_genesis/generate_genesis.cpp +++ b/libraries/plugins/generate_genesis/generate_genesis.cpp @@ -296,12 +296,12 @@ void generate_genesis_plugin::generate_snapshot() auto balance_iter = by_effective_balance_index.begin(); for (; balance_iter != by_effective_balance_index.end(); ++balance_iter) { - fc::uint128 share_drop_amount = total_amount_to_distribute.value; + fc::uint128_t share_drop_amount = total_amount_to_distribute.value; share_drop_amount *= balance_iter->get_effective_balance().value; share_drop_amount /= total_bts_balance.value; - if (!share_drop_amount.to_uint64()) + if (!share_drop_amount) break; // balances are decreasing, so every balance after will also round to zero - total_shares_dropped += share_drop_amount.to_uint64(); + total_shares_dropped += share_drop_amount; effective_total_bts_balance += balance_iter->get_effective_balance(); } @@ -312,10 +312,10 @@ void generate_genesis_plugin::generate_snapshot() do { --balance_iter; - fc::uint128 share_drop_amount = remaining_amount_to_distribute.value; + fc::uint128_t share_drop_amount = remaining_amount_to_distribute.value; share_drop_amount *= balance_iter->get_effective_balance().value; share_drop_amount /= bts_balance_remaining.value; - graphene::chain::share_type amount_distributed = share_drop_amount.to_uint64(); + graphene::chain::share_type amount_distributed = share_drop_amount; by_effective_balance_index.modify(balance_iter, [&](my_account_balance_object& balance_object) { balance_object.sharedrop += amount_distributed; diff --git a/libraries/plugins/witness/include/graphene/witness/witness.hpp b/libraries/plugins/witness/include/graphene/witness/witness.hpp index f0c3ece7..9ec5a02c 100644 --- a/libraries/plugins/witness/include/graphene/witness/witness.hpp +++ b/libraries/plugins/witness/include/graphene/witness/witness.hpp @@ -79,7 +79,6 @@ private: boost::program_options::variables_map _options; bool _production_enabled = false; - bool _consecutive_production_enabled = false; uint32_t _required_witness_participation = 33 * GRAPHENE_1_PERCENT; uint32_t _production_skip_flags = graphene::chain::database::skip_nothing; diff --git a/libraries/protocol/account.cpp b/libraries/protocol/account.cpp index b5180978..149270ee 100644 --- a/libraries/protocol/account.cpp +++ b/libraries/protocol/account.cpp @@ -23,6 +23,8 @@ */ #include +#include + namespace graphene { namespace protocol { /** @@ -59,13 +61,6 @@ bool is_valid_name( const string& name ) { try { const size_t len = name.size(); - /** this condition will prevent witnesses from including new names before this time, but - * allow them after this time. This check can be removed from the code after HARDFORK_385_TIME - * has passed. - */ - if( fc::time_point::now() < fc::time_point(HARDFORK_385_TIME) ) - FC_ASSERT( len >= 3 ); - if( len < GRAPHENE_MIN_ACCOUNT_NAME_LENGTH ) { ilog( "."); diff --git a/libraries/protocol/address.cpp b/libraries/protocol/address.cpp index 502960ac..4069f430 100644 --- a/libraries/protocol/address.cpp +++ b/libraries/protocol/address.cpp @@ -89,7 +89,7 @@ namespace graphene { namespace protocol { address::operator std::string()const { std::array bin_addr; - static_assert( bin_addr.size() >= sizeof(addr) + 4 ); + static_assert( bin_addr.size() >= sizeof(addr) + 4, "" ); memcpy( bin_addr.data(), addr.data(), sizeof(addr) ); auto checksum = fc::ripemd160::hash( addr.data(), sizeof(addr) ); memcpy( bin_addr.data() + 20, (char*)&checksum._hash[0], 4 ); diff --git a/libraries/protocol/betting_market.cpp b/libraries/protocol/betting_market.cpp index 99712f9c..a27b3dc7 100644 --- a/libraries/protocol/betting_market.cpp +++ b/libraries/protocol/betting_market.cpp @@ -21,9 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void betting_market_rules_create_operation::validate() const { @@ -77,5 +77,5 @@ void bet_cancel_operation::validate() const -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/protocol/block.cpp b/libraries/protocol/block.cpp index ddf6ae6d..3b96579c 100644 --- a/libraries/protocol/block.cpp +++ b/libraries/protocol/block.cpp @@ -23,7 +23,6 @@ */ #include #include -#include #include namespace graphene { namespace protocol { @@ -91,6 +90,6 @@ namespace graphene { namespace protocol { } } -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::block_header) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::signed_block_header) -GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::chain::signed_block) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::block_header) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::signed_block_header) +GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::signed_block) diff --git a/libraries/protocol/event.cpp b/libraries/protocol/event.cpp index 730e3fb6..7b492270 100644 --- a/libraries/protocol/event.cpp +++ b/libraries/protocol/event.cpp @@ -21,9 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void event_create_operation::validate() const { @@ -40,5 +40,5 @@ void event_update_status_operation::validate() const FC_ASSERT( fee.amount >= 0 ); } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/protocol/event_group.cpp b/libraries/protocol/event_group.cpp index 39fe0f3c..dfa0a904 100644 --- a/libraries/protocol/event_group.cpp +++ b/libraries/protocol/event_group.cpp @@ -21,9 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void event_group_create_operation::validate() const { @@ -40,5 +40,5 @@ void event_group_delete_operation::validate() const FC_ASSERT( fee.amount >= 0 ); } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/protocol/fee_schedule.cpp b/libraries/protocol/fee_schedule.cpp index 5375637b..3e333029 100644 --- a/libraries/protocol/fee_schedule.cpp +++ b/libraries/protocol/fee_schedule.cpp @@ -121,10 +121,10 @@ namespace graphene { namespace protocol { scaled /= GRAPHENE_100_PERCENT; FC_ASSERT( scaled <= GRAPHENE_MAX_SHARE_SUPPLY ); //idump( (base_value)(scaled)(core_exchange_rate) ); - auto result = asset( scaled.to_uint64(), asset_id_type(0) ) * core_exchange_rate; + auto result = asset( scaled, asset_id_type(0) ) * core_exchange_rate; //FC_ASSERT( result * core_exchange_rate >= asset( scaled.to_uint64()) ); - while( result * core_exchange_rate < asset( scaled.to_uint64()) ) + while( result * core_exchange_rate < asset(scaled) ) result.amount++; FC_ASSERT( result.amount <= GRAPHENE_MAX_SHARE_SUPPLY ); diff --git a/libraries/protocol/include/graphene/protocol/affiliate.hpp b/libraries/protocol/include/graphene/protocol/affiliate.hpp index b2c3ee88..15509ee0 100644 --- a/libraries/protocol/include/graphene/protocol/affiliate.hpp +++ b/libraries/protocol/include/graphene/protocol/affiliate.hpp @@ -22,11 +22,13 @@ * THE SOFTWARE. */ #pragma once -#include -#include -#include -namespace graphene { namespace chain { +#include +#include +#include +#include + +namespace graphene { namespace protocol { /** * Virtual op generated when an affiliate receives payout. @@ -83,10 +85,10 @@ namespace graphene { namespace chain { { return 0; } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::affiliate_payout_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::affiliate_referral_payout_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::affiliate_payout_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::affiliate_referral_payout_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::affiliate_payout_operation, (fee)(affiliate)(tag)(payout) ) -FC_REFLECT( graphene::chain::affiliate_referral_payout_operation, (fee)(player)(payout) ) +FC_REFLECT( graphene::protocol::affiliate_payout_operation, (fee)(affiliate)(tag)(payout) ) +FC_REFLECT( graphene::protocol::affiliate_referral_payout_operation, (fee)(player)(payout) ) diff --git a/libraries/protocol/include/graphene/protocol/asset_ops.hpp b/libraries/protocol/include/graphene/protocol/asset_ops.hpp index 7aa798c0..836f29d9 100644 --- a/libraries/protocol/include/graphene/protocol/asset_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/asset_ops.hpp @@ -23,11 +23,10 @@ */ #pragma once #include -#include #include +#include -namespace graphene { namespace protocol { - +namespace graphene { namespace protocol { bool is_valid_symbol( const string& symbol ); struct benefactor { @@ -152,13 +151,13 @@ namespace graphene { namespace protocol { /// the options are updated again. fc::optional payout_interval; /// Each dividend distribution incurs a fee that is based on the number of accounts - /// that hold the dividend asset, not as a percentage of the amount paid out. + /// that hold the dividend asset, not as a percentage of the amount paid out. /// This parameter prevents assets from being distributed unless the fee is less than /// the percentage here, to prevent a slow trickle of deposits to the account from being /// completely consumed. /// In other words, if you set this parameter to 10% and the fees work out to 100 BTS /// to share out, balances in the dividend distribution accounts will not be shared out - /// if the balance is less than 10000 BTS. + /// if the balance is less than 10000 BTS. uint64_t minimum_fee_percentage; /// Normally, pending dividend payments are calculated each maintenance interval in @@ -171,7 +170,7 @@ namespace graphene { namespace protocol { /// /// Payouts will always occur at the next payout time whether or not it falls on a /// multiple of the distribution interval, and the timer on the distribution interval - /// are reset at payout time. So if you have the distribution interval at three days + /// are reset at payout time. So if you have the distribution interval at three days /// and the payout interval at one week, payouts will occur at days 3, 6, 7, 10, 13, 14... fc::optional minimum_distribution_interval; @@ -188,7 +187,7 @@ namespace graphene { namespace protocol { */ struct asset_create_operation : public base_operation { - struct fee_parameters_type { + struct fee_parameters_type { uint64_t symbol3 = 500000 * GRAPHENE_BLOCKCHAIN_PRECISION; uint64_t symbol4 = 300000 * GRAPHENE_BLOCKCHAIN_PRECISION; uint64_t long_symbol = 5000 * GRAPHENE_BLOCKCHAIN_PRECISION; @@ -225,7 +224,7 @@ namespace graphene { namespace protocol { ///Operation for creation of lottery struct lottery_asset_create_operation : public base_operation { - struct fee_parameters_type { + struct fee_parameters_type { uint64_t lottery_asset = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; uint32_t price_per_kbyte = 10; /// only required for large lottery names. }; @@ -296,9 +295,9 @@ namespace graphene { namespace protocol { */ struct asset_settle_operation : public base_operation { - struct fee_parameters_type { + struct fee_parameters_type { /** this fee should be high to encourage small settlement requests to - * be performed on the market rather than via forced settlement. + * be performed on the market rather than via forced settlement. * * Note that in the event of a black swan or prediction market close out * everyone will have to pay this fee. @@ -367,7 +366,7 @@ namespace graphene { namespace protocol { * payments. */ uint64_t distribution_base_fee; - /** This fee is charged (in addition to the distribution_base_fee) for each + /** This fee is charged (in addition to the distribution_base_fee) for each * user the dividend payment is shared out amongst */ uint32_t distribution_fee_per_holder; @@ -429,7 +428,7 @@ namespace graphene { namespace protocol { */ struct asset_update_operation : public base_operation { - struct fee_parameters_type { + struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; uint32_t price_per_kbyte = 10; }; @@ -482,9 +481,9 @@ namespace graphene { namespace protocol { * @brief Update options specific to dividend-paying assets * @ingroup operations * - * Dividend-paying assets have some options which are not relevant to other asset types. + * Dividend-paying assets have some options which are not relevant to other asset types. * This operation is used to update those options an an existing dividend-paying asset. - * This can also be used to convert a non-dividend-paying asset into a dividend-paying + * This can also be used to convert a non-dividend-paying asset into a dividend-paying * asset. * * @pre @ref issuer MUST be an existing account and MUST match asset_object::issuer on @ref asset_to_update @@ -573,8 +572,8 @@ namespace graphene { namespace protocol { */ struct asset_issue_operation : public base_operation { - struct fee_parameters_type { - uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; + struct fee_parameters_type { + uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; }; @@ -629,19 +628,19 @@ namespace graphene { namespace protocol { account_id_type fee_payer()const { return issuer; } void validate()const; }; - + struct sweeps_vesting_claim_operation : public base_operation { struct fee_parameters_type { uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; }; - + asset fee; account_id_type account; asset amount_to_claim; extensions_type extensions; - - + + account_id_type fee_payer()const { return account; } void validate()const {}; }; @@ -691,6 +690,7 @@ FC_REFLECT( graphene::protocol::benefactor, (id)(share) ) FC_REFLECT( graphene::protocol::lottery_asset_options, (benefactors)(owner)(winning_tickets)(ticket_price)(end_date)(ending_on_soldout)(is_active) ) + FC_REFLECT( graphene::protocol::asset_create_operation::fee_parameters_type, (symbol3)(symbol4)(long_symbol)(price_per_kbyte) ) FC_REFLECT( graphene::protocol::lottery_asset_create_operation::fee_parameters_type, (lottery_asset)(price_per_kbyte) ) FC_REFLECT( graphene::protocol::asset_global_settle_operation::fee_parameters_type, (fee) ) @@ -734,20 +734,6 @@ FC_REFLECT( graphene::protocol::asset_update_operation, (new_options) (extensions) ) -FC_REFLECT( graphene::protocol::asset_update_issuer_operation, - (fee) - (issuer) - (asset_to_update) - (new_options) - (extensions) - ) -FC_REFLECT( graphene::chain::asset_update_dividend_operation, - (fee) - (issuer) - (asset_to_update) - (new_options) - (extensions) - ) FC_REFLECT( graphene::protocol::asset_update_bitasset_operation, (fee) (issuer) @@ -755,6 +741,13 @@ FC_REFLECT( graphene::protocol::asset_update_bitasset_operation, (new_options) (extensions) ) +FC_REFLECT( graphene::protocol::asset_update_dividend_operation, + (fee) + (issuer) + (asset_to_update) + (new_options) + (extensions) + ) FC_REFLECT( graphene::protocol::asset_update_feed_producers_operation, (fee)(issuer)(asset_to_update)(new_feed_producers)(extensions) ) diff --git a/libraries/protocol/include/graphene/protocol/betting_market.hpp b/libraries/protocol/include/graphene/protocol/betting_market.hpp index 26b6f263..306840ab 100644 --- a/libraries/protocol/include/graphene/protocol/betting_market.hpp +++ b/libraries/protocol/include/graphene/protocol/betting_market.hpp @@ -23,10 +23,11 @@ */ #pragma once -#include -#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct betting_market_rules_create_operation : public base_operation { @@ -417,22 +418,22 @@ struct bet_adjusted_operation : public base_operation } } -FC_REFLECT( graphene::chain::betting_market_rules_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_rules_create_operation, +FC_REFLECT( graphene::protocol::betting_market_rules_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_rules_create_operation, (fee)(name)(description)(extensions) ) -FC_REFLECT( graphene::chain::betting_market_rules_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_rules_update_operation, +FC_REFLECT( graphene::protocol::betting_market_rules_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_rules_update_operation, (fee)(new_name)(new_description)(extensions)(betting_market_rules_id) ) -FC_REFLECT_ENUM( graphene::chain::betting_market_status, +FC_REFLECT_ENUM( graphene::protocol::betting_market_status, (unresolved) (frozen) (graded) (canceled) (settled) (BETTING_MARKET_STATUS_COUNT) ) -FC_REFLECT_ENUM( graphene::chain::betting_market_group_status, +FC_REFLECT_ENUM( graphene::protocol::betting_market_group_status, (upcoming) (in_play) (closed) @@ -443,51 +444,51 @@ FC_REFLECT_ENUM( graphene::chain::betting_market_group_status, (canceled) (BETTING_MARKET_GROUP_STATUS_COUNT) ) -FC_REFLECT( graphene::chain::betting_market_group_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_group_create_operation, +FC_REFLECT( graphene::protocol::betting_market_group_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_group_create_operation, (fee)(description)(event_id)(rules_id)(asset_id) (never_in_play)(delay_before_settling) (extensions) ) -FC_REFLECT( graphene::chain::betting_market_group_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_group_update_operation, +FC_REFLECT( graphene::protocol::betting_market_group_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_group_update_operation, (fee)(betting_market_group_id)(new_description)(new_rules_id)(status)(extensions) ) -FC_REFLECT( graphene::chain::betting_market_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_create_operation, +FC_REFLECT( graphene::protocol::betting_market_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_create_operation, (fee)(group_id)(description)(payout_condition)(extensions) ) -FC_REFLECT( graphene::chain::betting_market_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_update_operation, +FC_REFLECT( graphene::protocol::betting_market_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_update_operation, (fee)(betting_market_id)(new_group_id)(new_description)(new_payout_condition)(extensions) ) -FC_REFLECT_ENUM( graphene::chain::betting_market_resolution_type, (win)(not_win)(cancel)(BETTING_MARKET_RESOLUTION_COUNT) ) +FC_REFLECT_ENUM( graphene::protocol::betting_market_resolution_type, (win)(not_win)(cancel)(BETTING_MARKET_RESOLUTION_COUNT) ) -FC_REFLECT( graphene::chain::betting_market_group_resolve_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_group_resolve_operation, +FC_REFLECT( graphene::protocol::betting_market_group_resolve_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_group_resolve_operation, (fee)(betting_market_group_id)(resolutions)(extensions) ) -FC_REFLECT( graphene::chain::betting_market_group_resolved_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::betting_market_group_resolved_operation, +FC_REFLECT( graphene::protocol::betting_market_group_resolved_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::betting_market_group_resolved_operation, (bettor_id)(betting_market_group_id)(resolutions)(winnings)(fees_paid)(fee) ) -FC_REFLECT( graphene::chain::betting_market_group_cancel_unmatched_bets_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::betting_market_group_cancel_unmatched_bets_operation, +FC_REFLECT( graphene::protocol::betting_market_group_cancel_unmatched_bets_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::betting_market_group_cancel_unmatched_bets_operation, (fee)(betting_market_group_id)(extensions) ) -FC_REFLECT_ENUM( graphene::chain::bet_type, (back)(lay) ) -FC_REFLECT( graphene::chain::bet_place_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::bet_place_operation, +FC_REFLECT_ENUM( graphene::protocol::bet_type, (back)(lay) ) +FC_REFLECT( graphene::protocol::bet_place_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::bet_place_operation, (fee)(bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(back_or_lay)(extensions) ) -FC_REFLECT( graphene::chain::bet_matched_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::bet_matched_operation, (bettor_id)(bet_id)(amount_bet)(backer_multiplier)(guaranteed_winnings_returned) ) +FC_REFLECT( graphene::protocol::bet_matched_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::bet_matched_operation, (fee)(bettor_id)(bet_id)(amount_bet)(backer_multiplier)(guaranteed_winnings_returned) ) -FC_REFLECT( graphene::chain::bet_cancel_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::bet_cancel_operation, (fee) (bettor_id) (bet_to_cancel) (extensions) ) +FC_REFLECT( graphene::protocol::bet_cancel_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::bet_cancel_operation, (fee) (bettor_id) (bet_to_cancel) (extensions) ) -FC_REFLECT( graphene::chain::bet_canceled_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::bet_canceled_operation, (bettor_id)(bet_id)(stake_returned) ) +FC_REFLECT( graphene::protocol::bet_canceled_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::bet_canceled_operation, (fee)(bettor_id)(bet_id)(stake_returned) ) -FC_REFLECT( graphene::chain::bet_adjusted_operation::fee_parameters_type, ) -FC_REFLECT( graphene::chain::bet_adjusted_operation, (bettor_id)(bet_id)(stake_returned) ) +FC_REFLECT( graphene::protocol::bet_adjusted_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::bet_adjusted_operation, (fee) (bettor_id)(bet_id)(stake_returned) ) diff --git a/libraries/protocol/include/graphene/protocol/chain_parameters.hpp b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp index 8685349f..19022630 100644 --- a/libraries/protocol/include/graphene/protocol/chain_parameters.hpp +++ b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp @@ -24,8 +24,8 @@ #pragma once #include -#include <../hardfork.d/GPOS.hf> -#include + +#include #include namespace graphene { namespace protocol { @@ -44,7 +44,7 @@ namespace graphene { namespace protocol { /* gpos parameters */ optional < uint32_t > gpos_period = GPOS_PERIOD; optional < uint32_t > gpos_subperiod = GPOS_SUBPERIOD; - optional < uint32_t > gpos_period_start = HARDFORK_GPOS_TIME.sec_since_epoch(); + optional < uint32_t > gpos_period_start = GPOS_PERIOD_START.sec_since_epoch(); optional < uint32_t > gpos_vesting_lockin_period = GPOS_VESTING_LOCKIN_PERIOD; /* rbac parameters */ optional < uint16_t > rbac_max_permissions_per_account = RBAC_MAX_PERMISSIONS_PER_ACCOUNT; @@ -101,6 +101,8 @@ namespace graphene { namespace protocol { extension extensions; + chain_parameters(); + /** defined in fee_schedule.cpp */ void validate()const; inline bet_multiplier_type min_bet_multiplier()const { @@ -135,7 +137,7 @@ namespace graphene { namespace protocol { return extensions.value.gpos_subperiod.valid() ? *extensions.value.gpos_subperiod : GPOS_SUBPERIOD; /// gpos_period % gpos_subperiod = 0 } inline uint32_t gpos_period_start()const { - return extensions.value.gpos_period_start.valid() ? *extensions.value.gpos_period_start : HARDFORK_GPOS_TIME.sec_since_epoch(); /// current period start date + return extensions.value.gpos_period_start.valid() ? *extensions.value.gpos_period_start : GPOS_PERIOD_START.sec_since_epoch(); /// current period start date } inline uint32_t gpos_vesting_lockin_period()const { return extensions.value.gpos_vesting_lockin_period.valid() ? *extensions.value.gpos_vesting_lockin_period : GPOS_VESTING_LOCKIN_PERIOD; /// GPOS vesting lockin period diff --git a/libraries/protocol/include/graphene/protocol/config.hpp b/libraries/protocol/include/graphene/protocol/config.hpp index 8ea4bcc5..fe18aa9a 100644 --- a/libraries/protocol/include/graphene/protocol/config.hpp +++ b/libraries/protocol/include/graphene/protocol/config.hpp @@ -23,11 +23,8 @@ */ #pragma once -#define GRAPHENE_SYMBOL "BTS" -#define GRAPHENE_ADDRESS_PREFIX "BTS" - -#define GRAPHENE_BLOCKCHAIN_PRECISION uint64_t( 100000 ) -#define GRAPHENE_BLOCKCHAIN_PRECISION_DIGITS 5 +#define GRAPHENE_SYMBOL "TEST" +#define GRAPHENE_ADDRESS_PREFIX "TEST" #define GRAPHENE_MIN_ACCOUNT_NAME_LENGTH 1 #define GRAPHENE_MAX_ACCOUNT_NAME_LENGTH 63 @@ -36,21 +33,8 @@ #define GRAPHENE_MAX_ASSET_SYMBOL_LENGTH 16 #define GRAPHENE_MAX_SHARE_SUPPLY int64_t(1000000000000000ll) - -#define GRAPHENE_MAX_WORKER_NAME_LENGTH 63 -#define GRAPHENE_MAX_URL_LENGTH 127 - +#define GRAPHENE_MAX_PAY_RATE 10000 /* 100% */ #define GRAPHENE_MAX_SIG_CHECK_DEPTH 2 - -#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT) - -/** - * every second, the fraction of burned core asset which cycles is - * GRAPHENE_CORE_ASSET_CYCLE_RATE / (1 << GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS) - */ -#define GRAPHENE_CORE_ASSET_CYCLE_RATE 17 -#define GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS 32 - /** * Don't allow the committee_members to publish a limit that would * make the network unable to operate. @@ -59,51 +43,34 @@ #define GRAPHENE_MIN_BLOCK_INTERVAL 1 /* seconds */ #define GRAPHENE_MAX_BLOCK_INTERVAL 30 /* seconds */ -#define GRAPHENE_DEFAULT_BLOCK_INTERVAL 5 /* seconds */ +#define GRAPHENE_DEFAULT_BLOCK_INTERVAL 3 /* seconds */ #define GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE 2048 -#define GRAPHENE_DEFAULT_MAX_BLOCK_SIZE (2*1000*1000) /* < 2 MiB (less than MAX_MESSAGE_SIZE in graphene/net/config.hpp) */ +#define GRAPHENE_DEFAULT_MAX_BLOCK_SIZE (GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE*GRAPHENE_DEFAULT_BLOCK_INTERVAL*200000) #define GRAPHENE_DEFAULT_MAX_TIME_UNTIL_EXPIRATION (60*60*24) // seconds, aka: 1 day #define GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL (60*60*24) // seconds, aka: 1 day #define GRAPHENE_DEFAULT_MAINTENANCE_SKIP_SLOTS 3 // number of slots to skip for maintenance interval -#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_DELAY (60*60*24) ///< 1 day -#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_OFFSET 0 ///< 1% -#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_MAX_VOLUME (20* GRAPHENE_1_PERCENT) ///< 20% -#define GRAPHENE_DEFAULT_PRICE_FEED_LIFETIME (60*60*24) ///< 1 day -#define GRAPHENE_DEFAULT_MAX_AUTHORITY_MEMBERSHIP 10 -#define GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES 10 -#define GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS 10 - -#define GRAPHENE_DEFAULT_MIN_WITNESS_COUNT (11) -#define GRAPHENE_DEFAULT_MIN_COMMITTEE_MEMBER_COUNT (11) -#define GRAPHENE_DEFAULT_MAX_WITNESSES (1001) // SHOULD BE ODD -#define GRAPHENE_DEFAULT_MAX_COMMITTEE (1001) // SHOULD BE ODD -#define GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC (60*60*24*7*4) // Four weeks -#define GRAPHENE_DEFAULT_COMMITTEE_PROPOSAL_REVIEW_PERIOD_SEC (60*60*24*7*2) // Two weeks -#define GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT) -#define GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE (30*GRAPHENE_1_PERCENT) -#define GRAPHENE_DEFAULT_CASHBACK_VESTING_PERIOD_SEC (60*60*24*365) ///< 1 year -#define GRAPHENE_DEFAULT_CASHBACK_VESTING_THRESHOLD (GRAPHENE_BLOCKCHAIN_PRECISION*int64_t(100)) -#define GRAPHENE_DEFAULT_BURN_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT) -#define GRAPHENE_DEFAULT_MAX_ASSERT_OPCODE 1 -#define GRAPHENE_DEFAULT_FEE_LIQUIDATION_THRESHOLD GRAPHENE_BLOCKCHAIN_PRECISION * 100; -#define GRAPHENE_DEFAULT_ACCOUNTS_PER_FEE_SCALE 1000 -#define GRAPHENE_DEFAULT_ACCOUNT_FEE_SCALE_BITSHIFTS 4 -#define GRAPHENE_DEFAULT_MAX_BUYBACK_MARKETS 4 - -#define GRAPHENE_DEFAULT_WITNESS_PAY_PER_BLOCK (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t( 10) ) -#define GRAPHENE_DEFAULT_WITNESS_PAY_VESTING_SECONDS (60*60*24) -#define GRAPHENE_DEFAULT_WORKER_BUDGET_PER_DAY (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t(500) * 1000 ) -#define GRAPHENE_DEFAULT_MINIMUM_FEEDS 7 - #define GRAPHENE_MIN_BLOCK_SIZE_LIMIT (GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT*5) // 5 transactions per block +#define GRAPHENE_MIN_TRANSACTION_EXPIRATION_LIMIT (GRAPHENE_MAX_BLOCK_INTERVAL * 5) // 5 transactions per block +#define GRAPHENE_BLOCKCHAIN_PRECISION uint64_t( 100000 ) +#define GRAPHENE_BLOCKCHAIN_PRECISION_DIGITS 5 +#define GRAPHENE_DEFAULT_TRANSFER_FEE (1*GRAPHENE_BLOCKCHAIN_PRECISION) +#define GRAPHENE_MAX_INSTANCE_ID (uint64_t(-1)>>16) /** percentage fields are fixed point with a denominator of 10,000 */ #define GRAPHENE_100_PERCENT 10000 #define GRAPHENE_1_PERCENT (GRAPHENE_100_PERCENT/100) /** NOTE: making this a power of 2 (say 2^15) would greatly accelerate fee calcs */ - #define GRAPHENE_MAX_MARKET_FEE_PERCENT GRAPHENE_100_PERCENT +#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_DELAY (60*60*24) ///< 1 day +#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_OFFSET 0 ///< 1% +#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_MAX_VOLUME (20* GRAPHENE_1_PERCENT) ///< 20% +#define GRAPHENE_DEFAULT_PRICE_FEED_LIFETIME (60*60*24) ///< 1 day +#define GRAPHENE_MAX_FEED_PRODUCERS 200 +#define GRAPHENE_DEFAULT_MAX_AUTHORITY_MEMBERSHIP 10 +#define GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES 10 +#define GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS 10 + /** * These ratios are fixed point numbers with a denominator of GRAPHENE_COLLATERAL_RATIO_DENOM, the * minimum maitenance collateral is therefore 1.001x and the default @@ -116,25 +83,155 @@ #define GRAPHENE_DEFAULT_MAINTENANCE_COLLATERAL_RATIO 1750 ///< Call when collateral only pays off 175% the debt #define GRAPHENE_DEFAULT_MAX_SHORT_SQUEEZE_RATIO 1500 ///< Stop calling when collateral only pays off 150% of the debt ///@} +#define GRAPHENE_DEFAULT_MARGIN_PERIOD_SEC (30*60*60*24) + +#define GRAPHENE_DEFAULT_MIN_WITNESS_COUNT (11) +#define GRAPHENE_DEFAULT_MIN_COMMITTEE_MEMBER_COUNT (11) +#define GRAPHENE_DEFAULT_MAX_WITNESSES (1001) // SHOULD BE ODD +#define GRAPHENE_DEFAULT_MAX_COMMITTEE (1001) // SHOULD BE ODD +#define GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC (60*60*24*7*4) // Four weeks +#define GRAPHENE_DEFAULT_COMMITTEE_PROPOSAL_REVIEW_PERIOD_SEC (60*60*24*7*2) // Two weeks +#define GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT) +#define GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE (30*GRAPHENE_1_PERCENT) +#define GRAPHENE_DEFAULT_MAX_BULK_DISCOUNT_PERCENT (50*GRAPHENE_1_PERCENT) +#define GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN ( GRAPHENE_BLOCKCHAIN_PRECISION*int64_t(1000) ) +#define GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MAX ( GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN*int64_t(100) ) +#define GRAPHENE_DEFAULT_CASHBACK_VESTING_PERIOD_SEC (60*60*24*365) ///< 1 year +#define GRAPHENE_DEFAULT_CASHBACK_VESTING_THRESHOLD (GRAPHENE_BLOCKCHAIN_PRECISION*int64_t(100)) +#define GRAPHENE_DEFAULT_BURN_PERCENT_OF_FEE (20*GRAPHENE_1_PERCENT) +#define GRAPHENE_WITNESS_PAY_PERCENT_PRECISION (1000000000) +#define GRAPHENE_DEFAULT_MAX_ASSERT_OPCODE 1 +#define GRAPHENE_DEFAULT_FEE_LIQUIDATION_THRESHOLD GRAPHENE_BLOCKCHAIN_PRECISION * 100; +#define GRAPHENE_DEFAULT_ACCOUNTS_PER_FEE_SCALE 1000 +#define GRAPHENE_DEFAULT_ACCOUNT_FEE_SCALE_BITSHIFTS 4 +#define GRAPHENE_DEFAULT_MAX_BUYBACK_MARKETS 4 + +#define GRAPHENE_MAX_WORKER_NAME_LENGTH 63 + +#define GRAPHENE_MAX_URL_LENGTH 127 + +#define GRAPHENE_WITNESS_SHUFFLED_ALGORITHM 0 +#define GRAPHENE_WITNESS_SCHEDULED_ALGORITHM 1 + +// counter initialization values used to derive near and far future seeds for shuffling witnesses +// we use the fractional bits of sqrt(2) in hex +#define GRAPHENE_NEAR_SCHEDULE_CTR_IV ( (uint64_t( 0x6a09 ) << 0x30) \ + | (uint64_t( 0xe667 ) << 0x20) \ + | (uint64_t( 0xf3bc ) << 0x10) \ + | (uint64_t( 0xc908 ) ) ) + +// and the fractional bits of sqrt(3) in hex +#define GRAPHENE_FAR_SCHEDULE_CTR_IV ( (uint64_t( 0xbb67 ) << 0x30) \ + | (uint64_t( 0xae85 ) << 0x20) \ + | (uint64_t( 0x84ca ) << 0x10) \ + | (uint64_t( 0xa73b ) ) ) + +// counter used to determine bits of entropy +// must be less than or equal to secret_hash_type::data_length() +#define GRAPHENE_RNG_SEED_LENGTH (160 / 8) + +/** + * every second, the fraction of burned core asset which cycles is + * GRAPHENE_CORE_ASSET_CYCLE_RATE / (1 << GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS) + */ +#define GRAPHENE_CORE_ASSET_CYCLE_RATE 17 +#define GRAPHENE_CORE_ASSET_CYCLE_RATE_BITS 32 + +#define GRAPHENE_DEFAULT_WITNESS_PAY_PER_BLOCK (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t( 10) ) +#define GRAPHENE_DEFAULT_WITNESS_PAY_VESTING_SECONDS (60*60*24) +#define GRAPHENE_DEFAULT_WORKER_BUDGET_PER_DAY (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t(500) * 1000 ) + +#define GRAPHENE_DEFAULT_MINIMUM_FEEDS 7 + +#define GRAPHENE_MAX_INTEREST_APR uint16_t( 10000 ) + +#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT) /** * Reserved Account IDs with special meaning */ ///@{ /// Represents the current committee members, two-week review period -#define GRAPHENE_COMMITTEE_ACCOUNT (graphene::protocol::account_id_type(0)) +#define GRAPHENE_COMMITTEE_ACCOUNT (graphene::chain::account_id_type(0)) /// Represents the current witnesses -#define GRAPHENE_WITNESS_ACCOUNT (graphene::protocol::account_id_type(1)) +#define GRAPHENE_WITNESS_ACCOUNT (graphene::chain::account_id_type(1)) /// Represents the current committee members -#define GRAPHENE_RELAXED_COMMITTEE_ACCOUNT (graphene::protocol::account_id_type(2)) +#define GRAPHENE_RELAXED_COMMITTEE_ACCOUNT (graphene::chain::account_id_type(2)) /// Represents the canonical account with NO authority (nobody can access funds in null account) -#define GRAPHENE_NULL_ACCOUNT (graphene::protocol::account_id_type(3)) +#define GRAPHENE_NULL_ACCOUNT (graphene::chain::account_id_type(3)) /// Represents the canonical account with WILDCARD authority (anybody can access funds in temp account) -#define GRAPHENE_TEMP_ACCOUNT (graphene::protocol::account_id_type(4)) +#define GRAPHENE_TEMP_ACCOUNT (graphene::chain::account_id_type(4)) /// Represents the canonical account for specifying you will vote directly (as opposed to a proxy) -#define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::protocol::account_id_type(5)) +#define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::chain::account_id_type(5)) +/// +#define GRAPHENE_RAKE_FEE_ACCOUNT_ID (graphene::chain::account_id_type(6)) /// Sentinel value used in the scheduler. -#define GRAPHENE_NULL_WITNESS (graphene::protocol::witness_id_type(0)) +#define GRAPHENE_NULL_WITNESS (graphene::chain::witness_id_type(0)) ///@} #define GRAPHENE_FBA_STEALTH_DESIGNATED_ASSET (asset_id_type(743)) + +#define GRAPHENE_DEFAULT_RAKE_FEE_PERCENTAGE (3*GRAPHENE_1_PERCENT) + +/** + * Betting-related constants. + * + * We store bet multipliers as fixed-precision uint32_t. These values are + * the maximum power-of-ten bet we can have on a "symmetric" market: + * (decimal) 1.0001 - 10001 + * (fractional) 1:10000 - 10000:1 + */ +///@{ +/// betting odds (multipliers) are stored as fixed-precision, divide by this to get the actual multiplier +#define GRAPHENE_BETTING_ODDS_PRECISION 10000 +/// the smallest bet multiplier we will accept +#define GRAPHENE_BETTING_MIN_MULTIPLIER 10001 +/// the largest bet multiplier we will accept +#define GRAPHENE_BETTING_MAX_MULTIPLIER 100010000 +///@} +#define GRAPHENE_DEFAULT_MIN_BET_MULTIPLIER 10100 +#define GRAPHENE_DEFAULT_MAX_BET_MULTIPLIER 10000000 +#define GRAPHENE_DEFAULT_PERMITTED_BETTING_ODDS_INCREMENTS { { 20000, 100}, /* <= 2: 0.01 */ \ + { 30000, 200}, /* <= 3: 0.02 */ \ + { 40000, 500}, /* <= 4: 0.05 */ \ + { 60000, 1000}, /* <= 6: 0.10 */ \ + { 100000, 2000}, /* <= 10: 0.20 */ \ + { 200000, 5000}, /* <= 20: 0.50 */ \ + { 300000, 10000}, /* <= 30: 1.00 */ \ + { 500000, 20000}, /* <= 50: 2.00 */ \ + { 1000000, 50000}, /* <= 100: 5.00 */ \ + { 10000000, 100000} } /* <= 1000: 10.00 */ +#define GRAPHENE_DEFAULT_BETTING_PERCENT_FEE (2 * GRAPHENE_1_PERCENT) +#define GRAPHENE_DEFAULT_LIVE_BETTING_DELAY_TIME 5 // seconds +#define TOURNAMENT_MIN_ROUND_DELAY 0 +#define TOURNAMENT_MAX_ROUND_DELAY 600 +#define TOURNAMENT_MIN_TIME_PER_COMMIT_MOVE 0 +#define TOURNAMENT_MAN_TIME_PER_COMMIT_MOVE 600 +#define TOURNAMENT_MIN_TIME_PER_REVEAL_MOVE 0 +#define TOURNAMENT_MAX_TIME_PER_REVEAL_MOVE 600 +#define TOURNAMENT_DEFAULT_RAKE_FEE_PERCENTAGE (3*GRAPHENE_1_PERCENT) +#define TOURNAMENT_MINIMAL_RAKE_FEE_PERCENTAGE (1*GRAPHENE_1_PERCENT) +#define TOURNAMENT_MAXIMAL_RAKE_FEE_PERCENTAGE (20*GRAPHENE_1_PERCENT) +#define TOURNAMENT_MAXIMAL_REGISTRATION_DEADLINE (60*60*24*30) // seconds, 30 days +#define TOURNAMENT_MAX_NUMBER_OF_WINS 100 +#define TOURNAMENT_MAX_PLAYERS_NUMBER 256 +#define TOURNAMENT_MAX_WHITELIST_LENGTH 1000 +#define TOURNAMENT_MAX_START_TIME_IN_FUTURE (60*60*24*7*4) // 1 month +#define TOURNAMENT_MAX_START_DELAY (60*60*24*7) // 1 week +#define SWEEPS_DEFAULT_DISTRIBUTION_PERCENTAGE (2*GRAPHENE_1_PERCENT) +#define SWEEPS_DEFAULT_DISTRIBUTION_ASSET (graphene::chain::asset_id_type(0)) +#define SWEEPS_VESTING_BALANCE_MULTIPLIER 100000000 +#define SWEEPS_ACCUMULATOR_ACCOUNT (graphene::chain::account_id_type(0)) +#define GPOS_PERIOD (60*60*24*30*6) // 6 months +#define GPOS_SUBPERIOD (60*60*24*30) // 1 month +#define GPOS_VESTING_LOCKIN_PERIOD (60*60*24*30) // 1 month + +#define RBAC_MIN_PERMISSION_NAME_LENGTH 3 +#define RBAC_MAX_PERMISSION_NAME_LENGTH 10 +#define RBAC_MAX_PERMISSIONS_PER_ACCOUNT 5 // 5 per account +#define RBAC_MAX_ACCOUNT_AUTHORITY_LIFETIME 180*24*60*60 // 6 months +#define RBAC_MAX_AUTHS_PER_PERMISSION 15 // 15 ops linked per permission + +#define NFT_TOKEN_MIN_LENGTH 3 +#define NFT_TOKEN_MAX_LENGTH 15 +#define NFT_URI_MAX_LENGTH GRAPHENE_MAX_URL_LENGTH diff --git a/libraries/protocol/include/graphene/protocol/event.hpp b/libraries/protocol/include/graphene/protocol/event.hpp index 5934ad89..fdf2e74d 100644 --- a/libraries/protocol/include/graphene/protocol/event.hpp +++ b/libraries/protocol/include/graphene/protocol/event.hpp @@ -23,10 +23,11 @@ */ #pragma once -#include -#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct event_create_operation : public base_operation { @@ -132,16 +133,16 @@ struct event_update_status_operation : public base_operation } } -FC_REFLECT( graphene::chain::event_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::event_create_operation, +FC_REFLECT( graphene::protocol::event_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::event_create_operation, (fee)(name)(season)(start_time)(event_group_id)(extensions) ) -FC_REFLECT( graphene::chain::event_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::event_update_operation, +FC_REFLECT( graphene::protocol::event_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::event_update_operation, (fee)(event_id)(new_event_group_id)(new_name)(new_season)(new_start_time)(new_status)(extensions) ) -FC_REFLECT_ENUM( graphene::chain::event_status, (upcoming)(in_progress)(frozen)(finished)(canceled)(settled)(STATUS_COUNT) ) -FC_REFLECT( graphene::chain::event_update_status_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::event_update_status_operation, +FC_REFLECT_ENUM( graphene::protocol::event_status, (upcoming)(in_progress)(frozen)(finished)(canceled)(settled)(STATUS_COUNT) ) +FC_REFLECT( graphene::protocol::event_update_status_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::event_update_status_operation, (fee)(event_id)(status)(scores)(extensions) ) diff --git a/libraries/protocol/include/graphene/protocol/event_group.hpp b/libraries/protocol/include/graphene/protocol/event_group.hpp index ad88ed35..9b21f057 100644 --- a/libraries/protocol/include/graphene/protocol/event_group.hpp +++ b/libraries/protocol/include/graphene/protocol/event_group.hpp @@ -23,10 +23,11 @@ */ #pragma once -#include -#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct event_group_create_operation : public base_operation { @@ -86,14 +87,14 @@ struct event_group_delete_operation : public base_operation } } -FC_REFLECT( graphene::chain::event_group_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::event_group_create_operation, +FC_REFLECT( graphene::protocol::event_group_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::event_group_create_operation, (fee)(name)(sport_id)(extensions) ) -FC_REFLECT( graphene::chain::event_group_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::event_group_update_operation, +FC_REFLECT( graphene::protocol::event_group_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::event_group_update_operation, (fee)(new_sport_id)(new_name)(event_group_id)(extensions) ) -FC_REFLECT( graphene::chain::event_group_delete_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::event_group_delete_operation, +FC_REFLECT( graphene::protocol::event_group_delete_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::event_group_delete_operation, (fee)(event_group_id)(extensions) ) diff --git a/libraries/protocol/include/graphene/protocol/exceptions.hpp b/libraries/protocol/include/graphene/protocol/exceptions.hpp index 5141151d..21a6e95b 100644 --- a/libraries/protocol/include/graphene/protocol/exceptions.hpp +++ b/libraries/protocol/include/graphene/protocol/exceptions.hpp @@ -33,16 +33,16 @@ namespace graphene { namespace protocol { - FC_DECLARE_EXCEPTION( protocol_exception, 4000000, "protocol exception" ) + FC_DECLARE_EXCEPTION( protocol_exception, 4000000 ) - FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, graphene::protocol::protocol_exception, 4010000, "transaction validation exception" ) + FC_DECLARE_DERIVED_EXCEPTION( transaction_exception, graphene::protocol::protocol_exception, 4010000 ) - FC_DECLARE_DERIVED_EXCEPTION( tx_missing_active_auth, graphene::protocol::transaction_exception, 4010001, "missing required active authority" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_missing_owner_auth, graphene::protocol::transaction_exception, 4010002, "missing required owner authority" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_missing_other_auth, graphene::protocol::transaction_exception, 4010003, "missing required other authority" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_sig, graphene::protocol::transaction_exception, 4010004, "irrelevant signature included" ) - FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate_sig, graphene::protocol::transaction_exception, 4010005, "duplicate signature included" ) - FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_approval, graphene::protocol::transaction_exception, 4010006, "committee account cannot directly approve transaction" ) - FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::protocol::transaction_exception, 4010007, "insufficient fee" ) + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_active_auth, graphene::protocol::transaction_exception, 4010001 ) + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_owner_auth, graphene::protocol::transaction_exception, 4010002 ) + FC_DECLARE_DERIVED_EXCEPTION( tx_missing_other_auth, graphene::protocol::transaction_exception, 4010003 ) + FC_DECLARE_DERIVED_EXCEPTION( tx_irrelevant_sig, graphene::protocol::transaction_exception, 4010004 ) + FC_DECLARE_DERIVED_EXCEPTION( tx_duplicate_sig, graphene::protocol::transaction_exception, 4010005 ) + FC_DECLARE_DERIVED_EXCEPTION( invalid_committee_approval, graphene::protocol::transaction_exception, 4010006 ) + FC_DECLARE_DERIVED_EXCEPTION( insufficient_fee, graphene::protocol::transaction_exception, 4010007 ) } } // graphene::protocol diff --git a/libraries/protocol/include/graphene/protocol/fee_schedule.hpp b/libraries/protocol/include/graphene/protocol/fee_schedule.hpp index deb5a087..3c523663 100644 --- a/libraries/protocol/include/graphene/protocol/fee_schedule.hpp +++ b/libraries/protocol/include/graphene/protocol/fee_schedule.hpp @@ -83,10 +83,6 @@ namespace graphene { namespace protocol { } } // graphene::protocol -namespace fc { - template<> struct get_typename> { static const char* name() { return "shared_ptr"; } }; -} - FC_REFLECT_TYPENAME( graphene::protocol::fee_parameters ) FC_REFLECT( graphene::protocol::fee_schedule, (parameters)(scale) ) diff --git a/libraries/protocol/include/graphene/protocol/lottery_ops.hpp b/libraries/protocol/include/graphene/protocol/lottery_ops.hpp index 4f512bce..4dc65632 100644 --- a/libraries/protocol/include/graphene/protocol/lottery_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/lottery_ops.hpp @@ -22,10 +22,10 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { /** * @ingroup operations @@ -104,9 +104,9 @@ namespace graphene { namespace chain { share_type calculate_fee( const fee_parameters_type& k )const { return k.fee; } }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::ticket_purchase_operation, +FC_REFLECT( graphene::protocol::ticket_purchase_operation, (fee) (lottery) (buyer) @@ -114,10 +114,10 @@ FC_REFLECT( graphene::chain::ticket_purchase_operation, (amount) (extensions) ) -FC_REFLECT( graphene::chain::ticket_purchase_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::ticket_purchase_operation::fee_parameters_type, (fee) ) -FC_REFLECT_TYPENAME( graphene::chain::ticket_num ) -FC_REFLECT( graphene::chain::lottery_reward_operation, +FC_REFLECT_TYPENAME( graphene::protocol::ticket_num ) +FC_REFLECT( graphene::protocol::lottery_reward_operation, (fee) (lottery) (winner) @@ -126,13 +126,13 @@ FC_REFLECT( graphene::chain::lottery_reward_operation, (is_benefactor_reward) (winner_ticket_id) ) -FC_REFLECT( graphene::chain::lottery_reward_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::lottery_reward_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::lottery_end_operation, +FC_REFLECT( graphene::protocol::lottery_end_operation, (fee) (lottery) (participants) (extensions) ) -FC_REFLECT( graphene::chain::lottery_end_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::lottery_end_operation::fee_parameters_type, (fee) ) diff --git a/libraries/protocol/include/graphene/protocol/market.hpp b/libraries/protocol/include/graphene/protocol/market.hpp index 4c38b6fa..3e3b9c21 100644 --- a/libraries/protocol/include/graphene/protocol/market.hpp +++ b/libraries/protocol/include/graphene/protocol/market.hpp @@ -167,8 +167,7 @@ FC_REFLECT( graphene::protocol::fill_order_operation::fee_parameters_type, ) // FC_REFLECT( graphene::protocol::limit_order_create_operation,(fee)(seller)(amount_to_sell)(min_to_receive)(expiration)(fill_or_kill)(extensions)) FC_REFLECT( graphene::protocol::limit_order_cancel_operation,(fee)(fee_paying_account)(order)(extensions) ) FC_REFLECT( graphene::protocol::call_order_update_operation, (fee)(funding_account)(delta_collateral)(delta_debt)(extensions) ) -FC_REFLECT( graphene::protocol::fill_order_operation, (fee)(order_id)(account_id)(pays)(receives)(fill_price)(is_maker) ) -FC_REFLECT( graphene::chain::fill_order_operation, (fee)(order_id)(account_id)(pays)(receives) ) +FC_REFLECT( graphene::protocol::fill_order_operation, (fee)(order_id)(account_id)(pays)(receives) ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_create_operation::fee_parameters_type ) GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::protocol::limit_order_cancel_operation::fee_parameters_type ) diff --git a/libraries/protocol/include/graphene/protocol/protocol.hpp b/libraries/protocol/include/graphene/protocol/protocol.hpp index faf6bdc2..3932639f 100644 --- a/libraries/protocol/include/graphene/protocol/protocol.hpp +++ b/libraries/protocol/include/graphene/protocol/protocol.hpp @@ -22,5 +22,5 @@ * THE SOFTWARE. */ #pragma once -#include -#include +#include +#include diff --git a/libraries/protocol/include/graphene/protocol/rock_paper_scissors.hpp b/libraries/protocol/include/graphene/protocol/rock_paper_scissors.hpp index 1dff56cc..0ed1b56c 100644 --- a/libraries/protocol/include/graphene/protocol/rock_paper_scissors.hpp +++ b/libraries/protocol/include/graphene/protocol/rock_paper_scissors.hpp @@ -30,8 +30,9 @@ #include #include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct rock_paper_scissors_game_options { @@ -69,14 +70,17 @@ namespace graphene { namespace chain { uint64_t nonce1; uint64_t nonce2; rock_paper_scissors_gesture gesture; - fc::sha256 calculate_hash() const; + fc::sha256 calculate_hash() const { + std::vector full_throw_packed(fc::raw::pack(*this)); + return fc::sha256::hash(full_throw_packed.data(), full_throw_packed.size()); + } }; struct rock_paper_scissors_throw_commit { uint64_t nonce1; fc::sha256 throw_hash; - bool operator<(const graphene::chain::rock_paper_scissors_throw_commit& rhs) const + bool operator<(const graphene::protocol::rock_paper_scissors_throw_commit& rhs) const { return std::tie(nonce1, throw_hash) < std::tie(rhs.nonce1, rhs.throw_hash); } @@ -92,25 +96,25 @@ namespace graphene { namespace chain { } } -FC_REFLECT( graphene::chain::rock_paper_scissors_game_options, (insurance_enabled)(time_per_commit_move)(time_per_reveal_move)(number_of_gestures) ) +FC_REFLECT( graphene::protocol::rock_paper_scissors_game_options, (insurance_enabled)(time_per_commit_move)(time_per_reveal_move)(number_of_gestures) ) -// FC_REFLECT_TYPENAME( graphene::chain::rock_paper_scissors_gesture) -FC_REFLECT_ENUM( graphene::chain::rock_paper_scissors_gesture, +// FC_REFLECT_TYPENAME( graphene::protocol::rock_paper_scissors_gesture) +FC_REFLECT_ENUM( graphene::protocol::rock_paper_scissors_gesture, (rock) (paper) (scissors) (spock) (lizard)) -FC_REFLECT( graphene::chain::rock_paper_scissors_throw, +FC_REFLECT( graphene::protocol::rock_paper_scissors_throw, (nonce1) (nonce2) (gesture) ) -FC_REFLECT( graphene::chain::rock_paper_scissors_throw_commit, +FC_REFLECT( graphene::protocol::rock_paper_scissors_throw_commit, (nonce1) (throw_hash) ) -FC_REFLECT( graphene::chain::rock_paper_scissors_throw_reveal, +FC_REFLECT( graphene::protocol::rock_paper_scissors_throw_reveal, (nonce2)(gesture) ) diff --git a/libraries/protocol/include/graphene/protocol/sport.hpp b/libraries/protocol/include/graphene/protocol/sport.hpp index a33e70e9..f0a644e1 100644 --- a/libraries/protocol/include/graphene/protocol/sport.hpp +++ b/libraries/protocol/include/graphene/protocol/sport.hpp @@ -23,10 +23,11 @@ */ #pragma once -#include -#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct sport_create_operation : public base_operation { @@ -74,14 +75,14 @@ struct sport_delete_operation : public base_operation } } -FC_REFLECT( graphene::chain::sport_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sport_create_operation, +FC_REFLECT( graphene::protocol::sport_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::sport_create_operation, (fee)(name)(extensions) ) -FC_REFLECT( graphene::chain::sport_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sport_update_operation, +FC_REFLECT( graphene::protocol::sport_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::sport_update_operation, (fee)(sport_id)(new_name)(extensions) ) -FC_REFLECT( graphene::chain::sport_delete_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sport_delete_operation, +FC_REFLECT( graphene::protocol::sport_delete_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::sport_delete_operation, (fee)(sport_id)(extensions) ) diff --git a/libraries/protocol/include/graphene/protocol/tournament.hpp b/libraries/protocol/include/graphene/protocol/tournament.hpp index 5c9398d7..09b5d37a 100644 --- a/libraries/protocol/include/graphene/protocol/tournament.hpp +++ b/libraries/protocol/include/graphene/protocol/tournament.hpp @@ -30,11 +30,11 @@ #include #include -#include -#include -#include +#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { enum class payout_type { @@ -220,15 +220,15 @@ namespace graphene { namespace chain { } } -FC_REFLECT_ENUM(graphene::chain::payout_type, +FC_REFLECT_ENUM(graphene::protocol::payout_type, (prize_award) (buyin_refund) (rake_fee) ) -FC_REFLECT_TYPENAME( graphene::chain::game_specific_options ) -FC_REFLECT_TYPENAME( graphene::chain::game_specific_moves ) -FC_REFLECT( graphene::chain::tournament_options, +FC_REFLECT_TYPENAME( graphene::protocol::game_specific_options ) +FC_REFLECT_TYPENAME( graphene::protocol::game_specific_moves ) +FC_REFLECT( graphene::protocol::tournament_options, (registration_deadline) (number_of_players) (buy_in) @@ -239,31 +239,31 @@ FC_REFLECT( graphene::chain::tournament_options, (number_of_wins) (meta) (game_options)) -FC_REFLECT( graphene::chain::tournament_create_operation, +FC_REFLECT( graphene::protocol::tournament_create_operation, (fee) (creator) (options) (extensions)) -FC_REFLECT( graphene::chain::tournament_join_operation, +FC_REFLECT( graphene::protocol::tournament_join_operation, (fee) (payer_account_id) (player_account_id) (tournament_id) (buy_in) (extensions)) -FC_REFLECT( graphene::chain::tournament_leave_operation, +FC_REFLECT( graphene::protocol::tournament_leave_operation, (fee) (canceling_account_id) (player_account_id) (tournament_id) (extensions)) -FC_REFLECT( graphene::chain::game_move_operation, +FC_REFLECT( graphene::protocol::game_move_operation, (fee) (game_id) (player_account_id) (move) (extensions)) -FC_REFLECT( graphene::chain::tournament_payout_operation, +FC_REFLECT( graphene::protocol::tournament_payout_operation, (fee) (payout_account_id) (tournament_id) @@ -271,9 +271,9 @@ FC_REFLECT( graphene::chain::tournament_payout_operation, (type) (extensions)) -FC_REFLECT( graphene::chain::tournament_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::tournament_join_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::tournament_leave_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::game_move_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::tournament_payout_operation::fee_parameters_type, ) +FC_REFLECT( graphene::protocol::tournament_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::tournament_join_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::tournament_leave_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::game_move_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::tournament_payout_operation::fee_parameters_type, ) diff --git a/libraries/protocol/include/graphene/protocol/transaction.hpp b/libraries/protocol/include/graphene/protocol/transaction.hpp index c75ca522..cc226a72 100644 --- a/libraries/protocol/include/graphene/protocol/transaction.hpp +++ b/libraries/protocol/include/graphene/protocol/transaction.hpp @@ -230,7 +230,8 @@ namespace graphene { namespace protocol { FC_REFLECT( graphene::protocol::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::protocol::signed_transaction, (graphene::protocol::transaction), (signatures) ) -FC_REFLECT_DERIVED( graphene::protocol::processed_transaction, (graphene::protocol::precomputable_transaction), (operation_results) ) +FC_REFLECT_DERIVED( graphene::protocol::processed_transaction, (graphene::protocol::signed_transaction), + (operation_results) ) GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::transaction) diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index 122bc27a..94ea006e 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -177,6 +177,9 @@ using digest_type = fc::sha256; using signature_type = fc::ecc::compact_signature; using share_type = safe; using weight_type = uint16_t; +using secret_hash_type = fc::ripemd160; +using bet_multiplier_type = uint32_t; +using internationalized_string_type = flat_map; struct public_key_type { struct binary_key { @@ -195,6 +198,9 @@ struct public_key_type { friend bool operator == (const public_key_type& p1, const fc::ecc::public_key& p2); friend bool operator == (const public_key_type& p1, const public_key_type& p2); friend bool operator != (const public_key_type& p1, const public_key_type& p2); + // TODO: This is temporary for testing + bool is_valid_v1( const std::string& base58str ); + bool is_valid_muse( const std::string& base58str ); }; class pubkey_comparator { @@ -242,22 +248,22 @@ GRAPHENE_DEFINE_IDS(protocol, protocol_ids, /*protocol objects are not prefixed* (vesting_balance) (worker) (balance) - (tournament_object_type) - (tournament_details_object_type) - (match_object_type) - (game_object_type) - (sport_object_type) - (event_group_object_type) - (event_object_type) - (betting_market_rules_object_type) - (betting_market_group_object_type) - (betting_market_object_type) - (bet_object_type) - (custom_permission_object_type) - (custom_account_authority_object_type) - (offer_object_type) + (tournament) + (tournament_details) + (match) + (game) + (sport) + (event_group) + (event) + (betting_market_rules) + (betting_market_group) + (betting_market) + (bet) + (custom_permission) + (custom_account_authority) + (offer) (nft_metadata_type) - (nft_object_type)) + (nft)) FC_REFLECT(graphene::protocol::public_key_type, (key_data)) FC_REFLECT(graphene::protocol::public_key_type::binary_key, (data)(check)) diff --git a/libraries/protocol/include/graphene/protocol/vesting.hpp b/libraries/protocol/include/graphene/protocol/vesting.hpp index 98294716..ff388301 100644 --- a/libraries/protocol/include/graphene/protocol/vesting.hpp +++ b/libraries/protocol/include/graphene/protocol/vesting.hpp @@ -132,7 +132,6 @@ FC_REFLECT( graphene::protocol::vesting_balance_withdraw_operation, (fee)(vestin FC_REFLECT(graphene::protocol::linear_vesting_policy_initializer, (begin_timestamp)(vesting_cliff_seconds)(vesting_duration_seconds) ) FC_REFLECT(graphene::protocol::cdd_vesting_policy_initializer, (start_claim)(vesting_seconds) ) -FC_REFLECT_EMPTY( graphene::protocol::instant_vesting_policy_initializer ) FC_REFLECT_TYPENAME( graphene::protocol::vesting_policy_initializer ) FC_REFLECT_ENUM( graphene::protocol::vesting_balance_type, (normal)(gpos) ) diff --git a/libraries/protocol/lottery_ops.cpp b/libraries/protocol/lottery_ops.cpp index d4f11fc4..090ab556 100644 --- a/libraries/protocol/lottery_ops.cpp +++ b/libraries/protocol/lottery_ops.cpp @@ -21,9 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void ticket_purchase_operation::validate() const { @@ -36,4 +36,4 @@ share_type ticket_purchase_operation::calculate_fee( const fee_parameters_type& return k.fee; } -} } // namespace graphene::chain +} } // namespace graphene::protocol diff --git a/libraries/protocol/operations.cpp b/libraries/protocol/operations.cpp index 4dac9c86..e525f73b 100644 --- a/libraries/protocol/operations.cpp +++ b/libraries/protocol/operations.cpp @@ -33,7 +33,7 @@ uint64_t base_operation::calculate_data_fee( uint64_t bytes, uint64_t price_per_ { auto result = (fc::uint128_t(bytes) * price_per_kbyte) / 1024; FC_ASSERT( result <= GRAPHENE_MAX_SHARE_SUPPLY ); - return result.convert_to(); + return result; } void balance_claim_operation::validate()const diff --git a/libraries/protocol/small_ops.cpp b/libraries/protocol/small_ops.cpp index 5dcf2ac9..c0ced431 100644 --- a/libraries/protocol/small_ops.cpp +++ b/libraries/protocol/small_ops.cpp @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +#include #include #include #include diff --git a/libraries/protocol/sport.cpp b/libraries/protocol/sport.cpp index a8fdbf2a..a7d52f8d 100644 --- a/libraries/protocol/sport.cpp +++ b/libraries/protocol/sport.cpp @@ -21,9 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void sport_create_operation::validate() const { @@ -40,5 +40,5 @@ void sport_delete_operation::validate() const FC_ASSERT( fee.amount >= 0 ); } -} } // graphene::chain +} } // graphene::protocol diff --git a/libraries/protocol/tournament.cpp b/libraries/protocol/tournament.cpp index 78ab4c01..33ca25de 100644 --- a/libraries/protocol/tournament.cpp +++ b/libraries/protocol/tournament.cpp @@ -21,10 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include +#include #include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { void tournament_options::validate() const { @@ -73,4 +73,4 @@ void game_move_operation::validate()const { } -} } // namespace graphene::chain +} } // namespace graphene::protocol diff --git a/libraries/protocol/transaction.cpp b/libraries/protocol/transaction.cpp index c47e1e56..04549691 100644 --- a/libraries/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -29,7 +29,6 @@ #include #include -#include #include #include @@ -64,7 +63,7 @@ void transaction::validate() const operation_validate(op); } -graphene::chain::transaction_id_type graphene::chain::transaction::id() const +graphene::protocol::transaction_id_type graphene::protocol::transaction::id() const { auto h = digest(); transaction_id_type result; @@ -448,4 +447,3 @@ void signed_transaction::verify_authority( GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::transaction) GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::signed_transaction) GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::processed_transaction) - diff --git a/libraries/protocol/witness.cpp b/libraries/protocol/witness.cpp index 484a1589..91915323 100644 --- a/libraries/protocol/witness.cpp +++ b/libraries/protocol/witness.cpp @@ -21,7 +21,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include #include #include diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index b0b41051..e5d4ed66 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -74,7 +74,7 @@ #include #include #include -#include +#include #include #include diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 98c68835..6c19406d 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include #include diff --git a/programs/js_operation_serializer/main.cpp b/programs/js_operation_serializer/main.cpp index 63a6d604..74d817ba 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -133,7 +133,6 @@ template<> struct js_name { static std::string name(){ retu template<> struct js_name { static std::string name(){ return "bytes 28"; } }; template<> struct js_name { static std::string name(){ return "bytes 32"; } }; template<> struct js_name { static std::string name(){ return "varuint32"; } }; -template<> struct js_name { static std::string name(){ return "varint32"; } }; template<> struct js_name< vote_id_type > { static std::string name(){ return "vote_id"; } }; template<> struct js_name< time_point_sec > { static std::string name(){ return "time_point_sec"; } }; @@ -141,12 +140,8 @@ template struct js_name > { static std::string name(){ -<<<<<<< HEAD - return "protocol_id_type \"" + remove_namespace(fc::get_typename::name()) + "\""; -======= return "protocol_id_type(\"" + remove_namespace(fc::get_typename>>::name()) + "\")"; ->>>>>>> eec1da5b... Ref #1506: Isolate chain/protocol to its own library }; }; @@ -351,14 +346,15 @@ class register_member_visitor } }; -template +template ()> struct serializer_init_helper { static void init() { auto name = js_name::name(); if( st.find(name) == st.end() ) { - fc::reflector::visit( register_member_visitor() ); + register_member_visitor visitor; + fc::reflector::visit( visitor ); register_serializer( name, [=](){ generate(); } ); } } @@ -370,14 +366,15 @@ struct serializer_init_helper { << " = new Serializer( \n" << " \"" + name + "\"\n"; - fc::reflector::visit( serialize_member_visitor() ); + serialize_member_visitor visitor; + fc::reflector::visit( visitor ); std::cout <<")\n\n"; } }; template -struct serializer_init_helper { +struct serializer_init_helper { static void init() { } @@ -390,7 +387,7 @@ struct serializer static void init() { - serializer_init_helper< T, typename fc::reflector::is_enum >::init(); + serializer_init_helper< T >::init(); } }; diff --git a/tests/betting/betting_tests.cpp b/tests/betting/betting_tests.cpp index 4befe25c..fe4134ec 100644 --- a/tests/betting/betting_tests.cpp +++ b/tests/betting/betting_tests.cpp @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include diff --git a/tests/common/database_fixture.hpp b/tests/common/database_fixture.hpp index 5f1ebc16..7f29f7ee 100644 --- a/tests/common/database_fixture.hpp +++ b/tests/common/database_fixture.hpp @@ -31,6 +31,9 @@ #include #include #include +#include +#include +#include #include #include diff --git a/tests/generate_empty_blocks/main.cpp b/tests/generate_empty_blocks/main.cpp index 6e40e2cb..b3da426d 100644 --- a/tests/generate_empty_blocks/main.cpp +++ b/tests/generate_empty_blocks/main.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include diff --git a/tests/intense/block_tests.cpp b/tests/intense/block_tests.cpp index 7004f13f..25134fce 100644 --- a/tests/intense/block_tests.cpp +++ b/tests/intense/block_tests.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include diff --git a/tests/performance/performance_tests.cpp b/tests/performance/performance_tests.cpp index e7d0c98b..70824818 100644 --- a/tests/performance/performance_tests.cpp +++ b/tests/performance/performance_tests.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include diff --git a/tests/tests/authority_tests.cpp b/tests/tests/authority_tests.cpp index a6169489..5d4edff1 100644 --- a/tests/tests/authority_tests.cpp +++ b/tests/tests/authority_tests.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/tests/tests/basic_tests.cpp b/tests/tests/basic_tests.cpp index da608541..cb214ed8 100644 --- a/tests/tests/basic_tests.cpp +++ b/tests/tests/basic_tests.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/tests/tests/confidential_tests.cpp b/tests/tests/confidential_tests.cpp index a6a19f06..b57f2625 100644 --- a/tests/tests/confidential_tests.cpp +++ b/tests/tests/confidential_tests.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/tests/tests/network_broadcast_api_tests.cpp b/tests/tests/network_broadcast_api_tests.cpp index 4c3e7ed4..1b235c95 100644 --- a/tests/tests/network_broadcast_api_tests.cpp +++ b/tests/tests/network_broadcast_api_tests.cpp @@ -5,10 +5,11 @@ #include #include #include -#include +#include #include #include -#include +#include +#include #include #include diff --git a/tests/tournament/tournament_tests.cpp b/tests/tournament/tournament_tests.cpp index 8aa88479..1c5f51f7 100644 --- a/tests/tournament/tournament_tests.cpp +++ b/tests/tournament/tournament_tests.cpp @@ -273,7 +273,6 @@ BOOST_FIXTURE_TEST_CASE( whitelist_must_not_be_longer_than, database_fixture ) BOOST_CHECK(nathan.is_lifetime_member()); asset buy_in = asset(10000); - db.get_global_properties().parameters.maximum_tournament_whitelist_length; flat_set whitelist; for(uint16_t i = 0; i < db.get_global_properties().parameters.maximum_tournament_whitelist_length+1; ++i) { @@ -1611,7 +1610,7 @@ BOOST_FIXTURE_TEST_CASE( simple, database_fixture ) const account_object winner = winner_id(db); BOOST_TEST_MESSAGE( "The winner is " + winner.name ); - share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64(); + share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100); optional dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id); if (dividend_account.valid()) players_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount; @@ -1728,7 +1727,7 @@ BOOST_FIXTURE_TEST_CASE( ties, database_fixture ) assert(final_match.match_winners.size() == 1); const account_id_type& winner_id = *final_match.match_winners.begin(); BOOST_TEST_MESSAGE( "The winner of " + std::string(object_id_type(tournament_id)) + " is " + winner_id(db).name + " " + std::string(object_id_type(winner_id))); - share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64(); + share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100); optional dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id); if (dividend_account.valid()) players_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount; players_balances[winner_id][tournament.options.buy_in.asset_id] += tournament.prize_pool - rake_amount; @@ -1940,7 +1939,7 @@ BOOST_FIXTURE_TEST_CASE( assets, database_fixture ) assert(final_match.match_winners.size() == 1); const account_id_type& winner_id = *final_match.match_winners.begin(); BOOST_TEST_MESSAGE( "The winner of " + std::string(object_id_type(tournament_id)) + " is " + winner_id(db).name + " " + std::string(object_id_type(winner_id))); - share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64(); + share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100); optional dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id); if (dividend_account.valid()) players_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount; players_balances[winner_id][tournament.options.buy_in.asset_id] += tournament.prize_pool - rake_amount; @@ -2076,7 +2075,7 @@ BOOST_FIXTURE_TEST_CASE( basic, database_fixture ) assert(final_match.match_winners.size() == 1); const account_id_type& winner_id = *final_match.match_winners.begin(); BOOST_TEST_MESSAGE( "The winner of " + std::string(object_id_type(tournament_id)) + " is " + winner_id(db).name + " " + std::string(object_id_type(winner_id))); - share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64(); + share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100); optional dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id); if (dividend_account.valid()) players_initial_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount; @@ -2214,7 +2213,7 @@ BOOST_FIXTURE_TEST_CASE( massive, database_fixture ) assert(final_match.match_winners.size() == 1); const account_id_type& winner_id = *final_match.match_winners.begin(); BOOST_TEST_MESSAGE( "The winner of " + std::string(object_id_type(tournament_id)) + " is " + winner_id(db).name + " " + std::string(object_id_type(winner_id))); - share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100).to_uint64(); + share_type rake_amount = (fc::uint128_t(tournament.prize_pool.value) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100); optional dividend_account = tournament_helper.get_asset_dividend_account(tournament.options.buy_in.asset_id); if (dividend_account.valid()) players_balances[*dividend_account][tournament.options.buy_in.asset_id] += rake_amount; From a31e56f531b298fa07e720e7b7dc69b50fb43d36 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 28 May 2019 21:32:33 +0200 Subject: [PATCH 32/77] Fix #1772 by decprecating cli_wallet -H --- programs/cli_wallet/main.cpp | 42 ++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 6c19406d..66ce18f2 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -29,10 +29,8 @@ #include #include -#include #include #include -#include #include #include @@ -80,7 +78,8 @@ int main( int argc, char** argv ) ("rpc-endpoint,r", bpo::value()->implicit_value("127.0.0.1:8091"), "Endpoint for wallet websocket RPC to listen on") ("rpc-tls-endpoint,t", bpo::value()->implicit_value("127.0.0.1:8092"), "Endpoint for wallet websocket TLS RPC to listen on") ("rpc-tls-certificate,c", bpo::value()->implicit_value("server.pem"), "PEM certificate for wallet websocket TLS RPC") - ("rpc-http-endpoint,H", bpo::value()->implicit_value("127.0.0.1:8093"), "Endpoint for wallet HTTP RPC to listen on") + ("rpc-http-endpoint,H", bpo::value()->implicit_value("127.0.0.1:8093"), + "Endpoint for wallet HTTP RPC to listen on (DEPRECATED, use rpc-endpoint instead)") ("daemon,d", "Run the wallet in daemon mode" ) ("wallet-file,w", bpo::value()->implicit_value("wallet.json"), "wallet to load") ("chain-id", bpo::value(), "chain ID to connect to"); @@ -175,7 +174,7 @@ int main( int argc, char** argv ) fc::http::websocket_client client; idump((wdata.ws_server)); auto con = client.connect( wdata.ws_server ); - auto apic = std::make_shared(*con, GRAPHENE_MAX_NESTED_OBJECTS); + auto apic = std::make_shared(con, GRAPHENE_MAX_NESTED_OBJECTS); auto remote_api = apic->get_remote_api< login_api >(1); edump((wdata.ws_user)(wdata.ws_password) ); @@ -214,11 +213,11 @@ int main( int argc, char** argv ) _websocket_server->on_connection([&wapi]( const fc::http::websocket_connection_ptr& c ){ std::cout << "here... \n"; wlog("." ); - auto wsc = std::make_shared(*c, GRAPHENE_MAX_NESTED_OBJECTS); + auto wsc = std::make_shared(c, GRAPHENE_MAX_NESTED_OBJECTS); wsc->register_api(wapi); c->set_session_data( wsc ); }); - ilog( "Listening for incoming RPC requests on ${p}", ("p", options.at("rpc-endpoint").as() )); + ilog( "Listening for incoming HTTP and WS RPC requests on ${p}", ("p", options.at("rpc-endpoint").as() )); _websocket_server->listen( fc::ip::endpoint::from_string(options.at("rpc-endpoint").as()) ); _websocket_server->start_accept(); } @@ -227,35 +226,32 @@ int main( int argc, char** argv ) if( options.count( "rpc-tls-certificate" ) ) cert_pem = options.at("rpc-tls-certificate").as(); - auto _websocket_tls_server = std::make_shared(cert_pem); + auto _websocket_tls_server = std::make_shared(cert_pem, ""); if( options.count("rpc-tls-endpoint") ) { _websocket_tls_server->on_connection([&]( const fc::http::websocket_connection_ptr& c ){ - auto wsc = std::make_shared(*c, GRAPHENE_MAX_NESTED_OBJECTS); + auto wsc = std::make_shared(c, GRAPHENE_MAX_NESTED_OBJECTS); wsc->register_api(wapi); c->set_session_data( wsc ); }); - ilog( "Listening for incoming TLS RPC requests on ${p}", ("p", options.at("rpc-tls-endpoint").as() )); + ilog( "Listening for incoming HTTPS and WSS RPC requests on ${p}", + ("p", options.at("rpc-tls-endpoint").as()) ); _websocket_tls_server->listen( fc::ip::endpoint::from_string(options.at("rpc-tls-endpoint").as()) ); _websocket_tls_server->start_accept(); } - auto _http_server = std::make_shared(); + auto _http_ws_server = std::make_shared(); if( options.count("rpc-http-endpoint" ) ) { - ilog( "Listening for incoming HTTP RPC requests on ${p}", ("p", options.at("rpc-http-endpoint").as() ) ); - _http_server->listen( fc::ip::endpoint::from_string( options.at( "rpc-http-endpoint" ).as() ) ); - // - // due to implementation, on_request() must come AFTER listen() - // - _http_server->on_request( - [&wapi]( const fc::http::request& req, const fc::http::server::response& resp ) - { - std::shared_ptr< fc::rpc::http_api_connection > conn = - std::make_shared< fc::rpc::http_api_connection >( GRAPHENE_MAX_NESTED_OBJECTS ); - conn->register_api( wapi ); - conn->on_request( req, resp ); - } ); + ilog( "Listening for incoming HTTP and WS RPC requests on ${p}", + ("p", options.at("rpc-http-endpoint").as()) ); + _http_ws_server->on_connection([&wapi]( const fc::http::websocket_connection_ptr& c ){ + auto wsc = std::make_shared(c, GRAPHENE_MAX_NESTED_OBJECTS); + wsc->register_api(wapi); + c->set_session_data( wsc ); + }); + _http_ws_server->listen( fc::ip::endpoint::from_string(options.at("rpc-http-endpoint").as()) ); + _http_ws_server->start_accept(); } if( !options.count( "daemon" ) ) From b8c3e63f1b5c8d9a741aacba610dae540c3a7792 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 21 Aug 2020 15:23:12 -0500 Subject: [PATCH 33/77] More fixes Fix errors and warnings and generally coax it to build --- libraries/wallet/wallet.cpp | 28 ++++++++++---------- programs/build_helpers/member_enumerator.cpp | 8 +++--- programs/debug_node/main.cpp | 2 +- tests/cli/main.cpp | 2 +- tests/tests/database_tests.cpp | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index e5d4ed66..b8cf8c46 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -374,7 +374,7 @@ private: // return true if any of my_accounts are players in this tournament bool tournament_is_relevant_to_my_accounts(const tournament_object& tournament_obj) { - tournament_details_object tournament_details = get_object(tournament_obj.tournament_details_id); + tournament_details_object tournament_details = get_object(tournament_obj.tournament_details_id); for (const account_object& account_obj : _wallet.my_accounts) if (tournament_details.registered_players.find(account_obj.id) != tournament_details.registered_players.end()) return true; @@ -967,7 +967,7 @@ public: ("match", match_obj.id)("account", get_account(account_id).name)); for (const game_id_type& game_id : match_obj.games) { - game_object game_obj = get_object(game_id); + game_object game_obj = get_object(game_id); auto insert_result = game_cache.insert(game_obj); if (insert_result.second) game_in_new_state(game_obj); @@ -981,10 +981,10 @@ public: // updates on those matches void monitor_matches_in_tournament(const tournament_object& tournament_obj) { try { - tournament_details_object tournament_details = get_object(tournament_obj.tournament_details_id); + tournament_details_object tournament_details = get_object(tournament_obj.tournament_details_id); for (const match_id_type& match_id : tournament_details.matches) { - match_object match_obj = get_object(match_id); + match_object match_obj = get_object(match_id); auto insert_result = match_cache.insert(match_obj); if (insert_result.second) match_in_new_state(match_obj); @@ -1006,7 +1006,7 @@ public: { try { - tournament_object tournament = get_object(tournament_id); + tournament_object tournament = get_object(tournament_id); auto insert_result = tournament_cache.insert(tournament); if (insert_result.second) { @@ -2118,7 +2118,7 @@ public: FC_THROW("Account ${account} has no core Token ${TOKEN} vested and thus its not allowed to withdraw.", ("account", witness_name)("TOKEN", GRAPHENE_SYMBOL)); } - vesting_balance_object vbo = get_object< vesting_balance_object >( *vbid ); + vesting_balance_object vbo = get_object( *vbid ); if(vbo.balance_type != vesting_balance_type::normal) FC_THROW("Allowed to withdraw only Normal type vest balances with this method"); @@ -2163,7 +2163,7 @@ public: //whether it is a witness or user, keep it in a container and iterate over to process all vesting balances and types if(!vbos.size()) - vbos.emplace_back( get_object(*vbid) ); + vbos.emplace_back( get_object(*vbid) ); for (const vesting_balance_object& vesting_balance_obj: vbos) { if(vesting_balance_obj.balance_type == vesting_balance_type::gpos) @@ -2924,7 +2924,7 @@ public: std::string player_name; if (round == num_rounds) { - match_object match = get_object(tournament_details.matches[num_matches - 1]); + match_object match = get_object(tournament_details.matches[num_matches - 1]); if (match.get_state() == match_state::match_complete && !match.match_winners.empty()) { @@ -2934,7 +2934,7 @@ public: } else { - match_object match = get_object(tournament_details.matches[match_number]); + match_object match = get_object(tournament_details.matches[match_number]); if (!match.players.empty()) { if (player_in_match < match.players.size()) @@ -2972,7 +2972,7 @@ public: return ss.str(); }; - m["get_order_book"] = [this](variant result, const fc::variants& a) + m["get_order_book"] = [](variant result, const fc::variants&) { auto orders = result.as( GRAPHENE_MAX_NESTED_OBJECTS ); auto bids = orders.bids; @@ -4773,7 +4773,7 @@ string wallet_api::help()const { std::vector method_names = my->method_documentation.get_method_names(); std::stringstream ss; - for (const std::string method_name : method_names) + for (const std::string& method_name : method_names) { try { @@ -6296,9 +6296,9 @@ signed_transaction wallet_api::rps_throw(game_id_type game_id, FC_ASSERT( !is_locked() ); // check whether the gesture is appropriate for the game we're playing - graphene::chain::game_object game_obj = my->get_object(game_id); - graphene::chain::match_object match_obj = my->get_object(game_obj.match_id); - graphene::chain::tournament_object tournament_obj = my->get_object(match_obj.tournament_id); + graphene::chain::game_object game_obj = my->get_object(game_id); + graphene::chain::match_object match_obj = my->get_object(game_obj.match_id); + graphene::chain::tournament_object tournament_obj = my->get_object(match_obj.tournament_id); graphene::chain::rock_paper_scissors_game_options game_options = tournament_obj.options.game_options.get(); if ((int)gesture >= game_options.number_of_gestures) diff --git a/programs/build_helpers/member_enumerator.cpp b/programs/build_helpers/member_enumerator.cpp index 44e8cfac..e7c44301 100644 --- a/programs/build_helpers/member_enumerator.cpp +++ b/programs/build_helpers/member_enumerator.cpp @@ -109,7 +109,7 @@ void class_processor::process_class( const static_variant< T... >* dummy ) } } -template +template struct if_enum { template< typename T > @@ -130,7 +130,7 @@ struct if_enum }; template<> -struct if_enum +struct if_enum { template< typename T > static void process_class( class_processor* proc, const T* dummy ) @@ -157,7 +157,7 @@ struct if_reflected template< typename T > static void process_class( class_processor* proc, const T* dummy ) { - if_enum< typename fc::reflector::is_enum >::process_class(proc, dummy); + if_enum< std::is_enum::value >::process_class(proc, dummy); } }; @@ -216,7 +216,7 @@ int main( int argc, char** argv ) graphene::member_enumerator::class_processor::process_class(result); fc::mutable_variant_object mvo; - for( const std::pair< std::string, std::vector< std::string > >& e : result ) + for( const auto& e : result ) { variant v; to_variant( e.second, v , 1); diff --git a/programs/debug_node/main.cpp b/programs/debug_node/main.cpp index c94d3fd2..c93909b6 100644 --- a/programs/debug_node/main.cpp +++ b/programs/debug_node/main.cpp @@ -164,7 +164,7 @@ int main(int argc, char** argv) { node->startup(); node->startup_plugins(); - fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); + fc::promise::ptr exit_promise = fc::promise::create("UNIX Signal Handler"); fc::set_signal_handler([&exit_promise](int signal) { elog( "Caught SIGINT attempting to exit cleanly" ); diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 9c9fcd1a..f1b5065b 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -224,7 +224,7 @@ public: wallet_data.ws_password = ""; websocket_connection = websocket_client.connect( wallet_data.ws_server ); - api_connection = std::make_shared(*websocket_connection, GRAPHENE_MAX_NESTED_OBJECTS); + api_connection = std::make_shared(websocket_connection, GRAPHENE_MAX_NESTED_OBJECTS); remote_login_api = api_connection->get_remote_api< graphene::app::login_api >(1); BOOST_CHECK(remote_login_api->login( wallet_data.ws_user, wallet_data.ws_password ) ); diff --git a/tests/tests/database_tests.cpp b/tests/tests/database_tests.cpp index 9585d4a1..443d2dae 100644 --- a/tests/tests/database_tests.cpp +++ b/tests/tests/database_tests.cpp @@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE( flat_index_test ) price_feed current_feed; current_feed.settlement_price = bitusd.amount(100) / asset(100); publish_feed(bitusd, sam, current_feed); - FC_ASSERT( bitusd.bitasset_data_id->instance == 0 ); + FC_ASSERT( bitusd.bitasset_data_id->instance.value == 0 ); FC_ASSERT( !(*bitusd.bitasset_data_id)(db).current_feed.settlement_price.is_null() ); try { auto ses = db._undo_db.start_undo_session(); From ce8caae327d1cb21a542f9bab2c6cb5dd0db7e2b Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 21 Aug 2020 16:11:23 -0500 Subject: [PATCH 34/77] Fix test I'm pretty sure this didn't break from what I did... But I can't build the original code, so I can't tell. Anyways, this one now passes... Others still fail... --- libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp b/libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp index 03b54659..7ec59e82 100644 --- a/libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp +++ b/libraries/plugins/affiliate_stats/affiliate_stats_plugin.cpp @@ -152,8 +152,8 @@ static optional> get_accou { FC_ASSERT( dynamic_cast(&obj) ); const account_transaction_history_object& ath = static_cast(obj); - const operation_history_object& oho = db.get( ath.operation_id ); - if( oho.op.which() == operation::tag::value ) + const operation_history_object* oho = db.find( ath.operation_id ); + if( oho != nullptr && oho->op.which() == operation::tag::value ) return std::make_pair( ath.account, ath.operation_id ); return optional>(); } From 3dd78de312d23101993d526e9fbf35834a8a7af5 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sun, 23 Aug 2020 14:05:25 -0500 Subject: [PATCH 35/77] Small fix --- libraries/chain/db_bet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/chain/db_bet.cpp b/libraries/chain/db_bet.cpp index f0557aeb..2df5238d 100644 --- a/libraries/chain/db_bet.cpp +++ b/libraries/chain/db_bet.cpp @@ -495,7 +495,7 @@ int match_bet(database& db, const bet_object& taker_bet, const bet_object& maker payout_128 += taker_amount_to_match.value; payout_128 *= GRAPHENE_BETTING_ODDS_PRECISION; payout_128 /= maker_bet.back_or_lay == bet_type::back ? maker_amount_to_match.value : taker_amount_to_match.value; - assert(payout_128.to_uint64() == maker_bet.backer_multiplier); + assert(payout_128 == maker_bet.backer_multiplier); } #endif From a9135cbdd2cf4759269e0c4ebce2ac9cdc59e519 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sun, 23 Aug 2020 19:31:38 -0500 Subject: [PATCH 36/77] Fix crash in auth checks --- libraries/protocol/transaction.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/protocol/transaction.cpp b/libraries/protocol/transaction.cpp index 04549691..a9c72218 100644 --- a/libraries/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -231,7 +231,7 @@ struct sign_state sign_state( const flat_set& sigs, const std::function& a, - const flat_set& keys = flat_set() ) + const flat_set& keys ) :get_active(a),available_keys(keys) { for( const auto& key : sigs ) @@ -260,8 +260,9 @@ void verify_authority( const vector& ops, const flat_set required_active; flat_set required_owner; vector other; + flat_set available_keys; - sign_state s(sigs,get_active); + sign_state s(sigs,get_active, available_keys); s.max_recursion = max_recursion_depth; for( auto& id : active_aprovals ) s.approved_by.insert( id ); From 4e3e0e010ae0848c533f57b91337e0cdcc03936a Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 25 Aug 2020 13:01:51 -0500 Subject: [PATCH 37/77] Final fixes Last round of fixes following the rebase to Beatrice --- .gitmodules | 2 +- libraries/chain/CMakeLists.txt | 6 ++++ libraries/chain/db_block.cpp | 2 ++ .../custom_account_authority_evaluator.hpp | 5 +-- .../chain/custom_account_authority_object.hpp | 8 +++-- .../chain/custom_permission_evaluator.hpp | 6 ++-- .../chain/custom_permission_object.hpp | 11 +++++-- .../include/graphene/chain/nft_evaluator.hpp | 5 +-- .../include/graphene/chain/nft_object.hpp | 9 ++++-- .../graphene/chain/offer_evaluator.hpp | 3 +- .../include/graphene/chain/offer_object.hpp | 9 +++++- libraries/chain/offer_evaluator.cpp | 3 +- libraries/protocol/CMakeLists.txt | 1 + .../protocol/custom_account_authority.cpp | 8 ++--- libraries/protocol/custom_permission.cpp | 8 ++--- .../include/graphene/protocol/base.hpp | 1 + .../graphene/protocol/betting_market.hpp | 1 - .../include/graphene/protocol/config.hpp | 21 ++++++------ .../protocol/custom_account_authority.hpp | 18 +++++------ .../graphene/protocol/custom_permission.hpp | 19 +++++------ .../include/graphene/protocol/event.hpp | 1 - .../include/graphene/protocol/event_group.hpp | 1 - .../include/graphene/protocol/lottery_ops.hpp | 1 - .../include/graphene/protocol/nft_ops.hpp | 32 +++++++++---------- .../include/graphene/protocol/object_id.hpp | 1 - .../include/graphene/protocol/offer.hpp | 26 +++++++-------- .../include/graphene/protocol/sport.hpp | 1 - .../include/graphene/protocol/tournament.hpp | 1 - .../include/graphene/protocol/types.hpp | 2 +- libraries/protocol/nft.cpp | 8 ++--- libraries/protocol/offer.cpp | 8 ++--- programs/build_helpers/member_enumerator.cpp | 4 +-- tests/tests/custom_permission_tests.cpp | 7 ++-- 33 files changed, 135 insertions(+), 104 deletions(-) diff --git a/.gitmodules b/.gitmodules index 4d3518d1..495183b6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,6 @@ ignore = dirty [submodule "libraries/fc"] path = libraries/fc - url = https://github.com/peerplays-network/peerplays-fc.git + url = https://github.com/nathanhourt/peerplays-fc branch = latest-fc ignore = dirty diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 7901308b..f4c72289 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -80,9 +80,15 @@ add_library( graphene_chain betting_market_evaluator.cpp betting_market_object.cpp betting_market_group_object.cpp + custom_permission_evaluator.cpp + custom_account_authority_evaluator.cpp affiliate_payout.cpp + offer_object.cpp + offer_evaluator.cpp + nft_evaluator.cpp + ${HEADERS} "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp" ) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 41821baf..a4688471 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -41,6 +41,8 @@ #include #include +#include + namespace { struct proposed_operations_digest_accumulator diff --git a/libraries/chain/include/graphene/chain/custom_account_authority_evaluator.hpp b/libraries/chain/include/graphene/chain/custom_account_authority_evaluator.hpp index 3fe1f6f9..1ca2f0bb 100644 --- a/libraries/chain/include/graphene/chain/custom_account_authority_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/custom_account_authority_evaluator.hpp @@ -1,6 +1,7 @@ #pragma once #include -#include + +#include namespace graphene { @@ -35,4 +36,4 @@ public: }; } // namespace chain -} // namespace graphene \ No newline at end of file +} // namespace graphene diff --git a/libraries/chain/include/graphene/chain/custom_account_authority_object.hpp b/libraries/chain/include/graphene/chain/custom_account_authority_object.hpp index acca8bcf..6bbf39c0 100644 --- a/libraries/chain/include/graphene/chain/custom_account_authority_object.hpp +++ b/libraries/chain/include/graphene/chain/custom_account_authority_object.hpp @@ -1,5 +1,6 @@ #pragma once -#include +#include + #include #include @@ -23,7 +24,6 @@ namespace graphene { namespace chain { time_point_sec valid_to; }; - struct by_id; struct by_permission_and_op; struct by_expiration; using custom_account_authority_multi_index_type = multi_index_container< @@ -51,5 +51,7 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::custom_account_authority_object) + FC_REFLECT_DERIVED( graphene::chain::custom_account_authority_object, (graphene::db::object), - (permission_id)(operation_type)(valid_from)(valid_to) ) \ No newline at end of file + (permission_id)(operation_type)(valid_from)(valid_to) ) diff --git a/libraries/chain/include/graphene/chain/custom_permission_evaluator.hpp b/libraries/chain/include/graphene/chain/custom_permission_evaluator.hpp index c9bc2801..9c1043ff 100644 --- a/libraries/chain/include/graphene/chain/custom_permission_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/custom_permission_evaluator.hpp @@ -1,6 +1,8 @@ #pragma once + #include -#include + +#include namespace graphene { @@ -35,4 +37,4 @@ public: }; } // namespace chain -} // namespace graphene \ No newline at end of file +} // namespace graphene diff --git a/libraries/chain/include/graphene/chain/custom_permission_object.hpp b/libraries/chain/include/graphene/chain/custom_permission_object.hpp index 72789ef4..29b28f9f 100644 --- a/libraries/chain/include/graphene/chain/custom_permission_object.hpp +++ b/libraries/chain/include/graphene/chain/custom_permission_object.hpp @@ -1,5 +1,9 @@ #pragma once -#include + +#include + +#include + #include #include @@ -25,7 +29,6 @@ namespace graphene { namespace chain { authority auth; }; - struct by_id; struct by_account_and_permission; using custom_permission_multi_index_type = multi_index_container< custom_permission_object, @@ -45,5 +48,7 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::custom_permission_object) + FC_REFLECT_DERIVED( graphene::chain::custom_permission_object, (graphene::db::object), - (account)(permission_name)(auth) ) \ No newline at end of file + (account)(permission_name)(auth) ) diff --git a/libraries/chain/include/graphene/chain/nft_evaluator.hpp b/libraries/chain/include/graphene/chain/nft_evaluator.hpp index 0d0f5f51..a75cc44b 100644 --- a/libraries/chain/include/graphene/chain/nft_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/nft_evaluator.hpp @@ -2,8 +2,9 @@ #include #include -#include -#include + +#include +#include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/nft_object.hpp b/libraries/chain/include/graphene/chain/nft_object.hpp index 1994a92e..d5ffe09a 100644 --- a/libraries/chain/include/graphene/chain/nft_object.hpp +++ b/libraries/chain/include/graphene/chain/nft_object.hpp @@ -1,5 +1,7 @@ #pragma once -#include + +#include + #include #include @@ -10,7 +12,7 @@ namespace graphene { namespace chain { { public: static const uint8_t space_id = protocol_ids; - static const uint8_t type_id = nft_metadata_type; + static const uint8_t type_id = nft_metadata_object_type; account_id_type owner; std::string name; @@ -87,6 +89,9 @@ namespace graphene { namespace chain { } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::nft_metadata_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::nft_object) + FC_REFLECT_DERIVED( graphene::chain::nft_metadata_object, (graphene::db::object), (owner) (name) diff --git a/libraries/chain/include/graphene/chain/offer_evaluator.hpp b/libraries/chain/include/graphene/chain/offer_evaluator.hpp index 46f7045b..5d779cd6 100644 --- a/libraries/chain/include/graphene/chain/offer_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/offer_evaluator.hpp @@ -1,7 +1,8 @@ -#include #include #include +#include + namespace graphene { namespace chain diff --git a/libraries/chain/include/graphene/chain/offer_object.hpp b/libraries/chain/include/graphene/chain/offer_object.hpp index fe176332..cb6440c8 100644 --- a/libraries/chain/include/graphene/chain/offer_object.hpp +++ b/libraries/chain/include/graphene/chain/offer_object.hpp @@ -1,5 +1,9 @@ #pragma once -#include + +#include + +#include + #include namespace graphene @@ -99,6 +103,9 @@ namespace graphene } // namespace chain } // namespace graphene +MAP_OBJECT_ID_TO_TYPE(graphene::chain::offer_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::offer_history_object) + FC_REFLECT_DERIVED(graphene::chain::offer_object, (graphene::db::object), (issuer)(item_ids)(bidder)(bid_price)(minimum_price)( maximum_price)(buying_item)(offer_expiration_date)) diff --git a/libraries/chain/offer_evaluator.cpp b/libraries/chain/offer_evaluator.cpp index 0d1b1947..c91e79ed 100644 --- a/libraries/chain/offer_evaluator.cpp +++ b/libraries/chain/offer_evaluator.cpp @@ -83,7 +83,6 @@ namespace graphene auto now = d.head_block_time(); FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); const auto &offer = op.offer_id(d); - op.bidder(d); for (const auto &item : offer.item_ids) { const auto &nft_obj = item(d); @@ -335,4 +334,4 @@ namespace graphene FC_CAPTURE_AND_RETHROW((op)) } } // namespace chain -} // namespace graphene \ No newline at end of file +} // namespace graphene diff --git a/libraries/protocol/CMakeLists.txt b/libraries/protocol/CMakeLists.txt index a814ba2a..0fb7b64b 100644 --- a/libraries/protocol/CMakeLists.txt +++ b/libraries/protocol/CMakeLists.txt @@ -37,6 +37,7 @@ list(APPEND SOURCES account.cpp custom_permission.cpp custom_account_authority.cpp offer.cpp + nft.cpp ) diff --git a/libraries/protocol/custom_account_authority.cpp b/libraries/protocol/custom_account_authority.cpp index a74234d7..eaf939bc 100644 --- a/libraries/protocol/custom_account_authority.cpp +++ b/libraries/protocol/custom_account_authority.cpp @@ -1,9 +1,9 @@ -#include -#include +#include +#include namespace graphene { -namespace chain +namespace protocol { void custom_account_authority_create_operation::validate() const @@ -39,5 +39,5 @@ share_type custom_account_authority_create_operation::calculate_fee(const fee_pa return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); } -} // namespace chain +} // namespace protocol } // namespace graphene diff --git a/libraries/protocol/custom_permission.cpp b/libraries/protocol/custom_permission.cpp index c0919cbd..5084bf0b 100644 --- a/libraries/protocol/custom_permission.cpp +++ b/libraries/protocol/custom_permission.cpp @@ -1,9 +1,9 @@ -#include -#include +#include +#include namespace graphene { -namespace chain +namespace protocol { bool is_valid_permission_name(const string &name) @@ -81,5 +81,5 @@ share_type custom_permission_create_operation::calculate_fee(const fee_parameter return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); } -} // namespace chain +} // namespace protocol } // namespace graphene diff --git a/libraries/protocol/include/graphene/protocol/base.hpp b/libraries/protocol/include/graphene/protocol/base.hpp index faef9b09..73d60eab 100644 --- a/libraries/protocol/include/graphene/protocol/base.hpp +++ b/libraries/protocol/include/graphene/protocol/base.hpp @@ -25,6 +25,7 @@ #include #include +#include #include diff --git a/libraries/protocol/include/graphene/protocol/betting_market.hpp b/libraries/protocol/include/graphene/protocol/betting_market.hpp index 306840ab..e1d804d5 100644 --- a/libraries/protocol/include/graphene/protocol/betting_market.hpp +++ b/libraries/protocol/include/graphene/protocol/betting_market.hpp @@ -25,7 +25,6 @@ #include #include -#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/config.hpp b/libraries/protocol/include/graphene/protocol/config.hpp index fe18aa9a..8a7a911d 100644 --- a/libraries/protocol/include/graphene/protocol/config.hpp +++ b/libraries/protocol/include/graphene/protocol/config.hpp @@ -152,21 +152,21 @@ */ ///@{ /// Represents the current committee members, two-week review period -#define GRAPHENE_COMMITTEE_ACCOUNT (graphene::chain::account_id_type(0)) +#define GRAPHENE_COMMITTEE_ACCOUNT (graphene::protocol::account_id_type(0)) /// Represents the current witnesses -#define GRAPHENE_WITNESS_ACCOUNT (graphene::chain::account_id_type(1)) +#define GRAPHENE_WITNESS_ACCOUNT (graphene::protocol::account_id_type(1)) /// Represents the current committee members -#define GRAPHENE_RELAXED_COMMITTEE_ACCOUNT (graphene::chain::account_id_type(2)) +#define GRAPHENE_RELAXED_COMMITTEE_ACCOUNT (graphene::protocol::account_id_type(2)) /// Represents the canonical account with NO authority (nobody can access funds in null account) -#define GRAPHENE_NULL_ACCOUNT (graphene::chain::account_id_type(3)) +#define GRAPHENE_NULL_ACCOUNT (graphene::protocol::account_id_type(3)) /// Represents the canonical account with WILDCARD authority (anybody can access funds in temp account) -#define GRAPHENE_TEMP_ACCOUNT (graphene::chain::account_id_type(4)) +#define GRAPHENE_TEMP_ACCOUNT (graphene::protocol::account_id_type(4)) /// Represents the canonical account for specifying you will vote directly (as opposed to a proxy) -#define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::chain::account_id_type(5)) +#define GRAPHENE_PROXY_TO_SELF_ACCOUNT (graphene::protocol::account_id_type(5)) /// -#define GRAPHENE_RAKE_FEE_ACCOUNT_ID (graphene::chain::account_id_type(6)) +#define GRAPHENE_RAKE_FEE_ACCOUNT_ID (graphene::protocol::account_id_type(6)) /// Sentinel value used in the scheduler. -#define GRAPHENE_NULL_WITNESS (graphene::chain::witness_id_type(0)) +#define GRAPHENE_NULL_WITNESS (graphene::protocol::witness_id_type(0)) ///@} #define GRAPHENE_FBA_STEALTH_DESIGNATED_ASSET (asset_id_type(743)) @@ -219,9 +219,10 @@ #define TOURNAMENT_MAX_START_TIME_IN_FUTURE (60*60*24*7*4) // 1 month #define TOURNAMENT_MAX_START_DELAY (60*60*24*7) // 1 week #define SWEEPS_DEFAULT_DISTRIBUTION_PERCENTAGE (2*GRAPHENE_1_PERCENT) -#define SWEEPS_DEFAULT_DISTRIBUTION_ASSET (graphene::chain::asset_id_type(0)) +#define SWEEPS_DEFAULT_DISTRIBUTION_ASSET (graphene::protocol::asset_id_type(0)) #define SWEEPS_VESTING_BALANCE_MULTIPLIER 100000000 -#define SWEEPS_ACCUMULATOR_ACCOUNT (graphene::chain::account_id_type(0)) +#define SWEEPS_ACCUMULATOR_ACCOUNT (graphene::protocol::account_id_type(0)) +#define GPOS_PERIOD_START (fc::time_point_sec(1578272400)) #define GPOS_PERIOD (60*60*24*30*6) // 6 months #define GPOS_SUBPERIOD (60*60*24*30) // 1 month #define GPOS_VESTING_LOCKIN_PERIOD (60*60*24*30) // 1 month diff --git a/libraries/protocol/include/graphene/protocol/custom_account_authority.hpp b/libraries/protocol/include/graphene/protocol/custom_account_authority.hpp index f5f8c1cd..2d6b353e 100644 --- a/libraries/protocol/include/graphene/protocol/custom_account_authority.hpp +++ b/libraries/protocol/include/graphene/protocol/custom_account_authority.hpp @@ -1,9 +1,9 @@ #pragma once -#include +#include namespace graphene { -namespace chain +namespace protocol { struct custom_account_authority_create_operation : public base_operation @@ -60,14 +60,14 @@ struct custom_account_authority_delete_operation : public base_operation share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } }; -} // namespace chain +} // namespace protocol } // namespace graphene -FC_REFLECT(graphene::chain::custom_account_authority_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) -FC_REFLECT(graphene::chain::custom_account_authority_create_operation, (fee)(permission_id)(operation_type)(valid_from)(valid_to)(owner_account)) +FC_REFLECT(graphene::protocol::custom_account_authority_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) +FC_REFLECT(graphene::protocol::custom_account_authority_create_operation, (fee)(permission_id)(operation_type)(valid_from)(valid_to)(owner_account)) -FC_REFLECT(graphene::chain::custom_account_authority_update_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_account_authority_update_operation, (fee)(auth_id)(new_valid_from)(new_valid_to)(owner_account)) +FC_REFLECT(graphene::protocol::custom_account_authority_update_operation::fee_parameters_type, (fee)) +FC_REFLECT(graphene::protocol::custom_account_authority_update_operation, (fee)(auth_id)(new_valid_from)(new_valid_to)(owner_account)) -FC_REFLECT(graphene::chain::custom_account_authority_delete_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_account_authority_delete_operation, (fee)(auth_id)(owner_account)) \ No newline at end of file +FC_REFLECT(graphene::protocol::custom_account_authority_delete_operation::fee_parameters_type, (fee)) +FC_REFLECT(graphene::protocol::custom_account_authority_delete_operation, (fee)(auth_id)(owner_account)) diff --git a/libraries/protocol/include/graphene/protocol/custom_permission.hpp b/libraries/protocol/include/graphene/protocol/custom_permission.hpp index 8093ef07..6c708bcf 100644 --- a/libraries/protocol/include/graphene/protocol/custom_permission.hpp +++ b/libraries/protocol/include/graphene/protocol/custom_permission.hpp @@ -1,9 +1,10 @@ #pragma once -#include +#include +#include namespace graphene { -namespace chain +namespace protocol { struct custom_permission_create_operation : public base_operation @@ -57,14 +58,14 @@ struct custom_permission_delete_operation : public base_operation share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } }; -} // namespace chain +} // namespace protocol } // namespace graphene -FC_REFLECT(graphene::chain::custom_permission_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) -FC_REFLECT(graphene::chain::custom_permission_create_operation, (fee)(owner_account)(permission_name)(auth)) +FC_REFLECT(graphene::protocol::custom_permission_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) +FC_REFLECT(graphene::protocol::custom_permission_create_operation, (fee)(owner_account)(permission_name)(auth)) -FC_REFLECT(graphene::chain::custom_permission_update_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_permission_update_operation, (fee)(permission_id)(new_auth)(owner_account)) +FC_REFLECT(graphene::protocol::custom_permission_update_operation::fee_parameters_type, (fee)) +FC_REFLECT(graphene::protocol::custom_permission_update_operation, (fee)(permission_id)(new_auth)(owner_account)) -FC_REFLECT(graphene::chain::custom_permission_delete_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_permission_delete_operation, (fee)(permission_id)(owner_account)) \ No newline at end of file +FC_REFLECT(graphene::protocol::custom_permission_delete_operation::fee_parameters_type, (fee)) +FC_REFLECT(graphene::protocol::custom_permission_delete_operation, (fee)(permission_id)(owner_account)) diff --git a/libraries/protocol/include/graphene/protocol/event.hpp b/libraries/protocol/include/graphene/protocol/event.hpp index fdf2e74d..75012733 100644 --- a/libraries/protocol/include/graphene/protocol/event.hpp +++ b/libraries/protocol/include/graphene/protocol/event.hpp @@ -25,7 +25,6 @@ #include #include -#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/event_group.hpp b/libraries/protocol/include/graphene/protocol/event_group.hpp index 9b21f057..daf8676d 100644 --- a/libraries/protocol/include/graphene/protocol/event_group.hpp +++ b/libraries/protocol/include/graphene/protocol/event_group.hpp @@ -25,7 +25,6 @@ #include #include -#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/lottery_ops.hpp b/libraries/protocol/include/graphene/protocol/lottery_ops.hpp index 4dc65632..22e81d44 100644 --- a/libraries/protocol/include/graphene/protocol/lottery_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/lottery_ops.hpp @@ -23,7 +23,6 @@ */ #pragma once #include -#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/nft_ops.hpp b/libraries/protocol/include/graphene/protocol/nft_ops.hpp index 41e77b06..f5235661 100644 --- a/libraries/protocol/include/graphene/protocol/nft_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/nft_ops.hpp @@ -1,8 +1,8 @@ #pragma once -#include -#include +#include +#include -namespace graphene { namespace chain { +namespace graphene { namespace protocol { struct nft_metadata_create_operation : public base_operation { @@ -117,19 +117,19 @@ namespace graphene { namespace chain { share_type calculate_fee(const fee_parameters_type &k) const; }; -} } // graphene::chain +} } // graphene::protocol -FC_REFLECT( graphene::chain::nft_metadata_create_operation::fee_parameters_type, (fee) (price_per_kbyte) ) -FC_REFLECT( graphene::chain::nft_metadata_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::nft_mint_operation::fee_parameters_type, (fee) (price_per_kbyte) ) -FC_REFLECT( graphene::chain::nft_safe_transfer_from_operation::fee_parameters_type, (fee) (price_per_kbyte) ) -FC_REFLECT( graphene::chain::nft_approve_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::nft_set_approval_for_all_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::nft_metadata_create_operation::fee_parameters_type, (fee) (price_per_kbyte) ) +FC_REFLECT( graphene::protocol::nft_metadata_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::nft_mint_operation::fee_parameters_type, (fee) (price_per_kbyte) ) +FC_REFLECT( graphene::protocol::nft_safe_transfer_from_operation::fee_parameters_type, (fee) (price_per_kbyte) ) +FC_REFLECT( graphene::protocol::nft_approve_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::protocol::nft_set_approval_for_all_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::nft_metadata_create_operation, (fee) (owner) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) ) -FC_REFLECT( graphene::chain::nft_metadata_update_operation, (fee) (owner) (nft_metadata_id) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) ) -FC_REFLECT( graphene::chain::nft_mint_operation, (fee) (payer) (nft_metadata_id) (owner) (approved) (approved_operators) (token_uri) ) -FC_REFLECT( graphene::chain::nft_safe_transfer_from_operation, (fee) (operator_) (from) (to) (token_id) (data) ) -FC_REFLECT( graphene::chain::nft_approve_operation, (fee) (operator_) (approved) (token_id) ) -FC_REFLECT( graphene::chain::nft_set_approval_for_all_operation, (fee) (owner) (operator_) (approved) ) +FC_REFLECT( graphene::protocol::nft_metadata_create_operation, (fee) (owner) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) ) +FC_REFLECT( graphene::protocol::nft_metadata_update_operation, (fee) (owner) (nft_metadata_id) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) ) +FC_REFLECT( graphene::protocol::nft_mint_operation, (fee) (payer) (nft_metadata_id) (owner) (approved) (approved_operators) (token_uri) ) +FC_REFLECT( graphene::protocol::nft_safe_transfer_from_operation, (fee) (operator_) (from) (to) (token_id) (data) ) +FC_REFLECT( graphene::protocol::nft_approve_operation, (fee) (operator_) (approved) (token_id) ) +FC_REFLECT( graphene::protocol::nft_set_approval_for_all_operation, (fee) (owner) (operator_) (approved) ) diff --git a/libraries/protocol/include/graphene/protocol/object_id.hpp b/libraries/protocol/include/graphene/protocol/object_id.hpp index 7471ff6a..b641e760 100644 --- a/libraries/protocol/include/graphene/protocol/object_id.hpp +++ b/libraries/protocol/include/graphene/protocol/object_id.hpp @@ -34,7 +34,6 @@ namespace graphene { namespace db { using fc::flat_map; using fc::variant; using fc::unsigned_int; - using fc::signed_int; struct object_id_type { diff --git a/libraries/protocol/include/graphene/protocol/offer.hpp b/libraries/protocol/include/graphene/protocol/offer.hpp index 2bf3dfc2..d5a890fd 100644 --- a/libraries/protocol/include/graphene/protocol/offer.hpp +++ b/libraries/protocol/include/graphene/protocol/offer.hpp @@ -1,10 +1,10 @@ #pragma once -#include -#include +#include +#include namespace graphene { - namespace chain + namespace protocol { /* @@ -118,26 +118,26 @@ namespace graphene share_type calculate_fee(const fee_parameters_type &k) const; }; - } // namespace chain + } // namespace protocol } // namespace graphene -FC_REFLECT(graphene::chain::offer_operation::fee_parameters_type, +FC_REFLECT(graphene::protocol::offer_operation::fee_parameters_type, (fee)(price_per_kbyte)); -FC_REFLECT(graphene::chain::offer_operation, +FC_REFLECT(graphene::protocol::offer_operation, (fee)(item_ids)(issuer)(minimum_price)(maximum_price)(buying_item)(offer_expiration_date)(memo)(extensions)); -FC_REFLECT(graphene::chain::bid_operation::fee_parameters_type, +FC_REFLECT(graphene::protocol::bid_operation::fee_parameters_type, (fee)); -FC_REFLECT(graphene::chain::bid_operation, +FC_REFLECT(graphene::protocol::bid_operation, (fee)(bidder)(bid_price)(offer_id)(extensions)); -FC_REFLECT(graphene::chain::cancel_offer_operation::fee_parameters_type, +FC_REFLECT(graphene::protocol::cancel_offer_operation::fee_parameters_type, (fee)); -FC_REFLECT(graphene::chain::cancel_offer_operation, +FC_REFLECT(graphene::protocol::cancel_offer_operation, (fee)(issuer)(offer_id)(extensions)); -FC_REFLECT_ENUM(graphene::chain::result_type, (Expired)(ExpiredNoBid)(Cancelled)); -FC_REFLECT(graphene::chain::finalize_offer_operation::fee_parameters_type, +FC_REFLECT_ENUM(graphene::protocol::result_type, (Expired)(ExpiredNoBid)(Cancelled)); +FC_REFLECT(graphene::protocol::finalize_offer_operation::fee_parameters_type, (fee)); -FC_REFLECT(graphene::chain::finalize_offer_operation, +FC_REFLECT(graphene::protocol::finalize_offer_operation, (fee)(fee_paying_account)(offer_id)(result)(extensions)); diff --git a/libraries/protocol/include/graphene/protocol/sport.hpp b/libraries/protocol/include/graphene/protocol/sport.hpp index f0a644e1..cdb64984 100644 --- a/libraries/protocol/include/graphene/protocol/sport.hpp +++ b/libraries/protocol/include/graphene/protocol/sport.hpp @@ -25,7 +25,6 @@ #include #include -#include namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/tournament.hpp b/libraries/protocol/include/graphene/protocol/tournament.hpp index 09b5d37a..6eebece2 100644 --- a/libraries/protocol/include/graphene/protocol/tournament.hpp +++ b/libraries/protocol/include/graphene/protocol/tournament.hpp @@ -30,7 +30,6 @@ #include #include -#include #include #include diff --git a/libraries/protocol/include/graphene/protocol/types.hpp b/libraries/protocol/include/graphene/protocol/types.hpp index 94ea006e..35fdf3a2 100644 --- a/libraries/protocol/include/graphene/protocol/types.hpp +++ b/libraries/protocol/include/graphene/protocol/types.hpp @@ -262,7 +262,7 @@ GRAPHENE_DEFINE_IDS(protocol, protocol_ids, /*protocol objects are not prefixed* (custom_permission) (custom_account_authority) (offer) - (nft_metadata_type) + (nft_metadata) (nft)) FC_REFLECT(graphene::protocol::public_key_type, (key_data)) diff --git a/libraries/protocol/nft.cpp b/libraries/protocol/nft.cpp index 802bf425..be7cce32 100644 --- a/libraries/protocol/nft.cpp +++ b/libraries/protocol/nft.cpp @@ -1,9 +1,9 @@ -#include -#include +#include +#include namespace graphene { -namespace chain +namespace protocol { bool is_valid_nft_token_name(const string &name) @@ -95,5 +95,5 @@ share_type nft_set_approval_for_all_operation::calculate_fee(const fee_parameter return k.fee; } -} // namespace chain +} // namespace protocol } // namespace graphene diff --git a/libraries/protocol/offer.cpp b/libraries/protocol/offer.cpp index e83af3f8..aefb813e 100644 --- a/libraries/protocol/offer.cpp +++ b/libraries/protocol/offer.cpp @@ -1,9 +1,9 @@ -#include +#include #include namespace graphene { - namespace chain + namespace protocol { share_type offer_operation::calculate_fee(const fee_parameters_type &schedule) const { @@ -53,5 +53,5 @@ namespace graphene return core_fee_required; } - } // namespace chain -} // namespace graphene \ No newline at end of file + } // namespace protocol +} // namespace graphene diff --git a/programs/build_helpers/member_enumerator.cpp b/programs/build_helpers/member_enumerator.cpp index e7c44301..232d994f 100644 --- a/programs/build_helpers/member_enumerator.cpp +++ b/programs/build_helpers/member_enumerator.cpp @@ -140,7 +140,7 @@ struct if_enum } }; -template +template struct if_reflected { template< typename T > @@ -152,7 +152,7 @@ struct if_reflected }; template<> -struct if_reflected +struct if_reflected { template< typename T > static void process_class( class_processor* proc, const T* dummy ) diff --git a/tests/tests/custom_permission_tests.cpp b/tests/tests/custom_permission_tests.cpp index 4aad1897..030ad97f 100644 --- a/tests/tests/custom_permission_tests.cpp +++ b/tests/tests/custom_permission_tests.cpp @@ -1,7 +1,5 @@ -#include #include #include -#include #include #include @@ -13,7 +11,12 @@ #include +#include + #include + +#include + #include "../common/database_fixture.hpp" using namespace graphene::chain; From 6b59f8269fd879224a909da93fbd7b12a4670c82 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 25 Aug 2020 13:02:45 -0500 Subject: [PATCH 38/77] Rename project in CMakeLists.txt The CMakeLists.txt declared this project as BitShares and not Peerplays, which makes it confusing in IDEs. Rename it to be clear which project is open. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 671cfed3..4f68f529 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -# Defines BitShares library target. -project( BitShares ) +# Defines Peerplays library target. +project( Peerplays ) cmake_minimum_required( VERSION 2.8.12 ) set( BLOCKCHAIN_NAME "BitShares" ) From f2d4bce003a916a2d62fa8629988f8a0b2207abd Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Thu, 27 Aug 2020 18:55:37 -0500 Subject: [PATCH 39/77] Resolve #374 Replace all object refs in macros with IDs, and fix affected tests to look up objects by ID rather than using invalidated refs. A full audit of all tests should be performed to eliminate any further usage of invalidated object references. --- tests/betting/betting_tests.cpp | 1161 +++++++++++++++---------------- 1 file changed, 562 insertions(+), 599 deletions(-) diff --git a/tests/betting/betting_tests.cpp b/tests/betting/betting_tests.cpp index fe4134ec..38ff6f02 100644 --- a/tests/betting/betting_tests.cpp +++ b/tests/betting/betting_tests.cpp @@ -132,113 +132,115 @@ using namespace graphene::chain::keywords; // 1.58 50:29 | 2.34 50:67 | 4.6 5:18 | 25 1:24 | 430 1:429 | // 1.59 100:59 | 2.36 25:34 | 4.7 10:37 +template object_id to_id(const O& o) { return o.id; } + #define CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ create_sport({{"en", "Ice Hockey"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \ generate_blocks(1); \ - const sport_object& ice_hockey = *db.get_index_type().indices().get().rbegin(); \ - create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey.id); \ + const auto ice_hockey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey_id); \ generate_blocks(1); \ - const event_group_object& nhl = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl.id); \ + const auto nhl_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl_id); \ generate_blocks(1); \ - const event_object& capitals_vs_blackhawks = *db.get_index_type().indices().get().rbegin(); \ + const auto capitals_vs_blackhawks_id = to_id(*db.get_index_type().indices().get().rbegin()); \ create_betting_market_rules({{"en", "NHL Rules v1.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); \ generate_blocks(1); \ - const betting_market_rules_object& betting_market_rules = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + const auto betting_market_rules_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto moneyline_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)capitals_win_market; (void)blackhawks_win_market; + const auto blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)capitals_win_market_id; (void)blackhawks_win_market_id; // create the basic betting market, plus groups for the first, second, and third period results #define CREATE_EXTENDED_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ - create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& first_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(first_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto first_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(first_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& first_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(first_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto first_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(first_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& first_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)first_period_capitals_win_market; (void)first_period_blackhawks_win_market; \ + const auto first_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)first_period_capitals_win_market_id; (void)first_period_blackhawks_win_market_id; \ \ - create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& second_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(second_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto second_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(second_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& second_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(second_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto second_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(second_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& second_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)second_period_capitals_win_market; (void)second_period_blackhawks_win_market; \ + const auto second_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)second_period_capitals_win_market_id; (void)second_period_blackhawks_win_market_id; \ \ - create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& third_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(third_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto third_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(third_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& third_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(third_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto third_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(third_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& third_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)third_period_capitals_win_market; (void)third_period_blackhawks_win_market; + const auto third_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)third_period_capitals_win_market_id; (void)third_period_blackhawks_win_market_id; #define CREATE_TENNIS_BETTING_MARKET() \ create_betting_market_rules({{"en", "Tennis Rules v1.0"}}, {{"en", "The winner is the player who wins the last ball in the match."}}); \ generate_blocks(1); \ - const betting_market_rules_object& tennis_rules = *db.get_index_type().indices().get().rbegin(); \ + const auto tennis_rules_id = to_id(*db.get_index_type().indices().get().rbegin()); \ create_sport({{"en", "Tennis"}}); \ generate_blocks(1); \ - const sport_object& tennis = *db.get_index_type().indices().get().rbegin(); \ - create_event_group({{"en", "Wimbledon"}}, tennis.id); \ + const auto tennis_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event_group({{"en", "Wimbledon"}}, tennis_id); \ generate_blocks(1); \ - const event_group_object& wimbledon = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon.id); \ + const auto wimbledon_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon_id); \ generate_blocks(1); \ - const event_object& berdych_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon.id); \ + const auto berdych_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon_id); \ generate_blocks(1); \ - const event_object& cilic_vs_querrey = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \ + const auto cilic_vs_querrey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_berdych_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey.id, tennis_rules.id, asset_id_type(), false, 0); \ + const auto moneyline_berdych_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey_id, tennis_rules_id, asset_id_type(), false, 0); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_cilic_vs_querrey = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "T. Berdych defeats R. Federer"}}); \ + const auto moneyline_cilic_vs_querrey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "T. Berdych defeats R. Federer"}}); \ generate_blocks(1); \ - const betting_market_object& berdych_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "R. Federer defeats T. Berdych"}}); \ + const auto berdych_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "R. Federer defeats T. Berdych"}}); \ generate_blocks(1); \ - const betting_market_object& federer_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "M. Cilic defeats S. Querrey"}}); \ + const auto federer_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "M. Cilic defeats S. Querrey"}}); \ generate_blocks(1); \ - const betting_market_object& cilic_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "S. Querrey defeats M. Cilic"}});\ + const auto cilic_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "S. Querrey defeats M. Cilic"}});\ generate_blocks(1); \ - const betting_market_object& querrey_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon.id); \ + const auto querrey_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon_id); \ generate_blocks(1); \ - const event_object& cilic_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \ + const auto cilic_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_cilic_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "R. Federer defeats M. Cilic"}}); \ + const auto moneyline_cilic_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "R. Federer defeats M. Cilic"}}); \ generate_blocks(1); \ - const betting_market_object& federer_wins_final_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "M. Cilic defeats R. Federer"}}); \ + const auto federer_wins_final_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "M. Cilic defeats R. Federer"}}); \ generate_blocks(1); \ - const betting_market_object& cilic_wins_final_market = *db.get_index_type().indices().get().rbegin(); \ - (void)federer_wins_market;(void)cilic_wins_market;(void)federer_wins_final_market; (void)cilic_wins_final_market; (void)berdych_wins_market; (void)querrey_wins_market; + const auto cilic_wins_final_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)federer_wins_market_id;(void)cilic_wins_market_id;(void)federer_wins_final_market_id; (void)cilic_wins_final_market_id; (void)berdych_wins_market_id; (void)querrey_wins_market_id; BOOST_FIXTURE_TEST_SUITE( betting_tests, database_fixture ) @@ -309,12 +311,12 @@ BOOST_AUTO_TEST_CASE(simple_bet_win) transfer(account_id_type(), bob_id, asset(10000)); // place bets at 10:1 - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); // reverse positions at 1:1 - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); } FC_LOG_AND_RETHROW() } @@ -332,23 +334,23 @@ BOOST_AUTO_TEST_CASE(binned_order_books) transfer(account_id_type(), bob_id, asset(10000)); // place back bets at decimal odds of 1.55, 1.6, 1.65, 1.66, and 1.67 - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 155 * GRAPHENE_BETTING_ODDS_PRECISION / 100); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 16 * GRAPHENE_BETTING_ODDS_PRECISION / 10); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 166 * GRAPHENE_BETTING_ODDS_PRECISION / 100); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 167 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 155 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 16 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 166 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 167 * GRAPHENE_BETTING_ODDS_PRECISION / 100); const auto& bet_odds_idx = db.get_index_type().indices().get(); - auto bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + auto bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); while (bet_iter != bet_odds_idx.end() && - bet_iter->betting_market_id == capitals_win_market.id) + bet_iter->betting_market_id == capitals_win_market_id) { idump((*bet_iter)); ++bet_iter; } - graphene::bookie::binned_order_book binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market.id, 1); + graphene::bookie::binned_order_book binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market_id, 1); idump((binned_orders_point_one)); // the binned orders returned should be chosen so that we if we assume those orders are real and we place @@ -362,28 +364,28 @@ BOOST_AUTO_TEST_CASE(binned_order_books) // compute the matching lay order share_type lay_amount = bet_object::get_approximate_matching_amount(binned_order.amount_to_bet, binned_order.backer_multiplier, bet_type::back, true /* round up */); ilog("Alice is laying with ${lay_amount} at odds ${odds} to match the binned back amount ${back_amount}", ("lay_amount", lay_amount)("odds", binned_order.backer_multiplier)("back_amount", binned_order.amount_to_bet)); - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(lay_amount, asset_id_type()), binned_order.backer_multiplier); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(lay_amount, asset_id_type()), binned_order.backer_multiplier); } - bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); while (bet_iter != bet_odds_idx.end() && - bet_iter->betting_market_id == capitals_win_market.id) + bet_iter->betting_market_id == capitals_win_market_id) { idump((*bet_iter)); ++bet_iter; } - BOOST_CHECK(bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)) == bet_odds_idx.end()); + BOOST_CHECK(bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)) == bet_odds_idx.end()); // place lay bets at decimal odds of 1.55, 1.6, 1.65, 1.66, and 1.67 // these bets will get rounded down, actual amounts are 99, 99, 91, 99, and 67 -// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 155 * GRAPHENE_BETTING_ODDS_PRECISION / 100); -// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 155 * GRAPHENE_BETTING_ODDS_PRECISION / 100); -// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); -// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); -// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); +// place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 155 * GRAPHENE_BETTING_ODDS_PRECISION / 100); +// place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 155 * GRAPHENE_BETTING_ODDS_PRECISION / 100); +// place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); +// place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); +// place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 165 * GRAPHENE_BETTING_ODDS_PRECISION / 100); // -// binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market.id, 1); +// binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market_id, 1); // idump((binned_orders_point_one)); // // // the binned orders returned should be chosen so that we if we assume those orders are real and we place @@ -397,20 +399,20 @@ BOOST_AUTO_TEST_CASE(binned_order_books) // // compute the matching lay order // share_type back_amount = bet_object::get_approximate_matching_amount(binned_order.amount_to_bet, binned_order.backer_multiplier, bet_type::lay, true /* round up */); // ilog("Alice is backing with ${back_amount} at odds ${odds} to match the binned lay amount ${lay_amount}", ("back_amount", back_amount)("odds", binned_order.backer_multiplier)("lay_amount", binned_order.amount_to_bet)); -// place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(back_amount, asset_id_type()), binned_order.backer_multiplier); +// place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(back_amount, asset_id_type()), binned_order.backer_multiplier); // // } // // -// bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); +// bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); // while (bet_iter != bet_odds_idx.end() && -// bet_iter->betting_market_id == capitals_win_market.id) +// bet_iter->betting_market_id == capitals_win_market_id) // { // idump((*bet_iter)); // ++bet_iter; // } // -// BOOST_CHECK(bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)) == bet_odds_idx.end()); +// BOOST_CHECK(bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)) == bet_odds_idx.end()); // } FC_LOG_AND_RETHROW() } @@ -427,19 +429,19 @@ BOOST_AUTO_TEST_CASE( peerplays_sport_create_test ) transfer(account_id_type(), bob_id, asset(10000000)); // have bob lay a bet for 1M (+20k fees) at 1:1 odds - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // have alice back a matching bet at 1:1 odds (also costing 1.02M) - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); // caps win - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); @@ -464,18 +466,18 @@ BOOST_AUTO_TEST_CASE( cancel_unmatched_in_betting_group_test ) transfer(account_id_type(), bob_id, asset(10000000)); // have bob lay a bet for 1M (+20k fees) at 1:1 odds - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // have alice back a matching bet at 1:1 odds (also costing 1.02M) - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // place unmatched - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, blackhawks_win_market.id, bet_type::lay, asset(600, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, blackhawks_win_market_id, bet_type::lay, asset(600, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000 - 500); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000 - 600); // cancel unmatched - cancel_unmatched_bets(moneyline_betting_markets.id); + cancel_unmatched_bets(moneyline_betting_markets_id); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); @@ -498,19 +500,19 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts) // lay 46 at 1.94 odds (50:47) -- this is too small to be placed on the books and there's // nothing for it to match, so it should be canceled BOOST_TEST_MESSAGE("lay 46 at 1.94 odds (50:47) -- this is too small to be placed on the books and there's nothing for it to match, so it should be canceled"); - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(46, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(46, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); BOOST_TEST_MESSAGE("alice's balance should be " << alice_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); ilog("message"); // lay 47 at 1.94 odds (50:47) -- this is an exact amount, nothing surprising should happen here BOOST_TEST_MESSAGE("alice lays 470 at 1.94 odds (50:47) -- this is an exact amount, nothing surprising should happen here"); - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(47, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(47, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 47; BOOST_TEST_MESSAGE("alice's balance should be " << alice_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // lay 100 at 1.91 odds (100:91) -- this is an inexact match, we should get refunded 9 and leave a bet for 91 on the books - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 191 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 191 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 91; BOOST_TEST_MESSAGE("alice's balance should be " << alice_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); @@ -528,7 +530,7 @@ ilog("message"); // bob's balance goes down by 300 (150 is matched, 150 is still on the books) // leaves a back bet of 150 @ 1.5 on the books BOOST_TEST_MESSAGE("now have bob match it with a back of 300 at 1.5"); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(300, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(300, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); bob_expected_balance -= 300; BOOST_TEST_MESSAGE("bob's balance should be " << bob_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); @@ -550,7 +552,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts2) // lay 470 at 1.94 odds (50:47) -- this is an exact amount, nothing surprising should happen here BOOST_TEST_MESSAGE("alice lays 470 at 1.94 odds (50:47) -- this is an exact amount, nothing surprising should happen here"); - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(470, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(470, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 470; BOOST_TEST_MESSAGE("alice's balance should be " << alice_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); @@ -565,7 +567,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts2) // bob's balance goes down by the 900 he paid (500 matched, 400 unmatched) // alice's bet is completely removed from the books. BOOST_TEST_MESSAGE("now have bob match it with a back of 900 at 1.5"); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(900, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(900, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); bob_expected_balance -= 900; BOOST_TEST_MESSAGE("bob's balance should be " << bob_expected_balance.value); @@ -587,7 +589,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts3) BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // lay 470 at 1.94 odds (50:47) -- this is an exact amount, nothing surprising should happen here - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(470, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(470, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 470; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); @@ -600,7 +602,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts3) // match all of the 470 @ 1.94 with 500, and leave 500 left on the books // bob's balance goes down by the 1000 he paid, 500 matching, 500 unmatching // alice's bet is removed from the books - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(1000, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(1000, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); bob_expected_balance -= 1000; BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); } @@ -620,12 +622,12 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts4) BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // back 1000 at 1.89 odds (100:89) -- this is an exact amount, nothing surprising should happen here - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000, asset_id_type()), 189 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000, asset_id_type()), 189 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 1000; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // back 1000 at 1.97 odds (100:97) -- again, this is an exact amount, nothing surprising should happen here - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000, asset_id_type()), 197 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000, asset_id_type()), 197 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 1000; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); @@ -655,7 +657,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts4) // * alice's top bet on the books is reduced 200 @ 1.97 // * Bob now has as much of a position as he was willing to buy. We refund // the remainder of his bet, which is 552 - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(3000, asset_id_type()), 266 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(3000, asset_id_type()), 266 * GRAPHENE_BETTING_ODDS_PRECISION / 100); bob_expected_balance -= 3000 - 12 - 770 - 552; BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); } @@ -675,7 +677,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts5) BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // back 1100 at 1.86 odds (50:43) -- this is an exact amount, nothing surprising should happen here - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1100, asset_id_type()), 186 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1100, asset_id_type()), 186 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 1100; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); @@ -699,7 +701,7 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts5) // * bob's bet is fully matched, he is refunded the remaining 132 and his // bet is complete // * bob's balance is reduced by the 946 he paid - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1100, asset_id_type()), 198 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1100, asset_id_type()), 198 * GRAPHENE_BETTING_ODDS_PRECISION / 100); bob_expected_balance -= 1100 - 22 - 132; BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); } @@ -720,40 +722,40 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts6) share_type alice_expected_balance = 1000000000; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(10000000, asset_id_type()), 13 * GRAPHENE_BETTING_ODDS_PRECISION / 10); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(10000000, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(10000000, asset_id_type()), 16 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(10000000, asset_id_type()), 13 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(10000000, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(10000000, asset_id_type()), 16 * GRAPHENE_BETTING_ODDS_PRECISION / 10); alice_expected_balance -= 30000000; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // check order books to see they match the bets we placed const auto& bet_odds_idx = db.get_index_type().indices().get(); - auto bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + auto bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); BOOST_REQUIRE(bet_iter != bet_odds_idx.end()); - BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market.id); + BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market_id); BOOST_REQUIRE(bet_iter->bettor_id == alice_id); BOOST_REQUIRE(bet_iter->amount_to_bet == asset(10000000, asset_id_type())); BOOST_REQUIRE(bet_iter->backer_multiplier == 13 * GRAPHENE_BETTING_ODDS_PRECISION / 10); BOOST_REQUIRE(bet_iter->back_or_lay == bet_type::back); ++bet_iter; BOOST_REQUIRE(bet_iter != bet_odds_idx.end()); - BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market.id); + BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market_id); BOOST_REQUIRE(bet_iter->bettor_id == alice_id); BOOST_REQUIRE(bet_iter->amount_to_bet == asset(10000000, asset_id_type())); BOOST_REQUIRE(bet_iter->backer_multiplier == 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); BOOST_REQUIRE(bet_iter->back_or_lay == bet_type::back); ++bet_iter; BOOST_REQUIRE(bet_iter != bet_odds_idx.end()); - BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market.id); + BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market_id); BOOST_REQUIRE(bet_iter->bettor_id == alice_id); BOOST_REQUIRE(bet_iter->amount_to_bet == asset(10000000, asset_id_type())); BOOST_REQUIRE(bet_iter->backer_multiplier == 16 * GRAPHENE_BETTING_ODDS_PRECISION / 10); BOOST_REQUIRE(bet_iter->back_or_lay == bet_type::back); ++bet_iter; - BOOST_REQUIRE(bet_iter == bet_odds_idx.end() || bet_iter->betting_market_id != capitals_win_market.id); + BOOST_REQUIRE(bet_iter == bet_odds_idx.end() || bet_iter->betting_market_id != capitals_win_market_id); // check the binned order books from the bookie plugin to make sure they match - graphene::bookie::binned_order_book binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market.id, 1); + graphene::bookie::binned_order_book binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market_id, 1); auto aggregated_back_bets_iter = binned_orders_point_one.aggregated_back_bets.begin(); BOOST_REQUIRE(aggregated_back_bets_iter != binned_orders_point_one.aggregated_back_bets.end()); BOOST_REQUIRE(aggregated_back_bets_iter->amount_to_bet.value == 10000000); @@ -774,11 +776,11 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts6) share_type bob_expected_balance = 1000000000; BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(5000000, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(5000000, asset_id_type()), 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); ilog("Order books after bob's matching lay bet:"); - bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); while (bet_iter != bet_odds_idx.end() && - bet_iter->betting_market_id == capitals_win_market.id) + bet_iter->betting_market_id == capitals_win_market_id) { idump((*bet_iter)); ++bet_iter; @@ -788,25 +790,25 @@ BOOST_AUTO_TEST_CASE(match_using_takers_expected_amounts6) BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); // check order books to see they match after bob's bet matched - bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + bet_iter = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); BOOST_REQUIRE(bet_iter != bet_odds_idx.end()); - BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market.id); + BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market_id); BOOST_REQUIRE(bet_iter->bettor_id == alice_id); BOOST_REQUIRE(bet_iter->amount_to_bet == asset(10000000, asset_id_type())); BOOST_REQUIRE(bet_iter->backer_multiplier == 15 * GRAPHENE_BETTING_ODDS_PRECISION / 10); BOOST_REQUIRE(bet_iter->back_or_lay == bet_type::back); ++bet_iter; BOOST_REQUIRE(bet_iter != bet_odds_idx.end()); - BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market.id); + BOOST_REQUIRE(bet_iter->betting_market_id == capitals_win_market_id); BOOST_REQUIRE(bet_iter->bettor_id == alice_id); BOOST_REQUIRE(bet_iter->amount_to_bet == asset(10000000, asset_id_type())); BOOST_REQUIRE(bet_iter->backer_multiplier == 16 * GRAPHENE_BETTING_ODDS_PRECISION / 10); BOOST_REQUIRE(bet_iter->back_or_lay == bet_type::back); ++bet_iter; - BOOST_REQUIRE(bet_iter == bet_odds_idx.end() || bet_iter->betting_market_id != capitals_win_market.id); + BOOST_REQUIRE(bet_iter == bet_odds_idx.end() || bet_iter->betting_market_id != capitals_win_market_id); // check the binned order books from the bookie plugin to make sure they match - binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market.id, 1); + binned_orders_point_one = bookie_api.get_binned_order_book(capitals_win_market_id, 1); aggregated_back_bets_iter = binned_orders_point_one.aggregated_back_bets.begin(); BOOST_REQUIRE(aggregated_back_bets_iter != binned_orders_point_one.aggregated_back_bets.end()); BOOST_REQUIRE(aggregated_back_bets_iter->amount_to_bet.value == 10000000); @@ -838,16 +840,16 @@ BOOST_AUTO_TEST_CASE(inexact_odds) // lay 46 at 1.94 odds (50:47) -- this is too small to be placed on the books and there's // nothing for it to match, so it should be canceled - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(46, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(46, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // lay 47 at 1.94 odds (50:47) -- this is an exact amount, nothing surprising should happen here - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(47, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(47, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 47; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // lay 100 at 1.91 odds (100:91) -- this is an inexact match, we should get refunded 9 and leave a bet for 91 on the books - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 191 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 191 * GRAPHENE_BETTING_ODDS_PRECISION / 100); alice_expected_balance -= 91; BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); @@ -863,7 +865,7 @@ BOOST_AUTO_TEST_CASE(inexact_odds) // leaving 150 // back bets at 100:91 must be a multiple of 100, so refund 50 // leaves a back bet of 100 @ 1.91 on the books - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(300, asset_id_type()), 191 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(300, asset_id_type()), 191 * GRAPHENE_BETTING_ODDS_PRECISION / 100); bob_expected_balance -= 250; BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); } @@ -884,15 +886,15 @@ BOOST_AUTO_TEST_CASE(bet_reversal_test) BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); // back with our entire balance - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), 0); // reverse the bet - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(20000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(20000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), 0); // try to re-reverse it, but go too far - BOOST_CHECK_THROW( place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(30000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION), fc::exception); + BOOST_CHECK_THROW( place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(30000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION), fc::exception); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), 0); } FC_LOG_AND_RETHROW() @@ -916,21 +918,21 @@ BOOST_AUTO_TEST_CASE(bet_reversal_test) // BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance); // // // back with alice's entire balance -// place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); +// place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // alice_expected_balance -= 10000000; // BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance); // // // lay with bob's entire balance, which fully matches bob's bet -// place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); +// place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(10000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // bob_expected_balance -= 10000000; // BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance); // // // reverse the bet -// place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(20000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); +// place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(20000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance); // // // try to re-reverse it, but go too far -// BOOST_CHECK_THROW( place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(30000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION), fc::exception); +// BOOST_CHECK_THROW( place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(30000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION), fc::exception); // BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance); // } // FC_LOG_AND_RETHROW() @@ -952,11 +954,11 @@ BOOST_AUTO_TEST_CASE(persistent_objects_test) BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); - idump((capitals_win_market.get_status())); + idump((capitals_win_market_id(db).get_status())); // lay 46 at 1.94 odds (50:47) -- this is too small to be placed on the books and there's // nothing for it to match, so it should be canceled - bet_id_type automatically_canceled_bet_id = place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(46, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + bet_id_type automatically_canceled_bet_id = place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(46, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); generate_blocks(1); BOOST_CHECK_MESSAGE(!db.find(automatically_canceled_bet_id), "Bet should have been canceled, but the blockchain still knows about it"); fc::variants objects_from_bookie = bookie_api.get_objects({automatically_canceled_bet_id}); @@ -965,7 +967,7 @@ BOOST_AUTO_TEST_CASE(persistent_objects_test) BOOST_CHECK_MESSAGE(objects_from_bookie[0]["id"].as(1) == automatically_canceled_bet_id, "Bookie Plugin didn't return a deleted bet it"); // lay 47 at 1.94 odds (50:47) -- this bet should go on the order books normally - bet_id_type first_bet_on_books = place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(47, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + bet_id_type first_bet_on_books = place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(47, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); generate_blocks(1); BOOST_CHECK_MESSAGE(db.find(first_bet_on_books), "Bet should exist on the blockchain"); objects_from_bookie = bookie_api.get_objects({first_bet_on_books}); @@ -974,7 +976,7 @@ BOOST_AUTO_TEST_CASE(persistent_objects_test) BOOST_CHECK_MESSAGE(objects_from_bookie[0]["id"].as(1) == first_bet_on_books, "Bookie Plugin didn't return a bet that is currently on the books"); // place a bet that exactly matches 'first_bet_on_books', should result in empty books (thus, no bet_objects from the blockchain) - bet_id_type matching_bet = place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(50, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); + bet_id_type matching_bet = place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(50, asset_id_type()), 194 * GRAPHENE_BETTING_ODDS_PRECISION / 100); BOOST_CHECK_MESSAGE(!db.find(first_bet_on_books), "Bet should have been filled, but the blockchain still knows about it"); BOOST_CHECK_MESSAGE(!db.find(matching_bet), "Bet should have been filled, but the blockchain still knows about it"); generate_blocks(1); // the bookie plugin doesn't detect matches until a block is generated @@ -985,17 +987,11 @@ BOOST_AUTO_TEST_CASE(persistent_objects_test) BOOST_CHECK_MESSAGE(objects_from_bookie[0]["id"].as(1) == first_bet_on_books, "Bookie Plugin didn't return a bet that has been filled"); BOOST_CHECK_MESSAGE(objects_from_bookie[1]["id"].as(1) == matching_bet, "Bookie Plugin didn't return a bet that has been filled"); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::cancel}, - {blackhawks_win_market.id, betting_market_resolution_type::cancel}}); - - // as soon as the market is resolved during the generate_block(), these markets - // should be deleted and our references will go out of scope. Save the - // market ids here so we can verify that they were really deleted - betting_market_id_type capitals_win_market_id = capitals_win_market.id; - betting_market_id_type blackhawks_win_market_id = blackhawks_win_market.id; + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::cancel}, + {blackhawks_win_market_id, betting_market_resolution_type::cancel}}); generate_blocks(1); @@ -1049,25 +1045,19 @@ BOOST_AUTO_TEST_CASE(test_settled_market_states) BOOST_REQUIRE_EQUAL(get_balance(bob_id, asset_id_type()), bob_expected_balance.value); BOOST_REQUIRE_EQUAL(get_balance(alice_id, asset_id_type()), alice_expected_balance.value); - idump((capitals_win_market.get_status())); + idump((capitals_win_market_id(db).get_status())); BOOST_TEST_MESSAGE("setting the event to in_progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); - - // as soon as the market is resolved during the generate_block(), these markets - // should be deleted and our references will go out of scope. Save the - // market ids here so we can verify that they were really deleted - betting_market_id_type capitals_win_market_id = capitals_win_market.id; - betting_market_id_type blackhawks_win_market_id = blackhawks_win_market.id; + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); @@ -1098,7 +1088,7 @@ BOOST_AUTO_TEST_CASE(delayed_bets_test) // test live betting generate_blocks(1); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::in_play); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::in_play); generate_blocks(1); transfer(account_id_type(), alice_id, asset(10000000)); @@ -1113,17 +1103,17 @@ BOOST_AUTO_TEST_CASE(delayed_bets_test) // test live betting BOOST_TEST_MESSAGE("Testing basic delayed bet mechanics"); // alice backs 100 at odds 2 BOOST_TEST_MESSAGE("Alice places a back bet of 100 at odds 2.0"); - bet_id_type delayed_back_bet = place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + bet_id_type delayed_back_bet = place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); generate_blocks(1); // verify the bet hasn't been placed in the active book - auto first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + auto first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); BOOST_CHECK(first_bet_in_market == bet_odds_idx.end()); // after 3 blocks, the delay should have expired and it will be promoted to the active book generate_blocks(2); - first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); - auto last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market.id)); + first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); + auto last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market_id)); BOOST_CHECK(first_bet_in_market != bet_odds_idx.end()); BOOST_CHECK(std::distance(first_bet_in_market, last_bet_in_market) == 1); @@ -1131,19 +1121,19 @@ BOOST_AUTO_TEST_CASE(delayed_bets_test) // test live betting edump((bet)); // bob lays 100 at odds 2 to match alice's bet currently on the books BOOST_TEST_MESSAGE("Bob places a lay bet of 100 at odds 2.0"); - /* bet_id_type delayed_lay_bet = */ place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + /* bet_id_type delayed_lay_bet = */ place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); edump((db.get_global_properties().parameters.block_interval)(db.head_block_time())); // the bet should not enter the order books before a block has been generated - first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); - last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market.id)); + first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); + last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market_id)); for (const auto& bet : bet_odds_idx) edump((bet)); generate_blocks(1); // bob's bet will still be delayed, so the active order book will only contain alice's bet - first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); - last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market.id)); + first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); + last_bet_in_market = bet_odds_idx.upper_bound(std::make_tuple(capitals_win_market_id)); // edump((std::distance(first_bet_in_market, last_bet_in_market))); BOOST_CHECK(std::distance(first_bet_in_market, last_bet_in_market) == 1); for (const auto& bet : boost::make_iterator_range(first_bet_in_market, last_bet_in_market)) @@ -1156,13 +1146,13 @@ BOOST_AUTO_TEST_CASE(delayed_bets_test) // test live betting // now test that when we cancel all bets on a market, delayed bets get canceled too BOOST_TEST_MESSAGE("Alice places a back bet of 100 at odds 2.0"); - delayed_back_bet = place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + delayed_back_bet = place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); generate_blocks(1); - first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market.id)); + first_bet_in_market = bet_odds_idx.lower_bound(std::make_tuple(capitals_win_market_id)); BOOST_CHECK(!bet_odds_idx.empty()); BOOST_CHECK(first_bet_in_market == bet_odds_idx.end()); BOOST_TEST_MESSAGE("Cancel all bets"); - cancel_unmatched_bets(moneyline_betting_markets.id); + cancel_unmatched_bets(moneyline_betting_markets_id); BOOST_CHECK(bet_odds_idx.empty()); } FC_LOG_AND_RETHROW() @@ -1283,28 +1273,28 @@ BOOST_AUTO_TEST_CASE( testnet_witness_block_production_error ) try { CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); - create_betting_market_group({{"en", "Unused"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), false, 0); + create_betting_market_group({{"en", "Unused"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), false, 0); generate_blocks(1); const betting_market_group_object& unused_betting_markets = *db.get_index_type().indices().get().rbegin(); BOOST_TEST_MESSAGE("setting the event in progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); BOOST_CHECK(unused_betting_markets.get_status() == betting_market_group_status::in_play); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_CHECK(unused_betting_markets.get_status() == betting_market_group_status::closed); BOOST_TEST_MESSAGE("setting the event to canceled"); - update_event(capitals_vs_blackhawks.id, _status = event_status::canceled); + update_event(capitals_vs_blackhawks_id, _status = event_status::canceled); generate_blocks(1); } FC_LOG_AND_RETHROW() } @@ -1318,10 +1308,10 @@ BOOST_AUTO_TEST_CASE( cancel_one_event_in_group ) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); // create a second event in the same betting market group - create_event({{"en", "Boston Bruins/Pittsburgh Penguins"}}, {{"en", "2016-17"}}, nhl.id); + create_event({{"en", "Boston Bruins/Pittsburgh Penguins"}}, {{"en", "2016-17"}}, nhl_id); generate_blocks(1); const event_object& bruins_vs_penguins = *db.get_index_type().indices().get().rbegin(); - create_betting_market_group({{"en", "Moneyline"}}, bruins_vs_penguins.id, betting_market_rules.id, asset_id_type(), false, 0); + create_betting_market_group({{"en", "Moneyline"}}, bruins_vs_penguins.id, betting_market_rules_id, asset_id_type(), false, 0); generate_blocks(1); const betting_market_group_object& bruins_penguins_moneyline_betting_markets = *db.get_index_type().indices().get().rbegin(); create_betting_market(bruins_penguins_moneyline_betting_markets.id, {{"en", "Boston Bruins win"}}); @@ -1333,14 +1323,14 @@ BOOST_AUTO_TEST_CASE( cancel_one_event_in_group ) (void)bruins_win_market; (void)penguins_win_market; // check the initial state - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); BOOST_CHECK(bruins_vs_penguins.get_status() == event_status::upcoming); BOOST_TEST_MESSAGE("setting the capitals_vs_blackhawks event to in-progress, leaving bruins_vs_penguins in upcoming"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); BOOST_CHECK(bruins_vs_penguins.get_status() == event_status::upcoming); BOOST_CHECK(bruins_penguins_moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); @@ -1348,19 +1338,19 @@ BOOST_AUTO_TEST_CASE( cancel_one_event_in_group ) BOOST_CHECK(penguins_win_market.get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the capitals_vs_blackhawks event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_CHECK(bruins_vs_penguins.get_status() == event_status::upcoming); BOOST_CHECK(bruins_penguins_moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); BOOST_CHECK(bruins_win_market.get_status() == betting_market_status::unresolved); BOOST_CHECK(penguins_win_market.get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the capitals_vs_blackhawks event to canceled"); - update_event(capitals_vs_blackhawks.id, _status = event_status::canceled); + update_event(capitals_vs_blackhawks_id, _status = event_status::canceled); generate_blocks(1); BOOST_CHECK(bruins_vs_penguins.get_status() == event_status::upcoming); BOOST_CHECK(bruins_penguins_moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); @@ -1456,23 +1446,23 @@ struct simple_bet_test_fixture_2 : database_fixture { transfer(account_id_type(), bob_id, asset(10000)); // alice backs 1000 at 1:1, matches - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // now alice lays at 2500 at 1:1. This should require a deposit of 500, with the remaining 200 being funded from exposure - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(2500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(2500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // match the bet bit by bit. bob matches 500 of alice's 2500 bet. This effectively cancels half of bob's lay position // so he immediately gets 500 back. It reduces alice's back position, but doesn't return any money to her (all 2000 of her exposure // was already "promised" to her lay bet, so the 500 she would have received is placed in her refundable_unmatched_bets) - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // match another 500, which will fully cancel bob's lay position and return the other 500 he had locked up in his position. // alice's back position is now canceled, 1500 remains of her unmatched lay bet, and the 500 from canceling her position has // been moved to her refundable_unmatched_bets - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(500, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - capitals_win_betting_market_id = capitals_win_market.id; + capitals_win_betting_market_id = capitals_win_market_id; } }; @@ -1484,10 +1474,10 @@ BOOST_AUTO_TEST_CASE(sport_update_test) { ACTORS( (alice) ); CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); - update_sport(ice_hockey.id, {{"en", "Hockey on Ice"}, {"zh_Hans", "冰"}, {"ja", "アイスホッケ"}}); + update_sport(ice_hockey_id, {{"en", "Hockey on Ice"}, {"zh_Hans", "冰"}, {"ja", "アイスホッケ"}}); transfer(account_id_type(), alice_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); @@ -1500,13 +1490,13 @@ BOOST_AUTO_TEST_CASE(sport_delete_test) { CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); - const auto& event_group_1 = create_event_group({{"en", "group1"}}, ice_hockey.id); - const auto& event_group_2 = create_event_group({{"en", "group2"}}, ice_hockey.id); + const auto& event_group_1 = create_event_group({{"en", "group1"}}, ice_hockey_id); + const auto& event_group_2 = create_event_group({{"en", "group2"}}, ice_hockey_id); - delete_sport(ice_hockey.id); + delete_sport(ice_hockey_id); const auto& sport_by_id = db.get_index_type().indices().get(); - BOOST_CHECK(sport_by_id.end() == sport_by_id.find(ice_hockey.id)); + BOOST_CHECK(sport_by_id.end() == sport_by_id.find(ice_hockey_id)); const auto& event_group_by_id = db.get_index_type().indices().get(); BOOST_CHECK(event_group_by_id.end() == event_group_by_id.find(event_group_1.id)); @@ -1521,7 +1511,7 @@ BOOST_AUTO_TEST_CASE(sport_delete_test_not_proposal) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); sport_delete_operation sport_delete_op; - sport_delete_op.sport_id = ice_hockey.id; + sport_delete_op.sport_id = ice_hockey_id; BOOST_CHECK_THROW(force_operation_by_witnesses(sport_delete_op), fc::exception); } FC_LOG_AND_RETHROW() @@ -1534,9 +1524,9 @@ BOOST_AUTO_TEST_CASE(sport_delete_test_not_proposal) // { // CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); // -// delete_sport(ice_hockey.id); +// delete_sport(ice_hockey_id); // -// BOOST_CHECK_THROW(delete_sport(ice_hockey.id), fc::exception); +// BOOST_CHECK_THROW(delete_sport(ice_hockey_id), fc::exception); // } FC_LOG_AND_RETHROW() // } @@ -1550,28 +1540,28 @@ BOOST_AUTO_TEST_CASE(event_group_update_test) transfer(account_id_type(), alice_id, asset(10000000)); transfer(account_id_type(), bob_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); const sport_object& ice_on_hockey = create_sport({{"en", "Hockey on Ice"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \ fc::optional sport_id = ice_on_hockey.id; fc::optional name = internationalized_string_type({{"en", "IBM"}, {"zh_Hans", "國家冰球聯"}, {"ja", "ナショナルホッケーリー"}}); - update_event_group(nhl.id, fc::optional(), name); - update_event_group(nhl.id, sport_id, fc::optional()); - update_event_group(nhl.id, sport_id, name); + update_event_group(nhl_id, fc::optional(), name); + update_event_group(nhl_id, sport_id, fc::optional()); + update_event_group(nhl_id, sport_id, name); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); // caps win - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); @@ -1760,9 +1750,9 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test) transfer(account_id_type(), alice_id, asset(initialAccountAsset)); transfer(account_id_type(), bob_id, asset(initialAccountAsset)); - const auto& event = create_event({{"en", "event"}}, {{"en", "2016-17"}}, nhl.id); + const auto& event = create_event({{"en", "event"}}, {{"en", "2016-17"}}, nhl_id); - const auto& market_group = create_betting_market_group({{"en", "market group"}}, event.id, betting_market_rules.id, asset_id_type(), false, 0); + const auto& market_group = create_betting_market_group({{"en", "market group"}}, event.id, betting_market_rules_id, asset_id_type(), false, 0); //to make bets be not removed immediately update_betting_market_group_impl(market_group.id, fc::optional(), @@ -1772,17 +1762,17 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test) const auto& market = create_betting_market(market_group.id, {{"en", "market"}}); - test_events events(*this, nhl.id); - test_markets_groups markets_groups(*this, event.id, betting_market_rules.id); + test_events events(*this, nhl_id); + test_markets_groups markets_groups(*this, event.id, betting_market_rules_id); test_markets markets(*this, market_group.id); const auto& bet_1_id = place_bet(alice_id, market.id, bet_type::back, asset(betAsset, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); const auto& bet_2_id = place_bet(bob_id, market.id, bet_type::lay, asset(betAsset, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - delete_event_group(nhl.id); + delete_event_group(nhl_id); const auto& event_group_by_id = db.get_index_type().indices().get(); - BOOST_CHECK(event_group_by_id.end() == event_group_by_id.find(nhl.id)); + BOOST_CHECK(event_group_by_id.end() == event_group_by_id.find(nhl_id)); BOOST_CHECK(event_status::canceled == event.get_status()); @@ -1838,10 +1828,10 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test_with_matched_bets) transfer(account_id_type(), bob_id, asset(initialAccountAsset)); generate_blocks(1); - const auto& event = create_event({{"en", "event"}}, {{"en", "2016-17"}}, nhl.id); + const auto& event = create_event({{"en", "event"}}, {{"en", "2016-17"}}, nhl_id); generate_blocks(1); - const auto& market_group = create_betting_market_group({{"en", "market group"}}, event.id, betting_market_rules.id, asset_id_type(), false, 0); + const auto& market_group = create_betting_market_group({{"en", "market group"}}, event.id, betting_market_rules_id, asset_id_type(), false, 0); generate_blocks(1); const auto& market = create_betting_market(market_group.id, {{"en", "market"}}); @@ -1851,7 +1841,7 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test_with_matched_bets) place_bet(bob_id, market.id, bet_type::lay, asset(betAsset, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); generate_blocks(1); - delete_event_group(nhl.id); + delete_event_group(nhl_id); generate_blocks(1); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), initialAccountAsset); @@ -1866,7 +1856,7 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test_not_proposal) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); event_group_delete_operation event_group_delete_op; - event_group_delete_op.event_group_id = nhl.id; + event_group_delete_op.event_group_id = nhl_id; BOOST_CHECK_THROW(force_operation_by_witnesses(event_group_delete_op), fc::exception); } FC_LOG_AND_RETHROW() @@ -1878,9 +1868,9 @@ BOOST_AUTO_TEST_CASE(event_group_delete_test_not_existed_event_group) { CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); - delete_event_group(nhl.id); + delete_event_group(nhl_id); - BOOST_CHECK_THROW(delete_event_group(nhl.id), fc::exception); + BOOST_CHECK_THROW(delete_event_group(nhl_id), fc::exception); } FC_LOG_AND_RETHROW() } @@ -1894,31 +1884,31 @@ BOOST_AUTO_TEST_CASE(event_update_test) transfer(account_id_type(), alice_id, asset(10000000)); transfer(account_id_type(), bob_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); fc::optional name = internationalized_string_type({{"en", "Washington Capitals vs. Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホーク"}}); fc::optional season = internationalized_string_type({{"en", "2017-18"}}); - update_event(capitals_vs_blackhawks.id, _name = name); - update_event(capitals_vs_blackhawks.id, _season = season); - update_event(capitals_vs_blackhawks.id, _name = name, _season = season); + update_event(capitals_vs_blackhawks_id, _name = name); + update_event(capitals_vs_blackhawks_id, _season = season); + update_event(capitals_vs_blackhawks_id, _name = name, _season = season); const sport_object& ice_on_hockey = create_sport({{"en", "Hockey on Ice"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); const event_group_object& nhl2 = create_event_group({{"en", "NHL2"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_on_hockey.id); - update_event(capitals_vs_blackhawks.id, _event_group_id = nhl2.id); + update_event(capitals_vs_blackhawks_id, _event_group_id = nhl2.id); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); // caps win - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); @@ -1943,12 +1933,12 @@ BOOST_AUTO_TEST_CASE(betting_market_rules_update_test) fc::optional name = internationalized_string_type({{"en", "NHL Rules v1.1"}}); fc::optional desc = internationalized_string_type({{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); - update_betting_market_rules(betting_market_rules.id, name, empty); - update_betting_market_rules(betting_market_rules.id, empty, desc); - update_betting_market_rules(betting_market_rules.id, name, desc); + update_betting_market_rules(betting_market_rules_id, name, empty); + update_betting_market_rules(betting_market_rules_id, empty, desc); + update_betting_market_rules(betting_market_rules_id, name, desc); transfer(account_id_type(), alice_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); @@ -1963,28 +1953,28 @@ BOOST_AUTO_TEST_CASE(betting_market_group_update_test) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); transfer(account_id_type(), alice_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); internationalized_string_type new_description = internationalized_string_type({{"en", "Money line"}}); const betting_market_rules_object& new_betting_market_rules = create_betting_market_rules({{"en", "NHL Rules v2.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); fc::optional new_rule = new_betting_market_rules.id; - update_betting_market_group(moneyline_betting_markets.id, _description = new_description); - update_betting_market_group(moneyline_betting_markets.id, _rules_id = new_betting_market_rules.id); - update_betting_market_group(moneyline_betting_markets.id, _description = new_description, _rules_id = new_betting_market_rules.id); + update_betting_market_group(moneyline_betting_markets_id, _description = new_description); + update_betting_market_group(moneyline_betting_markets_id, _rules_id = new_betting_market_rules.id); + update_betting_market_group(moneyline_betting_markets_id, _description = new_description, _rules_id = new_betting_market_rules.id); transfer(account_id_type(), bob_id, asset(10000000)); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); // caps win - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); @@ -2005,24 +1995,24 @@ BOOST_AUTO_TEST_CASE(betting_market_update_test) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); transfer(account_id_type(), alice_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); fc::optional payout_condition = internationalized_string_type({{"en", "Washington Capitals lose"}}); // update the payout condition - update_betting_market(capitals_win_market.id, fc::optional(), payout_condition); + update_betting_market(capitals_win_market_id, fc::optional(), payout_condition); transfer(account_id_type(), bob_id, asset(10000000)); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); // caps win - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); uint16_t rake_fee_percentage = db.get_global_properties().parameters.betting_rake_fee_percentage(); @@ -2049,27 +2039,25 @@ BOOST_AUTO_TEST_CASE(event_driven_standard_progression_1) { CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading betting market"); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // as soon as a block is generated, the betting market group will settle, and the market @@ -2093,40 +2081,33 @@ BOOST_AUTO_TEST_CASE(event_driven_standard_progression_1_with_delay) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 60 /* seconds */); graphene::bookie::bookie_api bookie_api(app); - // save the ids for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; - betting_market_group_id_type moneyline_betting_markets_id = moneyline_betting_markets.id; - betting_market_id_type capitals_win_market_id = capitals_win_market.id; - betting_market_id_type blackhawks_win_market_id = blackhawks_win_market.id; - - BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading betting market"); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // it should be waiting 60 seconds before it settles - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::graded); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::graded); - BOOST_CHECK(capitals_win_market.resolution == betting_market_resolution_type::win); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::graded); - BOOST_CHECK(blackhawks_win_market.resolution == betting_market_resolution_type::not_win); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::graded); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::graded); + BOOST_CHECK(capitals_win_market_id(db).resolution == betting_market_resolution_type::win); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::graded); + BOOST_CHECK(blackhawks_win_market_id(db).resolution == betting_market_resolution_type::not_win); generate_blocks(60); // as soon as a block is generated, the betting market group will settle, and the market @@ -2164,65 +2145,63 @@ BOOST_AUTO_TEST_CASE(event_driven_standard_progression_2) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event back to upcoming"); - update_event(capitals_vs_blackhawks.id, _status = event_status::upcoming); + update_event(capitals_vs_blackhawks_id, _status = event_status::upcoming); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event in-progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event back in-progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading betting market"); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // as soon as a block is generated, the betting market group will settle, and the market @@ -2252,65 +2231,63 @@ BOOST_AUTO_TEST_CASE(event_driven_standard_progression_2_never_in_play) CREATE_ICE_HOCKEY_BETTING_MARKET(true, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event back to upcoming"); - update_event(capitals_vs_blackhawks.id, _status = event_status::upcoming); + update_event(capitals_vs_blackhawks_id, _status = event_status::upcoming); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event in-progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event back in-progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading betting market"); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // as soon as a block is generated, the betting market group will settle, and the market @@ -2338,55 +2315,53 @@ BOOST_AUTO_TEST_CASE(event_driven_standard_progression_3) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event in progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event back in-progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to canceled"); - update_event(capitals_vs_blackhawks.id, _status = event_status::canceled); + update_event(capitals_vs_blackhawks_id, _status = event_status::canceled); generate_blocks(1); // as soon as a block is generated, the betting market group will cancel, and the market @@ -2411,80 +2386,78 @@ BOOST_AUTO_TEST_CASE(event_driven_progression_errors_1) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_REQUIRE(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_REQUIRE(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_REQUIRE(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); // settled is the only illegal transition from upcoming BOOST_TEST_MESSAGE("verifying we can't jump to settled"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::settled, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::settled, _force = true), fc::exception); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_REQUIRE(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_REQUIRE(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_REQUIRE(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_REQUIRE(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); // settled is the only illegal transition from this frozen event BOOST_TEST_MESSAGE("verifying we can't jump to settled"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::settled, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::settled, _force = true), fc::exception); BOOST_TEST_MESSAGE("setting the event in progress"); - update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress); + update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress); generate_blocks(1); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::in_progress); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::in_progress); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); // we can't go back to upcoming from in_progress. // settled is disallowed everywhere BOOST_TEST_MESSAGE("verifying we can't jump to upcoming"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::upcoming, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::upcoming, _force = true), fc::exception); BOOST_TEST_MESSAGE("verifying we can't jump to settled"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::settled, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::settled, _force = true), fc::exception); BOOST_TEST_MESSAGE("setting the event frozen"); - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_REQUIRE(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_REQUIRE(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_REQUIRE(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_REQUIRE(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); // we can't go back to upcoming from frozen once we've gone in_progress. // settled is disallowed everywhere BOOST_TEST_MESSAGE("verifying we can't jump to upcoming"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::upcoming, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::upcoming, _force = true), fc::exception); BOOST_TEST_MESSAGE("verifying we can't jump to settled"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::settled, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::settled, _force = true), fc::exception); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_REQUIRE(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_REQUIRE(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_REQUIRE(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); // we can't go back to upcoming, in_progress, or frozen once we're finished. // settled is disallowed everywhere BOOST_TEST_MESSAGE("verifying we can't jump to upcoming"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::upcoming, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::upcoming, _force = true), fc::exception); BOOST_TEST_MESSAGE("verifying we can't jump to in_progress"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::in_progress, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::in_progress, _force = true), fc::exception); BOOST_TEST_MESSAGE("verifying we can't jump to frozen"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::frozen, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::frozen, _force = true), fc::exception); BOOST_TEST_MESSAGE("verifying we can't jump to settled"); - BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks.id, _status = event_status::settled, _force = true), fc::exception); + BOOST_CHECK_THROW(update_event(capitals_vs_blackhawks_id, _status = event_status::settled, _force = true), fc::exception); BOOST_TEST_MESSAGE("setting the event to canceled"); - update_event(capitals_vs_blackhawks.id, _status = event_status::canceled); + update_event(capitals_vs_blackhawks_id, _status = event_status::canceled); generate_blocks(1); fc::variants objects_from_bookie = bookie_api.get_objects({capitals_vs_blackhawks_id}); @@ -2514,27 +2487,25 @@ BOOST_AUTO_TEST_CASE(event_driven_progression_errors_2) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_REQUIRE(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_REQUIRE(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_REQUIRE(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting the event to finished"); - update_event(capitals_vs_blackhawks.id, _status = event_status::finished); + update_event(capitals_vs_blackhawks_id, _status = event_status::finished); generate_blocks(1); - BOOST_REQUIRE(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_REQUIRE(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_REQUIRE(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_REQUIRE(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_REQUIRE(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_REQUIRE(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_REQUIRE(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading betting market"); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // as soon as a block is generated, the betting market group will settle, and the market @@ -2566,47 +2537,45 @@ BOOST_AUTO_TEST_CASE(betting_market_group_driven_standard_progression) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("setting betting market to frozen"); // the event should stay in the upcoming state - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::frozen); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting the event frozen"); // this should only change the status of the event, just verify that nothing weird happens when // we try to set the bmg to frozen when it's already frozen - update_event(capitals_vs_blackhawks.id, _status = event_status::frozen); + update_event(capitals_vs_blackhawks_id, _status = event_status::frozen); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::frozen); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::frozen); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::frozen); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::frozen); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::frozen); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::frozen); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::frozen); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::frozen); BOOST_TEST_MESSAGE("setting betting market to closed"); // the event should go to finished automatically - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading betting market"); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // as soon as a block is generated, the betting market group will settle, and the market @@ -2625,99 +2594,97 @@ BOOST_AUTO_TEST_CASE(multi_betting_market_group_driven_standard_progression) CREATE_EXTENDED_ICE_HOCKEY_BETTING_MARKET(false, 0); graphene::bookie::bookie_api bookie_api(app); - // save the event id for checking after it is deleted - event_id_type capitals_vs_blackhawks_id = capitals_vs_blackhawks.id; BOOST_TEST_MESSAGE("verify everything is in the correct initial state"); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(first_period_result_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(first_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(first_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(second_period_result_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(second_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(second_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(third_period_result_betting_markets.get_status() == betting_market_group_status::upcoming); - BOOST_CHECK(third_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(third_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(first_period_result_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(first_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(first_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(second_period_result_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(second_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(second_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(third_period_result_betting_markets_id(db).get_status() == betting_market_group_status::upcoming); + BOOST_CHECK(third_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(third_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("the game is starting, setting the main betting market and the first period to in_play"); // the event should stay in the upcoming state - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::in_play); - update_betting_market_group(first_period_result_betting_markets.id, _status = betting_market_group_status::in_play); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::in_play); + update_betting_market_group(first_period_result_betting_markets_id, _status = betting_market_group_status::in_play); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(first_period_result_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(first_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(first_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(first_period_result_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(first_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(first_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("the first period is over, starting the second period"); - update_betting_market_group(first_period_result_betting_markets.id, _status = betting_market_group_status::closed); - update_betting_market_group(second_period_result_betting_markets.id, _status = betting_market_group_status::in_play); + update_betting_market_group(first_period_result_betting_markets_id, _status = betting_market_group_status::closed); + update_betting_market_group(second_period_result_betting_markets_id, _status = betting_market_group_status::in_play); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(first_period_result_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(first_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(first_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(second_period_result_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(second_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(second_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(first_period_result_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(first_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(first_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(second_period_result_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(second_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(second_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading the first period market"); - resolve_betting_market_group(first_period_result_betting_markets.id, - {{first_period_capitals_win_market.id, betting_market_resolution_type::win}, - {first_period_blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(first_period_result_betting_markets_id, + {{first_period_capitals_win_market_id, betting_market_resolution_type::win}, + {first_period_blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); BOOST_TEST_MESSAGE("the second period is over, starting the third period"); - update_betting_market_group(second_period_result_betting_markets.id, _status = betting_market_group_status::closed); - update_betting_market_group(third_period_result_betting_markets.id, _status = betting_market_group_status::in_play); + update_betting_market_group(second_period_result_betting_markets_id, _status = betting_market_group_status::closed); + update_betting_market_group(third_period_result_betting_markets_id, _status = betting_market_group_status::in_play); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::upcoming); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(second_period_result_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(second_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(second_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(third_period_result_betting_markets.get_status() == betting_market_group_status::in_play); - BOOST_CHECK(third_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(third_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::upcoming); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(second_period_result_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(second_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(second_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(third_period_result_betting_markets_id(db).get_status() == betting_market_group_status::in_play); + BOOST_CHECK(third_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(third_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading the second period market"); - resolve_betting_market_group(second_period_result_betting_markets.id, - {{second_period_capitals_win_market.id, betting_market_resolution_type::win}, - {second_period_blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(second_period_result_betting_markets_id, + {{second_period_capitals_win_market_id, betting_market_resolution_type::win}, + {second_period_blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); BOOST_TEST_MESSAGE("the game is over, closing 3rd period and game"); - update_betting_market_group(third_period_result_betting_markets.id, _status = betting_market_group_status::closed); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(third_period_result_betting_markets_id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); generate_blocks(1); - BOOST_CHECK(capitals_vs_blackhawks.get_status() == event_status::finished); - BOOST_CHECK(moneyline_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(blackhawks_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(third_period_result_betting_markets.get_status() == betting_market_group_status::closed); - BOOST_CHECK(third_period_capitals_win_market.get_status() == betting_market_status::unresolved); - BOOST_CHECK(third_period_blackhawks_win_market.get_status() == betting_market_status::unresolved); + BOOST_CHECK(capitals_vs_blackhawks_id(db).get_status() == event_status::finished); + BOOST_CHECK(moneyline_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(third_period_result_betting_markets_id(db).get_status() == betting_market_group_status::closed); + BOOST_CHECK(third_period_capitals_win_market_id(db).get_status() == betting_market_status::unresolved); + BOOST_CHECK(third_period_blackhawks_win_market_id(db).get_status() == betting_market_status::unresolved); BOOST_TEST_MESSAGE("grading the third period and game"); - resolve_betting_market_group(third_period_result_betting_markets.id, - {{third_period_capitals_win_market.id, betting_market_resolution_type::win}, - {third_period_blackhawks_win_market.id, betting_market_resolution_type::not_win}}); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(third_period_result_betting_markets_id, + {{third_period_capitals_win_market_id, betting_market_resolution_type::win}, + {third_period_blackhawks_win_market_id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); // as soon as a block is generated, the two betting market groups will settle, and the market @@ -2766,47 +2733,47 @@ BOOST_FIXTURE_TEST_CASE( another_event_group_update_test, database_fixture) transfer(account_id_type(), alice_id, asset(10000000)); transfer(account_id_type(), bob_id, asset(10000000)); - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); fc::optional name = internationalized_string_type({{"en", "IBM"}, {"zh_Hans", "國家冰球聯"}, {"ja", "ナショナルホッケーリー"}}); const sport_object& ice_on_hockey = create_sport({{"en", "Hockey on Ice"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \ fc::optional sport_id = ice_on_hockey.id; - update_event_group(nhl.id, fc::optional(), name); - update_event_group(nhl.id, sport_id, fc::optional()); - update_event_group(nhl.id, sport_id, name); + update_event_group(nhl_id, fc::optional(), name); + update_event_group(nhl_id, sport_id, fc::optional()); + update_event_group(nhl_id, sport_id, name); //Disabling the below 4 TRY_EXPECT_THROW lines to not throw anything beacuse functioning as expected // trx_state->_is_proposed_trx - //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl.id, fc::optional(), fc::optional(), true), fc::exception); - // TRY_EXPECT_THROW(try_update_event_group(nhl.id, fc::optional(), fc::optional(), true), fc::exception, "_is_proposed_trx"); + //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl_id, fc::optional(), fc::optional(), true), fc::exception); + // TRY_EXPECT_THROW(try_update_event_group(nhl_id, fc::optional(), fc::optional(), true), fc::exception, "_is_proposed_trx"); // #! nothing to change - //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl.id, fc::optional(), fc::optional()), fc::exception); - //TRY_EXPECT_THROW(try_update_event_group(nhl.id, fc::optional(), fc::optional()), fc::exception, "nothing to change"); + //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl_id, fc::optional(), fc::optional()), fc::exception); + //TRY_EXPECT_THROW(try_update_event_group(nhl_id, fc::optional(), fc::optional()), fc::exception, "nothing to change"); // #! sport_id must refer to a sport_id_type - sport_id = capitals_win_market.id; - //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl.id, sport_id, fc::optional()), fc::exception); - //TRY_EXPECT_THROW(try_update_event_group(nhl.id, sport_id, fc::optional()), fc::exception, "sport_id must refer to a sport_id_type"); + sport_id = capitals_win_market_id; + //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl_id, sport_id, fc::optional()), fc::exception); + //TRY_EXPECT_THROW(try_update_event_group(nhl_id, sport_id, fc::optional()), fc::exception, "sport_id must refer to a sport_id_type"); // #! invalid sport specified sport_id = sport_id_type(13); - //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl.id, sport_id, fc::optional()), fc::exception); - //TRY_EXPECT_THROW(try_update_event_group(nhl.id, sport_id, fc::optional()), fc::exception, "invalid sport specified"); + //GRAPHENE_REQUIRE_THROW(try_update_event_group(nhl_id, sport_id, fc::optional()), fc::exception); + //TRY_EXPECT_THROW(try_update_event_group(nhl_id, sport_id, fc::optional()), fc::exception, "invalid sport specified"); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - update_betting_market_group(moneyline_betting_markets.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, _status = betting_market_group_status::closed); // caps win - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); uint16_t rake_fee_percentage = db.get_global_properties().parameters.betting_rake_fee_percentage(); @@ -2834,31 +2801,31 @@ BOOST_AUTO_TEST_CASE( wimbledon_2017_gentelmen_singles_sf_test ) transfer(account_id_type(), alice_id, asset(10000000)); transfer(account_id_type(), bob_id, asset(10000000)); - BOOST_TEST_MESSAGE("moneyline_berdych_vs_federer " << fc::variant(moneyline_berdych_vs_federer.id, 1).as(1)); - BOOST_TEST_MESSAGE("moneyline_cilic_vs_querrey " << fc::variant(moneyline_cilic_vs_querrey.id, 1).as(1)); + BOOST_TEST_MESSAGE("moneyline_berdych_vs_federer " << fc::variant(moneyline_berdych_vs_federer_id, 1).as(1)); + BOOST_TEST_MESSAGE("moneyline_cilic_vs_querrey " << fc::variant(moneyline_cilic_vs_querrey_id, 1).as(1)); - BOOST_TEST_MESSAGE("berdych_wins_market " << fc::variant(berdych_wins_market.id, 1).as(1)); - BOOST_TEST_MESSAGE("federer_wins_market " << fc::variant(federer_wins_market.id, 1).as(1)); - BOOST_TEST_MESSAGE("cilic_wins_market " << fc::variant(cilic_wins_market.id, 1).as(1)); - BOOST_TEST_MESSAGE("querrey_wins_market " << fc::variant(querrey_wins_market.id, 1).as(1)); + BOOST_TEST_MESSAGE("berdych_wins_market " << fc::variant(berdych_wins_market_id, 1).as(1)); + BOOST_TEST_MESSAGE("federer_wins_market " << fc::variant(federer_wins_market_id, 1).as(1)); + BOOST_TEST_MESSAGE("cilic_wins_market " << fc::variant(cilic_wins_market_id, 1).as(1)); + BOOST_TEST_MESSAGE("querrey_wins_market " << fc::variant(querrey_wins_market_id, 1).as(1)); - place_bet(alice_id, berdych_wins_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, berdych_wins_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, berdych_wins_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, berdych_wins_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000); - place_bet(alice_id, cilic_wins_market.id, bet_type::back, asset(100000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, cilic_wins_market.id, bet_type::lay, asset(100000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, cilic_wins_market_id, bet_type::back, asset(100000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, cilic_wins_market_id, bet_type::lay, asset(100000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000 - 100000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000 - 100000); - update_betting_market_group(moneyline_berdych_vs_federer.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_berdych_vs_federer_id, _status = betting_market_group_status::closed); // federer wins - resolve_betting_market_group(moneyline_berdych_vs_federer.id, - {{berdych_wins_market.id, betting_market_resolution_type::not_win}, - {federer_wins_market.id, betting_market_resolution_type::win}}); + resolve_betting_market_group(moneyline_berdych_vs_federer_id, + {{berdych_wins_market_id, betting_market_resolution_type::not_win}, + {federer_wins_market_id, betting_market_resolution_type::win}}); generate_blocks(1); uint32_t bob_rake_value = (-1000000 + 2000000) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100; @@ -2867,11 +2834,11 @@ BOOST_AUTO_TEST_CASE( wimbledon_2017_gentelmen_singles_sf_test ) BOOST_CHECK_EQUAL(get_balance(alice_id, asset_id_type()), 10000000 - 1000000 - 100000); BOOST_CHECK_EQUAL(get_balance(bob_id, asset_id_type()), 10000000 - 1000000 - 100000 + 2000000 - bob_rake_value); - update_betting_market_group(moneyline_cilic_vs_querrey.id, _status = betting_market_group_status::closed); + update_betting_market_group(moneyline_cilic_vs_querrey_id, _status = betting_market_group_status::closed); // cilic wins - resolve_betting_market_group(moneyline_cilic_vs_querrey.id, - {{cilic_wins_market.id, betting_market_resolution_type::win}, - {querrey_wins_market.id, betting_market_resolution_type::not_win}}); + resolve_betting_market_group(moneyline_cilic_vs_querrey_id, + {{cilic_wins_market_id, betting_market_resolution_type::win}, + {querrey_wins_market_id, betting_market_resolution_type::not_win}}); generate_blocks(1); uint32_t alice_rake_value = (-100000 + 200000) * rake_fee_percentage / GRAPHENE_1_PERCENT / 100; @@ -2895,21 +2862,17 @@ BOOST_AUTO_TEST_CASE( wimbledon_2017_gentelmen_singles_final_test ) transfer(account_id_type(), alice_id, asset(10000000)); transfer(account_id_type(), bob_id, asset(10000000)); - BOOST_TEST_MESSAGE("moneyline_cilic_vs_federer " << fc::variant(moneyline_cilic_vs_federer.id, 1).as(1)); + BOOST_TEST_MESSAGE("moneyline_cilic_vs_federer " << fc::variant(moneyline_cilic_vs_federer_id, 1).as(1)); - BOOST_TEST_MESSAGE("federer_wins_final_market " << fc::variant(federer_wins_final_market.id, 1).as(1)); - BOOST_TEST_MESSAGE("cilic_wins_final_market " << fc::variant(cilic_wins_final_market.id, 1).as(1)); + BOOST_TEST_MESSAGE("federer_wins_final_market " << fc::variant(federer_wins_final_market_id, 1).as(1)); + BOOST_TEST_MESSAGE("cilic_wins_final_market " << fc::variant(cilic_wins_final_market_id, 1).as(1)); - betting_market_group_id_type moneyline_cilic_vs_federer_id = moneyline_cilic_vs_federer.id; update_betting_market_group(moneyline_cilic_vs_federer_id, _status = betting_market_group_status::in_play); - place_bet(alice_id, cilic_wins_final_market.id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, cilic_wins_final_market.id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, cilic_wins_final_market_id, bet_type::back, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, cilic_wins_final_market_id, bet_type::lay, asset(1000000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - auto cilic_wins_final_market_id = cilic_wins_final_market.id; - auto federer_wins_final_market_id = federer_wins_final_market.id; - - update_event(cilic_vs_federer.id, _name = internationalized_string_type({{"en", "R. Federer vs. M. Cilic"}})); + update_event(cilic_vs_federer_id, _name = internationalized_string_type({{"en", "R. Federer vs. M. Cilic"}})); generate_blocks(13); From ed7b8b60e03535360593ddf77ae4bcc8a540f846 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Thu, 27 Aug 2020 20:07:36 -0500 Subject: [PATCH 40/77] Resolve #373: Add object notifiers --- libraries/chain/db_notify.cpp | 120 +++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/libraries/chain/db_notify.cpp b/libraries/chain/db_notify.cpp index c1873ccd..c03b2196 100644 --- a/libraries/chain/db_notify.cpp +++ b/libraries/chain/db_notify.cpp @@ -40,7 +40,13 @@ #include #include #include - +#include +#include +#include +#include +#include +#include +#include using namespace fc; using namespace graphene::chain; @@ -431,6 +437,84 @@ void get_relevant_accounts( const object* obj, flat_set& accoun } case balance_object_type:{ /** these are free from any accounts */ break; + } case tournament_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->creator); + accounts.insert(aobj->options.whitelist.begin(), aobj->options.whitelist.end()); + break; + } case tournament_details_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->registered_players.begin(), aobj->registered_players.end()); + std::transform(aobj->payers.begin(), aobj->payers.end(), std::inserter(accounts, accounts.end()), + [](const auto& pair) { return pair.first; }); + std::for_each(aobj->players_payers.begin(), aobj->players_payers.end(), + [&accounts](const auto& pair) { + accounts.insert(pair.first); + accounts.insert(pair.second); + }); + break; + } case match_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->players.begin(), aobj->players.end()); + std::for_each(aobj->game_winners.begin(), aobj->game_winners.end(), + [&accounts](const auto& set) { accounts.insert(set.begin(), set.end()); }); + accounts.insert(aobj->match_winners.begin(), aobj->match_winners.end()); + break; + } case game_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->players.begin(), aobj->players.end()); + accounts.insert(aobj->winners.begin(), aobj->winners.end()); + break; + } case sport_object_type: + break; + case event_group_object_type: + break; + case event_object_type: + break; + case betting_market_rules_object_type: + break; + case betting_market_group_object_type: + break; + case betting_market_object_type: + break; + case bet_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->bettor_id); + break; + } case custom_permission_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->account); + add_authority_accounts(accounts, aobj->auth); + break; + } case custom_account_authority_object_type: + break; + case offer_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->issuer); + if (aobj->bidder.valid()) + accounts.insert(*aobj->bidder); + break; + } case nft_metadata_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->owner); + if (aobj->revenue_partner.valid()) + accounts.insert(*aobj->revenue_partner); + break; + } case nft_object_type:{ + auto aobj = dynamic_cast(obj); + assert(aobj != nullptr); + accounts.insert(aobj->owner); + accounts.insert(aobj->approved); + accounts.insert(aobj->approved_operators.begin(), aobj->approved_operators.end()); + break; } } } @@ -485,6 +569,40 @@ void get_relevant_accounts( const object* obj, flat_set& accoun break; case impl_fba_accumulator_object_type: break; + case impl_asset_dividend_data_object_type:{ + const auto& aobj = dynamic_cast(obj); + assert( aobj != nullptr ); + accounts.insert(aobj->dividend_distribution_account); + break; + } case impl_pending_dividend_payout_balance_for_holder_object_type:{ + const auto& aobj = dynamic_cast(obj); + assert( aobj != nullptr ); + accounts.insert(aobj->owner); + break; + } case impl_total_distributed_dividend_balance_object_type: + break; + case impl_betting_market_position_object_type:{ + const auto& aobj = dynamic_cast(obj); + assert( aobj != nullptr ); + accounts.insert(aobj->bettor_id); + break; + } case impl_global_betting_statistics_object_type: + break; + case impl_lottery_balance_object_type: + break; + case impl_sweeps_vesting_balance_object_type:{ + const auto& aobj = dynamic_cast(obj); + assert( aobj != nullptr ); + accounts.insert(aobj->owner); + break; + } case impl_offer_history_object_type:{ + const auto& aobj = dynamic_cast(obj); + assert( aobj != nullptr ); + accounts.insert(aobj->issuer); + if (aobj->bidder.valid()) + accounts.insert(*aobj->bidder); + break; + } } } } // end get_relevant_accounts( const object* obj, flat_set& accounts ) From 4d836dacb942b05106b49f47e853c450feba3968 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Thu, 8 Oct 2020 21:05:59 -0500 Subject: [PATCH 41/77] Ref !3/#376: Graphene Updates This adds the most important updates to Graphene from BitShares. Most notably, https://github.com/bitshares/bitshares-core/issues/1506 Second most notably, it updates Peerplays' FC to be in sync with BitShares FC. This is a squash commit of several subcommits. The subcommit messages are reproduced below: Replace fc::uint128 with boost::multiprecision::uint128_t replace smart_ref with shared_ptr Fixes/Remove Unused Remove NTP time Remove old macro This macro is now in FC, so no need to define it here anymore Replaced fc::array with std::array Separate exception declaration and implementation Adapted to fc promise changes Fixes Add back in some of Peter's fixes that got lost in the cherry pick _hash endianness fixes Remove all uses of fc/smart_ref It's gone, can't use it anymore Replace improper static_variant operator overloads with comparators Fixes Remove boost::signals from build system; it's header-only so it's not listed in cmake anymore. Also remove some unused hashing code Impl. pack/unpack functions for extension class Ref #1506: Isolate chain/protocol to its own library Ref #1506: Add object_downcast_t Allows the more concise expression `object_downcast_t` instead of the old `typename object_downcast::type` Ref #1506: Move ID types from db to protocol The ID types, object_id and object_id_type, were defined in the db library, and the protocol library depends on db to get these types. Technically, the ID types are defined by the protocol and used by the database, and not vice versa. Therefore these types should be in the protocol library, and db should depend on protocol to get them. This commit makes it so. Ref #1506: Isolate chain/protocol to its own library Remove commented-out index code Wrap overlength line Remove unused key types Probably fix Docker build Fix build after rebase Ref #1506/#1737: Some requested changes Ref #1506/#1737: Macro-fy ID type definitions Define macros to fully de-boilerplate ID type definitions. Externalities: - Rename transaction_object -> transaction_history_object - Rename impl_asset_dynamic_data_type -> impl_asset_dynamic_data_object_type - Rename impl_asset_bitasset_data_type -> impl_asset_bitasset_data_object_type The first is to avoid a naming collision on transaction_id_type, and the other two are to maintain consistency with the naming of the other types. Ref #1506/#1737: Fix clean_name() Ref #1506/#1737: Oops Fix .gitignore Externalized serialization in protocol library Fix compile sets Delete a couple of ghost files that were in the tree but not part of the project (I accidentally added them to CMakeLists while merging, but they're broken and not part of the Peerplays code), and add several files that got dropped from the build during merge. General fixes Fix warnings, build issues, unused code, etc. Fix #1772 by decprecating cli_wallet -H More fixes Fix errors and warnings and generally coax it to build Fix test I'm pretty sure this didn't break from what I did... But I can't build the original code, so I can't tell. Anyways, this one now passes... Others still fail... Small fix Fix crash in auth checks Final fixes Last round of fixes following the rebase to Beatrice Rename project in CMakeLists.txt The CMakeLists.txt declared this project as BitShares and not Peerplays, which makes it confusing in IDEs. Rename it to be clear which project is open. Resolve #374 Replace all object refs in macros with IDs, and fix affected tests to look up objects by ID rather than using invalidated refs. A full audit of all tests should be performed to eliminate any further usage of invalidated object references. Resolve #373: Add object notifiers Various fixes Fixes to various issues, primarily reflections, that cropped up during merge conflict resolution Fix startup bug in Bookie plugin Bookie plugin was preventing the node from starting up because it registered its secondary indexes to create objects in its own primary indexes to track objects being created in other primary indexes, and did so during its `initialize()` step, which is to say, before the database was loaded from disk at startup. This caused the secondary indexes to create tracker objects when the observed indexes were loading objects from disk. This then caused a failure when these tracker indexes were later loaded from disk, and the first object IDs collided. This is fixed by refraining from defining secondary indexes until the `startup()` stage rather than the `initialize()` stage. Primary indexes are registered in `initialize()`, secondary indexes are registered in `startup()`. This also involved adding a new method, "add_secondary_index()", to `object_database`, as before there was no way to do this because you couldn't get a non-const index from a non-const database. I have no idea how this was working before I got here... Fix egenesis install Fixes after updates Rebase on updated develop branch and fix conflicts --- CMakeLists.txt | 2 +- libraries/app/CMakeLists.txt | 30 +- .../graphene/app/custom_account_authority.hpp | 76 --- .../graphene/app/custom_permission.hpp | 73 --- .../app/include/graphene/app/full_account.hpp | 1 - .../app/include/graphene/app/nft_ops.hpp | 148 ----- libraries/app/include/graphene/app/offer.hpp | 143 ----- .../graphene/app/sidechain_address.hpp | 80 --- .../graphene/app/sidechain_transaction.hpp | 88 --- libraries/app/include/graphene/app/son.hpp | 119 ---- .../app/include/graphene/app/son_wallet.hpp | 40 -- .../graphene/app/son_wallet_deposit.hpp | 57 -- .../graphene/app/son_wallet_withdraw.hpp | 56 -- libraries/chain/CMakeLists.txt | 93 +-- libraries/chain/db_maint.cpp | 8 +- libraries/chain/db_notify.cpp | 13 +- libraries/chain/db_update.cpp | 2 + .../graphene/chain/betting_market_object.hpp | 1 + .../include/graphene/chain/block_database.hpp | 2 - .../chain/include/graphene/chain/database.hpp | 13 +- .../include/graphene/chain/event_object.hpp | 4 +- .../include/graphene/chain/game_object.hpp | 2 +- .../include/graphene/chain/get_config.hpp | 1 + .../graphene/chain/global_property_object.hpp | 4 +- .../include/graphene/chain/match_object.hpp | 2 +- .../graphene/chain/offer_evaluator.hpp | 1 - .../chain/operation_history_object.hpp | 2 +- .../include/graphene/chain/protocol/types.hpp | 599 ------------------ .../chain/sidechain_address_evaluator.hpp | 1 + .../chain/sidechain_address_object.hpp | 3 +- .../include/graphene/chain/sidechain_defs.hpp | 22 - .../chain/sidechain_transaction_evaluator.hpp | 1 + .../chain/sidechain_transaction_object.hpp | 5 +- .../include/graphene/chain/son_evaluator.hpp | 3 +- .../chain/include/graphene/chain/son_info.hpp | 47 -- .../include/graphene/chain/son_object.hpp | 5 +- .../graphene/chain/son_proposal_object.hpp | 5 +- .../graphene/chain/son_wallet_object.hpp | 2 + .../graphene/chain/tournament_object.hpp | 2 +- .../chain/transaction_evaluation_state.hpp | 2 + .../graphene/chain/vesting_balance_object.hpp | 1 - .../chain/witness_schedule_object.hpp | 9 +- libraries/chain/index.cpp | 43 -- libraries/chain/nft_evaluator.cpp | 2 + libraries/chain/offer_evaluator.cpp | 5 +- libraries/chain/protocol/types.cpp | 280 -------- libraries/db/include/graphene/db/object.hpp | 2 - .../include/graphene/db/object_database.hpp | 6 + libraries/egenesis/CMakeLists.txt | 2 + libraries/fc | 2 +- libraries/net/CMakeLists.txt | 4 +- libraries/net/account_role.cpp | 61 -- libraries/net/chain_parameters.cpp | 92 --- libraries/net/custom_account_authority.cpp | 43 -- libraries/net/custom_permission.cpp | 85 --- libraries/net/nft.cpp | 95 --- libraries/net/node.cpp | 8 +- libraries/net/offer.cpp | 57 -- libraries/net/peer_connection.cpp | 2 +- libraries/net/small_ops.cpp | 43 -- libraries/plugins/bookie/bookie_plugin.cpp | 40 +- .../bitcoin/bitcoin_transaction.cpp | 2 +- .../bitcoin/bitcoin_address.hpp | 2 + .../peerplays_sidechain/bitcoin/serialize.hpp | 14 +- .../bitcoin/sign_bitcoin_transaction.hpp | 2 +- .../peerplays_sidechain/bitcoin/types.hpp | 2 +- .../sidechain_net_handler_bitcoin.hpp | 1 + .../sidechain_net_manager.hpp | 1 + .../peerplays_sidechain_plugin.cpp | 3 +- .../sidechain_net_handler_bitcoin.cpp | 3 +- .../sidechain_net_handler_peerplays.cpp | 2 + libraries/protocol/authority.cpp | 1 + libraries/protocol/custom_permission.cpp | 2 +- .../include/graphene/protocol/account.hpp | 2 +- .../graphene/protocol/chain_parameters.hpp | 8 +- .../include/graphene/protocol/nft_ops.hpp | 3 +- .../include/graphene/protocol/pts_address.hpp | 4 + .../include/graphene/protocol/transaction.hpp | 1 - .../include/graphene/protocol/vesting.hpp | 2 +- .../include/graphene/protocol/witness.hpp | 2 +- libraries/protocol/proposal.cpp | 1 - libraries/protocol/small_ops.cpp | 1 + libraries/protocol/transaction.cpp | 8 +- programs/build_helpers/check_reflect.py | 4 +- programs/cli_wallet/main.cpp | 3 +- tests/betting/betting_tests.cpp | 110 +--- tests/common/betting_test_markets.hpp | 144 ++--- tests/common/database_fixture.cpp | 1 + .../bitcoin_sign_tests.cpp | 12 +- tests/tests/account_role_tests.cpp | 3 + tests/tests/affiliate_tests.cpp | 20 +- tests/tests/custom_permission_tests.cpp | 1 - tests/tests/sidechain_addresses_test.cpp | 1 + tests/tests/son_wallet_tests.cpp | 1 + 94 files changed, 278 insertions(+), 2729 deletions(-) delete mode 100644 libraries/app/include/graphene/app/custom_account_authority.hpp delete mode 100644 libraries/app/include/graphene/app/custom_permission.hpp delete mode 100644 libraries/app/include/graphene/app/nft_ops.hpp delete mode 100644 libraries/app/include/graphene/app/offer.hpp delete mode 100644 libraries/app/include/graphene/app/sidechain_address.hpp delete mode 100644 libraries/app/include/graphene/app/sidechain_transaction.hpp delete mode 100644 libraries/app/include/graphene/app/son.hpp delete mode 100644 libraries/app/include/graphene/app/son_wallet.hpp delete mode 100644 libraries/app/include/graphene/app/son_wallet_deposit.hpp delete mode 100644 libraries/app/include/graphene/app/son_wallet_withdraw.hpp delete mode 100644 libraries/chain/include/graphene/chain/protocol/types.hpp delete mode 100644 libraries/chain/include/graphene/chain/sidechain_defs.hpp delete mode 100644 libraries/chain/include/graphene/chain/son_info.hpp delete mode 100644 libraries/chain/index.cpp delete mode 100644 libraries/chain/protocol/types.cpp delete mode 100644 libraries/net/account_role.cpp delete mode 100644 libraries/net/chain_parameters.cpp delete mode 100644 libraries/net/custom_account_authority.cpp delete mode 100644 libraries/net/custom_permission.cpp delete mode 100644 libraries/net/nft.cpp delete mode 100644 libraries/net/offer.cpp delete mode 100644 libraries/net/small_ops.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9acff8a0..debcd378 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ set( CLI_CLIENT_EXECUTABLE_NAME graphene_client ) set( GUI_CLIENT_EXECUTABLE_NAME BitShares ) set( CUSTOM_URL_SCHEME "gcs" ) set( INSTALLER_APP_ID "68ad7005-8eee-49c9-95ce-9eed97e5b347" ) -set( CMAKE_CXX_VERSION 14 ) +set( CMAKE_CXX_STANDARD 14 ) # http://stackoverflow.com/a/18369825 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") diff --git a/libraries/app/CMakeLists.txt b/libraries/app/CMakeLists.txt index 1a90aa0f..55985589 100644 --- a/libraries/app/CMakeLists.txt +++ b/libraries/app/CMakeLists.txt @@ -12,7 +12,12 @@ add_library( graphene_app ) # need to link graphene_debug_witness because plugins aren't sufficiently isolated #246 -target_link_libraries( graphene_app graphene_market_history graphene_account_history graphene_accounts_list graphene_affiliate_stats graphene_chain fc graphene_db graphene_net graphene_utilities graphene_debug_witness graphene_bookie graphene_elasticsearch peerplays_sidechain ) +target_link_libraries( graphene_app + PUBLIC graphene_chain graphene_net graphene_utilities + fc graphene_db peerplays_sidechain + graphene_account_history graphene_accounts_list graphene_affiliate_stats graphene_bookie graphene_debug_witness graphene_elasticsearch + graphene_es_objects graphene_generate_genesis graphene_market_history ) + target_include_directories( graphene_app PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/../egenesis/include" ) @@ -29,3 +34,26 @@ INSTALL( TARGETS ARCHIVE DESTINATION lib ) INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/app" ) + + + +add_library( graphene_plugin + plugin.cpp + + include/graphene/app/plugin.hpp + ) + +target_link_libraries( graphene_plugin + PUBLIC graphene_chain graphene_net graphene_utilities ) + +target_include_directories( graphene_plugin + PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) + +INSTALL( TARGETS + graphene_app + + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) + diff --git a/libraries/app/include/graphene/app/custom_account_authority.hpp b/libraries/app/include/graphene/app/custom_account_authority.hpp deleted file mode 100644 index b3fe2903..00000000 --- a/libraries/app/include/graphene/app/custom_account_authority.hpp +++ /dev/null @@ -1,76 +0,0 @@ -#pragma once -#include - -namespace graphene -{ -namespace chain -{ - -struct custom_account_authority_create_operation : public base_operation -{ - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - custom_permission_id_type permission_id; - int operation_type; - time_point_sec valid_from; - time_point_sec valid_to; - account_id_type owner_account; - extensions_type extensions; - - account_id_type fee_payer() const { return owner_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; -}; - -struct custom_account_authority_update_operation : public base_operation -{ - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - custom_account_authority_id_type auth_id; - optional new_valid_from; - optional new_valid_to; - account_id_type owner_account; - extensions_type extensions; - - account_id_type fee_payer() const { return owner_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } -}; - -struct custom_account_authority_delete_operation : public base_operation -{ - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - custom_account_authority_id_type auth_id; - account_id_type owner_account; - extensions_type extensions; - - account_id_type fee_payer() const { return owner_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } -}; - -} // namespace chain -} // namespace graphene - -FC_REFLECT(graphene::chain::custom_account_authority_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) -FC_REFLECT(graphene::chain::custom_account_authority_create_operation, (fee)(permission_id)(operation_type)(valid_from)(valid_to)(owner_account)(extensions)) - -FC_REFLECT(graphene::chain::custom_account_authority_update_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_account_authority_update_operation, (fee)(auth_id)(new_valid_from)(new_valid_to)(owner_account)(extensions)) - -FC_REFLECT(graphene::chain::custom_account_authority_delete_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_account_authority_delete_operation, (fee)(auth_id)(owner_account)(extensions)) diff --git a/libraries/app/include/graphene/app/custom_permission.hpp b/libraries/app/include/graphene/app/custom_permission.hpp deleted file mode 100644 index d61384c2..00000000 --- a/libraries/app/include/graphene/app/custom_permission.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once -#include - -namespace graphene -{ -namespace chain -{ - -struct custom_permission_create_operation : public base_operation -{ - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - account_id_type owner_account; - string permission_name; - authority auth; - extensions_type extensions; - - account_id_type fee_payer() const { return owner_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; -}; - -struct custom_permission_update_operation : public base_operation -{ - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - custom_permission_id_type permission_id; - optional new_auth; - account_id_type owner_account; - extensions_type extensions; - - account_id_type fee_payer() const { return owner_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } -}; - -struct custom_permission_delete_operation : public base_operation -{ - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - custom_permission_id_type permission_id; - account_id_type owner_account; - extensions_type extensions; - - account_id_type fee_payer() const { return owner_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const { return k.fee; } -}; - -} // namespace chain -} // namespace graphene - -FC_REFLECT(graphene::chain::custom_permission_create_operation::fee_parameters_type, (fee)(price_per_kbyte)) -FC_REFLECT(graphene::chain::custom_permission_create_operation, (fee)(owner_account)(permission_name)(auth)(extensions)) - -FC_REFLECT(graphene::chain::custom_permission_update_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_permission_update_operation, (fee)(permission_id)(new_auth)(owner_account)(extensions)) - -FC_REFLECT(graphene::chain::custom_permission_delete_operation::fee_parameters_type, (fee)) -FC_REFLECT(graphene::chain::custom_permission_delete_operation, (fee)(permission_id)(owner_account)(extensions)) diff --git a/libraries/app/include/graphene/app/full_account.hpp b/libraries/app/include/graphene/app/full_account.hpp index 43c7f803..200a77d7 100644 --- a/libraries/app/include/graphene/app/full_account.hpp +++ b/libraries/app/include/graphene/app/full_account.hpp @@ -69,7 +69,6 @@ FC_REFLECT( graphene::app::full_account, (limit_orders) (call_orders) (settle_orders) - (proposals) (assets) (withdraws) (pending_dividend_payments) diff --git a/libraries/app/include/graphene/app/nft_ops.hpp b/libraries/app/include/graphene/app/nft_ops.hpp deleted file mode 100644 index 4facf51a..00000000 --- a/libraries/app/include/graphene/app/nft_ops.hpp +++ /dev/null @@ -1,148 +0,0 @@ -#pragma once -#include -#include - -namespace graphene { namespace chain { - - struct nft_metadata_create_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - asset fee; - - account_id_type owner; - std::string name; - std::string symbol; - std::string base_uri; - optional revenue_partner; - optional revenue_split; - bool is_transferable = false; - bool is_sellable = true; - // Accounts Role - optional account_role; - extensions_type extensions; - - account_id_type fee_payer()const { return owner; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct nft_metadata_update_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - asset fee; - - account_id_type owner; - nft_metadata_id_type nft_metadata_id; - optional name; - optional symbol; - optional base_uri; - optional revenue_partner; - optional revenue_split; - optional is_transferable; - optional is_sellable; - // Accounts Role - optional account_role; - extensions_type extensions; - - account_id_type fee_payer()const { return owner; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct nft_mint_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - asset fee; - - account_id_type payer; - - nft_metadata_id_type nft_metadata_id; - account_id_type owner; - account_id_type approved; - vector approved_operators; - std::string token_uri; - extensions_type extensions; - - account_id_type fee_payer()const { return payer; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct nft_safe_transfer_from_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - asset fee; - - account_id_type operator_; - - account_id_type from; - account_id_type to; - nft_id_type token_id; - string data; - extensions_type extensions; - - account_id_type fee_payer()const { return operator_; } - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct nft_approve_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; - asset fee; - - account_id_type operator_; - - account_id_type approved; - nft_id_type token_id; - extensions_type extensions; - - account_id_type fee_payer()const { return operator_; } - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct nft_set_approval_for_all_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; - asset fee; - - account_id_type owner; - - account_id_type operator_; - bool approved; - extensions_type extensions; - - account_id_type fee_payer()const { return owner; } - share_type calculate_fee(const fee_parameters_type &k) const; - }; - -} } // graphene::chain - -FC_REFLECT( graphene::chain::nft_metadata_create_operation::fee_parameters_type, (fee) (price_per_kbyte) ) -FC_REFLECT( graphene::chain::nft_metadata_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::nft_mint_operation::fee_parameters_type, (fee) (price_per_kbyte) ) -FC_REFLECT( graphene::chain::nft_safe_transfer_from_operation::fee_parameters_type, (fee) (price_per_kbyte) ) -FC_REFLECT( graphene::chain::nft_approve_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::nft_set_approval_for_all_operation::fee_parameters_type, (fee) ) - -FC_REFLECT( graphene::chain::nft_metadata_create_operation, (fee) (owner) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) (account_role) (extensions) ) -FC_REFLECT( graphene::chain::nft_metadata_update_operation, (fee) (owner) (nft_metadata_id) (name) (symbol) (base_uri) (revenue_partner) (revenue_split) (is_transferable) (is_sellable) (account_role) (extensions) ) -FC_REFLECT( graphene::chain::nft_mint_operation, (fee) (payer) (nft_metadata_id) (owner) (approved) (approved_operators) (token_uri) (extensions) ) -FC_REFLECT( graphene::chain::nft_safe_transfer_from_operation, (fee) (operator_) (from) (to) (token_id) (data) (extensions) ) -FC_REFLECT( graphene::chain::nft_approve_operation, (fee) (operator_) (approved) (token_id) (extensions) ) -FC_REFLECT( graphene::chain::nft_set_approval_for_all_operation, (fee) (owner) (operator_) (approved) (extensions) ) diff --git a/libraries/app/include/graphene/app/offer.hpp b/libraries/app/include/graphene/app/offer.hpp deleted file mode 100644 index 2bf3dfc2..00000000 --- a/libraries/app/include/graphene/app/offer.hpp +++ /dev/null @@ -1,143 +0,0 @@ -#pragma once -#include -#include - -namespace graphene -{ - namespace chain - { - - /* - * @class offer_operation - * @brief To place an offer to buy or sell an item, a user broadcasts a - * proposed transaction - * @ingroup operations - * operation - */ - struct offer_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; /// only required for large memos. - }; - asset fee; - set item_ids; - // /** - // * minimum_price.asset_id == maximum_price.asset_id. - // * to set fixed price without auction minimum_price == maximum_price - // * If buying_item is true, and minimum_price != maximum_price, the user is - // proposing a “reverse auction” - // * where bidders can offer to sell the item for progressively lower prices. - // * In this case, minimum_price functions as the sell-it-now price for the - // reverse auction - // */ - account_id_type issuer; - /// minimum_price is minimum bid price. 0 if no minimum_price required - asset minimum_price; - /// buy_it_now price. 0 if no maximum price - asset maximum_price; - /// true means user wants to buy item, false mean user is selling item - bool buying_item; - /// not transaction expiration date - fc::time_point_sec offer_expiration_date; - - /// User provided data encrypted to the memo key of the "to" account - optional memo; - extensions_type extensions; - - account_id_type fee_payer() const { return issuer; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct bid_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - account_id_type bidder; - - asset bid_price; - offer_id_type offer_id; - - extensions_type extensions; - - account_id_type fee_payer() const { return bidder; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - struct cancel_offer_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; - }; - - asset fee; - - account_id_type issuer; - offer_id_type offer_id; - - extensions_type extensions; - - account_id_type fee_payer() const { return issuer; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - enum class result_type - { - Expired = 0, - ExpiredNoBid = 1, - Cancelled = 2 - }; - - struct finalize_offer_operation : public base_operation - { - struct fee_parameters_type - { - uint64_t fee = 0; - }; - - asset fee; - account_id_type fee_paying_account; - - offer_id_type offer_id; - - result_type result; - - extensions_type extensions; - - account_id_type fee_payer() const { return fee_paying_account; } - void validate() const; - share_type calculate_fee(const fee_parameters_type &k) const; - }; - - } // namespace chain -} // namespace graphene - -FC_REFLECT(graphene::chain::offer_operation::fee_parameters_type, - (fee)(price_per_kbyte)); -FC_REFLECT(graphene::chain::offer_operation, - (fee)(item_ids)(issuer)(minimum_price)(maximum_price)(buying_item)(offer_expiration_date)(memo)(extensions)); - -FC_REFLECT(graphene::chain::bid_operation::fee_parameters_type, - (fee)); -FC_REFLECT(graphene::chain::bid_operation, - (fee)(bidder)(bid_price)(offer_id)(extensions)); - -FC_REFLECT(graphene::chain::cancel_offer_operation::fee_parameters_type, - (fee)); -FC_REFLECT(graphene::chain::cancel_offer_operation, - (fee)(issuer)(offer_id)(extensions)); - -FC_REFLECT_ENUM(graphene::chain::result_type, (Expired)(ExpiredNoBid)(Cancelled)); -FC_REFLECT(graphene::chain::finalize_offer_operation::fee_parameters_type, - (fee)); -FC_REFLECT(graphene::chain::finalize_offer_operation, - (fee)(fee_paying_account)(offer_id)(result)(extensions)); diff --git a/libraries/app/include/graphene/app/sidechain_address.hpp b/libraries/app/include/graphene/app/sidechain_address.hpp deleted file mode 100644 index a5e12a03..00000000 --- a/libraries/app/include/graphene/app/sidechain_address.hpp +++ /dev/null @@ -1,80 +0,0 @@ -#pragma once -#include - -#include - -namespace graphene { namespace chain { - - struct sidechain_address_add_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - account_id_type sidechain_address_account; - sidechain_type sidechain; - string deposit_public_key; - string deposit_address; - string deposit_address_data; - string withdraw_public_key; - string withdraw_address; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct sidechain_address_update_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - sidechain_address_id_type sidechain_address_id; - account_id_type sidechain_address_account; - sidechain_type sidechain; - optional deposit_public_key; - optional deposit_address; - optional deposit_address_data; - optional withdraw_public_key; - optional withdraw_address; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct sidechain_address_delete_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - sidechain_address_id_type sidechain_address_id; - account_id_type sidechain_address_account; - sidechain_type sidechain; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - -} } // namespace graphene::chain - -FC_REFLECT(graphene::chain::sidechain_address_add_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::sidechain_address_add_operation, (fee)(payer) - (sidechain_address_account)(sidechain) - (deposit_public_key)(deposit_address)(deposit_address_data) - (withdraw_public_key)(withdraw_address) ) - -FC_REFLECT(graphene::chain::sidechain_address_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::sidechain_address_update_operation, (fee)(payer) - (sidechain_address_id) - (sidechain_address_account)(sidechain) - (deposit_public_key)(deposit_address)(deposit_address_data) - (withdraw_public_key)(withdraw_address) ) - -FC_REFLECT(graphene::chain::sidechain_address_delete_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::sidechain_address_delete_operation, (fee)(payer) - (sidechain_address_id) - (sidechain_address_account)(sidechain) ) diff --git a/libraries/app/include/graphene/app/sidechain_transaction.hpp b/libraries/app/include/graphene/app/sidechain_transaction.hpp deleted file mode 100644 index 01a4ce74..00000000 --- a/libraries/app/include/graphene/app/sidechain_transaction.hpp +++ /dev/null @@ -1,88 +0,0 @@ -#pragma once -#include -#include -#include -#include - -namespace graphene { namespace chain { - - struct sidechain_transaction_create_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - sidechain_type sidechain; - object_id_type object_id; - std::string transaction; - std::vector signers; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct sidechain_transaction_sign_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - son_id_type signer; - account_id_type payer; - - sidechain_transaction_id_type sidechain_transaction_id; - std::string signature; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee( const fee_parameters_type& k )const { return 0; } - }; - - struct sidechain_transaction_send_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - sidechain_transaction_id_type sidechain_transaction_id; - std::string sidechain_transaction; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee( const fee_parameters_type& k )const { return 0; } - }; - - struct sidechain_transaction_settle_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - sidechain_transaction_id_type sidechain_transaction_id; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee( const fee_parameters_type& k )const { return 0; } - }; - -} } // graphene::chain - -FC_REFLECT( graphene::chain::sidechain_transaction_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sidechain_transaction_create_operation, (fee)(payer) - (sidechain) - (object_id) - (transaction) - (signers) ) - -FC_REFLECT( graphene::chain::sidechain_transaction_sign_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sidechain_transaction_sign_operation, (fee)(signer)(payer) - (sidechain_transaction_id) - (signature) ) - -FC_REFLECT( graphene::chain::sidechain_transaction_send_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sidechain_transaction_send_operation, (fee)(payer) - (sidechain_transaction_id) - (sidechain_transaction) ) - -FC_REFLECT( graphene::chain::sidechain_transaction_settle_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::chain::sidechain_transaction_settle_operation, (fee)(payer) - (sidechain_transaction_id) ) diff --git a/libraries/app/include/graphene/app/son.hpp b/libraries/app/include/graphene/app/son.hpp deleted file mode 100644 index 10a75412..00000000 --- a/libraries/app/include/graphene/app/son.hpp +++ /dev/null @@ -1,119 +0,0 @@ -#pragma once -#include -#include - -namespace graphene { namespace chain { - - struct son_create_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type owner_account; - std::string url; - vesting_balance_id_type deposit; - public_key_type signing_key; - flat_map sidechain_public_keys; - vesting_balance_id_type pay_vb; - - account_id_type fee_payer()const { return owner_account; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct son_update_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - son_id_type son_id; - account_id_type owner_account; - optional new_url; - optional new_deposit; - optional new_signing_key; - optional> new_sidechain_public_keys; - optional new_pay_vb; - - account_id_type fee_payer()const { return owner_account; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct son_deregister_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - son_id_type son_id; - account_id_type payer; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct son_heartbeat_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - son_id_type son_id; - account_id_type owner_account; - time_point_sec ts; - - account_id_type fee_payer()const { return owner_account; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - - struct son_report_down_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - son_id_type son_id; - account_id_type payer; - time_point_sec down_ts; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - enum class son_maintenance_request_type - { - request_maintenance, - cancel_request_maintenance - }; - - struct son_maintenance_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - son_id_type son_id; - account_id_type owner_account; - son_maintenance_request_type request_type = son_maintenance_request_type::request_maintenance; - - account_id_type fee_payer()const { return owner_account; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - -} } // namespace graphene::chain - -FC_REFLECT(graphene::chain::son_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_create_operation, (fee)(owner_account)(url)(deposit)(signing_key)(sidechain_public_keys) - (pay_vb) ) - -FC_REFLECT(graphene::chain::son_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_update_operation, (fee)(son_id)(owner_account)(new_url)(new_deposit) - (new_signing_key)(new_sidechain_public_keys)(new_pay_vb) ) - -FC_REFLECT(graphene::chain::son_deregister_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_deregister_operation, (fee)(son_id)(payer) ) - -FC_REFLECT(graphene::chain::son_heartbeat_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_heartbeat_operation, (fee)(son_id)(owner_account)(ts) ) - -FC_REFLECT(graphene::chain::son_report_down_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_report_down_operation, (fee)(son_id)(payer)(down_ts) ) - -FC_REFLECT_ENUM( graphene::chain::son_maintenance_request_type, (request_maintenance)(cancel_request_maintenance) ) -FC_REFLECT(graphene::chain::son_maintenance_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_maintenance_operation, (fee)(son_id)(owner_account)(request_type) ) diff --git a/libraries/app/include/graphene/app/son_wallet.hpp b/libraries/app/include/graphene/app/son_wallet.hpp deleted file mode 100644 index 5194bed2..00000000 --- a/libraries/app/include/graphene/app/son_wallet.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -#include -#include - -namespace graphene { namespace chain { - - struct son_wallet_recreate_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - vector sons; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct son_wallet_update_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - son_wallet_id_type son_wallet_id; - sidechain_type sidechain; - string address; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - -} } // namespace graphene::chain - -FC_REFLECT(graphene::chain::son_wallet_recreate_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_recreate_operation, (fee)(payer)(sons) ) -FC_REFLECT(graphene::chain::son_wallet_update_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_update_operation, (fee)(payer)(son_wallet_id)(sidechain)(address) ) diff --git a/libraries/app/include/graphene/app/son_wallet_deposit.hpp b/libraries/app/include/graphene/app/son_wallet_deposit.hpp deleted file mode 100644 index 1b6a02c7..00000000 --- a/libraries/app/include/graphene/app/son_wallet_deposit.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once -#include -#include - -#include - -namespace graphene { namespace chain { - - struct son_wallet_deposit_create_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - son_id_type son_id; - fc::time_point_sec timestamp; - uint32_t block_num; - sidechain_type sidechain; - std::string sidechain_uid; - std::string sidechain_transaction_id; - std::string sidechain_from; - std::string sidechain_to; - std::string sidechain_currency; - fc::safe sidechain_amount; - chain::account_id_type peerplays_from; - chain::account_id_type peerplays_to; - chain::asset peerplays_asset; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct son_wallet_deposit_process_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - son_wallet_deposit_id_type son_wallet_deposit_id; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - -} } // namespace graphene::chain - -FC_REFLECT(graphene::chain::son_wallet_deposit_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_deposit_create_operation, (fee)(payer) - (son_id) (timestamp) (block_num) (sidechain) - (sidechain_uid) (sidechain_transaction_id) (sidechain_from) (sidechain_to) (sidechain_currency) (sidechain_amount) - (peerplays_from) (peerplays_to) (peerplays_asset) ) - -FC_REFLECT(graphene::chain::son_wallet_deposit_process_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_deposit_process_operation, (fee)(payer) - (son_wallet_deposit_id) ) diff --git a/libraries/app/include/graphene/app/son_wallet_withdraw.hpp b/libraries/app/include/graphene/app/son_wallet_withdraw.hpp deleted file mode 100644 index 0461d4b2..00000000 --- a/libraries/app/include/graphene/app/son_wallet_withdraw.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once -#include -#include - -#include - -namespace graphene { namespace chain { - - struct son_wallet_withdraw_create_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - son_id_type son_id; - fc::time_point_sec timestamp; - uint32_t block_num; - sidechain_type sidechain; - std::string peerplays_uid; - std::string peerplays_transaction_id; - chain::account_id_type peerplays_from; - chain::asset peerplays_asset; - sidechain_type withdraw_sidechain; - std::string withdraw_address; - std::string withdraw_currency; - safe withdraw_amount; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - - struct son_wallet_withdraw_process_operation : public base_operation - { - struct fee_parameters_type { uint64_t fee = 0; }; - - asset fee; - account_id_type payer; - - son_wallet_withdraw_id_type son_wallet_withdraw_id; - - account_id_type fee_payer()const { return payer; } - share_type calculate_fee(const fee_parameters_type& k)const { return 0; } - }; - -} } // namespace graphene::chain - -FC_REFLECT(graphene::chain::son_wallet_withdraw_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_withdraw_create_operation, (fee)(payer) - (son_id) (timestamp) (block_num) (sidechain) - (peerplays_uid) (peerplays_transaction_id) (peerplays_from) (peerplays_asset) - (withdraw_sidechain) (withdraw_address) (withdraw_currency) (withdraw_amount) ) - -FC_REFLECT(graphene::chain::son_wallet_withdraw_process_operation::fee_parameters_type, (fee) ) -FC_REFLECT(graphene::chain::son_wallet_withdraw_process_operation, (fee)(payer) - (son_wallet_withdraw_id) ) diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 0312c306..8d13885a 100755 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -5,22 +5,13 @@ set_source_files_properties( "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain add_dependencies( build_hardfork_hpp cat-parts ) -file(GLOB HEADERS "include/graphene/chain/*.hpp") +file(GLOB HEADERS "include/graphene/chain/*.hpp" "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp") + +file(GLOB CPP_FILES "*.cpp") if( GRAPHENE_DISABLE_UNITY_BUILD ) - set( GRAPHENE_DB_FILES - db_balance.cpp - db_bet.cpp - db_block.cpp - db_debug.cpp - db_getter.cpp - db_init.cpp - db_maint.cpp - db_management.cpp - db_market.cpp - db_update.cpp - db_witness_schedule.cpp - ) + list(FILTER CPP_FILES EXCLUDE REGEX "[/]database[.]cpp$") + #message ("--- ${CPP_FILES}") message( STATUS "Graphene database unity build disabled" ) else( GRAPHENE_DISABLE_UNITY_BUILD ) set( GRAPHENE_DB_FILES @@ -30,79 +21,7 @@ endif( GRAPHENE_DISABLE_UNITY_BUILD ) ## SORT .cpp by most likely to change / break compile add_library( graphene_chain - - # As database takes the longest to compile, start it first - ${GRAPHENE_DB_FILES} - fork_database.cpp - - genesis_state.cpp - get_config.cpp - exceptions.cpp - - evaluator.cpp - balance_evaluator.cpp - account_evaluator.cpp - assert_evaluator.cpp - witness_evaluator.cpp - committee_member_evaluator.cpp - asset_evaluator.cpp - lottery_evaluator.cpp - transfer_evaluator.cpp - proposal_evaluator.cpp - market_evaluator.cpp - vesting_balance_evaluator.cpp - tournament_evaluator.cpp - tournament_object.cpp - match_object.cpp - game_object.cpp - withdraw_permission_evaluator.cpp - worker_evaluator.cpp - confidential_evaluator.cpp - special_authority_evaluation.cpp - buyback.cpp - - account_object.cpp - asset_object.cpp - fba_object.cpp - proposal_object.cpp - vesting_balance_object.cpp - small_objects.cpp - - block_database.cpp - - is_authorized_asset.cpp - - sport_evaluator.cpp - event_group_evaluator.cpp - event_group_object.cpp - event_evaluator.cpp - event_object.cpp - betting_market_evaluator.cpp - betting_market_object.cpp - betting_market_group_object.cpp - custom_permission_evaluator.cpp - custom_account_authority_evaluator.cpp - - affiliate_payout.cpp - - offer_object.cpp - offer_evaluator.cpp - nft_evaluator.cpp - -### protocol/nft.cpp -### protocol/account_role.cpp - account_role_evaluator.cpp - - son_evaluator.cpp - son_object.cpp - - son_wallet_evaluator.cpp - son_wallet_deposit_evaluator.cpp - son_wallet_withdraw_evaluator.cpp - - sidechain_address_evaluator.cpp - sidechain_transaction_evaluator.cpp - + ${CPP_FILES} ${HEADERS} "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp" ) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 8a1a78bb..294626b1 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -22,10 +22,6 @@ * THE SOFTWARE. */ -#include - -#include - #include #include #include @@ -42,6 +38,8 @@ #include #include #include +#include +#include #include #include #include @@ -55,6 +53,8 @@ #include +#include + #define USE_VESTING_OBJECT_BY_ASSET_BALANCE_INDEX // vesting_balance_object by_asset_balance index needed namespace graphene { namespace chain { diff --git a/libraries/chain/db_notify.cpp b/libraries/chain/db_notify.cpp index 4ac34e3b..a14d7686 100644 --- a/libraries/chain/db_notify.cpp +++ b/libraries/chain/db_notify.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -47,7 +48,9 @@ #include #include #include - +#include +#include +#include using namespace fc; using namespace graphene::chain; @@ -597,6 +600,8 @@ void get_relevant_accounts( const object* obj, flat_set& accoun assert( aobj != nullptr ); accounts.insert( aobj->son_account ); break; + } case son_proposal_object_type:{ + break; } case son_wallet_object_type:{ break; } case son_wallet_deposit_object_type:{ @@ -641,7 +646,7 @@ void get_relevant_accounts( const object* obj, flat_set& accoun const auto& aobj = dynamic_cast(obj); FC_ASSERT( aobj != nullptr ); transaction_get_impacted_accounts( aobj->trx, accounts, - ignore_custom_operation_required_auths); + ignore_custom_operation_required_auths ); break; } case impl_blinded_balance_object_type:{ const auto& aobj = dynamic_cast(obj); @@ -698,6 +703,10 @@ void get_relevant_accounts( const object* obj, flat_set& accoun if (aobj->bidder.valid()) accounts.insert(*aobj->bidder); break; + } case impl_son_statistics_object_type: { + break; + } case impl_son_schedule_object_type: { + break; } } } diff --git a/libraries/chain/db_update.cpp b/libraries/chain/db_update.cpp index ccb3dd69..c75b0d53 100644 --- a/libraries/chain/db_update.cpp +++ b/libraries/chain/db_update.cpp @@ -30,12 +30,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include diff --git a/libraries/chain/include/graphene/chain/betting_market_object.hpp b/libraries/chain/include/graphene/chain/betting_market_object.hpp index 9a3b3af1..55271ddf 100644 --- a/libraries/chain/include/graphene/chain/betting_market_object.hpp +++ b/libraries/chain/include/graphene/chain/betting_market_object.hpp @@ -732,3 +732,4 @@ FC_REFLECT_DERIVED( graphene::chain::betting_market_object, (graphene::db::objec FC_REFLECT_DERIVED( graphene::chain::bet_object, (graphene::db::object), (bettor_id)(betting_market_id)(amount_to_bet)(backer_multiplier)(back_or_lay)(end_of_delay) ) FC_REFLECT_DERIVED( graphene::chain::betting_market_position_object, (graphene::db::object), (bettor_id)(betting_market_id)(pay_if_payout_condition)(pay_if_not_payout_condition)(pay_if_canceled)(pay_if_not_canceled)(fees_collected) ) + diff --git a/libraries/chain/include/graphene/chain/block_database.hpp b/libraries/chain/include/graphene/chain/block_database.hpp index b3b040cc..2580e326 100644 --- a/libraries/chain/include/graphene/chain/block_database.hpp +++ b/libraries/chain/include/graphene/chain/block_database.hpp @@ -27,8 +27,6 @@ #include -#include - namespace graphene { namespace chain { struct index_entry; using namespace graphene::protocol; diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index b42604d2..f3c56ead 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -23,8 +23,6 @@ */ #pragma once -#include - #include #include #include @@ -34,19 +32,19 @@ #include #include #include -#include #include #include #include + +#include +#include +#include + #include #include -#include - -#include - #include #include @@ -64,6 +62,7 @@ namespace graphene { namespace chain { class force_settlement_object; class limit_order_object; class call_order_object; + class account_role_object; struct budget_record; diff --git a/libraries/chain/include/graphene/chain/event_object.hpp b/libraries/chain/include/graphene/chain/event_object.hpp index c00e3c6b..21b76a9f 100644 --- a/libraries/chain/include/graphene/chain/event_object.hpp +++ b/libraries/chain/include/graphene/chain/event_object.hpp @@ -164,4 +164,6 @@ typedef generic_index event_object_ MAP_OBJECT_ID_TO_TYPE(graphene::chain::event_object) -FC_REFLECT(graphene::chain::event_object, (name)(season)(start_time)(event_group_id)(at_least_one_betting_market_group_settled)(scores)) +FC_REFLECT_DERIVED(graphene::chain::event_object, (graphene::db::object), + (name)(season)(start_time)(event_group_id)(at_least_one_betting_market_group_settled)(scores)) + diff --git a/libraries/chain/include/graphene/chain/game_object.hpp b/libraries/chain/include/graphene/chain/game_object.hpp index 2a6f0b16..67a843bc 100644 --- a/libraries/chain/include/graphene/chain/game_object.hpp +++ b/libraries/chain/include/graphene/chain/game_object.hpp @@ -173,6 +173,6 @@ FC_REFLECT_ENUM(graphene::chain::game_state, (game_complete)) //FC_REFLECT_TYPENAME(graphene::chain::game_object) // manually serialized -FC_REFLECT(graphene::chain::game_object, (players)) +FC_REFLECT_DERIVED(graphene::chain::game_object, (graphene::db::object), (players)) diff --git a/libraries/chain/include/graphene/chain/get_config.hpp b/libraries/chain/include/graphene/chain/get_config.hpp index 4e49e688..adbdcee9 100644 --- a/libraries/chain/include/graphene/chain/get_config.hpp +++ b/libraries/chain/include/graphene/chain/get_config.hpp @@ -30,3 +30,4 @@ namespace graphene { namespace chain { fc::variant_object get_config(); } } // graphene::chain + diff --git a/libraries/chain/include/graphene/chain/global_property_object.hpp b/libraries/chain/include/graphene/chain/global_property_object.hpp index f203a964..a33e98dc 100644 --- a/libraries/chain/include/graphene/chain/global_property_object.hpp +++ b/libraries/chain/include/graphene/chain/global_property_object.hpp @@ -26,10 +26,12 @@ #include #include + #include -#include #include +#include + namespace graphene { namespace chain { /** diff --git a/libraries/chain/include/graphene/chain/match_object.hpp b/libraries/chain/include/graphene/chain/match_object.hpp index b7c73f59..07f5679e 100644 --- a/libraries/chain/include/graphene/chain/match_object.hpp +++ b/libraries/chain/include/graphene/chain/match_object.hpp @@ -172,5 +172,5 @@ FC_REFLECT_ENUM(graphene::chain::match_state, (match_complete)) //FC_REFLECT_TYPENAME(graphene::chain::match_object) // manually serialized -FC_REFLECT(graphene::chain::match_object, (players)) +FC_REFLECT_DERIVED(graphene::chain::match_object, (graphene::db::object), (players)) diff --git a/libraries/chain/include/graphene/chain/offer_evaluator.hpp b/libraries/chain/include/graphene/chain/offer_evaluator.hpp index 2ee42b17..5d779cd6 100644 --- a/libraries/chain/include/graphene/chain/offer_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/offer_evaluator.hpp @@ -3,7 +3,6 @@ #include - namespace graphene { namespace chain diff --git a/libraries/chain/include/graphene/chain/operation_history_object.hpp b/libraries/chain/include/graphene/chain/operation_history_object.hpp index 4fcb398d..b4538c60 100644 --- a/libraries/chain/include/graphene/chain/operation_history_object.hpp +++ b/libraries/chain/include/graphene/chain/operation_history_object.hpp @@ -100,7 +100,7 @@ class account_transaction_history_object : public abstract_object -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#define GRAPHENE_EXTERNAL_SERIALIZATION(ext, type) \ -namespace fc { \ - ext template void from_variant( const variant& v, type& vo, uint32_t max_depth ); \ - ext template void to_variant( const type& v, variant& vo, uint32_t max_depth ); \ -namespace raw { \ - ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ - ext template void pack< datastream, type >( datastream& s, const type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ - ext template void unpack< datastream, type >( datastream& s, type& tx, uint32_t _max_depth=FC_PACK_MAX_DEPTH ); \ -} } // fc::raw - -#define FC_REFLECT_DERIVED_NO_TYPENAME( TYPE, INHERITS, MEMBERS ) \ -namespace fc { \ -template<> struct reflector {\ - typedef TYPE type; \ - typedef fc::true_type is_defined; \ - typedef fc::false_type is_enum; \ - enum member_count_enum { \ - local_member_count = 0 BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_MEMBER_COUNT, +, MEMBERS ),\ - total_member_count = local_member_count BOOST_PP_SEQ_FOR_EACH( FC_REFLECT_BASE_MEMBER_COUNT, +, INHERITS )\ - }; \ - FC_REFLECT_DERIVED_IMPL_INLINE( TYPE, INHERITS, MEMBERS ) \ -}; \ -} // fc - - -namespace graphene { namespace chain { - using namespace graphene::db; - - using std::map; - using std::vector; - using std::unordered_map; - using std::string; - using std::deque; - using std::shared_ptr; - using std::weak_ptr; - using std::unique_ptr; - using std::set; - using std::pair; - using std::enable_shared_from_this; - using std::tie; - using std::make_pair; - - using fc::smart_ref; - using fc::variant_object; - using fc::variant; - using fc::enum_type; - using fc::optional; - using fc::unsigned_int; - using fc::signed_int; - using fc::time_point_sec; - using fc::time_point; - using fc::safe; - using fc::flat_map; - using fc::flat_set; - using fc::static_variant; - using fc::ecc::range_proof_type; - using fc::ecc::range_proof_info; - using fc::ecc::commitment_type; - struct void_t{}; - - typedef fc::ecc::private_key private_key_type; - typedef fc::sha256 chain_id_type; - - enum asset_issuer_permission_flags - { - charge_market_fee = 0x01, /**< an issuer-specified percentage of all market trades in this asset is paid to the issuer */ - white_list = 0x02, /**< accounts must be whitelisted in order to hold this asset */ - override_authority = 0x04, /**< issuer may transfer asset back to himself */ - transfer_restricted = 0x08, /**< require the issuer to be one party to every transfer */ - disable_force_settle = 0x10, /**< disable force settling */ - global_settle = 0x20, /**< allow the bitasset issuer to force a global settling -- this may be set in permissions, but not flags */ - disable_confidential = 0x40, /**< allow the asset to be used with confidential transactions */ - witness_fed_asset = 0x80, /**< allow the asset to be fed by witnesses */ - committee_fed_asset = 0x100 /**< allow the asset to be fed by the committee */ - }; - const static uint32_t ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_force_settle|global_settle|disable_confidential - |witness_fed_asset|committee_fed_asset; - const static uint32_t UIA_ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_confidential; - - enum reserved_spaces - { - relative_protocol_ids = 0, - protocol_ids = 1, - implementation_ids = 2 - }; - - inline bool is_relative( object_id_type o ){ return o.space() == 0; } - - /** - * List all object types from all namespaces here so they can - * be easily reflected and displayed in debug output. If a 3rd party - * wants to extend the core code then they will have to change the - * packed_object::type field from enum_type to uint16 to avoid - * warnings when converting packed_objects to/from json. - */ - enum object_type - { - null_object_type, - base_object_type, - account_object_type, - asset_object_type, - force_settlement_object_type, - committee_member_object_type, - witness_object_type, - limit_order_object_type, - call_order_object_type, - custom_object_type, - proposal_object_type, - operation_history_object_type, - withdraw_permission_object_type, - vesting_balance_object_type, - worker_object_type, - balance_object_type, - tournament_object_type, - tournament_details_object_type, - match_object_type, - game_object_type, - sport_object_type, - event_group_object_type, - event_object_type, - betting_market_rules_object_type, - betting_market_group_object_type, - betting_market_object_type, - bet_object_type, - custom_permission_object_type, - custom_account_authority_object_type, - offer_object_type, - nft_metadata_type, - nft_object_type, - account_role_type, - son_object_type, - son_proposal_object_type, - son_wallet_object_type, - son_wallet_deposit_object_type, - son_wallet_withdraw_object_type, - sidechain_address_object_type, - sidechain_transaction_object_type, - OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types - }; - - enum impl_object_type - { - impl_global_property_object_type, - impl_dynamic_global_property_object_type, - impl_reserved0_object_type, // formerly index_meta_object_type, TODO: delete me - impl_asset_dynamic_data_type, - impl_asset_bitasset_data_type, - impl_account_balance_object_type, - impl_account_statistics_object_type, - impl_transaction_object_type, - impl_block_summary_object_type, - impl_account_transaction_history_object_type, - impl_blinded_balance_object_type, - impl_chain_property_object_type, - impl_witness_schedule_object_type, - impl_budget_record_object_type, - impl_special_authority_object_type, - impl_buyback_object_type, - impl_fba_accumulator_object_type, - impl_asset_dividend_data_type, - impl_pending_dividend_payout_balance_for_holder_object_type, - impl_distributed_dividend_balance_data_type, - impl_betting_market_position_object_type, - impl_global_betting_statistics_object_type, - impl_lottery_balance_object_type, - impl_sweeps_vesting_balance_object_type, - impl_offer_history_object_type, - impl_son_statistics_object_type, - impl_son_schedule_object_type - }; - - //typedef fc::unsigned_int object_id_type; - //typedef uint64_t object_id_type; - class account_object; - class committee_member_object; - class witness_object; - class asset_object; - class force_settlement_object; - class limit_order_object; - class call_order_object; - class custom_object; - class proposal_object; - class operation_history_object; - class withdraw_permission_object; - class vesting_balance_object; - class worker_object; - class balance_object; - class blinded_balance_object; - class tournament_object; - class tournament_details_object; - class match_object; - class game_object; - class sport_object; - class event_group_object; - class event_object; - class betting_market_rules_object; - class betting_market_group_object; - class betting_market_object; - class bet_object; - class custom_permission_object; - class custom_account_authority_object; - class offer_object; - class nft_metadata_object; - class nft_object; - class account_role_object; - class son_object; - class son_proposal_object; - class son_wallet_object; - class son_wallet_deposit_object; - class son_wallet_withdraw_object; - class sidechain_address_object; - class sidechain_transaction_object; - - typedef object_id< protocol_ids, account_object_type, account_object> account_id_type; - typedef object_id< protocol_ids, asset_object_type, asset_object> asset_id_type; - typedef object_id< protocol_ids, force_settlement_object_type, force_settlement_object> force_settlement_id_type; - typedef object_id< protocol_ids, committee_member_object_type, committee_member_object> committee_member_id_type; - typedef object_id< protocol_ids, witness_object_type, witness_object> witness_id_type; - typedef object_id< protocol_ids, limit_order_object_type, limit_order_object> limit_order_id_type; - typedef object_id< protocol_ids, call_order_object_type, call_order_object> call_order_id_type; - typedef object_id< protocol_ids, custom_object_type, custom_object> custom_id_type; - typedef object_id< protocol_ids, proposal_object_type, proposal_object> proposal_id_type; - typedef object_id< protocol_ids, operation_history_object_type, operation_history_object> operation_history_id_type; - typedef object_id< protocol_ids, withdraw_permission_object_type,withdraw_permission_object> withdraw_permission_id_type; - typedef object_id< protocol_ids, vesting_balance_object_type, vesting_balance_object> vesting_balance_id_type; - typedef object_id< protocol_ids, worker_object_type, worker_object> worker_id_type; - typedef object_id< protocol_ids, balance_object_type, balance_object> balance_id_type; - typedef object_id< protocol_ids, tournament_object_type, tournament_object> tournament_id_type; - typedef object_id< protocol_ids, tournament_details_object_type, tournament_details_object> tournament_details_id_type; - typedef object_id< protocol_ids, match_object_type, match_object> match_id_type; - typedef object_id< protocol_ids, game_object_type, game_object> game_id_type; - typedef object_id< protocol_ids, sport_object_type, sport_object> sport_id_type; - typedef object_id< protocol_ids, event_group_object_type, event_group_object> event_group_id_type; - typedef object_id< protocol_ids, event_object_type, event_object> event_id_type; - typedef object_id< protocol_ids, betting_market_rules_object_type, betting_market_rules_object> betting_market_rules_id_type; - typedef object_id< protocol_ids, betting_market_group_object_type, betting_market_group_object> betting_market_group_id_type; - typedef object_id< protocol_ids, betting_market_object_type, betting_market_object> betting_market_id_type; - typedef object_id< protocol_ids, bet_object_type, bet_object> bet_id_type; - typedef object_id< protocol_ids, custom_permission_object_type, custom_permission_object> custom_permission_id_type; - typedef object_id< protocol_ids, custom_account_authority_object_type, custom_account_authority_object> custom_account_authority_id_type; - typedef object_id< protocol_ids, offer_object_type, offer_object> offer_id_type; - typedef object_id< protocol_ids, nft_metadata_type, nft_metadata_object> nft_metadata_id_type; - typedef object_id< protocol_ids, nft_object_type, nft_object> nft_id_type; - typedef object_id< protocol_ids, account_role_type, account_role_object> account_role_id_type; - typedef object_id< protocol_ids, son_object_type, son_object> son_id_type; - typedef object_id< protocol_ids, son_proposal_object_type, son_proposal_object> son_proposal_id_type; - typedef object_id< protocol_ids, son_wallet_object_type, son_wallet_object> son_wallet_id_type; - typedef object_id< protocol_ids, son_wallet_deposit_object_type, son_wallet_deposit_object> son_wallet_deposit_id_type; - typedef object_id< protocol_ids, son_wallet_withdraw_object_type, son_wallet_withdraw_object> son_wallet_withdraw_id_type; - typedef object_id< protocol_ids, sidechain_address_object_type, sidechain_address_object> sidechain_address_id_type; - typedef object_id< protocol_ids, sidechain_transaction_object_type,sidechain_transaction_object> sidechain_transaction_id_type; - - // implementation types - class global_property_object; - class dynamic_global_property_object; - class asset_dynamic_data_object; - class asset_bitasset_data_object; - class account_balance_object; - class account_statistics_object; - class transaction_object; - class block_summary_object; - class account_transaction_history_object; - class chain_property_object; - class witness_schedule_object; - class budget_record_object; - class special_authority_object; - class buyback_object; - class fba_accumulator_object; - class asset_dividend_data_object; - class pending_dividend_payout_balance_for_holder_object; - class betting_market_position_object; - class global_betting_statistics_object; - class lottery_balance_object; - class sweeps_vesting_balance_object; - class offer_history_object; - class son_statistics_object; - class son_schedule_object; - - typedef object_id< implementation_ids, impl_global_property_object_type, global_property_object> global_property_id_type; - typedef object_id< implementation_ids, impl_dynamic_global_property_object_type, dynamic_global_property_object> dynamic_global_property_id_type; - typedef object_id< implementation_ids, impl_asset_dynamic_data_type, asset_dynamic_data_object> asset_dynamic_data_id_type; - typedef object_id< implementation_ids, impl_asset_bitasset_data_type, asset_bitasset_data_object> asset_bitasset_data_id_type; - typedef object_id< implementation_ids, impl_asset_dividend_data_type, asset_dividend_data_object> asset_dividend_data_id_type; - typedef object_id< implementation_ids, - impl_pending_dividend_payout_balance_for_holder_object_type, - pending_dividend_payout_balance_for_holder_object> pending_dividend_payout_balance_for_holder_object_type; - typedef object_id< implementation_ids, impl_account_balance_object_type, account_balance_object> account_balance_id_type; - typedef object_id< implementation_ids, impl_account_statistics_object_type, account_statistics_object> account_statistics_id_type; - typedef object_id< implementation_ids, impl_transaction_object_type, transaction_object> transaction_obj_id_type; - typedef object_id< implementation_ids, impl_block_summary_object_type, block_summary_object> block_summary_id_type; - - typedef object_id< implementation_ids, - impl_account_transaction_history_object_type, - account_transaction_history_object> account_transaction_history_id_type; - typedef object_id< implementation_ids, impl_chain_property_object_type, chain_property_object> chain_property_id_type; - typedef object_id< implementation_ids, impl_witness_schedule_object_type, witness_schedule_object> witness_schedule_id_type; - typedef object_id< implementation_ids, impl_budget_record_object_type, budget_record_object > budget_record_id_type; - typedef object_id< implementation_ids, impl_blinded_balance_object_type, blinded_balance_object > blinded_balance_id_type; - typedef object_id< implementation_ids, impl_special_authority_object_type, special_authority_object > special_authority_id_type; - typedef object_id< implementation_ids, impl_buyback_object_type, buyback_object > buyback_id_type; - typedef object_id< implementation_ids, impl_fba_accumulator_object_type, fba_accumulator_object > fba_accumulator_id_type; - typedef object_id< implementation_ids, impl_betting_market_position_object_type, betting_market_position_object > betting_market_position_id_type; - typedef object_id< implementation_ids, impl_global_betting_statistics_object_type, global_betting_statistics_object > global_betting_statistics_id_type; - typedef object_id< implementation_ids, impl_lottery_balance_object_type, lottery_balance_object > lottery_balance_id_type; - typedef object_id< implementation_ids, impl_sweeps_vesting_balance_object_type, sweeps_vesting_balance_object> sweeps_vesting_balance_id_type; - typedef object_id< implementation_ids, impl_offer_history_object_type, offer_history_object> offer_history_id_type; - typedef object_id< implementation_ids, impl_son_statistics_object_type, son_statistics_object > son_statistics_id_type; - typedef object_id< implementation_ids, impl_son_schedule_object_type, son_schedule_object> son_schedule_id_type; - - typedef fc::array symbol_type; - typedef fc::ripemd160 block_id_type; - typedef fc::ripemd160 checksum_type; - typedef fc::ripemd160 transaction_id_type; - typedef fc::sha256 digest_type; - typedef fc::ecc::compact_signature signature_type; - typedef safe share_type; - typedef fc::ripemd160 secret_hash_type; - typedef uint16_t weight_type; - - struct public_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::public_key_data data; - }; - fc::ecc::public_key_data key_data; - public_key_type(); - public_key_type( const fc::ecc::public_key_data& data ); - public_key_type( const fc::ecc::public_key& pubkey ); - explicit public_key_type( const std::string& base58str ); - operator fc::ecc::public_key_data() const; - operator fc::ecc::public_key() const; - explicit operator std::string() const; - friend bool operator == ( const public_key_type& p1, const fc::ecc::public_key& p2); - friend bool operator == ( const public_key_type& p1, const public_key_type& p2); - friend bool operator != ( const public_key_type& p1, const public_key_type& p2); - // TODO: This is temporary for testing - bool is_valid_v1( const std::string& base58str ); - bool is_valid_muse( const std::string& base58str ); - }; - - struct extended_public_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::extended_key_data data; - }; - - fc::ecc::extended_key_data key_data; - - extended_public_key_type(); - extended_public_key_type( const fc::ecc::extended_key_data& data ); - extended_public_key_type( const fc::ecc::extended_public_key& extpubkey ); - explicit extended_public_key_type( const std::string& base58str ); - operator fc::ecc::extended_public_key() const; - explicit operator std::string() const; - friend bool operator == ( const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2); - friend bool operator == ( const extended_public_key_type& p1, const extended_public_key_type& p2); - friend bool operator != ( const extended_public_key_type& p1, const extended_public_key_type& p2); - }; - - struct extended_private_key_type - { - struct binary_key - { - binary_key() {} - uint32_t check = 0; - fc::ecc::extended_key_data data; - }; - - fc::ecc::extended_key_data key_data; - - extended_private_key_type(); - extended_private_key_type( const fc::ecc::extended_key_data& data ); - extended_private_key_type( const fc::ecc::extended_private_key& extprivkey ); - explicit extended_private_key_type( const std::string& base58str ); - operator fc::ecc::extended_private_key() const; - explicit operator std::string() const; - friend bool operator == ( const extended_private_key_type& p1, const fc::ecc::extended_private_key& p2); - friend bool operator == ( const extended_private_key_type& p1, const extended_private_key_type& p2); - friend bool operator != ( const extended_private_key_type& p1, const extended_private_key_type& p2); - }; - - typedef flat_map internationalized_string_type; - - typedef uint32_t bet_multiplier_type; -} } // graphene::chain - -namespace fc -{ - void to_variant( const graphene::chain::public_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::public_key_type& vo, uint32_t max_depth = 2 ); - void to_variant( const graphene::chain::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::extended_public_key_type& vo, uint32_t max_depth = 2 ); - void to_variant( const graphene::chain::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth = 2 ); - void from_variant( const fc::variant& var, graphene::chain::extended_private_key_type& vo, uint32_t max_depth = 2 ); -} - -FC_REFLECT( graphene::chain::public_key_type, (key_data) ) -FC_REFLECT( graphene::chain::public_key_type::binary_key, (data)(check) ) -FC_REFLECT( graphene::chain::extended_public_key_type, (key_data) ) -FC_REFLECT( graphene::chain::extended_public_key_type::binary_key, (check)(data) ) -FC_REFLECT( graphene::chain::extended_private_key_type, (key_data) ) -FC_REFLECT( graphene::chain::extended_private_key_type::binary_key, (check)(data) ) - -FC_REFLECT_ENUM( graphene::chain::object_type, - (null_object_type) - (base_object_type) - (account_object_type) - (force_settlement_object_type) - (asset_object_type) - (committee_member_object_type) - (witness_object_type) - (limit_order_object_type) - (call_order_object_type) - (custom_object_type) - (proposal_object_type) - (operation_history_object_type) - (withdraw_permission_object_type) - (vesting_balance_object_type) - (worker_object_type) - (balance_object_type) - (tournament_object_type) - (tournament_details_object_type) - (match_object_type) - (game_object_type) - (sport_object_type) - (event_group_object_type) - (event_object_type) - (betting_market_rules_object_type) - (betting_market_group_object_type) - (betting_market_object_type) - (bet_object_type) - (custom_permission_object_type) - (custom_account_authority_object_type) - (offer_object_type) - (nft_metadata_type) - (nft_object_type) - (account_role_type) - (son_object_type) - (son_proposal_object_type) - (son_wallet_object_type) - (son_wallet_deposit_object_type) - (son_wallet_withdraw_object_type) - (sidechain_address_object_type) - (sidechain_transaction_object_type) - (OBJECT_TYPE_COUNT) - ) -FC_REFLECT_ENUM( graphene::chain::impl_object_type, - (impl_global_property_object_type) - (impl_dynamic_global_property_object_type) - (impl_reserved0_object_type) - (impl_asset_dynamic_data_type) - (impl_asset_bitasset_data_type) - (impl_account_balance_object_type) - (impl_account_statistics_object_type) - (impl_transaction_object_type) - (impl_block_summary_object_type) - (impl_account_transaction_history_object_type) - (impl_blinded_balance_object_type) - (impl_chain_property_object_type) - (impl_witness_schedule_object_type) - (impl_budget_record_object_type) - (impl_special_authority_object_type) - (impl_buyback_object_type) - (impl_fba_accumulator_object_type) - (impl_asset_dividend_data_type) - (impl_pending_dividend_payout_balance_for_holder_object_type) - (impl_distributed_dividend_balance_data_type) - (impl_betting_market_position_object_type) - (impl_global_betting_statistics_object_type) - (impl_lottery_balance_object_type) - (impl_sweeps_vesting_balance_object_type) - (impl_offer_history_object_type) - (impl_son_statistics_object_type) - (impl_son_schedule_object_type) - ) - -FC_REFLECT_TYPENAME( graphene::chain::share_type ) - -FC_REFLECT_TYPENAME( graphene::chain::account_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::force_settlement_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::committee_member_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::witness_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::limit_order_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::call_order_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::proposal_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::operation_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::withdraw_permission_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::vesting_balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::worker_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::sport_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::event_group_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::event_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_rules_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_group_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::bet_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::tournament_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::offer_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::global_property_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::dynamic_global_property_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_dynamic_data_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::asset_bitasset_data_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_balance_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_statistics_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::transaction_obj_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::block_summary_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_transaction_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::budget_record_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::special_authority_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::buyback_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::fba_accumulator_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::betting_market_position_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::global_betting_statistics_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::tournament_details_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_permission_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::custom_account_authority_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::offer_history_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::nft_metadata_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::nft_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::account_role_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_proposal_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_wallet_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_wallet_deposit_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::son_wallet_withdraw_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::sidechain_address_id_type ) -FC_REFLECT_TYPENAME( graphene::chain::sidechain_transaction_id_type ) - - -FC_REFLECT( graphene::chain::void_t, ) - -FC_REFLECT_ENUM( graphene::chain::asset_issuer_permission_flags, - (charge_market_fee) - (white_list) - (transfer_restricted) - (override_authority) - (disable_force_settle) - (global_settle) - (disable_confidential) - (witness_fed_asset) - (committee_fed_asset) - ) diff --git a/libraries/chain/include/graphene/chain/sidechain_address_evaluator.hpp b/libraries/chain/include/graphene/chain/sidechain_address_evaluator.hpp index 5da9d44a..1ff564b6 100644 --- a/libraries/chain/include/graphene/chain/sidechain_address_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/sidechain_address_evaluator.hpp @@ -1,5 +1,6 @@ #pragma once #include + #include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/sidechain_address_object.hpp b/libraries/chain/include/graphene/chain/sidechain_address_object.hpp index b9646c52..6e58c8c6 100644 --- a/libraries/chain/include/graphene/chain/sidechain_address_object.hpp +++ b/libraries/chain/include/graphene/chain/sidechain_address_object.hpp @@ -1,9 +1,10 @@ #pragma once -#include #include #include +#include #include + #include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/sidechain_defs.hpp b/libraries/chain/include/graphene/chain/sidechain_defs.hpp deleted file mode 100644 index 6bbc8b5c..00000000 --- a/libraries/chain/include/graphene/chain/sidechain_defs.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include - -namespace graphene { namespace chain { - -enum class sidechain_type { - unknown, - bitcoin, - ethereum, - eos, - peerplays -}; - -} } - -FC_REFLECT_ENUM(graphene::chain::sidechain_type, - (unknown) - (bitcoin) - (ethereum) - (eos) - (peerplays) ) diff --git a/libraries/chain/include/graphene/chain/sidechain_transaction_evaluator.hpp b/libraries/chain/include/graphene/chain/sidechain_transaction_evaluator.hpp index dabd2b94..66b817e9 100644 --- a/libraries/chain/include/graphene/chain/sidechain_transaction_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/sidechain_transaction_evaluator.hpp @@ -1,5 +1,6 @@ #pragma once #include + #include namespace graphene { namespace chain { diff --git a/libraries/chain/include/graphene/chain/sidechain_transaction_object.hpp b/libraries/chain/include/graphene/chain/sidechain_transaction_object.hpp index 0f01e689..9a0837bc 100644 --- a/libraries/chain/include/graphene/chain/sidechain_transaction_object.hpp +++ b/libraries/chain/include/graphene/chain/sidechain_transaction_object.hpp @@ -1,9 +1,10 @@ #pragma once -#include #include #include #include +#include + namespace graphene { namespace chain { using namespace graphene::db; using namespace graphene::protocol; @@ -70,6 +71,8 @@ FC_REFLECT_ENUM( graphene::chain::sidechain_transaction_status, (sent) (settled) ) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::sidechain_transaction_object) + FC_REFLECT_DERIVED( graphene::chain::sidechain_transaction_object, (graphene::db::object ), (sidechain) (object_id) diff --git a/libraries/chain/include/graphene/chain/son_evaluator.hpp b/libraries/chain/include/graphene/chain/son_evaluator.hpp index 1e5c239f..9ac66e49 100644 --- a/libraries/chain/include/graphene/chain/son_evaluator.hpp +++ b/libraries/chain/include/graphene/chain/son_evaluator.hpp @@ -1,7 +1,8 @@ #pragma once -#include #include +#include + namespace graphene { namespace chain { class create_son_evaluator : public evaluator diff --git a/libraries/chain/include/graphene/chain/son_info.hpp b/libraries/chain/include/graphene/chain/son_info.hpp deleted file mode 100644 index 2bfecac4..00000000 --- a/libraries/chain/include/graphene/chain/son_info.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once -#include -#include - -namespace graphene { namespace chain { - using namespace graphene::db; - - /** - * @class son_info - * @brief tracks information about a SON info required to re/create primary wallet - * @ingroup object - */ - struct son_info { - son_id_type son_id; - weight_type weight = 0; - public_key_type signing_key; - flat_map sidechain_public_keys; - - bool operator==(const son_info& rhs) { - bool son_sets_equal = - (son_id == rhs.son_id) && - (weight == rhs.weight) && - (signing_key == rhs.signing_key) && - (sidechain_public_keys.size() == rhs.sidechain_public_keys.size()); - - if (son_sets_equal) { - bool sidechain_public_keys_equal = true; - for (size_t i = 0; i < sidechain_public_keys.size(); i++) { - const auto lhs_scpk = sidechain_public_keys.nth(i); - const auto rhs_scpk = rhs.sidechain_public_keys.nth(i); - sidechain_public_keys_equal = sidechain_public_keys_equal && - (lhs_scpk->first == rhs_scpk->first) && - (lhs_scpk->second == rhs_scpk->second); - } - son_sets_equal = son_sets_equal && sidechain_public_keys_equal; - } - return son_sets_equal; - } - }; - -} } - -FC_REFLECT( graphene::chain::son_info, - (son_id) - (weight) - (signing_key) - (sidechain_public_keys) ) diff --git a/libraries/chain/include/graphene/chain/son_object.hpp b/libraries/chain/include/graphene/chain/son_object.hpp index c3dc39be..bc69eb28 100644 --- a/libraries/chain/include/graphene/chain/son_object.hpp +++ b/libraries/chain/include/graphene/chain/son_object.hpp @@ -1,7 +1,8 @@ #pragma once -#include #include #include + +#include #include namespace graphene { namespace chain { @@ -112,8 +113,8 @@ namespace graphene { namespace chain { } } // graphene::chain -MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_statistics_object) MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_object) +MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_statistics_object) FC_REFLECT_ENUM(graphene::chain::son_status, (inactive)(active)(request_maintenance)(in_maintenance)(deregistered) ) diff --git a/libraries/chain/include/graphene/chain/son_proposal_object.hpp b/libraries/chain/include/graphene/chain/son_proposal_object.hpp index 529f2e2f..92ecf4a5 100644 --- a/libraries/chain/include/graphene/chain/son_proposal_object.hpp +++ b/libraries/chain/include/graphene/chain/son_proposal_object.hpp @@ -1,9 +1,10 @@ #pragma once -#include #include #include +#include + namespace graphene { namespace chain { enum class son_proposal_type @@ -37,6 +38,8 @@ using son_proposal_index = generic_index; } } // graphene::chain +MAP_OBJECT_ID_TO_TYPE(graphene::chain::son_wallet_object) + FC_REFLECT_DERIVED( graphene::chain::son_wallet_object, (graphene::db::object), (valid_from) (expires) (addresses) (sons) ) diff --git a/libraries/chain/include/graphene/chain/tournament_object.hpp b/libraries/chain/include/graphene/chain/tournament_object.hpp index b6ef883e..9f2e5860 100644 --- a/libraries/chain/include/graphene/chain/tournament_object.hpp +++ b/libraries/chain/include/graphene/chain/tournament_object.hpp @@ -251,7 +251,7 @@ FC_REFLECT_DERIVED(graphene::chain::tournament_details_object, (graphene::db::ob (players_payers) (matches)) //FC_REFLECT_TYPENAME(graphene::chain::tournament_object) // manually serialized -FC_REFLECT(graphene::chain::tournament_object, (creator)) +FC_REFLECT_DERIVED(graphene::chain::tournament_object, (graphene::db::object), (creator)) FC_REFLECT_ENUM(graphene::chain::tournament_state, (accepting_registrations) (awaiting_start) diff --git a/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp b/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp index c53c3733..c6daeaa4 100644 --- a/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp +++ b/libraries/chain/include/graphene/chain/transaction_evaluation_state.hpp @@ -22,6 +22,8 @@ * THE SOFTWARE. */ #pragma once +#include + #include namespace graphene { diff --git a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp index f831f05e..c60439b0 100644 --- a/libraries/chain/include/graphene/chain/vesting_balance_object.hpp +++ b/libraries/chain/include/graphene/chain/vesting_balance_object.hpp @@ -26,7 +26,6 @@ #include #include - #include #include diff --git a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp index 20c57c7b..3e6616ba 100644 --- a/libraries/chain/include/graphene/chain/witness_schedule_object.hpp +++ b/libraries/chain/include/graphene/chain/witness_schedule_object.hpp @@ -33,6 +33,13 @@ #include +#include + +#include +#include + +#include + namespace graphene { namespace chain { typedef hash_ctr_rng< @@ -103,7 +110,7 @@ class son_schedule_object : public graphene::db::abstract_object rng_seed; + std::array< char, sizeof(secret_hash_type) > rng_seed = {}; /** * Not necessary for consensus, but used for figuring out the participation rate. diff --git a/libraries/chain/index.cpp b/libraries/chain/index.cpp deleted file mode 100644 index 41a469b2..00000000 --- a/libraries/chain/index.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#include -#include -#include - -namespace graphene { namespace chain { - void base_primary_index::save_undo( const object& obj ) - { _db.save_undo( obj ); } - - void base_primary_index::on_add( const object& obj ) - { - _db.save_undo_add( obj ); - for( auto ob : _observers ) ob->on_add( obj ); - } - - void base_primary_index::on_remove( const object& obj ) - { _db.save_undo_remove( obj ); for( auto ob : _observers ) ob->on_remove( obj ); } - - void base_primary_index::on_modify( const object& obj ) - {for( auto ob : _observers ) ob->on_modify( obj ); } -} } // graphene::chain diff --git a/libraries/chain/nft_evaluator.cpp b/libraries/chain/nft_evaluator.cpp index 81fc2d95..81166e16 100644 --- a/libraries/chain/nft_evaluator.cpp +++ b/libraries/chain/nft_evaluator.cpp @@ -6,6 +6,8 @@ #include #include +#include + namespace graphene { namespace chain { void_result nft_metadata_create_evaluator::do_evaluate( const nft_metadata_create_operation& op ) diff --git a/libraries/chain/offer_evaluator.cpp b/libraries/chain/offer_evaluator.cpp index 01e05639..e4720611 100644 --- a/libraries/chain/offer_evaluator.cpp +++ b/libraries/chain/offer_evaluator.cpp @@ -2,11 +2,13 @@ #include #include #include -#include #include #include #include #include + +#include + #include namespace graphene @@ -94,7 +96,6 @@ namespace graphene auto now = d.head_block_time(); FC_ASSERT(now >= HARDFORK_NFT_TIME, "Not allowed until NFT HF"); const auto &offer = op.offer_id(d); - op.bidder(d); for (const auto &item : offer.item_ids) { const auto &nft_obj = item(d); diff --git a/libraries/chain/protocol/types.cpp b/libraries/chain/protocol/types.cpp deleted file mode 100644 index b7cac207..00000000 --- a/libraries/chain/protocol/types.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#include -#include - -#include -#include -#include -#include - -namespace graphene { namespace chain { - - public_key_type::public_key_type():key_data(){}; - - public_key_type::public_key_type( const fc::ecc::public_key_data& data ) - :key_data( data ) {}; - - public_key_type::public_key_type( const fc::ecc::public_key& pubkey ) - :key_data( pubkey ) {}; - - public_key_type::public_key_type( const std::string& base58str ) - { - // TODO: Refactor syntactic checks into static is_valid() - // to make public_key_type API more similar to address API - std::string prefix( GRAPHENE_ADDRESS_PREFIX ); - - // TODO: This is temporary for testing - try - { - if( is_valid_v1( base58str ) ) - prefix = std::string( "BTS" ); - } - catch( ... ) - { - } - - try - { - if( is_valid_muse( base58str ) ) - prefix = std::string( "MUSE" ); - } - catch( ... ) - { - } - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check ); - }; - - bool public_key_type::is_valid_muse( const std::string& base58str ) - { - std::string prefix( "MUSE" ); - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check ); - return true; - } - - // TODO: This is temporary for testing - bool public_key_type::is_valid_v1( const std::string& base58str ) - { - std::string prefix( "BTS" ); - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - fc::ecc::public_key_data key_data = bin_key.data; - FC_ASSERT( fc::ripemd160::hash( key_data.data, key_data.size() )._hash[0] == bin_key.check ); - return true; - } - - public_key_type::operator fc::ecc::public_key_data() const - { - return key_data; - }; - - public_key_type::operator fc::ecc::public_key() const - { - return fc::ecc::public_key( key_data ); - }; - - public_key_type::operator std::string() const - { - binary_key k; - k.data = key_data; - k.check = fc::ripemd160::hash( k.data.data, k.data.size() )._hash[0]; - auto data = fc::raw::pack( k ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); - } - - bool operator == ( const public_key_type& p1, const fc::ecc::public_key& p2) - { - return p1.key_data == p2.serialize(); - } - - bool operator == ( const public_key_type& p1, const public_key_type& p2) - { - return p1.key_data == p2.key_data; - } - - bool operator != ( const public_key_type& p1, const public_key_type& p2) - { - return p1.key_data != p2.key_data; - } - - // extended_public_key_type - - extended_public_key_type::extended_public_key_type():key_data(){}; - - extended_public_key_type::extended_public_key_type( const fc::ecc::extended_key_data& data ) - :key_data( data ){}; - - extended_public_key_type::extended_public_key_type( const fc::ecc::extended_public_key& extpubkey ) - { - key_data = extpubkey.serialize_extended(); - }; - - extended_public_key_type::extended_public_key_type( const std::string& base58str ) - { - std::string prefix( GRAPHENE_ADDRESS_PREFIX ); - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - FC_ASSERT( fc::ripemd160::hash( bin_key.data.data, bin_key.data.size() )._hash[0] == bin_key.check ); - key_data = bin_key.data; - } - - extended_public_key_type::operator fc::ecc::extended_public_key() const - { - return fc::ecc::extended_public_key::deserialize( key_data ); - } - - extended_public_key_type::operator std::string() const - { - binary_key k; - k.data = key_data; - k.check = fc::ripemd160::hash( k.data.data, k.data.size() )._hash[0]; - auto data = fc::raw::pack( k ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); - } - - bool operator == ( const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2) - { - return p1.key_data == p2.serialize_extended(); - } - - bool operator == ( const extended_public_key_type& p1, const extended_public_key_type& p2) - { - return p1.key_data == p2.key_data; - } - - bool operator != ( const extended_public_key_type& p1, const extended_public_key_type& p2) - { - return p1.key_data != p2.key_data; - } - - // extended_private_key_type - - extended_private_key_type::extended_private_key_type():key_data(){}; - - extended_private_key_type::extended_private_key_type( const fc::ecc::extended_key_data& data ) - :key_data( data ){}; - - extended_private_key_type::extended_private_key_type( const fc::ecc::extended_private_key& extprivkey ) - { - key_data = extprivkey.serialize_extended(); - }; - - extended_private_key_type::extended_private_key_type( const std::string& base58str ) - { - std::string prefix( GRAPHENE_ADDRESS_PREFIX ); - - const size_t prefix_len = prefix.size(); - FC_ASSERT( base58str.size() > prefix_len ); - FC_ASSERT( base58str.substr( 0, prefix_len ) == prefix , "", ("base58str", base58str) ); - auto bin = fc::from_base58( base58str.substr( prefix_len ) ); - auto bin_key = fc::raw::unpack(bin); - FC_ASSERT( fc::ripemd160::hash( bin_key.data.data, bin_key.data.size() )._hash[0] == bin_key.check ); - key_data = bin_key.data; - } - - extended_private_key_type::operator fc::ecc::extended_private_key() const - { - return fc::ecc::extended_private_key::deserialize( key_data ); - } - - extended_private_key_type::operator std::string() const - { - binary_key k; - k.data = key_data; - k.check = fc::ripemd160::hash( k.data.data, k.data.size() )._hash[0]; - auto data = fc::raw::pack( k ); - return GRAPHENE_ADDRESS_PREFIX + fc::to_base58( data.data(), data.size() ); - } - - bool operator == ( const extended_private_key_type& p1, const fc::ecc::extended_public_key& p2) - { - return p1.key_data == p2.serialize_extended(); - } - - bool operator == ( const extended_private_key_type& p1, const extended_private_key_type& p2) - { - return p1.key_data == p2.key_data; - } - - bool operator != ( const extended_private_key_type& p1, const extended_private_key_type& p2) - { - return p1.key_data != p2.key_data; - } - -} } // graphene::chain - -namespace fc -{ - using namespace std; - void to_variant( const graphene::chain::public_key_type& var, fc::variant& vo, uint32_t max_depth ) - { - vo = std::string( var ); - } - - void from_variant( const fc::variant& var, graphene::chain::public_key_type& vo, uint32_t max_depth ) - { - vo = graphene::chain::public_key_type( var.as_string() ); - } - - void to_variant( const graphene::chain::extended_public_key_type& var, fc::variant& vo, uint32_t max_depth ) - { - vo = std::string( var ); - } - - void from_variant( const fc::variant& var, graphene::chain::extended_public_key_type& vo, uint32_t max_depth ) - { - vo = graphene::chain::extended_public_key_type( var.as_string() ); - } - - void to_variant( const graphene::chain::extended_private_key_type& var, fc::variant& vo, uint32_t max_depth ) - { - vo = std::string( var ); - } - - void from_variant( const fc::variant& var, graphene::chain::extended_private_key_type& vo, uint32_t max_depth ) - { - vo = graphene::chain::extended_private_key_type( var.as_string() ); - } -} // fc diff --git a/libraries/db/include/graphene/db/object.hpp b/libraries/db/include/graphene/db/object.hpp index 3b8be32b..2c0f2adc 100644 --- a/libraries/db/include/graphene/db/object.hpp +++ b/libraries/db/include/graphene/db/object.hpp @@ -29,8 +29,6 @@ #define MAX_NESTING (200) -#define MAX_NESTING (200) - namespace graphene { namespace db { /** diff --git a/libraries/db/include/graphene/db/object_database.hpp b/libraries/db/include/graphene/db/object_database.hpp index 3a4315c1..d51249e1 100644 --- a/libraries/db/include/graphene/db/object_database.hpp +++ b/libraries/db/include/graphene/db/object_database.hpp @@ -143,6 +143,12 @@ namespace graphene { namespace db { return static_cast(_index[ObjectType::space_id][ObjectType::type_id].get()); } + template + SecondaryIndexType* add_secondary_index() + { + return get_mutable_index_type().template add_secondary_index(); + } + void pop_undo(); fc::path get_data_dir()const { return _data_dir; } diff --git a/libraries/egenesis/CMakeLists.txt b/libraries/egenesis/CMakeLists.txt index 68de4b00..225850d8 100644 --- a/libraries/egenesis/CMakeLists.txt +++ b/libraries/egenesis/CMakeLists.txt @@ -57,3 +57,5 @@ INSTALL( TARGETS LIBRARY DESTINATION lib ARCHIVE DESTINATION lib ) +file(GLOB HEADERS "include/graphene/egenesis/*.hpp") +INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/egenesis" ) diff --git a/libraries/fc b/libraries/fc index 69ebbf4b..21418ec4 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 69ebbf4ba490482956de0e331b22f1018747d789 +Subproject commit 21418ec46e7e9bb40f77b2312761976d909722ec diff --git a/libraries/net/CMakeLists.txt b/libraries/net/CMakeLists.txt index 202a792d..806864af 100644 --- a/libraries/net/CMakeLists.txt +++ b/libraries/net/CMakeLists.txt @@ -11,9 +11,9 @@ set(SOURCES node.cpp add_library( graphene_net ${SOURCES} ${HEADERS} ) -target_link_libraries( graphene_net +target_link_libraries( graphene_net PUBLIC fc graphene_db graphene_protocol ) -target_include_directories( graphene_net +target_include_directories( graphene_net PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../chain/include" "${CMAKE_CURRENT_BINARY_DIR}/../chain/include" ) diff --git a/libraries/net/account_role.cpp b/libraries/net/account_role.cpp deleted file mode 100644 index 1d71d6cc..00000000 --- a/libraries/net/account_role.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include - -namespace graphene -{ - namespace chain - { - - void account_role_create_operation::validate() const - { - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(allowed_operations.size() > 0, "Allowed operations should be positive"); - FC_ASSERT(whitelisted_accounts.size() > 0, "Whitelisted accounts should be positive"); - } - - void account_role_update_operation::validate() const - { - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - for (auto aop : allowed_operations_to_add) - { - FC_ASSERT(aop >= 0 && aop < operation::count(), "operation_type is not valid"); - FC_ASSERT(allowed_operations_to_remove.find(aop) == allowed_operations_to_remove.end(), - "Cannot add and remove allowed operation at the same time."); - } - for (auto aop : allowed_operations_to_remove) - { - FC_ASSERT(aop >= 0 && aop < operation::count(), "operation_type is not valid"); - FC_ASSERT(allowed_operations_to_add.find(aop) == allowed_operations_to_add.end(), - "Cannot add and remove allowed operation at the same time."); - } - - for (auto acc : accounts_to_add) - { - FC_ASSERT(accounts_to_remove.find(acc) == accounts_to_remove.end(), - "Cannot add and remove accounts at the same time."); - } - - for (auto acc : accounts_to_remove) - { - FC_ASSERT(accounts_to_add.find(acc) == accounts_to_add.end(), - "Cannot add and remove accounts at the same time."); - } - } - - void account_role_delete_operation::validate() const - { - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - } - - share_type account_role_create_operation::calculate_fee(const fee_parameters_type &k) const - { - return k.fee + calculate_data_fee(fc::raw::pack_size(*this), k.price_per_kbyte); - } - - share_type account_role_update_operation::calculate_fee(const fee_parameters_type &k) const - { - return k.fee + calculate_data_fee(fc::raw::pack_size(*this), k.price_per_kbyte); - } - - } // namespace chain -} // namespace graphene diff --git a/libraries/net/chain_parameters.cpp b/libraries/net/chain_parameters.cpp deleted file mode 100644 index a904b0e3..00000000 --- a/libraries/net/chain_parameters.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include - -namespace graphene { namespace chain { - chain_parameters::chain_parameters() { - current_fees = std::make_shared(); - } - - // copy constructor - chain_parameters::chain_parameters(const chain_parameters& other) - { - current_fees = std::make_shared(*other.current_fees); - safe_copy(*this, other); - } - - // copy assignment - chain_parameters& chain_parameters::operator=(const chain_parameters& other) - { - if (&other != this) - { - current_fees = std::make_shared(*other.current_fees); - safe_copy(*this, other); - } - return *this; - } - - // copies the easy stuff - void chain_parameters::safe_copy(chain_parameters& to, const chain_parameters& from) - { - to.block_interval = from.block_interval; - to.maintenance_interval = from.maintenance_interval; - to.maintenance_skip_slots = from.maintenance_skip_slots; - to.committee_proposal_review_period = from.committee_proposal_review_period; - to.maximum_transaction_size = from.maximum_transaction_size; - to.maximum_block_size = from.maximum_block_size; - to.maximum_time_until_expiration = from.maximum_time_until_expiration; - to.maximum_proposal_lifetime = from.maximum_proposal_lifetime; - to.maximum_asset_whitelist_authorities = from.maximum_asset_whitelist_authorities; - to.maximum_asset_feed_publishers = from.maximum_asset_feed_publishers; - to.maximum_witness_count = from.maximum_witness_count; - to.maximum_committee_count = from.maximum_committee_count; - to.maximum_authority_membership = from.maximum_authority_membership; - to.reserve_percent_of_fee = from.reserve_percent_of_fee; - to.network_percent_of_fee = from.network_percent_of_fee; - to.lifetime_referrer_percent_of_fee = from.lifetime_referrer_percent_of_fee; - to.cashback_vesting_period_seconds = from.cashback_vesting_period_seconds; - to.cashback_vesting_threshold = from.cashback_vesting_threshold; - to.count_non_member_votes = from.count_non_member_votes; - to.allow_non_member_whitelists = from.allow_non_member_whitelists; - to.witness_pay_per_block = from.witness_pay_per_block; - to.witness_pay_vesting_seconds = from.witness_pay_vesting_seconds; - to.worker_budget_per_day = from.worker_budget_per_day; - to.max_predicate_opcode = from.max_predicate_opcode; - to.fee_liquidation_threshold = from.fee_liquidation_threshold; - to.accounts_per_fee_scale = from.accounts_per_fee_scale; - to.account_fee_scale_bitshifts = from.account_fee_scale_bitshifts; - to.max_authority_depth = from.max_authority_depth; - to.witness_schedule_algorithm= from.witness_schedule_algorithm; - to.min_round_delay = from.min_round_delay; - to.max_round_delay = from.max_round_delay; - to.min_time_per_commit_move = from.min_time_per_commit_move; - to.max_time_per_commit_move = from.max_time_per_commit_move; - to.min_time_per_reveal_move = from.min_time_per_reveal_move; - to.max_time_per_reveal_move = from.max_time_per_reveal_move; - to.rake_fee_percentage = from.rake_fee_percentage; - to.maximum_registration_deadline = from.maximum_registration_deadline; - to.maximum_players_in_tournament = from.maximum_players_in_tournament; - to.maximum_tournament_whitelist_length = from.maximum_tournament_whitelist_length; - to.maximum_tournament_start_time_in_future= from.maximum_tournament_start_time_in_future; - to.maximum_tournament_start_delay = from.maximum_tournament_start_delay; - to.maximum_tournament_number_of_wins = from.maximum_tournament_number_of_wins; - to.extensions = from.extensions; - } - - // move constructor - chain_parameters::chain_parameters(chain_parameters&& other) - { - current_fees = std::move(other.current_fees); - safe_copy(*this, other); - } - - // move assignment - chain_parameters& chain_parameters::operator=(chain_parameters&& other) - { - if (&other != this) - { - current_fees = std::move(other.current_fees); - safe_copy(*this, other); - } - return *this; - } -}} diff --git a/libraries/net/custom_account_authority.cpp b/libraries/net/custom_account_authority.cpp deleted file mode 100644 index a74234d7..00000000 --- a/libraries/net/custom_account_authority.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include - -namespace graphene -{ -namespace chain -{ - -void custom_account_authority_create_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT, - "Custom permissions and account auths cannot be created for special accounts"); - FC_ASSERT(valid_from < valid_to, "valid_from should be earlier than valid_to"); - FC_ASSERT(operation_type >= 0 && operation_type < operation::count(), "operation_type is not valid"); -} - -void custom_account_authority_update_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT, - "Custom permissions and account auths cannot be created for special accounts"); - FC_ASSERT(new_valid_from.valid() || new_valid_to.valid(), "Something must be updated"); - if (new_valid_from && new_valid_to) - { - FC_ASSERT(*new_valid_from < *new_valid_to, "valid_from should be earlier than valid_to"); - } -} - -void custom_account_authority_delete_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT, - "Custom permissions and account auths cannot be created for special accounts"); -} - -share_type custom_account_authority_create_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); -} - -} // namespace chain -} // namespace graphene diff --git a/libraries/net/custom_permission.cpp b/libraries/net/custom_permission.cpp deleted file mode 100644 index c0919cbd..00000000 --- a/libraries/net/custom_permission.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include -#include - -namespace graphene -{ -namespace chain -{ - -bool is_valid_permission_name(const string &name) -{ - try - { - const size_t len = name.size(); - // RBAC_MIN_PERMISSION_NAME_LENGTH <= len minimum length check - if (len < RBAC_MIN_PERMISSION_NAME_LENGTH) - { - return false; - } - // len <= RBAC_MAX_PERMISSION_NAME_LENGTH max length check - if (len > RBAC_MAX_PERMISSION_NAME_LENGTH) - { - return false; - } - // First character should be a letter between a-z - if (!(name[0] >= 'a' && name[0] <= 'z')) - { - return false; - } - // Any character of a permission name should either be a small case letter a-z or a digit 0-9 - for (const auto &ch : name) - { - if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9'))) - { - return false; - } - } - // Don't accept active and owner permissions as we already have them by default - // This is for removing ambiguity for users, accepting them doesn't create any problems - if (name == "active" || name == "owner") - { - return false; - } - - return true; - } - FC_CAPTURE_AND_RETHROW((name)) -} - -void custom_permission_create_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(is_valid_permission_name(permission_name), "Invalid permission name provided"); - FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT, - "Custom permissions and account auths cannot be created for special accounts"); - FC_ASSERT(!auth.is_impossible(), "Impossible authority threshold auth provided"); - FC_ASSERT(auth.address_auths.size() == 0, "Only account and key auths supported"); -} - -void custom_permission_update_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT, - "Custom permissions and account auths cannot be created for special accounts"); - FC_ASSERT(new_auth.valid(), "Something must be updated"); - if (new_auth) - { - FC_ASSERT(!new_auth->is_impossible(), "Impossible authority threshold auth provided"); - FC_ASSERT(new_auth->address_auths.size() == 0, "Only account and key auths supported"); - } -} - -void custom_permission_delete_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(owner_account != GRAPHENE_TEMP_ACCOUNT && owner_account != GRAPHENE_COMMITTEE_ACCOUNT && owner_account != GRAPHENE_WITNESS_ACCOUNT && owner_account != GRAPHENE_RELAXED_COMMITTEE_ACCOUNT, - "Custom permissions and account auths cannot be created for special accounts"); -} - -share_type custom_permission_create_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); -} - -} // namespace chain -} // namespace graphene diff --git a/libraries/net/nft.cpp b/libraries/net/nft.cpp deleted file mode 100644 index 4a66f330..00000000 --- a/libraries/net/nft.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include -#include - -namespace graphene -{ -namespace chain -{ - -bool is_valid_nft_token_name(const string &name) -{ - try - { - const size_t len = name.size(); - // NFT_TOKEN_MIN_LENGTH <= len minimum length check - if (len < NFT_TOKEN_MIN_LENGTH) - { - return false; - } - // len <= NFT_TOKEN_MAX_LENGTH max length check - if (len > NFT_TOKEN_MAX_LENGTH) - { - return false; - } - // First character should be a letter between a-z/A-Z - if (!((name[0] >= 'a' && name[0] <= 'z') || (name[0] >= 'A' && name[0] <= 'Z'))) - { - return false; - } - // Any character should either be a small case letter a-z or a digit 0-9 - for (const auto &ch : name) - { - if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || (ch == ' '))) - { - return false; - } - } - - return true; - } - FC_CAPTURE_AND_RETHROW((name)) -} - -void nft_metadata_create_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - FC_ASSERT(is_valid_nft_token_name(name), "Invalid NFT name provided"); - FC_ASSERT(is_valid_nft_token_name(symbol), "Invalid NFT symbol provided"); -} - -void nft_metadata_update_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); - if(name) - FC_ASSERT(is_valid_nft_token_name(*name), "Invalid NFT name provided"); - if(symbol) - FC_ASSERT(is_valid_nft_token_name(*symbol), "Invalid NFT symbol provided"); -} - -void nft_mint_operation::validate() const -{ - FC_ASSERT(fee.amount >= 0, "Fee must not be negative"); -} - -share_type nft_metadata_create_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); -} - -share_type nft_metadata_update_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); -} - -share_type nft_mint_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); -} - -share_type nft_safe_transfer_from_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); -} - -share_type nft_approve_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee; -} - -share_type nft_set_approval_for_all_operation::calculate_fee(const fee_parameters_type &k) const -{ - return k.fee; -} - -} // namespace chain -} // namespace graphene diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index c7177251..28adc627 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -1340,7 +1340,7 @@ namespace graphene { namespace net { namespace detail { uint32_t handshaking_timeout = _peer_inactivity_timeout; fc::time_point handshaking_disconnect_threshold = fc::time_point::now() - fc::seconds(handshaking_timeout); - for( const peer_connection_ptr handshaking_peer : _handshaking_connections ) + for( const peer_connection_ptr& handshaking_peer : _handshaking_connections ) if( handshaking_peer->connection_initiation_time < handshaking_disconnect_threshold && handshaking_peer->get_last_message_received_time() < handshaking_disconnect_threshold && handshaking_peer->get_last_message_sent_time() < handshaking_disconnect_threshold ) @@ -1705,13 +1705,13 @@ namespace graphene { namespace net { namespace detail { dlog("is_already_connected_to_id returning true because the peer is us"); return true; } - for (const peer_connection_ptr active_peer : _active_connections) + for (const peer_connection_ptr& active_peer : _active_connections) if (node_id == active_peer->node_id) { dlog("is_already_connected_to_id returning true because the peer is already in our active list"); return true; } - for (const peer_connection_ptr handshaking_peer : _handshaking_connections) + for (const peer_connection_ptr& handshaking_peer : _handshaking_connections) if (node_id == handshaking_peer->node_id) { dlog("is_already_connected_to_id returning true because the peer is already in our handshaking list"); @@ -2878,7 +2878,7 @@ namespace graphene { namespace net { namespace detail { item_id advertised_item_id(item_ids_inventory_message_received.item_type, item_hash); bool we_advertised_this_item_to_a_peer = false; bool we_requested_this_item_from_a_peer = false; - for (const peer_connection_ptr peer : _active_connections) + for (const peer_connection_ptr& peer : _active_connections) { if (peer->inventory_advertised_to_peer.find(advertised_item_id) != peer->inventory_advertised_to_peer.end()) { diff --git a/libraries/net/offer.cpp b/libraries/net/offer.cpp deleted file mode 100644 index e83af3f8..00000000 --- a/libraries/net/offer.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include - -namespace graphene -{ - namespace chain - { - share_type offer_operation::calculate_fee(const fee_parameters_type &schedule) const - { - return schedule.fee + calculate_data_fee( fc::raw::pack_size(*this), schedule.price_per_kbyte ); - } - - void offer_operation::validate() const - { - FC_ASSERT(item_ids.size() > 0); - FC_ASSERT(fee.amount >= 0); - FC_ASSERT(minimum_price.asset_id == maximum_price.asset_id); - FC_ASSERT(minimum_price.amount >= 0 && maximum_price.amount > 0); - FC_ASSERT(maximum_price >= minimum_price); - } - - share_type bid_operation::calculate_fee(const fee_parameters_type &schedule) const - { - share_type core_fee_required = schedule.fee; - return core_fee_required; - } - - void bid_operation::validate() const - { - FC_ASSERT(fee.amount.value >= 0); - FC_ASSERT(bid_price.amount.value >= 0); - } - - void cancel_offer_operation::validate() const - { - FC_ASSERT(fee.amount.value >= 0); - } - - share_type cancel_offer_operation::calculate_fee(const fee_parameters_type &schedule) const - { - share_type core_fee_required = schedule.fee; - return core_fee_required; - } - - void finalize_offer_operation::validate() const - { - FC_ASSERT(fee.amount.value >= 0); - } - - share_type finalize_offer_operation::calculate_fee(const fee_parameters_type &schedule) const - { - share_type core_fee_required = schedule.fee; - return core_fee_required; - } - - } // namespace chain -} // namespace graphene \ No newline at end of file diff --git a/libraries/net/peer_connection.cpp b/libraries/net/peer_connection.cpp index e5099e79..44a803d1 100644 --- a/libraries/net/peer_connection.cpp +++ b/libraries/net/peer_connection.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include diff --git a/libraries/net/small_ops.cpp b/libraries/net/small_ops.cpp deleted file mode 100644 index cba4b1b7..00000000 --- a/libraries/net/small_ops.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2019 BitShares Blockchain Foundation, and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include - -#include - -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::balance_claim_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::buyback_account_options ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::fba_distribute_operation ) - -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_create_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_withdraw_operation::fee_parameters_type ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_create_operation ) -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::vesting_balance_withdraw_operation ) - -GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::chain::chain_parameters ) diff --git a/libraries/plugins/bookie/bookie_plugin.cpp b/libraries/plugins/bookie/bookie_plugin.cpp index 3dd17d1b..a8c06a0d 100644 --- a/libraries/plugins/bookie/bookie_plugin.cpp +++ b/libraries/plugins/bookie/bookie_plugin.cpp @@ -64,6 +64,8 @@ class persistent_bet_object_helper : public secondary_index public: virtual ~persistent_bet_object_helper() {} + using watched_index = primary_index; + 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; @@ -99,6 +101,8 @@ class persistent_betting_market_object_helper : public secondary_index public: virtual ~persistent_betting_market_object_helper() {} + using watched_index = primary_index; + 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; @@ -134,6 +138,8 @@ class persistent_betting_market_group_object_helper : public secondary_index public: virtual ~persistent_betting_market_group_object_helper() {} + using watched_index = primary_index; + 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; @@ -169,6 +175,8 @@ class persistent_event_object_helper : public secondary_index public: virtual ~persistent_event_object_helper() {} + using watched_index = primary_index; + 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; @@ -465,45 +473,31 @@ void bookie_plugin::plugin_set_program_options(boost::program_options::options_d void bookie_plugin::plugin_initialize(const boost::program_options::variables_map& options) { - ilog("bookie plugin: plugin_startup() begin"); + ilog("bookie plugin: plugin_initialize() begin"); database().force_slow_replays(); database().applied_block.connect( [&]( const signed_block& b){ my->on_block_applied(b); } ); database().changed_objects.connect([&](const vector& changed_object_ids, const fc::flat_set& impacted_accounts){ my->on_objects_changed(changed_object_ids); }); database().new_objects.connect([this](const vector& ids, const flat_set& impacted_accounts) { my->on_objects_new(ids); }); database().removed_objects.connect([this](const vector& ids, const vector& objs, const flat_set& impacted_accounts) { my->on_objects_removed(ids); }); - //auto event_index = database().add_index >(); database().add_index >(); database().add_index >(); database().add_index >(); - const primary_index& bet_object_idx = database().get_index_type >(); - primary_index& nonconst_bet_object_idx = const_cast&>(bet_object_idx); - detail::persistent_bet_object_helper* persistent_bet_object_helper_index = nonconst_bet_object_idx.add_secondary_index(); - persistent_bet_object_helper_index->set_plugin_instance(this); - - const primary_index& betting_market_object_idx = database().get_index_type >(); - primary_index& nonconst_betting_market_object_idx = const_cast&>(betting_market_object_idx); - detail::persistent_betting_market_object_helper* persistent_betting_market_object_helper_index = nonconst_betting_market_object_idx.add_secondary_index(); - persistent_betting_market_object_helper_index->set_plugin_instance(this); - - const primary_index& betting_market_group_object_idx = database().get_index_type >(); - primary_index& nonconst_betting_market_group_object_idx = const_cast&>(betting_market_group_object_idx); - detail::persistent_betting_market_group_object_helper* persistent_betting_market_group_object_helper_index = nonconst_betting_market_group_object_idx.add_secondary_index(); - persistent_betting_market_group_object_helper_index->set_plugin_instance(this); - - const primary_index& event_object_idx = database().get_index_type >(); - primary_index& nonconst_event_object_idx = const_cast&>(event_object_idx); - detail::persistent_event_object_helper* persistent_event_object_helper_index = nonconst_event_object_idx.add_secondary_index(); - persistent_event_object_helper_index->set_plugin_instance(this); - - ilog("bookie plugin: plugin_startup() end"); + ilog("bookie plugin: plugin_initialize() end"); } void bookie_plugin::plugin_startup() { ilog("bookie plugin: plugin_startup()"); + + // Register secondary indexes + database().add_secondary_index()->set_plugin_instance(this); + database().add_secondary_index()->set_plugin_instance(this); + database().add_secondary_index()->set_plugin_instance(this); + database().add_secondary_index()->set_plugin_instance(this); + my->fill_localized_event_strings(); } diff --git a/libraries/plugins/peerplays_sidechain/bitcoin/bitcoin_transaction.cpp b/libraries/plugins/peerplays_sidechain/bitcoin/bitcoin_transaction.cpp index 1ad3643b..4b1053e0 100644 --- a/libraries/plugins/peerplays_sidechain/bitcoin/bitcoin_transaction.cpp +++ b/libraries/plugins/peerplays_sidechain/bitcoin/bitcoin_transaction.cpp @@ -180,7 +180,7 @@ void bitcoin_transaction_builder::add_out(payment_type type, int64_t amount, con const auto pubkey_bytes = bytes(pubkey.begin(), pubkey.begin() + pubkey.size()); add_out(type, amount, pubkey_bytes, front); } else { - const auto hash256 = fc::sha256::hash((char*)pubkey.begin(), pubkey.size()); + const auto hash256 = fc::sha256::hash((const char*)pubkey.begin(), pubkey.size()); const auto hash160 = fc::ripemd160::hash(hash256.data(), hash256.data_size()); add_out(type, amount, bytes(hash160.data(), hash160.data() + hash160.data_size()), front); } diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp index 9ccdc781..4e6f251c 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp @@ -3,6 +3,7 @@ #include #include +using namespace graphene::protocol; namespace graphene { namespace peerplays_sidechain { namespace bitcoin { @@ -216,6 +217,7 @@ public: private: void create_redeem_script(const fc::ecc::public_key &user_key_data, const std::vector> &keys_data); +public: uint32_t latency_; }; diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp index 2f1dfffe..b234f8a4 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp @@ -186,7 +186,7 @@ inline void pack(Stream &s, const bitcoin_transaction &tx, bool with_witness = t pack(s, out); if (flags & 1) { - for (const auto in : tx.vin) { + for (const auto& in : tx.vin) { pack_compact_size(s, in.scriptWitness.size()); for (const auto &sc : in.scriptWitness) pack(s, sc); @@ -294,13 +294,13 @@ inline void pack_tx_witness_signature(Stream &s, const std::vector &script { fc::datastream ps; - for (const auto in : tx.vin) + for (const auto& in : tx.vin) pack(ps, in.prevout); std::vector vec(ps.tellp()); if (vec.size()) { fc::datastream ds(vec.data(), size_t(vec.size())); - for (const auto in : tx.vin) + for (const auto& in : tx.vin) pack(ds, in.prevout); } @@ -309,13 +309,13 @@ inline void pack_tx_witness_signature(Stream &s, const std::vector &script { fc::datastream ps; - for (const auto in : tx.vin) + for (const auto& in : tx.vin) pack(ps, in.nSequence); std::vector vec(ps.tellp()); if (vec.size()) { fc::datastream ds(vec.data(), size_t(vec.size())); - for (const auto in : tx.vin) + for (const auto& in : tx.vin) pack(ds, in.nSequence); } @@ -324,13 +324,13 @@ inline void pack_tx_witness_signature(Stream &s, const std::vector &script { fc::datastream ps; - for (const auto out : tx.vout) + for (const auto& out : tx.vout) pack(ps, out); std::vector vec(ps.tellp()); if (vec.size()) { fc::datastream ds(vec.data(), size_t(vec.size())); - for (const auto out : tx.vout) + for (const auto& out : tx.vout) pack(ds, out); } diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp index 41808562..365cbe4d 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/sign_bitcoin_transaction.hpp @@ -6,7 +6,7 @@ namespace graphene { namespace peerplays_sidechain { namespace bitcoin { -class bitcoin_transaction; +struct bitcoin_transaction; const secp256k1_context_t *btc_context(); diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/types.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/types.hpp index 36f8f0a6..659a568f 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/types.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/types.hpp @@ -9,7 +9,7 @@ namespace graphene { namespace peerplays_sidechain { namespace bitcoin { -class bitcoin_transaction; +struct bitcoin_transaction; using bytes = std::vector; using accounts_keys = std::map; diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp index 7284b88a..c641d49f 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp @@ -1,6 +1,7 @@ #pragma once #include + #include #include diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_manager.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_manager.hpp index 940db7d0..64518dd9 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_manager.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_manager.hpp @@ -1,6 +1,7 @@ #pragma once #include + #include #include diff --git a/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp index 17eddef2..a3dc989c 100644 --- a/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp +++ b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp @@ -5,11 +5,12 @@ #include #include + #include -#include #include #include #include +#include #include #include diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp index d4040e7e..b47cecc5 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp @@ -13,9 +13,10 @@ #include #include -#include #include #include +#include +#include #include #include #include diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp index 73363666..c30b6454 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include namespace graphene { namespace peerplays_sidechain { diff --git a/libraries/protocol/authority.cpp b/libraries/protocol/authority.cpp index 137568eb..47fc29b4 100644 --- a/libraries/protocol/authority.cpp +++ b/libraries/protocol/authority.cpp @@ -23,6 +23,7 @@ */ #include + #include namespace graphene { namespace protocol { diff --git a/libraries/protocol/custom_permission.cpp b/libraries/protocol/custom_permission.cpp index ac9b3daf..5084bf0b 100644 --- a/libraries/protocol/custom_permission.cpp +++ b/libraries/protocol/custom_permission.cpp @@ -81,5 +81,5 @@ share_type custom_permission_create_operation::calculate_fee(const fee_parameter return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); } -} // namespace chain +} // namespace protocol } // namespace graphene diff --git a/libraries/protocol/include/graphene/protocol/account.hpp b/libraries/protocol/include/graphene/protocol/account.hpp index 36b18b7e..f5b1f976 100644 --- a/libraries/protocol/include/graphene/protocol/account.hpp +++ b/libraries/protocol/include/graphene/protocol/account.hpp @@ -298,7 +298,7 @@ FC_REFLECT_ENUM( graphene::protocol::app_tag, (bookie)(rps) ) FC_REFLECT( graphene::protocol::affiliate_reward_distribution, (_dist) ); FC_REFLECT( graphene::protocol::affiliate_reward_distributions, (_dists) ); -FC_REFLECT(graphene::protocol::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options) ) +FC_REFLECT(graphene::protocol::account_create_operation::ext, (null_ext)(owner_special_authority)(active_special_authority)(buyback_options)(affiliate_distributions) ) FC_REFLECT_TYPENAME(graphene::protocol::extension) FC_REFLECT( graphene::protocol::account_create_operation, (fee)(registrar) diff --git a/libraries/protocol/include/graphene/protocol/chain_parameters.hpp b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp index 8e767ac1..7dcf5fe5 100644 --- a/libraries/protocol/include/graphene/protocol/chain_parameters.hpp +++ b/libraries/protocol/include/graphene/protocol/chain_parameters.hpp @@ -22,11 +22,9 @@ * THE SOFTWARE. */ #pragma once -#include -#include + #include -#include -#include +#include #include @@ -76,7 +74,7 @@ namespace graphene { namespace protocol { chain_parameters(chain_parameters&& other); chain_parameters& operator=(const chain_parameters& other); chain_parameters& operator=(chain_parameters&& other); - /** using a smart ref breaks the circular dependency created between operations and the fee schedule */ + /** using a shared_ptr breaks the circular dependency created between operations and the fee schedule */ std::shared_ptr current_fees; ///< current schedule of fees uint8_t block_interval = GRAPHENE_DEFAULT_BLOCK_INTERVAL; ///< interval in seconds between blocks uint32_t maintenance_interval = GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL; ///< interval in sections between blockchain maintenance events diff --git a/libraries/protocol/include/graphene/protocol/nft_ops.hpp b/libraries/protocol/include/graphene/protocol/nft_ops.hpp index 4805d5fb..d5ebb983 100644 --- a/libraries/protocol/include/graphene/protocol/nft_ops.hpp +++ b/libraries/protocol/include/graphene/protocol/nft_ops.hpp @@ -131,7 +131,7 @@ namespace graphene { namespace protocol { share_type calculate_fee(const fee_parameters_type &k) const; }; -} } // graphene::chain +} } // graphene::protocol FC_REFLECT( graphene::protocol::nft_metadata_create_operation::fee_parameters_type, (fee) (price_per_kbyte) ) FC_REFLECT( graphene::protocol::nft_metadata_update_operation::fee_parameters_type, (fee) ) @@ -146,3 +146,4 @@ FC_REFLECT( graphene::protocol::nft_mint_operation, (fee) (payer) (nft_metadata_ FC_REFLECT( graphene::protocol::nft_safe_transfer_from_operation, (fee) (operator_) (from) (to) (token_id) (data) (extensions) ) FC_REFLECT( graphene::protocol::nft_approve_operation, (fee) (operator_) (approved) (token_id) (extensions) ) FC_REFLECT( graphene::protocol::nft_set_approval_for_all_operation, (fee) (owner) (operator_) (approved) (extensions) ) + diff --git a/libraries/protocol/include/graphene/protocol/pts_address.hpp b/libraries/protocol/include/graphene/protocol/pts_address.hpp index e588f093..7c596b98 100644 --- a/libraries/protocol/include/graphene/protocol/pts_address.hpp +++ b/libraries/protocol/include/graphene/protocol/pts_address.hpp @@ -30,6 +30,10 @@ #include #include +#include +#include +#include + namespace fc { namespace ecc { class public_key; } } namespace graphene { namespace protocol { diff --git a/libraries/protocol/include/graphene/protocol/transaction.hpp b/libraries/protocol/include/graphene/protocol/transaction.hpp index b41d375d..aac83c95 100644 --- a/libraries/protocol/include/graphene/protocol/transaction.hpp +++ b/libraries/protocol/include/graphene/protocol/transaction.hpp @@ -239,7 +239,6 @@ FC_REFLECT_DERIVED( graphene::protocol::signed_transaction, (graphene::protocol: FC_REFLECT_DERIVED( graphene::protocol::processed_transaction, (graphene::protocol::signed_transaction), (operation_results) ) - GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::transaction) GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::signed_transaction) GRAPHENE_EXTERNAL_SERIALIZATION(extern, graphene::protocol::processed_transaction) diff --git a/libraries/protocol/include/graphene/protocol/vesting.hpp b/libraries/protocol/include/graphene/protocol/vesting.hpp index da2bfec9..35f34bf1 100644 --- a/libraries/protocol/include/graphene/protocol/vesting.hpp +++ b/libraries/protocol/include/graphene/protocol/vesting.hpp @@ -135,7 +135,7 @@ FC_REFLECT( graphene::protocol::vesting_balance_withdraw_operation, (fee)(vestin FC_REFLECT(graphene::protocol::linear_vesting_policy_initializer, (begin_timestamp)(vesting_cliff_seconds)(vesting_duration_seconds) ) FC_REFLECT(graphene::protocol::cdd_vesting_policy_initializer, (start_claim)(vesting_seconds) ) -FC_REFLECT_EMPTY( graphene::protocol::dormant_vesting_policy_initializer ) +FC_REFLECT(graphene::protocol::dormant_vesting_policy_initializer, ) FC_REFLECT_TYPENAME( graphene::protocol::vesting_policy_initializer ) FC_REFLECT_ENUM( graphene::protocol::vesting_balance_type, (normal)(gpos)(son) ) diff --git a/libraries/protocol/include/graphene/protocol/witness.hpp b/libraries/protocol/include/graphene/protocol/witness.hpp index afa2fc5c..466295c7 100644 --- a/libraries/protocol/include/graphene/protocol/witness.hpp +++ b/libraries/protocol/include/graphene/protocol/witness.hpp @@ -81,7 +81,7 @@ namespace graphene { namespace protocol { } } // graphene::protocol FC_REFLECT( graphene::protocol::witness_create_operation::fee_parameters_type, (fee) ) -FC_REFLECT( graphene::protocol::witness_create_operation, (fee)(witness_account)(url)(block_signing_key) ) +FC_REFLECT( graphene::protocol::witness_create_operation, (fee)(witness_account)(url)(block_signing_key)(initial_secret) ) FC_REFLECT( graphene::protocol::witness_update_operation::fee_parameters_type, (fee) ) FC_REFLECT( graphene::protocol::witness_update_operation, (fee)(witness)(witness_account)(new_url)(new_signing_key)(new_initial_secret) ) diff --git a/libraries/protocol/proposal.cpp b/libraries/protocol/proposal.cpp index aa2edd05..a1a40187 100644 --- a/libraries/protocol/proposal.cpp +++ b/libraries/protocol/proposal.cpp @@ -113,4 +113,3 @@ GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::proposal_de GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::proposal_create_operation ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::proposal_update_operation ) GRAPHENE_EXTERNAL_SERIALIZATION( /*not extern*/, graphene::protocol::proposal_delete_operation ) - diff --git a/libraries/protocol/small_ops.cpp b/libraries/protocol/small_ops.cpp index df234205..b870960a 100644 --- a/libraries/protocol/small_ops.cpp +++ b/libraries/protocol/small_ops.cpp @@ -65,3 +65,4 @@ FC_IMPLEMENT_DERIVED_EXCEPTION( invalid_committee_approval, transaction_exceptio FC_IMPLEMENT_DERIVED_EXCEPTION( insufficient_fee, transaction_exception, 4010007, "insufficient fee" ) } } // graphene::protocol + diff --git a/libraries/protocol/transaction.cpp b/libraries/protocol/transaction.cpp index c656a53a..491a340c 100644 --- a/libraries/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -265,8 +265,9 @@ void verify_authority( const vector& ops, const flat_set required_active; flat_set required_owner; vector other; + flat_set available_keys; - sign_state s(sigs,get_active); + sign_state s(sigs,get_active, available_keys); s.max_recursion = max_recursion_depth; for( auto& id : active_aprovals ) s.approved_by.insert( id ); @@ -450,10 +451,11 @@ void signed_transaction::verify_authority( bool ignore_custom_operation_required_auths, uint32_t max_recursion )const { try { - graphene::protocol::verify_authority( operations, get_signature_keys( chain_id ), get_active, get_owner, get_custom, ignore_custom_operation_required_auths, max_recursion ); + graphene::protocol::verify_authority( operations, get_signature_keys( chain_id ), get_active, get_owner, + get_custom, ignore_custom_operation_required_auths, max_recursion ); } FC_CAPTURE_AND_RETHROW( (*this) ) } -} } // graphene::chain +} } // graphene::protocol GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::transaction) GRAPHENE_EXTERNAL_SERIALIZATION(/*not extern*/, graphene::protocol::signed_transaction) diff --git a/programs/build_helpers/check_reflect.py b/programs/build_helpers/check_reflect.py index 0f41f355..58b2851c 100755 --- a/programs/build_helpers/check_reflect.py +++ b/programs/build_helpers/check_reflect.py @@ -108,8 +108,8 @@ def validate_members(name2members_ref, name2members_test): error_items.append(name) print("") print("error in", name) - print("doxygen:", name2members_ref[name]) - print("fc :", name2members_test[name]) + print("doxygen:", sorted(name2members_ref[name])) + print("fc :", sorted(name2members_test[name])) else: ok_items.append(name) return diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index bb48cd0e..bc8e8b10 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -242,10 +242,9 @@ int main( int argc, char** argv ) if( options.count( "rpc-tls-certificate" ) ) cert_pem = options.at("rpc-tls-certificate").as(); - std::shared_ptr _websocket_tls_server; + auto _websocket_tls_server = std::make_shared(cert_pem, ""); if( options.count("rpc-tls-endpoint") ) { - _websocket_tls_server = std::make_shared(cert_pem, ""); _websocket_tls_server->on_connection([&]( const fc::http::websocket_connection_ptr& c ){ auto wsc = std::make_shared(c, GRAPHENE_MAX_NESTED_OBJECTS); wsc->register_api(wapi); diff --git a/tests/betting/betting_tests.cpp b/tests/betting/betting_tests.cpp index b257d7db..5ac3d8c8 100644 --- a/tests/betting/betting_tests.cpp +++ b/tests/betting/betting_tests.cpp @@ -132,115 +132,6 @@ using namespace graphene::chain::keywords; // 1.58 50:29 | 2.34 50:67 | 4.6 5:18 | 25 1:24 | 430 1:429 | // 1.59 100:59 | 2.36 25:34 | 4.7 10:37 -template object_id to_id(const O& o) { return o.id; } - -#define CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ - create_sport({{"en", "Ice Hockey"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \ - generate_blocks(1); \ - const auto ice_hockey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey_id); \ - generate_blocks(1); \ - const auto nhl_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl_id); \ - generate_blocks(1); \ - const auto capitals_vs_blackhawks_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market_rules({{"en", "NHL Rules v1.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); \ - generate_blocks(1); \ - const auto betting_market_rules_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ - generate_blocks(1); \ - const auto moneyline_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_betting_markets_id, {{"en", "Washington Capitals win"}}); \ - generate_blocks(1); \ - const auto capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ - generate_blocks(1); \ - const auto blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - (void)capitals_win_market_id; (void)blackhawks_win_market_id; - -// create the basic betting market, plus groups for the first, second, and third period results -#define CREATE_EXTENDED_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ - CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ - create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ - generate_blocks(1); \ - const auto first_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(first_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ - generate_blocks(1); \ - const auto first_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(first_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ - generate_blocks(1); \ - const auto first_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - (void)first_period_capitals_win_market_id; (void)first_period_blackhawks_win_market_id; \ - \ - create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ - generate_blocks(1); \ - const auto second_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(second_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ - generate_blocks(1); \ - const auto second_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(second_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ - generate_blocks(1); \ - const auto second_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - (void)second_period_capitals_win_market_id; (void)second_period_blackhawks_win_market_id; \ - \ - create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ - generate_blocks(1); \ - const auto third_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(third_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ - generate_blocks(1); \ - const auto third_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(third_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ - generate_blocks(1); \ - const auto third_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - (void)third_period_capitals_win_market_id; (void)third_period_blackhawks_win_market_id; - -#define CREATE_TENNIS_BETTING_MARKET() \ - create_betting_market_rules({{"en", "Tennis Rules v1.0"}}, {{"en", "The winner is the player who wins the last ball in the match."}}); \ - generate_blocks(1); \ - const auto tennis_rules_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_sport({{"en", "Tennis"}}); \ - generate_blocks(1); \ - const auto tennis_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_event_group({{"en", "Wimbledon"}}, tennis_id); \ - generate_blocks(1); \ - const auto wimbledon_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon_id); \ - generate_blocks(1); \ - const auto berdych_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon_id); \ - generate_blocks(1); \ - const auto cilic_vs_querrey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \ - generate_blocks(1); \ - const auto moneyline_berdych_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey_id, tennis_rules_id, asset_id_type(), false, 0); \ - generate_blocks(1); \ - const auto moneyline_cilic_vs_querrey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "T. Berdych defeats R. Federer"}}); \ - generate_blocks(1); \ - const auto berdych_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "R. Federer defeats T. Berdych"}}); \ - generate_blocks(1); \ - const auto federer_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "M. Cilic defeats S. Querrey"}}); \ - generate_blocks(1); \ - const auto cilic_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "S. Querrey defeats M. Cilic"}});\ - generate_blocks(1); \ - const auto querrey_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon_id); \ - generate_blocks(1); \ - const auto cilic_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \ - generate_blocks(1); \ - const auto moneyline_cilic_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "R. Federer defeats M. Cilic"}}); \ - generate_blocks(1); \ - const auto federer_wins_final_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "M. Cilic defeats R. Federer"}}); \ - generate_blocks(1); \ - const auto cilic_wins_final_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ - (void)federer_wins_market_id;(void)cilic_wins_market_id;(void)federer_wins_final_market_id; (void)cilic_wins_final_market_id; (void)berdych_wins_market_id; (void)querrey_wins_market_id; BOOST_FIXTURE_TEST_SUITE( betting_tests, database_fixture ) @@ -2513,6 +2404,7 @@ BOOST_AUTO_TEST_CASE(event_driven_progression_errors_2) // as soon as a block is generated, the betting market group will settle, and the market // and group will cease to exist. The event should transition to "settled", then removed fc::variants objects_from_bookie = bookie_api.get_objects({capitals_vs_blackhawks_id}); + wdump((objects_from_bookie)(capitals_vs_blackhawks_id(db))); BOOST_CHECK_EQUAL(objects_from_bookie[0]["status"].as(1), "settled"); // we can't go back to upcoming, in_progress, frozen, or finished once we're canceled. diff --git a/tests/common/betting_test_markets.hpp b/tests/common/betting_test_markets.hpp index f67dc067..94c5b1c8 100644 --- a/tests/common/betting_test_markets.hpp +++ b/tests/common/betting_test_markets.hpp @@ -30,113 +30,115 @@ using namespace graphene::chain; +template object_id to_id(const O& o) { return o.id; } + #define CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ create_sport({{"en", "Ice Hockey"}, {"zh_Hans", "冰球"}, {"ja", "アイスホッケー"}}); \ generate_blocks(1); \ - const sport_object& ice_hockey = *db.get_index_type().indices().get().rbegin(); \ - create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey.id); \ + const auto ice_hockey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event_group({{"en", "NHL"}, {"zh_Hans", "國家冰球聯盟"}, {"ja", "ナショナルホッケーリーグ"}}, ice_hockey_id); \ generate_blocks(1); \ - const event_group_object& nhl = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl.id); \ + const auto nhl_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl_id); \ generate_blocks(1); \ - const event_object& capitals_vs_blackhawks = *db.get_index_type().indices().get().rbegin(); \ + const auto capitals_vs_blackhawks_id = to_id(*db.get_index_type().indices().get().rbegin()); \ create_betting_market_rules({{"en", "NHL Rules v1.0"}}, {{"en", "The winner will be the team with the most points at the end of the game. The team with fewer points will not be the winner."}}); \ generate_blocks(1); \ - const betting_market_rules_object& betting_market_rules = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + const auto betting_market_rules_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto moneyline_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)capitals_win_market; (void)blackhawks_win_market; + const auto blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)capitals_win_market_id; (void)blackhawks_win_market_id; // create the basic betting market, plus groups for the first, second, and third period results #define CREATE_EXTENDED_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ CREATE_ICE_HOCKEY_BETTING_MARKET(never_in_play, delay_before_settling) \ - create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + create_betting_market_group({{"en", "First Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& first_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(first_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto first_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(first_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& first_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(first_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto first_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(first_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& first_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)first_period_capitals_win_market; (void)first_period_blackhawks_win_market; \ + const auto first_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)first_period_capitals_win_market_id; (void)first_period_blackhawks_win_market_id; \ \ - create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + create_betting_market_group({{"en", "Second Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& second_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(second_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto second_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(second_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& second_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(second_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto second_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(second_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& second_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)second_period_capitals_win_market; (void)second_period_blackhawks_win_market; \ + const auto second_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)second_period_capitals_win_market_id; (void)second_period_blackhawks_win_market_id; \ \ - create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks.id, betting_market_rules.id, asset_id_type(), never_in_play, delay_before_settling); \ + create_betting_market_group({{"en", "Third Period Result"}}, capitals_vs_blackhawks_id, betting_market_rules_id, asset_id_type(), never_in_play, delay_before_settling); \ generate_blocks(1); \ - const betting_market_group_object& third_period_result_betting_markets = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(third_period_result_betting_markets.id, {{"en", "Washington Capitals win"}}); \ + const auto third_period_result_betting_markets_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(third_period_result_betting_markets_id, {{"en", "Washington Capitals win"}}); \ generate_blocks(1); \ - const betting_market_object& third_period_capitals_win_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(third_period_result_betting_markets.id, {{"en", "Chicago Blackhawks win"}}); \ + const auto third_period_capitals_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(third_period_result_betting_markets_id, {{"en", "Chicago Blackhawks win"}}); \ generate_blocks(1); \ - const betting_market_object& third_period_blackhawks_win_market = *db.get_index_type().indices().get().rbegin(); \ - (void)third_period_capitals_win_market; (void)third_period_blackhawks_win_market; + const auto third_period_blackhawks_win_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)third_period_capitals_win_market_id; (void)third_period_blackhawks_win_market_id; #define CREATE_TENNIS_BETTING_MARKET() \ create_betting_market_rules({{"en", "Tennis Rules v1.0"}}, {{"en", "The winner is the player who wins the last ball in the match."}}); \ generate_blocks(1); \ - const betting_market_rules_object& tennis_rules = *db.get_index_type().indices().get().rbegin(); \ + const auto tennis_rules_id = to_id(*db.get_index_type().indices().get().rbegin()); \ create_sport({{"en", "Tennis"}}); \ generate_blocks(1); \ - const sport_object& tennis = *db.get_index_type().indices().get().rbegin(); \ - create_event_group({{"en", "Wimbledon"}}, tennis.id); \ + const auto tennis_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event_group({{"en", "Wimbledon"}}, tennis_id); \ generate_blocks(1); \ - const event_group_object& wimbledon = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon.id); \ + const auto wimbledon_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "R. Federer/T. Berdych"}}, {{"en", "2017"}}, wimbledon_id); \ generate_blocks(1); \ - const event_object& berdych_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon.id); \ + const auto berdych_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "M. Cilic/S. Querrye"}}, {{"en", "2017"}}, wimbledon_id); \ generate_blocks(1); \ - const event_object& cilic_vs_querrey = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \ + const auto cilic_vs_querrey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline 1st sf"}}, berdych_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_berdych_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey.id, tennis_rules.id, asset_id_type(), false, 0); \ + const auto moneyline_berdych_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline 2nd sf"}}, cilic_vs_querrey_id, tennis_rules_id, asset_id_type(), false, 0); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_cilic_vs_querrey = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "T. Berdych defeats R. Federer"}}); \ + const auto moneyline_cilic_vs_querrey_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "T. Berdych defeats R. Federer"}}); \ generate_blocks(1); \ - const betting_market_object& berdych_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_berdych_vs_federer.id, {{"en", "R. Federer defeats T. Berdych"}}); \ + const auto berdych_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_berdych_vs_federer_id, {{"en", "R. Federer defeats T. Berdych"}}); \ generate_blocks(1); \ - const betting_market_object& federer_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "M. Cilic defeats S. Querrey"}}); \ + const auto federer_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "M. Cilic defeats S. Querrey"}}); \ generate_blocks(1); \ - const betting_market_object& cilic_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_querrey.id, {{"en", "S. Querrey defeats M. Cilic"}});\ + const auto cilic_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_querrey_id, {{"en", "S. Querrey defeats M. Cilic"}});\ generate_blocks(1); \ - const betting_market_object& querrey_wins_market = *db.get_index_type().indices().get().rbegin(); \ - create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon.id); \ + const auto querrey_wins_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_event({{"en", "R. Federer/M. Cilic"}}, {{"en", "2017"}}, wimbledon_id); \ generate_blocks(1); \ - const event_object& cilic_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer.id, tennis_rules.id, asset_id_type(), false, 0); \ + const auto cilic_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market_group({{"en", "Moneyline final"}}, cilic_vs_federer_id, tennis_rules_id, asset_id_type(), false, 0); \ generate_blocks(1); \ - const betting_market_group_object& moneyline_cilic_vs_federer = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "R. Federer defeats M. Cilic"}}); \ + const auto moneyline_cilic_vs_federer_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "R. Federer defeats M. Cilic"}}); \ generate_blocks(1); \ - const betting_market_object& federer_wins_final_market = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market(moneyline_cilic_vs_federer.id, {{"en", "M. Cilic defeats R. Federer"}}); \ + const auto federer_wins_final_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + create_betting_market(moneyline_cilic_vs_federer_id, {{"en", "M. Cilic defeats R. Federer"}}); \ generate_blocks(1); \ - const betting_market_object& cilic_wins_final_market = *db.get_index_type().indices().get().rbegin(); \ - (void)federer_wins_market;(void)cilic_wins_market;(void)federer_wins_final_market; (void)cilic_wins_final_market; (void)berdych_wins_market; (void)querrey_wins_market; + const auto cilic_wins_final_market_id = to_id(*db.get_index_type().indices().get().rbegin()); \ + (void)federer_wins_market_id;(void)cilic_wins_market_id;(void)federer_wins_final_market_id; (void)cilic_wins_final_market_id; (void)berdych_wins_market_id; (void)querrey_wins_market_id; // set up a fixture that places a series of two matched bets, we'll use this fixture to verify // the result in all three possible outcomes @@ -149,25 +151,23 @@ struct simple_bet_test_fixture : database_fixture { { ACTORS( (alice)(bob) ); CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); + capitals_win_betting_market_id = capitals_win_market_id; + blackhawks_win_betting_market_id = blackhawks_win_market_id; // give alice and bob 10k each transfer(account_id_type(), alice_id, asset(10000)); transfer(account_id_type(), bob_id, asset(10000)); // place bets at 10:1 - place_bet(alice_id, capitals_win_market.id, bet_type::back, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, capitals_win_market.id, bet_type::lay, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(alice_id, capitals_win_market_id, bet_type::back, asset(100, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::lay, asset(1000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); // reverse positions at 1:1 - place_bet(alice_id, capitals_win_market.id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(bob_id, capitals_win_market.id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - - capitals_win_betting_market_id = capitals_win_market.id; - blackhawks_win_betting_market_id = blackhawks_win_market.id; - moneyline_betting_markets_id = moneyline_betting_markets.id; + place_bet(alice_id, capitals_win_market_id, bet_type::lay, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(bob_id, capitals_win_market_id, bet_type::back, asset(1100, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); // close betting to prepare for the next operation which will be grading or cancel - update_betting_market_group(moneyline_betting_markets.id, graphene::chain::keywords::_status = betting_market_group_status::closed); + update_betting_market_group(moneyline_betting_markets_id, graphene::chain::keywords::_status = betting_market_group_status::closed); generate_blocks(1); } }; diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index d7895f52..459f02f1 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -1615,6 +1615,7 @@ void database_fixture::resolve_betting_market_group(betting_market_group_id_type betting_market_group_resolve_operation betting_market_group_resolve_op; betting_market_group_resolve_op.betting_market_group_id = betting_market_group_id; betting_market_group_resolve_op.resolutions = resolutions; + wdump((resolutions)(betting_market_group_resolve_op)); process_operation_by_witnesses(betting_market_group_resolve_op); } FC_CAPTURE_AND_RETHROW( (betting_market_group_id)(resolutions) ) } diff --git a/tests/peerplays_sidechain/bitcoin_sign_tests.cpp b/tests/peerplays_sidechain/bitcoin_sign_tests.cpp index 501b9d44..87244fd5 100644 --- a/tests/peerplays_sidechain/bitcoin_sign_tests.cpp +++ b/tests/peerplays_sidechain/bitcoin_sign_tests.cpp @@ -193,7 +193,8 @@ BOOST_AUTO_TEST_CASE(weighted_multisig_spend_test) { int32_t hash_type = 1; // implement SIGHASH_ALL scheme for (auto &key : priv_keys) { - bytes key_data(key.get_secret().data(), key.get_secret().data() + key.get_secret().data_size()); + auto secret = key.get_secret(); + bytes key_data(secret.data(), secret.data() + secret.data_size()); std::vector sigs = sign_witness_transaction_part(tx, {redeem_script}, {amount}, key_data, btc_context(), hash_type); // insert signatures in reverse order tx.vin[0].scriptWitness.insert(tx.vin[0].scriptWitness.begin(), sigs[0]); @@ -335,7 +336,8 @@ BOOST_AUTO_TEST_CASE(user_sig_one_or_weighted_multisig_spend_test) { uint64_t amount = 10000; int32_t hash_type = 1; // implement SIGHASH_ALL scheme - bytes key_data(user_key.get_secret().data(), user_key.get_secret().data() + user_key.get_secret().data_size()); + auto secret = user_key.get_secret(); + bytes key_data(secret.data(), secret.data() + secret.data_size()); std::vector sigs = sign_witness_transaction_part(tx, {redeem_script}, {amount}, key_data, btc_context(), hash_type); tx.vin[0].scriptWitness.push_back(sigs[0]); sign_witness_transaction_finalize(tx, {redeem_script}, false); @@ -369,7 +371,8 @@ BOOST_AUTO_TEST_CASE(user_sig_one_or_weighted_multisig_spend_test) { int32_t hash_type = 1; // implement SIGHASH_ALL scheme for (auto &key : priv_keys) { - bytes key_data(key.get_secret().data(), key.get_secret().data() + key.get_secret().data_size()); + auto secret = key.get_secret(); + bytes key_data(secret.data(), secret.data() + secret.data_size()); std::vector sigs = sign_witness_transaction_part(tx, {redeem_script}, {amount}, key_data, btc_context(), hash_type); // insert signatures in reverse order tx.vin[0].scriptWitness.insert(tx.vin[0].scriptWitness.begin(), sigs[0]); @@ -435,7 +438,8 @@ BOOST_AUTO_TEST_CASE(user_sig_timelocked_one_or_weighted_multisig_spend_test) { uint64_t amount = 10000; int32_t hash_type = 1; // implement SIGHASH_ALL scheme - bytes key_data(user_key.get_secret().data(), user_key.get_secret().data() + user_key.get_secret().data_size()); + auto secret = user_key.get_secret(); + bytes key_data(secret.data(), secret.data() + secret.data_size()); std::vector sigs = sign_witness_transaction_part(tx, {redeem_script}, {amount}, key_data, btc_context(), hash_type); tx.vin[0].scriptWitness.push_back(sigs[0]); sign_witness_transaction_finalize(tx, {redeem_script}, false); diff --git a/tests/tests/account_role_tests.cpp b/tests/tests/account_role_tests.cpp index 17142154..b85ec96d 100644 --- a/tests/tests/account_role_tests.cpp +++ b/tests/tests/account_role_tests.cpp @@ -16,6 +16,9 @@ #include #include +#include +#include + #include #include diff --git a/tests/tests/affiliate_tests.cpp b/tests/tests/affiliate_tests.cpp index 804d9e8a..ad34b384 100644 --- a/tests/tests/affiliate_tests.cpp +++ b/tests/tests/affiliate_tests.cpp @@ -524,17 +524,17 @@ BOOST_AUTO_TEST_CASE( bookie_payout_test ) CREATE_ICE_HOCKEY_BETTING_MARKET(false, 0); // place bets at 10:1 - place_bet(ath.paula_id, capitals_win_market.id, bet_type::back, asset(10000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(ath.penny_id, capitals_win_market.id, bet_type::lay, asset(100000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(ath.paula_id, capitals_win_market_id, bet_type::back, asset(10000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(ath.penny_id, capitals_win_market_id, bet_type::lay, asset(100000, asset_id_type()), 11 * GRAPHENE_BETTING_ODDS_PRECISION); // reverse positions at 1:1 - place_bet(ath.paula_id, capitals_win_market.id, bet_type::lay, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - place_bet(ath.penny_id, capitals_win_market.id, bet_type::back, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(ath.paula_id, capitals_win_market_id, bet_type::lay, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); + place_bet(ath.penny_id, capitals_win_market_id, bet_type::back, asset(110000, asset_id_type()), 2 * GRAPHENE_BETTING_ODDS_PRECISION); - update_betting_market_group(moneyline_betting_markets.id, graphene::chain::keywords::_status = betting_market_group_status::closed); - resolve_betting_market_group(moneyline_betting_markets.id, - {{capitals_win_market.id, betting_market_resolution_type::win}, - {blackhawks_win_market.id, betting_market_resolution_type::not_win}}); + update_betting_market_group(moneyline_betting_markets_id, graphene::chain::keywords::_status = betting_market_group_status::closed); + resolve_betting_market_group(moneyline_betting_markets_id, + {{capitals_win_market_id, betting_market_resolution_type::win}, + {blackhawks_win_market_id, betting_market_resolution_type::not_win}}); generate_block(); uint16_t rake_fee_percentage = db.get_global_properties().parameters.betting_rake_fee_percentage(); @@ -559,10 +559,10 @@ BOOST_AUTO_TEST_CASE( bookie_payout_test ) issue_uia( ath.paula_id, asset( 1000000, btc_id ) ); issue_uia( ath.petra_id, asset( 1000000, btc_id ) ); - create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl.id); \ + create_event({{"en", "Washington Capitals/Chicago Blackhawks"}, {"zh_Hans", "華盛頓首都隊/芝加哥黑鷹"}, {"ja", "ワシントン・キャピタルズ/シカゴ・ブラックホークス"}}, {{"en", "2016-17"}}, nhl_id); \ generate_blocks(1); \ const event_object& capitals_vs_blackhawks2 = *db.get_index_type().indices().get().rbegin(); \ - create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks2.id, betting_market_rules.id, btc_id, false, 0); + create_betting_market_group({{"en", "Moneyline"}}, capitals_vs_blackhawks2.id, betting_market_rules_id, btc_id, false, 0); generate_blocks(1); const betting_market_group_object& moneyline_betting_markets2 = *db.get_index_type().indices().get().rbegin(); create_betting_market(moneyline_betting_markets2.id, {{"en", "Washington Capitals win"}}); diff --git a/tests/tests/custom_permission_tests.cpp b/tests/tests/custom_permission_tests.cpp index eb6694bb..b8a111f6 100644 --- a/tests/tests/custom_permission_tests.cpp +++ b/tests/tests/custom_permission_tests.cpp @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/tests/tests/sidechain_addresses_test.cpp b/tests/tests/sidechain_addresses_test.cpp index a58c051a..99d28d4b 100644 --- a/tests/tests/sidechain_addresses_test.cpp +++ b/tests/tests/sidechain_addresses_test.cpp @@ -5,6 +5,7 @@ #include #include #include + #include using namespace graphene::chain; diff --git a/tests/tests/son_wallet_tests.cpp b/tests/tests/son_wallet_tests.cpp index c6508268..dcde84c8 100644 --- a/tests/tests/son_wallet_tests.cpp +++ b/tests/tests/son_wallet_tests.cpp @@ -4,6 +4,7 @@ #include #include + #include using namespace graphene; From ab113b2fc48fa935b80da475db3843c8276b857f Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 1 Sep 2020 17:46:52 -0500 Subject: [PATCH 42/77] Add support for multiple evaluators per operation type This commit adds the ability to register multiple evaluator types for a given operation type. This will be used to allow plug-ins to define their own evaluators for various operation types (most notably, custom operations) so that they may be used to carry app-specific data which can be parsed by a plug-in. --- .../chain/include/graphene/chain/database.hpp | 20 +++++++++++++++++-- .../include/graphene/chain/evaluator.hpp | 13 +++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index f3c56ead..7e829f00 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -344,11 +344,27 @@ namespace graphene { namespace chain { void initialize_indexes(); void init_genesis(const genesis_state_type& genesis_state = genesis_state_type()); + /** + * @brief Register a new evaluator to the evaluator chain for its operation type + * @tparam EvaluatorType An evaluator type which will be used to evaluate its declared operation type + * + * This method registers a new evaluator type with tthe database. The evaluator specifies an operation type + * which it should be used to evaluate. The evaluator will be instantiated each time an operaton of the + * appropriate type is processed and used to evaluate the operation. + * + * This method may be called more than once with multiple evaluator types for a given operation type. When + * multiple evaluator types are registered for a given operation type, they will all execute in the order of + * registration; however, only the return value of the first registered evaluator will be returned; return + * values of subsequently registered evaluators will be silently dropped. + */ template void register_evaluator() { - _operation_evaluators[ - operation::tag::value].reset( new op_evaluator_impl() ); + auto& eval_ptr = _operation_evaluators[operation::tag::value]; + if (eval_ptr == nullptr) + eval_ptr = std::make_unique>(); + else + eval_ptr->append_evaluator(std::make_unique>()); } //////////////////// db_balance.cpp //////////////////// diff --git a/libraries/chain/include/graphene/chain/evaluator.hpp b/libraries/chain/include/graphene/chain/evaluator.hpp index 0a1cc986..25680528 100644 --- a/libraries/chain/include/graphene/chain/evaluator.hpp +++ b/libraries/chain/include/graphene/chain/evaluator.hpp @@ -124,17 +124,28 @@ namespace graphene { namespace chain { { public: virtual ~op_evaluator(){} + virtual void append_evaluator(unique_ptr next_evaluator) = 0; virtual operation_result evaluate(transaction_evaluation_state& eval_state, const operation& op, bool apply) = 0; }; template class op_evaluator_impl : public op_evaluator { + unique_ptr next_evaluator; public: + virtual void append_evaluator(unique_ptr next_evaluator) override { + if (this->next_evaluator == nullptr) + this->next_evaluator = std::move(next_evaluator); + else + this->next_evaluator->append_evaluator(std::move(next_evaluator)); + } virtual operation_result evaluate(transaction_evaluation_state& eval_state, const operation& op, bool apply = true) override { T eval; - return eval.start_evaluate(eval_state, op, apply); + auto result = eval.start_evaluate(eval_state, op, apply); + if (next_evaluator != nullptr) + next_evaluator->evaluate(eval_state, op, apply); + return result; } }; From 95d4cbdf4af228f9c2dee3b4e31269942e346fdf Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 1 Sep 2020 17:47:19 -0500 Subject: [PATCH 43/77] Add build/IDE artifacts to gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 5f127e5f..4844838a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ *.a *.sw* +/build +/build-* + +CMakeLists.txt.user *.cmake CMakeCache.txt CMakeFiles From 082df7ab4a77c34685ec9c146931b5a5f176cd75 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Mon, 26 Oct 2020 17:02:22 -0500 Subject: [PATCH 44/77] Allow build of dynamic libraries In order to support dynamically linked nodes based on Graphene, add support for building dynamic libraries for the core Graphene modules: chain, db, protocol, net, and utilities. --- CMakeLists.txt | 6 ++++-- libraries/chain/CMakeLists.txt | 16 ++++++++++------ libraries/db/CMakeLists.txt | 15 ++++++++++++++- libraries/net/CMakeLists.txt | 6 +++++- libraries/protocol/CMakeLists.txt | 7 ++++++- libraries/utilities/CMakeLists.txt | 13 ++++++++++--- 6 files changed, 49 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index debcd378..82a21c3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,9 @@ set( CUSTOM_URL_SCHEME "gcs" ) set( INSTALLER_APP_ID "68ad7005-8eee-49c9-95ce-9eed97e5b347" ) set( CMAKE_CXX_STANDARD 14 ) +set( GRAPHENE_BUILD_DYNAMIC_LIBRARIES OFF CACHE BOOL + "Whether to build dynamic libraries instead of static. Applies only to chain, db, protocol, net, and utilities" ) + # http://stackoverflow.com/a/18369825 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) @@ -162,8 +165,7 @@ endif() add_subdirectory( libraries ) - -set(BUILD_BITSHARES_PROGRAMS TRUE CACHE BOOL "Build bitshares executables (witness node, cli wallet, etc)") +set(BUILD_PEERPLAYS_PROGRAMS TRUE CACHE BOOL "Build peerplays executables (witness node, cli wallet, etc)") add_subdirectory( programs ) set(BUILD_BITSHARES_TESTS TRUE CACHE BOOL "Build bitshares unit tests") diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 8d13885a..3319aedf 100755 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -19,12 +19,16 @@ else( GRAPHENE_DISABLE_UNITY_BUILD ) message( STATUS "Graphene database unity build enabled" ) endif( GRAPHENE_DISABLE_UNITY_BUILD ) -## SORT .cpp by most likely to change / break compile -add_library( graphene_chain - ${CPP_FILES} - ${HEADERS} - "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp" - ) +set( GRAPHENE_CHAIN_FILES + ${CPP_FILES} + ${HEADERS} + "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp" + ) +if (NOT ${GRAPHENE_BUILD_DYNAMIC_LIBRARIES}) + add_library( graphene_chain ${GRAPHENE_CHAIN_FILES} ) +else() + add_library( graphene_chain SHARED ${GRAPHENE_CHAIN_FILES} ) +endif() add_dependencies( graphene_chain build_hardfork_hpp ) target_link_libraries( graphene_chain fc graphene_db graphene_protocol ) diff --git a/libraries/db/CMakeLists.txt b/libraries/db/CMakeLists.txt index b0899d86..8ec6fea1 100644 --- a/libraries/db/CMakeLists.txt +++ b/libraries/db/CMakeLists.txt @@ -1,5 +1,18 @@ file(GLOB HEADERS "include/graphene/db/*.hpp") -add_library( graphene_db undo_database.cpp index.cpp object_database.cpp ${HEADERS} ) + +set( GRAPHENE_DB_FILES + undo_database.cpp + index.cpp + object_database.cpp + ${HEADERS} + ) + +if (NOT ${GRAPHENE_BUILD_DYNAMIC_LIBRARIES}) + add_library( graphene_db ${GRAPHENE_DB_FILES} ) +else() + add_library( graphene_db SHARED ${GRAPHENE_DB_FILES} ) +endif() + target_link_libraries( graphene_db graphene_protocol fc ) target_include_directories( graphene_db PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/net/CMakeLists.txt b/libraries/net/CMakeLists.txt index 806864af..2dcc2c78 100644 --- a/libraries/net/CMakeLists.txt +++ b/libraries/net/CMakeLists.txt @@ -9,7 +9,11 @@ set(SOURCES node.cpp message.cpp message_oriented_connection.cpp) -add_library( graphene_net ${SOURCES} ${HEADERS} ) +if (NOT ${GRAPHENE_BUILD_DYNAMIC_LIBRARIES}) + add_library( graphene_net ${SOURCES} ${HEADERS} ) +else() + add_library( graphene_net SHARED ${SOURCES} ${HEADERS} ) +endif() target_link_libraries( graphene_net PUBLIC fc graphene_db graphene_protocol ) diff --git a/libraries/protocol/CMakeLists.txt b/libraries/protocol/CMakeLists.txt index a96e3bfe..8c05638f 100644 --- a/libraries/protocol/CMakeLists.txt +++ b/libraries/protocol/CMakeLists.txt @@ -42,7 +42,12 @@ list(APPEND SOURCES account.cpp ) -add_library( graphene_protocol ${SOURCES} ${HEADERS} ) +if (NOT ${GRAPHENE_BUILD_DYNAMIC_LIBRARIES}) + add_library( graphene_protocol ${SOURCES} ${HEADERS} ) +else() + add_library( graphene_protocol SHARED ${SOURCES} ${HEADERS} ) +endif() + target_link_libraries( graphene_protocol fc ) target_include_directories( graphene_protocol PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) diff --git a/libraries/utilities/CMakeLists.txt b/libraries/utilities/CMakeLists.txt index 98086b10..22decaf7 100644 --- a/libraries/utilities/CMakeLists.txt +++ b/libraries/utilities/CMakeLists.txt @@ -20,9 +20,16 @@ set(sources configure_file("${CMAKE_CURRENT_SOURCE_DIR}/git_revision.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp" @ONLY) list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp") -add_library( graphene_utilities - ${sources} - ${HEADERS} ) +if (NOT ${GRAPHENE_BUILD_DYNAMIC_LIBRARIES}) + add_library( graphene_utilities + ${sources} + ${HEADERS} ) +else() + add_library( graphene_utilities SHARED + ${sources} + ${HEADERS} ) +endif() + target_link_libraries( graphene_utilities fc ) target_include_directories( graphene_utilities PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) From c76e1f3157a18e16519772ea89fffb526e4bb729 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sat, 23 Jan 2021 21:39:23 -0600 Subject: [PATCH 45/77] Toward dynamically reloading contracts... Add the ability to dynamically unload an auxiliary evaluator (any evaluator for a given operation type except the first one registered for that operation type), and as an added convenience, add an idiomatically consistent way to check if a given index is already registered or not. --- .../chain/include/graphene/chain/database.hpp | 30 +++++++++++- .../include/graphene/chain/evaluator.hpp | 49 ++++++++++++++++--- .../include/graphene/db/object_database.hpp | 4 ++ libraries/db/object_database.cpp | 7 +++ 4 files changed, 80 insertions(+), 10 deletions(-) diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index 7e829f00..a4d3248b 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -347,6 +347,8 @@ namespace graphene { namespace chain { /** * @brief Register a new evaluator to the evaluator chain for its operation type * @tparam EvaluatorType An evaluator type which will be used to evaluate its declared operation type + * @return If registering an evaluator for an operation that already has an evaluator, returns a handle for + * the newly added evaluator which can be used to delete it later. * * This method registers a new evaluator type with tthe database. The evaluator specifies an operation type * which it should be used to evaluate. The evaluator will be instantiated each time an operaton of the @@ -356,15 +358,39 @@ namespace graphene { namespace chain { * multiple evaluator types are registered for a given operation type, they will all execute in the order of * registration; however, only the return value of the first registered evaluator will be returned; return * values of subsequently registered evaluators will be silently dropped. + * + * The first evaluator registered for a given operation type is permanent, and is the only evaluator which + * can return a value. Subsequent (auxiliary) evaluators for that operation type can be deleted at runtime + * by calling @ref delete_evaluator() with the evaluator_handle obtained when registering the evaluator. */ template - void register_evaluator() + optional register_evaluator() { auto& eval_ptr = _operation_evaluators[operation::tag::value]; if (eval_ptr == nullptr) eval_ptr = std::make_unique>(); else - eval_ptr->append_evaluator(std::make_unique>()); + return eval_ptr->append_evaluator(std::make_unique>()); + return {}; + } + + /** + * @brief Delete an auxiliary evaluator + * @param handle The evaluator handle for the evaluator to delete, as returned by @ref register_evaluator + * + * Auxiliary evaluators, or the second and subsequent evaluators registered for a given operation type, + * can be deleted so that they no longer execute when operations of the relevant type are processed. + * + * If it may be desired to delete an auxiliary evaluator, retain the evaluator handle obtained when the + * evaluator was initially registered and when it is necessary to delete the evaluator, pass the handle + * to this function. + * + * The evaluator will have been deleted by the time this function returns. + */ + void delete_evaluator(op_evaluator::evaluator_handle&& handle) + { + if ((uint64_t)handle.get_operation_type() < _operation_evaluators.size()) + _operation_evaluators[handle.get_operation_type()]->delete_evaluator(std::move(handle)); } //////////////////// db_balance.cpp //////////////////// diff --git a/libraries/chain/include/graphene/chain/evaluator.hpp b/libraries/chain/include/graphene/chain/evaluator.hpp index 25680528..ca13a1d3 100644 --- a/libraries/chain/include/graphene/chain/evaluator.hpp +++ b/libraries/chain/include/graphene/chain/evaluator.hpp @@ -122,29 +122,62 @@ namespace graphene { namespace chain { class op_evaluator { + protected: + unique_ptr next_evaluator; public: + class evaluator_handle { + // Move-only semantics, and only friends can construct + evaluator_handle(const op_evaluator* pointer, operation::tag_type type) + : pointer(pointer), operation_type(type) {} + evaluator_handle(const evaluator_handle&) = delete; + evaluator_handle& operator=(const evaluator_handle&) = delete; + + friend class op_evaluator; + template + friend class op_evaluator_impl; + + // Pointer to the handled evaluator + const op_evaluator* pointer; + // Tag of the handled evaluator + operation::tag_type operation_type; + + public: + evaluator_handle(evaluator_handle&&) = default; + evaluator_handle& operator=(evaluator_handle&&) = default; + + operation::tag_type get_operation_type() const { return operation_type; } + }; + virtual ~op_evaluator(){} - virtual void append_evaluator(unique_ptr next_evaluator) = 0; + virtual evaluator_handle append_evaluator(unique_ptr next_evaluator) = 0; + virtual void delete_evaluator(evaluator_handle&& handle) { + if (next_evaluator.get() == handle.pointer) + // Next evaluator in chain is the one to delete. Move its next pointer into ours, and unique_ptr will delete the one that's going away. + next_evaluator = std::move(next_evaluator->next_evaluator); + else + next_evaluator->delete_evaluator(std::move(handle)); + } virtual operation_result evaluate(transaction_evaluation_state& eval_state, const operation& op, bool apply) = 0; }; template class op_evaluator_impl : public op_evaluator { - unique_ptr next_evaluator; public: - virtual void append_evaluator(unique_ptr next_evaluator) override { - if (this->next_evaluator == nullptr) + virtual evaluator_handle append_evaluator(unique_ptr next_evaluator) override { + if (this->next_evaluator == nullptr) { this->next_evaluator = std::move(next_evaluator); - else - this->next_evaluator->append_evaluator(std::move(next_evaluator)); + return evaluator_handle(this->next_evaluator.get(), operation::tag::value); + } else { + return this->next_evaluator->append_evaluator(std::move(next_evaluator)); + } } virtual operation_result evaluate(transaction_evaluation_state& eval_state, const operation& op, bool apply = true) override { T eval; auto result = eval.start_evaluate(eval_state, op, apply); - if (next_evaluator != nullptr) - next_evaluator->evaluate(eval_state, op, apply); + if (this->next_evaluator != nullptr) + this->next_evaluator->evaluate(eval_state, op, apply); return result; } }; diff --git a/libraries/db/include/graphene/db/object_database.hpp b/libraries/db/include/graphene/db/object_database.hpp index d51249e1..a1efbfff 100644 --- a/libraries/db/include/graphene/db/object_database.hpp +++ b/libraries/db/include/graphene/db/object_database.hpp @@ -75,6 +75,10 @@ namespace graphene { namespace db { const index& get_index()const { return get_index(T::space_id,T::type_id); } const index& get_index(uint8_t space_id, uint8_t type_id)const; const index& get_index(object_id_type id)const { return get_index(id.space(),id.type()); } + template + const index* find_index()const { return find_index(T::space_id,T::type_id); } + const index* find_index(object_id_type id)const { return find_index(id.space(), id.type()); } + const index* find_index(uint8_t space_id, uint8_t type_id)const; /// @} const object& get_object( object_id_type id )const; diff --git a/libraries/db/object_database.cpp b/libraries/db/object_database.cpp index 7e67c926..2f8d9565 100644 --- a/libraries/db/object_database.cpp +++ b/libraries/db/object_database.cpp @@ -58,6 +58,13 @@ const index& object_database::get_index(uint8_t space_id, uint8_t type_id)const FC_ASSERT( tmp ); return *tmp; } + +const index* object_database::find_index(uint8_t space_id, uint8_t type_id) const +{ + if (_index.size() > space_id && _index[space_id].size() > type_id) + return _index[space_id][type_id].get(); + return nullptr; +} index& object_database::get_mutable_index(uint8_t space_id, uint8_t type_id) { FC_ASSERT( _index.size() > space_id, "", ("space_id",space_id)("type_id",type_id)("index.size",_index.size()) ); From 3f50447013f2e249633213de22534fa599597caf Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 29 Jan 2021 12:56:42 -0600 Subject: [PATCH 46/77] Fix dynamic libs build --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82a21c3d..0460207a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,9 @@ set( CMAKE_CXX_STANDARD 14 ) set( GRAPHENE_BUILD_DYNAMIC_LIBRARIES OFF CACHE BOOL "Whether to build dynamic libraries instead of static. Applies only to chain, db, protocol, net, and utilities" ) +if( GRAPHENE_BUILD_DYNAMIC_LIBRARIES ) + set( CMAKE_POSITION_INDEPENDENT_CODE ON ) +endif() # http://stackoverflow.com/a/18369825 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") From e168d2d830223e9754843f2d47a63977df6f4437 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 29 Jan 2021 14:30:58 -0600 Subject: [PATCH 47/77] Fix install of hardfork.hpp --- libraries/chain/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 3319aedf..2fa3619c 100755 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -5,7 +5,8 @@ set_source_files_properties( "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain add_dependencies( build_hardfork_hpp cat-parts ) -file(GLOB HEADERS "include/graphene/chain/*.hpp" "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp") +file(GLOB HEADERS "include/graphene/chain/*.hpp") +list(APPEND HEADERS "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp") file(GLOB CPP_FILES "*.cpp") From 95afb342c3541a30cc5a00a8454dccf950bb300f Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 2 Mar 2021 11:14:13 -0600 Subject: [PATCH 48/77] Fix to dynamic builds FC wasn't always getting the memo that it should build dynamically if Graphene is. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0460207a..af731667 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ set( GRAPHENE_BUILD_DYNAMIC_LIBRARIES OFF CACHE BOOL if( GRAPHENE_BUILD_DYNAMIC_LIBRARIES ) set( CMAKE_POSITION_INDEPENDENT_CODE ON ) endif() +set( FC_BUILD_DYNAMIC_LIBRARIES ${GRAPHENE_BUILD_DYNAMIC_LIBRARIES} CACHE BOOL "Whether FC should build as a dynamic library rather than static" ) # http://stackoverflow.com/a/18369825 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") From 0d18523d8fcc60be2a1c014f63158b5f6ecedc2f Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 2 Mar 2021 12:53:57 -0600 Subject: [PATCH 49/77] Fix dynamic build In some environments, dynamic linking fails if Boost is static --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af731667..dd3383f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,12 @@ LIST(APPEND BOOST_COMPONENTS thread unit_test_framework context locale) -SET( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" ) + +IF( ${GRAPHENE_BUILD_DYNAMIC_LIBRARIES} ) + SET( Boost_USE_STATIC_LIBS OFF CACHE STRING "ON or OFF" ) +ELSE() + SET( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" ) +ENDIF() IF( WIN32 ) SET(BOOST_ROOT $ENV{BOOST_ROOT}) From 0c320fdc714e67e6c8d297197d2e0d31adfb9a41 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 2 Mar 2021 13:06:11 -0600 Subject: [PATCH 50/77] Add missing header --- .../include/graphene/peerplays_sidechain/bitcoin/serialize.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp index b234f8a4..60ab6c2f 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/serialize.hpp @@ -3,6 +3,8 @@ #include #include +#include + namespace graphene { namespace peerplays_sidechain { namespace bitcoin { inline void write_compact_size(bytes &vec, size_t size) { From 8a6bae6006b136aa579e6fea9ed4678081beaa31 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 2 Mar 2021 21:54:47 -0600 Subject: [PATCH 51/77] Fix tests These tests did not properly define their BOOST_TEST_MODULE macro, causing linking to fail in some environments. --- tests/betting/betting_tests.cpp | 3 +++ tests/peerplays_sidechain/peerplays_sidechain_tests.cpp | 4 ++-- tests/performance/performance_tests.cpp | 3 +++ tests/random/random_tests.cpp | 3 +++ tests/tournament/tournament_tests.cpp | 3 +++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/betting/betting_tests.cpp b/tests/betting/betting_tests.cpp index 5ac3d8c8..09ed9c38 100644 --- a/tests/betting/betting_tests.cpp +++ b/tests/betting/betting_tests.cpp @@ -21,6 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + +#define BOOST_TEST_MODULE Peerplays Betting Tests + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // disable auto_ptr deprecated warning, see https://svn.boost.org/trac10/ticket/11622 diff --git a/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp b/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp index 84577384..d14fa602 100644 --- a/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp +++ b/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp @@ -1,7 +1,7 @@ -#include - #define BOOST_TEST_MODULE Peerplays SON Tests +#include + BOOST_AUTO_TEST_CASE(peerplays_sidechain) { } diff --git a/tests/performance/performance_tests.cpp b/tests/performance/performance_tests.cpp index 70824818..5f36a3fc 100644 --- a/tests/performance/performance_tests.cpp +++ b/tests/performance/performance_tests.cpp @@ -21,6 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + +#define BOOST_TEST_MODULE Performance Tests + #include #include diff --git a/tests/random/random_tests.cpp b/tests/random/random_tests.cpp index e224439a..db30658d 100644 --- a/tests/random/random_tests.cpp +++ b/tests/random/random_tests.cpp @@ -21,6 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + +#define BOOST_TEST_MODULE Random Tests + #include //#include //#include diff --git a/tests/tournament/tournament_tests.cpp b/tests/tournament/tournament_tests.cpp index 1c5f51f7..ba0cffe2 100644 --- a/tests/tournament/tournament_tests.cpp +++ b/tests/tournament/tournament_tests.cpp @@ -21,6 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + +#define BOOST_TEST_MODULE Peerplays Tournament Tests + #include #include #include From 906ffa6351f9f5b260fefe0695af8a1394ee463e Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Fri, 5 Mar 2021 12:05:11 -0600 Subject: [PATCH 52/77] Fix tests better The solution being used for initializing the boost test modules is now deprecated, so update it to use the global test fixture instead --- tests/betting/betting_tests.cpp | 25 +++++------- tests/intense/main.cpp | 22 ++++++---- .../peerplays_sidechain_tests.cpp | 16 ++++---- tests/performance/performance_tests.cpp | 16 ++++---- tests/random/random_tests.cpp | 40 +++++++++---------- tests/tests/main.cpp | 22 +++++----- tests/tournament/tournament_tests.cpp | 16 ++++---- 7 files changed, 75 insertions(+), 82 deletions(-) diff --git a/tests/betting/betting_tests.cpp b/tests/betting/betting_tests.cpp index 09ed9c38..2732d874 100644 --- a/tests/betting/betting_tests.cpp +++ b/tests/betting/betting_tests.cpp @@ -2860,21 +2860,14 @@ BOOST_AUTO_TEST_CASE( wimbledon_2017_gentelmen_singles_final_test ) BOOST_AUTO_TEST_SUITE_END() +struct GlobalInitializationFixture { + GlobalInitializationFixture() { + std::srand(time(NULL)); + std::cout << "Random number generator seeded to " << time(NULL) << std::endl; - -//#define BOOST_TEST_MODULE "C++ Unit Tests for Graphene Blockchain Database" -#include -#include -#include - -boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { - std::srand(time(NULL)); - std::cout << "Random number generator seeded to " << time(NULL) << std::endl; - - // betting operations don't take effect until HARDFORK 1000 - GRAPHENE_TESTING_GENESIS_TIMESTAMP = - (HARDFORK_1000_TIME.sec_since_epoch() + 15) / GRAPHENE_DEFAULT_BLOCK_INTERVAL * GRAPHENE_DEFAULT_BLOCK_INTERVAL; - - return nullptr; -} + // betting operations don't take effect until HARDFORK 1000 + GRAPHENE_TESTING_GENESIS_TIMESTAMP = HARDFORK_1000_TIME.sec_since_epoch() + 2; + } +}; +BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture); diff --git a/tests/intense/main.cpp b/tests/intense/main.cpp index c337407f..b2b2a6cb 100644 --- a/tests/intense/main.cpp +++ b/tests/intense/main.cpp @@ -21,12 +21,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include -#include -boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { - std::srand(time(NULL)); - std::cout << "Random number generator seeded to " << time(NULL) << std::endl; - return nullptr; -} +#define BOOST_TEST_MODULE Intense Tests + +#include + +#include + +struct GlobalInitializationFixture { + GlobalInitializationFixture() { + std::srand(time(NULL)); + std::cout << "Random number generator seeded to " << time(NULL) << std::endl; + } +}; +BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture); + diff --git a/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp b/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp index d14fa602..ca2de270 100644 --- a/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp +++ b/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp @@ -5,13 +5,11 @@ BOOST_AUTO_TEST_CASE(peerplays_sidechain) { } -#include -#include -#include +struct GlobalInitializationFixture { + GlobalInitializationFixture() { + std::srand(time(NULL)); + std::cout << "Random number generator seeded to " << time(NULL) << std::endl; + } +}; +BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture); -boost::unit_test::test_suite *init_unit_test_suite(int argc, char *argv[]) { - std::srand(time(NULL)); - std::cout << "Random number generator seeded to " << time(NULL) << std::endl; - - return nullptr; -} diff --git a/tests/performance/performance_tests.cpp b/tests/performance/performance_tests.cpp index 5f36a3fc..c3fc2d74 100644 --- a/tests/performance/performance_tests.cpp +++ b/tests/performance/performance_tests.cpp @@ -74,13 +74,11 @@ BOOST_AUTO_TEST_CASE( transfer_benchmark ) //BOOST_AUTO_TEST_SUITE_END() -//#define BOOST_TEST_MODULE "C++ Unit Tests for Graphene Blockchain Database" -#include -#include -#include +struct GlobalInitializationFixture { + GlobalInitializationFixture() { + std::srand(time(NULL)); + std::cout << "Random number generator seeded to " << time(NULL) << std::endl; + } +}; +BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture); -boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { - std::srand(time(NULL)); - std::cout << "Random number generator seeded to " << time(NULL) << std::endl; - return nullptr; -} diff --git a/tests/random/random_tests.cpp b/tests/random/random_tests.cpp index db30658d..10c19d75 100644 --- a/tests/random/random_tests.cpp +++ b/tests/random/random_tests.cpp @@ -134,24 +134,24 @@ BOOST_FIXTURE_TEST_CASE( basic, database_fixture ) BOOST_AUTO_TEST_SUITE_END() -//#define BOOST_TEST_MODULE "C++ Unit Tests for Graphene Blockchain Database" -#include -#include -#include - -boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { - for (int i=1; i #include #include extern uint32_t GRAPHENE_TESTING_GENESIS_TIMESTAMP; -boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { - std::srand(time(NULL)); - std::cout << "Random number generator seeded to " << time(NULL) << std::endl; - const char* genesis_timestamp_str = getenv("GRAPHENE_TESTING_GENESIS_TIMESTAMP"); - if( genesis_timestamp_str != nullptr ) - { - GRAPHENE_TESTING_GENESIS_TIMESTAMP = std::stoul( genesis_timestamp_str ); - } - std::cout << "GRAPHENE_TESTING_GENESIS_TIMESTAMP is " << GRAPHENE_TESTING_GENESIS_TIMESTAMP << std::endl; - return nullptr; -} +struct GlobalInitializationFixture { + GlobalInitializationFixture() { + std::srand(time(NULL)); + std::cout << "Random number generator seeded to " << time(NULL) << std::endl; + } +}; +BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture); + diff --git a/tests/tournament/tournament_tests.cpp b/tests/tournament/tournament_tests.cpp index ba0cffe2..6ebd047a 100644 --- a/tests/tournament/tournament_tests.cpp +++ b/tests/tournament/tournament_tests.cpp @@ -2259,13 +2259,11 @@ BOOST_FIXTURE_TEST_CASE( massive, database_fixture ) BOOST_AUTO_TEST_SUITE_END() -//#define BOOST_TEST_MODULE "C++ Unit Tests for Graphene Blockchain Database" -#include -#include -#include +struct GlobalInitializationFixture { + GlobalInitializationFixture() { + std::srand(time(NULL)); + std::cout << "Random number generator seeded to " << time(NULL) << std::endl; + } +}; +BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture); -boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { - std::srand(time(NULL)); - std::cout << "Random number generator seeded to " << time(NULL) << std::endl; - return nullptr; -} From ec66970d78b3804aeeb90eba57fb6c07f21840ab Mon Sep 17 00:00:00 2001 From: Michel Santos Date: Thu, 11 Nov 2021 15:40:39 -0500 Subject: [PATCH 53/77] Add missing header --- tests/intense/main.cpp | 1 + tests/peerplays_sidechain/peerplays_sidechain_tests.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/tests/intense/main.cpp b/tests/intense/main.cpp index b2b2a6cb..5e9a5fd2 100644 --- a/tests/intense/main.cpp +++ b/tests/intense/main.cpp @@ -27,6 +27,7 @@ #include #include +#include struct GlobalInitializationFixture { GlobalInitializationFixture() { diff --git a/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp b/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp index ca2de270..7a7f9f9a 100644 --- a/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp +++ b/tests/peerplays_sidechain/peerplays_sidechain_tests.cpp @@ -2,6 +2,8 @@ #include +#include + BOOST_AUTO_TEST_CASE(peerplays_sidechain) { } From c8cfaeb5297cc67bb363fc8ced862b3a29a51abf Mon Sep 17 00:00:00 2001 From: Michel Santos Date: Thu, 11 Nov 2021 18:47:23 -0500 Subject: [PATCH 54/77] Fix test by reverting to the original timestamp used for the genesis --- tests/betting/betting_tests.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/betting/betting_tests.cpp b/tests/betting/betting_tests.cpp index 2732d874..9c1cfb74 100644 --- a/tests/betting/betting_tests.cpp +++ b/tests/betting/betting_tests.cpp @@ -2865,8 +2865,14 @@ struct GlobalInitializationFixture { std::srand(time(NULL)); std::cout << "Random number generator seeded to " << time(NULL) << std::endl; + // The genesis timestamp (GRAPHENE_TESTING_GENESIS_TIMESTAMP), + // which is verified by database::init_genesis(), + // should maintain compatibility with the periodicity + // expected from the GRAPHENE_DEFAULT_BLOCK_INTERVAL. + // // betting operations don't take effect until HARDFORK 1000 - GRAPHENE_TESTING_GENESIS_TIMESTAMP = HARDFORK_1000_TIME.sec_since_epoch() + 2; + GRAPHENE_TESTING_GENESIS_TIMESTAMP = + (HARDFORK_1000_TIME.sec_since_epoch() + 15) / GRAPHENE_DEFAULT_BLOCK_INTERVAL * GRAPHENE_DEFAULT_BLOCK_INTERVAL; } }; BOOST_TEST_GLOBAL_FIXTURE(GlobalInitializationFixture); From a5a78dacf143e6b685ff2aab4834f33fa5d0e1df Mon Sep 17 00:00:00 2001 From: Michel Santos Date: Sat, 13 Nov 2021 08:42:42 -0500 Subject: [PATCH 55/77] Update fc to merger of latest-fc into dapp-support-fc --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 21418ec4..9ed3f6e3 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 21418ec46e7e9bb40f77b2312761976d909722ec +Subproject commit 9ed3f6e338007c039af09fd86d5e42f685f51a6b From 8df442a65f9012ae747041953abcd85d065e516a Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Sun, 2 Jan 2022 14:22:03 -0600 Subject: [PATCH 56/77] Add secondary_index concerns Add a way to create a secondary index with the space/type ID of the object rather than the compile-time type, which may not always be available. Also, add a way to delete a secondary index (whether by compile-time type or by object space/type ID). --- libraries/db/include/graphene/db/index.hpp | 7 +++++++ .../include/graphene/db/object_database.hpp | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index 6a6fb3f1..c02aeb69 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -183,6 +183,13 @@ namespace graphene { namespace db { FC_THROW_EXCEPTION( fc::assert_exception, "invalid index type" ); } + void delete_secondary_index(const secondary_index& secondary) { + auto itr = std::find_if(_sindex.begin(), _sindex.end(), + [&secondary](const auto& ptr) { return &secondary == ptr.get(); }); + FC_ASSERT(itr != _sindex.end(), "Cannot remove secondary index: secondary index not found"); + _sindex.erase(itr); + } + protected: vector< shared_ptr > _observers; vector< unique_ptr > _sindex; diff --git a/libraries/db/include/graphene/db/object_database.hpp b/libraries/db/include/graphene/db/object_database.hpp index a1efbfff..f96f29c3 100644 --- a/libraries/db/include/graphene/db/object_database.hpp +++ b/libraries/db/include/graphene/db/object_database.hpp @@ -152,6 +152,27 @@ namespace graphene { namespace db { { return get_mutable_index_type().template add_secondary_index(); } + template + SecondaryIndexType* add_secondary_index(const uint8_t space_id, const uint8_t type_id) + { + auto* base_primary = dynamic_cast(&get_mutable_index(space_id, type_id)); + FC_ASSERT(base_primary != nullptr, + "Cannot add secondary index: index for space ID ${S} and type ID ${T} does not support secondary indexes.", + ("S", space_id)("T", type_id)); + return base_primary->template add_secondary_index(); + } + + template + void delete_secondary_index(const secondary_index& secondary) { + get_mutable_index_type().delete_secondary_index(secondary); + } + void delete_secondary_index(const uint8_t space_id, const uint8_t type_id, const secondary_index& secondary) { + auto* base_primary = dynamic_cast(&get_mutable_index(space_id, type_id)); + FC_ASSERT(base_primary != nullptr, + "Cannot add secondary index: index for space ID ${S} and type ID ${T} does not support secondary indexes.", + ("S", space_id)("T", type_id)); + base_primary->delete_secondary_index(secondary); + } void pop_undo(); From d2dedbc4e4b067783e81b18e1eca586b7efce433 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Sun, 2 Jan 2022 14:32:56 -0600 Subject: [PATCH 57/77] Remove database unity build Upstream dropped it and it was causing problems, so let it go! --- libraries/chain/CMakeLists.txt | 12 ++++++------ libraries/chain/database.cpp | 35 ---------------------------------- 2 files changed, 6 insertions(+), 41 deletions(-) delete mode 100644 libraries/chain/database.cpp diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 2fa3619c..c913b222 100755 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -10,15 +10,15 @@ list(APPEND HEADERS "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork file(GLOB CPP_FILES "*.cpp") -if( GRAPHENE_DISABLE_UNITY_BUILD ) +#if( GRAPHENE_DISABLE_UNITY_BUILD ) list(FILTER CPP_FILES EXCLUDE REGEX "[/]database[.]cpp$") #message ("--- ${CPP_FILES}") message( STATUS "Graphene database unity build disabled" ) -else( GRAPHENE_DISABLE_UNITY_BUILD ) - set( GRAPHENE_DB_FILES - database.cpp ) - message( STATUS "Graphene database unity build enabled" ) -endif( GRAPHENE_DISABLE_UNITY_BUILD ) +#else( GRAPHENE_DISABLE_UNITY_BUILD ) +# set( GRAPHENE_DB_FILES +# database.cpp ) +# message( STATUS "Graphene database unity build enabled" ) +#endif( GRAPHENE_DISABLE_UNITY_BUILD ) set( GRAPHENE_CHAIN_FILES ${CPP_FILES} diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp deleted file mode 100644 index 1e124902..00000000 --- a/libraries/chain/database.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#include "db_balance.cpp" -#include "db_bet.cpp" -#include "db_block.cpp" -#include "db_debug.cpp" -#include "db_getter.cpp" -#include "db_init.cpp" -#include "db_maint.cpp" -#include "db_management.cpp" -#include "db_market.cpp" -#include "db_update.cpp" -#include "db_witness_schedule.cpp" -#include "db_notify.cpp" \ No newline at end of file From 5fe3408893070648f4314108fac9fa3709cfffbd Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Sun, 2 Jan 2022 14:45:13 -0600 Subject: [PATCH 58/77] Allow querying number of objects in object space Previously, there was no good way to determine how many objects are in an object space. Add a way to do so. --- libraries/db/include/graphene/db/object_database.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libraries/db/include/graphene/db/object_database.hpp b/libraries/db/include/graphene/db/object_database.hpp index f96f29c3..e36353ea 100644 --- a/libraries/db/include/graphene/db/object_database.hpp +++ b/libraries/db/include/graphene/db/object_database.hpp @@ -174,6 +174,13 @@ namespace graphene { namespace db { base_primary->delete_secondary_index(secondary); } + // Count the number of objects (indexes) in the specified object space. + // Assuming there are no gaps in the list of type IDs in the space, this will be one greater than the last type ID. + uint8_t count_objects_in_space(const uint8_t space_id) const { + FC_ASSERT(space_id < _index.size(), "Cannot count objects in space ${S}: No such object space", ("S", space_id)); + return std::count_if(_index[space_id].begin(), _index[space_id].end(), [](const auto& ptr) { return bool(ptr); }); + } + void pop_undo(); fc::path get_data_dir()const { return _data_dir; } From c2675b44235b79eb0a788478399ac2f9c2af11f7 Mon Sep 17 00:00:00 2001 From: Michel Santos Date: Sat, 11 Dec 2021 16:47:28 -0500 Subject: [PATCH 59/77] Re-allow build of programs for compatibility with Commit 082df7 --- programs/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index ba73cdca..d9c82346 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -1,5 +1,5 @@ add_subdirectory( build_helpers ) -if( BUILD_BITSHARES_PROGRAMS ) +if( BUILD_PEERPLAYS_PROGRAMS ) add_subdirectory( cli_wallet ) add_subdirectory( genesis_util ) add_subdirectory( witness_node ) @@ -7,4 +7,4 @@ if( BUILD_BITSHARES_PROGRAMS ) add_subdirectory( delayed_node ) add_subdirectory( js_operation_serializer ) add_subdirectory( size_checker ) -endif( BUILD_BITSHARES_PROGRAMS ) +endif( BUILD_PEERPLAYS_PROGRAMS ) From 8325b25d0e6e94b4af5c959a05ccb80580a65120 Mon Sep 17 00:00:00 2001 From: Michel Santos Date: Mon, 13 Dec 2021 19:34:59 -0500 Subject: [PATCH 60/77] Harmonize the activation date of GPOS --- libraries/chain/hardfork.d/GPOS.hf | 1 + libraries/protocol/include/graphene/protocol/config.hpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/chain/hardfork.d/GPOS.hf b/libraries/chain/hardfork.d/GPOS.hf index 1cf9c75c..58ff85bf 100644 --- a/libraries/chain/hardfork.d/GPOS.hf +++ b/libraries/chain/hardfork.d/GPOS.hf @@ -1,4 +1,5 @@ // GPOS HARDFORK Monday, 17 February 2020 22:00:00 GMT +// The value should be harmonized with the protcol constant named GPOS_PERIOD_START #ifndef HARDFORK_GPOS_TIME #define HARDFORK_GPOS_TIME (fc::time_point_sec( 1581976800 )) #endif diff --git a/libraries/protocol/include/graphene/protocol/config.hpp b/libraries/protocol/include/graphene/protocol/config.hpp index c855b339..b230e216 100644 --- a/libraries/protocol/include/graphene/protocol/config.hpp +++ b/libraries/protocol/include/graphene/protocol/config.hpp @@ -222,7 +222,8 @@ #define SWEEPS_DEFAULT_DISTRIBUTION_ASSET (graphene::protocol::asset_id_type(0)) #define SWEEPS_VESTING_BALANCE_MULTIPLIER 100000000 #define SWEEPS_ACCUMULATOR_ACCOUNT (graphene::protocol::account_id_type(0)) -#define GPOS_PERIOD_START (fc::time_point_sec(1578272400)) +// // The value should be harmonized with the chain constant named HARDFORK_GPOS_TIME +#define GPOS_PERIOD_START (fc::time_point_sec(1581976800)) #define GPOS_PERIOD (60*60*24*30*6) // 6 months #define GPOS_SUBPERIOD (60*60*24*30) // 1 month #define GPOS_VESTING_LOCKIN_PERIOD (60*60*24*30) // 1 month From 8ec87b404f770f5716aa1e114cd8f09ffc612615 Mon Sep 17 00:00:00 2001 From: Michel Santos Date: Thu, 23 Dec 2021 17:03:43 -0500 Subject: [PATCH 61/77] Enhance secondary_index Enhance secondary_index by distinguishing between previous objects loaded from persistence versus new objects created during the session --- libraries/chain/account_object.cpp | 19 ++++++++++++--- .../include/graphene/chain/account_object.hpp | 9 +++++--- .../include/graphene/chain/offer_object.hpp | 3 ++- .../graphene/chain/proposal_object.hpp | 5 ++-- .../graphene/chain/tournament_object.hpp | 3 ++- libraries/chain/offer_object.cpp | 9 ++++++-- libraries/chain/proposal_object.cpp | 7 +++++- libraries/chain/tournament_object.cpp | 7 +++++- libraries/db/include/graphene/db/index.hpp | 23 +++++++++++++++---- .../account_history_plugin.hpp | 3 ++- libraries/plugins/bookie/bookie_plugin.cpp | 20 +++++++++------- .../graphene/bookie/bookie_objects.hpp | 12 +++++++--- .../grouped_orders/grouped_orders_plugin.cpp | 12 +++++++--- 13 files changed, 99 insertions(+), 33 deletions(-) diff --git a/libraries/chain/account_object.cpp b/libraries/chain/account_object.cpp index 15a41443..8b8f656e 100644 --- a/libraries/chain/account_object.cpp +++ b/libraries/chain/account_object.cpp @@ -142,7 +142,12 @@ set
account_member_index::get_address_members(const account_object& a)c return result; } -void account_member_index::object_inserted(const object& obj) +void account_member_index::object_loaded(const object& obj) +{ + object_created(obj); +} + +void account_member_index::object_created(const object& obj) { assert( dynamic_cast(&obj) ); // for debug only const account_object& a = static_cast(obj); @@ -256,7 +261,10 @@ void account_member_index::object_modified(const object& after) } -void account_referrer_index::object_inserted( const object& obj ) +void account_referrer_index::object_loaded( const object& obj ) +{ +} +void account_referrer_index::object_created( const object& obj ) { } void account_referrer_index::object_removed( const object& obj ) @@ -272,7 +280,12 @@ 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 ) +void balances_by_account_index::object_loaded( const object& obj ) +{ + object_created(obj); +} + +void balances_by_account_index::object_created( const object& obj ) { const auto& abo = dynamic_cast< const account_balance_object& >( obj ); while( balances.size() < (abo.owner.instance.value >> bits) + 1 ) diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index c547af22..3f7cb984 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -323,7 +323,8 @@ namespace graphene { namespace chain { }; public: - virtual void object_inserted( const object& obj ) override; + virtual void object_loaded( const object& obj ) override; + virtual void object_created( 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; @@ -354,7 +355,8 @@ namespace graphene { namespace chain { class account_referrer_index : public secondary_index { public: - virtual void object_inserted( const object& obj ) override; + virtual void object_loaded( const object& obj ) override; + virtual void object_created( 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; @@ -395,7 +397,8 @@ namespace graphene { namespace chain { class balances_by_account_index : public secondary_index { public: - virtual void object_inserted( const object& obj ) override; + virtual void object_loaded( const object& obj ) override; + virtual void object_created( 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; diff --git a/libraries/chain/include/graphene/chain/offer_object.hpp b/libraries/chain/include/graphene/chain/offer_object.hpp index cb6440c8..917a4f0f 100644 --- a/libraries/chain/include/graphene/chain/offer_object.hpp +++ b/libraries/chain/include/graphene/chain/offer_object.hpp @@ -60,7 +60,8 @@ namespace graphene class offer_item_index : public secondary_index { public: - virtual void object_inserted(const object &obj) override; + virtual void object_loaded(const object &obj) override; + virtual void object_created(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; diff --git a/libraries/chain/include/graphene/chain/proposal_object.hpp b/libraries/chain/include/graphene/chain/proposal_object.hpp index 3b83b748..8809aea0 100644 --- a/libraries/chain/include/graphene/chain/proposal_object.hpp +++ b/libraries/chain/include/graphene/chain/proposal_object.hpp @@ -62,7 +62,7 @@ class proposal_object : public abstract_object }; /** - * @brief tracks all of the proposal objects that requrie approval of + * @brief tracks all of the proposal objects that require approval of * an individual account. * * @ingroup object @@ -75,7 +75,8 @@ class proposal_object : public abstract_object class required_approval_index : public secondary_index { public: - virtual void object_inserted( const object& obj ) override; + virtual void object_loaded( const object& obj ) override; + virtual void object_created( 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{}; diff --git a/libraries/chain/include/graphene/chain/tournament_object.hpp b/libraries/chain/include/graphene/chain/tournament_object.hpp index 9f2e5860..51964f60 100644 --- a/libraries/chain/include/graphene/chain/tournament_object.hpp +++ b/libraries/chain/include/graphene/chain/tournament_object.hpp @@ -224,7 +224,8 @@ namespace graphene { namespace chain { class tournament_players_index : public secondary_index { public: - virtual void object_inserted( const object& obj ) override; + virtual void object_loaded( const object& obj ) override; + virtual void object_created( 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; diff --git a/libraries/chain/offer_object.cpp b/libraries/chain/offer_object.cpp index 35ac47d2..795648f3 100644 --- a/libraries/chain/offer_object.cpp +++ b/libraries/chain/offer_object.cpp @@ -6,7 +6,12 @@ namespace graphene namespace chain { - void offer_item_index::object_inserted(const object &obj) + void offer_item_index::object_loaded(const object &obj) + { + object_created(obj); + } + + void offer_item_index::object_created(const object &obj) { assert(dynamic_cast(&obj)); const offer_object &oo = static_cast(obj); @@ -47,4 +52,4 @@ namespace graphene } } // namespace chain -} // namespace graphene \ No newline at end of file +} // namespace graphene diff --git a/libraries/chain/proposal_object.cpp b/libraries/chain/proposal_object.cpp index 662c700a..2841daa9 100644 --- a/libraries/chain/proposal_object.cpp +++ b/libraries/chain/proposal_object.cpp @@ -52,7 +52,12 @@ bool proposal_object::is_authorized_to_execute( database& db ) const return true; } -void required_approval_index::object_inserted( const object& obj ) +void required_approval_index::object_loaded( const object& obj ) +{ + object_created(obj); +} + +void required_approval_index::object_created( const object& obj ) { assert( dynamic_cast(&obj) ); const proposal_object& p = static_cast(obj); diff --git a/libraries/chain/tournament_object.cpp b/libraries/chain/tournament_object.cpp index 715ef1d3..9465e048 100644 --- a/libraries/chain/tournament_object.cpp +++ b/libraries/chain/tournament_object.cpp @@ -653,7 +653,12 @@ namespace graphene { namespace chain { return vector(); } - void tournament_players_index::object_inserted(const object& obj) + void tournament_players_index::object_loaded(const object& obj) + { + object_created(obj); + } + + void tournament_players_index::object_created(const object& obj) { assert( dynamic_cast(&obj) ); // for debug only const tournament_details_object& details = static_cast(obj); diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index c02aeb69..2aa7cb9a 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -135,13 +135,23 @@ namespace graphene { namespace db { virtual void object_default( object& obj )const = 0; }; + /** @class secondary_index + * @brief A secondary index is intended to observe a primary index. + * A secondary index is not automatically persisted when the node shuts own. + */ class secondary_index { public: virtual ~secondary_index(){}; - virtual void object_inserted( const object& obj ){}; + // Called when an object from a previous node session is loaded from persistence + virtual void object_loaded( const object& obj ){}; + // Called when an object from the current node session is created + virtual void object_created( const object& obj ){}; + // Called when an object is removed virtual void object_removed( const object& obj ){}; + // Called when an object is about to be modified virtual void about_to_modify( const object& before ){}; + // Called when an object is modified virtual void object_modified( const object& after ){}; }; @@ -226,7 +236,12 @@ namespace graphene { namespace db { virtual ~direct_index(){} - virtual void object_inserted( const object& obj ) + virtual void object_loaded( const object& obj ) + { + object_created(obj); + } + + virtual void object_created( const object& obj ) { uint64_t instance = obj.id.instance(); if( instance == next ) @@ -386,7 +401,7 @@ namespace graphene { namespace db { { const auto& result = DerivedIndex::insert( fc::raw::unpack( data ) ); for( const auto& item : _sindex ) - item->object_inserted( result ); + item->object_loaded( result ); return result; } @@ -395,7 +410,7 @@ namespace graphene { namespace db { { const auto& result = DerivedIndex::create( constructor ); for( const auto& item : _sindex ) - item->object_inserted( result ); + item->object_created( result ); on_add( result ); return result; } diff --git a/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp b/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp index 84315013..9f042a13 100644 --- a/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp +++ b/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp @@ -84,7 +84,8 @@ class account_history_plugin : public graphene::app::plugin class affiliate_reward_index : public secondary_index { public: - virtual void object_inserted( const object& obj ) override; + virtual void object_loaded( const object& obj ) override; + virtual void object_created( 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{}; diff --git a/libraries/plugins/bookie/bookie_plugin.cpp b/libraries/plugins/bookie/bookie_plugin.cpp index a8c06a0d..a75624d3 100644 --- a/libraries/plugins/bookie/bookie_plugin.cpp +++ b/libraries/plugins/bookie/bookie_plugin.cpp @@ -66,7 +66,8 @@ class persistent_bet_object_helper : public secondary_index using watched_index = primary_index; - virtual void object_inserted(const object& obj) override; + //virtual void object_loaded(const object& obj) override; + virtual void object_created(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; @@ -75,7 +76,7 @@ class persistent_bet_object_helper : public secondary_index bookie_plugin* _bookie_plugin; }; -void persistent_bet_object_helper::object_inserted(const object& obj) +void persistent_bet_object_helper::object_created(const object& obj) { const bet_object& bet_obj = *boost::polymorphic_downcast(&obj); _bookie_plugin->database().create([&](persistent_bet_object& saved_bet_obj) { @@ -103,7 +104,8 @@ class persistent_betting_market_object_helper : public secondary_index using watched_index = primary_index; - virtual void object_inserted(const object& obj) override; + //virtual void object_loaded(const object& obj) override; + virtual void object_created(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; @@ -112,7 +114,7 @@ class persistent_betting_market_object_helper : public secondary_index bookie_plugin* _bookie_plugin; }; -void persistent_betting_market_object_helper::object_inserted(const object& obj) +void persistent_betting_market_object_helper::object_created(const object& obj) { const betting_market_object& betting_market_obj = *boost::polymorphic_downcast(&obj); _bookie_plugin->database().create([&](persistent_betting_market_object& saved_betting_market_obj) { @@ -140,7 +142,8 @@ class persistent_betting_market_group_object_helper : public secondary_index using watched_index = primary_index; - virtual void object_inserted(const object& obj) override; + //virtual void object_loaded(const object& obj) override; + virtual void object_created(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; @@ -149,7 +152,7 @@ class persistent_betting_market_group_object_helper : public secondary_index bookie_plugin* _bookie_plugin; }; -void persistent_betting_market_group_object_helper::object_inserted(const object& obj) +void persistent_betting_market_group_object_helper::object_created(const object& obj) { const betting_market_group_object& betting_market_group_obj = *boost::polymorphic_downcast(&obj); _bookie_plugin->database().create([&](persistent_betting_market_group_object& saved_betting_market_group_obj) { @@ -177,7 +180,8 @@ class persistent_event_object_helper : public secondary_index using watched_index = primary_index; - virtual void object_inserted(const object& obj) override; + //virtual void object_loaded(const object& obj) override; + virtual void object_created(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; @@ -186,7 +190,7 @@ class persistent_event_object_helper : public secondary_index bookie_plugin* _bookie_plugin; }; -void persistent_event_object_helper::object_inserted(const object& obj) +void persistent_event_object_helper::object_created(const object& obj) { const event_object& event_obj = *boost::polymorphic_downcast(&obj); _bookie_plugin->database().create([&](persistent_event_object& saved_event_obj) { diff --git a/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp b/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp index c9e20b8e..bd91ef17 100644 --- a/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp +++ b/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp @@ -68,7 +68,8 @@ class events_by_competitor_index : public secondary_index public: virtual ~events_by_competitor_index() {} - virtual void object_inserted( const object& obj ) override; + virtual void object_loaded( const object& obj ) override; + virtual void object_created( 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; @@ -77,7 +78,12 @@ class events_by_competitor_index : public secondary_index map > competitor_to_events; }; -void events_by_competitor_index::object_inserted( const object& obj ) +void events_by_competitor_index::object_loaded( const object& obj ) +{ + object_created(obj); +} + +void events_by_competitor_index::object_created( const object& obj ) { const persistent_event_object& event_obj = *boost::polymorphic_downcast(&obj); for (const competitor_id_type& competitor_id : event_obj.competitors) @@ -97,7 +103,7 @@ void events_by_competitor_index::about_to_modify( const object& before ) } void events_by_competitor_index::object_modified( const object& after ) { - object_inserted(after); + object_created(after); } #endif diff --git a/libraries/plugins/grouped_orders/grouped_orders_plugin.cpp b/libraries/plugins/grouped_orders/grouped_orders_plugin.cpp index ef1ae04c..99a77b5a 100644 --- a/libraries/plugins/grouped_orders/grouped_orders_plugin.cpp +++ b/libraries/plugins/grouped_orders/grouped_orders_plugin.cpp @@ -55,7 +55,8 @@ class limit_order_group_index : public secondary_index public: limit_order_group_index( const flat_set& groups ) : _tracked_groups( groups ) {}; - virtual void object_inserted( const object& obj ) override; + virtual void object_loaded( const object& obj ) override; + virtual void object_created( 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; @@ -76,7 +77,12 @@ class limit_order_group_index : public secondary_index map< limit_order_group_key, limit_order_group_data > _og_data; }; -void limit_order_group_index::object_inserted( const object& objct ) +void limit_order_group_index::object_loaded( const object& objct ) +{ + object_created(objct); +} + +void limit_order_group_index::object_created( const object& objct ) { try { const limit_order_object& o = static_cast( objct ); @@ -201,7 +207,7 @@ void limit_order_group_index::about_to_modify( const object& objct ) void limit_order_group_index::object_modified( const object& objct ) { try { - object_inserted( objct ); + object_created( objct ); } FC_CAPTURE_AND_RETHROW( (objct) ); } void limit_order_group_index::remove_order( const limit_order_object& o, bool remove_empty ) From 4fea0015862e70927819d2eabd39f1918b7d137a Mon Sep 17 00:00:00 2001 From: Michel Santos Date: Thu, 23 Dec 2021 17:04:31 -0500 Subject: [PATCH 62/77] Fix Bookie plugin to provide a consistent data state even when the node is started in replay mode --- libraries/plugins/bookie/bookie_plugin.cpp | 51 ++++++++++++++++++---- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/libraries/plugins/bookie/bookie_plugin.cpp b/libraries/plugins/bookie/bookie_plugin.cpp index a75624d3..e9f8a9bd 100644 --- a/libraries/plugins/bookie/bookie_plugin.cpp +++ b/libraries/plugins/bookie/bookie_plugin.cpp @@ -54,10 +54,42 @@ namespace detail /* As a plugin, we get notified of new/changed objects at the end of every block processed. * For most objects, that's fine, because we expect them to always be around until the end of * the block. However, with bet objects, it's possible that the user places a bet and it fills - * and is removed during the same block, so need another strategy to detect them immediately after - * they are created. + * and is removed during the same block, so need another strategy to detect these "ephemeral" + * node objects immediately after they are created. * We do this by creating a secondary index on bet_object. We don't actually use it * to index any property of the bet, we just use it to register for callbacks. + * + * One objective of the plugin's helper is to watch for database objects known by the the node + * (node objects) in order for the plugin to populate and persist a copy (plugin objects) + * within its own primary index. + * + * The life cycle of a naive helper object is: + * + * 1. During `plugin_initialize()` + * The helper registers with the database for future notifications (Step 2) of the creation of + * a watched object + * (`database().add_secondary_index<...>()`). + * The helper also delegates the future persistence (Step 3) of its own primary index + * to the database by registering it. + * (`database().add_index>()`). + * This primary index will be used to index plugin objects that are copies of node objects + * observed during Step 2. + * 2. During a node session: the helper is notified by the database about the watched node objects + * that are created during the node session through its `object_created()` callback. + * During that callback, the helper will create its own copy (plugin object) of the of node + * objectand inject it into its own primary index. + * 3. When the node session shuts down, the database will persist the helper's primary index + * that was registered during Step 1. + * 4. When the node is restarted, the database will automatically load the previous session(s)'s + * node objectsinto the helper's primary index. + * + * The helper can ignore the `object_loaded()` events that are triggered when the watched node + * objects are loaded from persistence by the database because those objects were already processed + * by the the helper's `object_created()` during the prior sessions. + * + * NOTE: The helper should register itself for notifications of new node objects + * during `plugin_initialize()` rather than `plugin_startup()` + * for compatibility with a blockchain replay. */ class persistent_bet_object_helper : public secondary_index { @@ -489,18 +521,19 @@ void bookie_plugin::plugin_initialize(const boost::program_options::variables_ma database().add_index >(); database().add_index >(); database().add_index >(); + + // Register secondary indexes + database().add_secondary_index()->set_plugin_instance(this); + database().add_secondary_index()->set_plugin_instance(this); + database().add_secondary_index()->set_plugin_instance(this); + database().add_secondary_index()->set_plugin_instance(this); + ilog("bookie plugin: plugin_initialize() end"); } void bookie_plugin::plugin_startup() { - ilog("bookie plugin: plugin_startup()"); - - // Register secondary indexes - database().add_secondary_index()->set_plugin_instance(this); - database().add_secondary_index()->set_plugin_instance(this); - database().add_secondary_index()->set_plugin_instance(this); - database().add_secondary_index()->set_plugin_instance(this); + ilog("bookie plugin: plugin_startup()"); my->fill_localized_event_strings(); } From fe02a1368536bffa0eca59586bea74b63386cd1b Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Wed, 5 Jan 2022 16:20:04 -0600 Subject: [PATCH 63/77] Replace count_objects_in_space with inspect_all_indexes The count_objects_in_space function, while providing the necessary functionality, was clumsy and inconvenient, and was not idiomatic. Replace it with inspect_all_indexes which resolves these shortcomings. --- .../db/include/graphene/db/object_database.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libraries/db/include/graphene/db/object_database.hpp b/libraries/db/include/graphene/db/object_database.hpp index e36353ea..ede9600c 100644 --- a/libraries/db/include/graphene/db/object_database.hpp +++ b/libraries/db/include/graphene/db/object_database.hpp @@ -174,11 +174,14 @@ namespace graphene { namespace db { base_primary->delete_secondary_index(secondary); } - // Count the number of objects (indexes) in the specified object space. - // Assuming there are no gaps in the list of type IDs in the space, this will be one greater than the last type ID. - uint8_t count_objects_in_space(const uint8_t space_id) const { - FC_ASSERT(space_id < _index.size(), "Cannot count objects in space ${S}: No such object space", ("S", space_id)); - return std::count_if(_index[space_id].begin(), _index[space_id].end(), [](const auto& ptr) { return bool(ptr); }); + // Inspect each index in an object space. F is a callable taking a const index& + template + void inspect_all_indexes(uint8_t space_id, F&& f) const { + FC_ASSERT(_index.size() > space_id, "Cannot inspect indexes in space ID ${ID}: no such object space", + ("ID", space_id)); + for (const auto& ptr : _index[space_id]) + if (ptr != nullptr) + f((const index&)(*ptr)); } void pop_undo(); From c833ca646f542e7a6d8bc1191c5e9788e6daf741 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Wed, 12 Jan 2022 16:55:01 -0600 Subject: [PATCH 64/77] Set CMAKE_INSTALL_RPATH for dynamic builds When building dynamic libraries, set the RPATH so that binaries know where to find their libraries. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd3383f8..9aca2963 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ set( GRAPHENE_BUILD_DYNAMIC_LIBRARIES OFF CACHE BOOL "Whether to build dynamic libraries instead of static. Applies only to chain, db, protocol, net, and utilities" ) if( GRAPHENE_BUILD_DYNAMIC_LIBRARIES ) set( CMAKE_POSITION_INDEPENDENT_CODE ON ) + set( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" ) endif() set( FC_BUILD_DYNAMIC_LIBRARIES ${GRAPHENE_BUILD_DYNAMIC_LIBRARIES} CACHE BOOL "Whether FC should build as a dynamic library rather than static" ) From de87e1b82cfc147d7a4082d65f7a4c6046567d04 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Wed, 12 Jan 2022 16:55:45 -0600 Subject: [PATCH 65/77] Canonicalize chain ID calculation When using an external genesis file, it doesn't make sense to calculate the chain ID as the literal text contents of the file, which are quite volatile. Rather, it should be calculated based on the logical content of the file. Serialize the genesis object to get a canonical representation, and calculate the chain ID off of that. --- libraries/app/application.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index d0da6de6..80248fc6 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -321,9 +321,8 @@ namespace detail { ilog("Initializing database..."); if( _options->count("genesis-json") ) { - std::string genesis_str; - fc::read_file_contents( _options->at("genesis-json").as(), genesis_str ); - genesis_state_type genesis = fc::json::from_string( genesis_str ).as( 20 ); + genesis_state_type genesis = fc::json::from_file( _options->at("genesis-json").as()).as( 20 ); + std::string genesis_str = fc::json::to_string(genesis) + "\n"; bool modified_genesis = false; if( _options->count("genesis-timestamp") ) { From d17eb5ec72b3ea15304a0558699d9f30a36ddbf4 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Fri, 14 Jan 2022 20:10:16 -0600 Subject: [PATCH 66/77] Add wallet command for custom_operation Create a new cli_wallet command, run_custom_operation, which makes it convenient to run custom_operation transactions which invoke third party contracts (i.e., dapps) --- .../wallet/include/graphene/wallet/wallet.hpp | 4 +++ libraries/wallet/wallet.cpp | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index ac7d8996..b7203ed7 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -2386,6 +2386,9 @@ class wallet_api bool broadcast); vector get_account_roles_by_owner(string owner_account_id_or_name) const; + signed_transaction run_custom_operation(string payer_id_or_name, std::vector required_auths, + string data, uint16_t id=0, bool broadcast=false); + void dbg_make_uia(string creator, string symbol); void dbg_make_mia(string creator, string symbol); void dbg_push_blocks( std::string src_filename, uint32_t count ); @@ -2709,4 +2712,5 @@ FC_API( graphene::wallet::wallet_api, (get_custom_account_authorities_by_permission_id) (get_custom_account_authorities_by_permission_name) (get_active_custom_account_authorities_by_operation) + (run_custom_operation) ) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 8ecee060..91fa3f9d 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -7340,6 +7340,31 @@ vector wallet_api::get_account_roles_by_owner(string owner_ account_object owner_account = my->get_account(owner_account_id_or_name); return my->_remote_db->get_account_roles_by_owner(owner_account.id); } + +signed_transaction wallet_api::run_custom_operation(string payer_id_or_name, std::vector required_auths, string data, uint16_t id, bool broadcast) +{ + account_object payer = my->get_account(payer_id_or_name); + custom_operation op; + + // FC offers no way to have quotes in the data string. Add a simple escape option. + boost::replace_all(data, "\\\"", "\""); + boost::replace_all(data, "\\\\", "\\"); + + op.payer = payer.get_id(); + if (!required_auths.empty()) + std::transform(required_auths.begin(), required_auths.end(), std::inserter(op.required_auths, op.required_auths.begin()), + [&my=my](const string& name_or_id) { return my->get_account(name_or_id).get_id(); }); + op.id = id; + op.data.reserve(data.size()); + op.data.assign(data.begin(), data.end()); + + signed_transaction trx; + trx.operations = {std::move(op)}; + my->set_operation_fees(trx, my->_remote_db->get_global_properties().parameters.current_fees); + trx.validate(); + + return my->sign_transaction(std::move(trx), broadcast); +} // default ctor necessary for FC_REFLECT signed_block_with_info::signed_block_with_info() { From 2a37d8a0a1a0af521c275f16bed3d4931b33111c Mon Sep 17 00:00:00 2001 From: Nathaniel Hourt Date: Thu, 27 Jan 2022 15:29:23 -0600 Subject: [PATCH 67/77] Fix build In some environments, this fails to build without this header. --- libraries/chain/db_maint.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/chain/db_maint.cpp b/libraries/chain/db_maint.cpp index 5080fca4..08671e6d 100644 --- a/libraries/chain/db_maint.cpp +++ b/libraries/chain/db_maint.cpp @@ -47,6 +47,8 @@ #include #include +#include + namespace graphene { namespace chain { template From ee0d2b21e098b9e65e693d81b1c71bcc09bebea9 Mon Sep 17 00:00:00 2001 From: Nathaniel Hourt Date: Sat, 29 Jan 2022 16:21:13 -0600 Subject: [PATCH 68/77] Fix build In some environments, build fails here due to `curl` dependency not being linked in time for `utilities` to see it. --- libraries/utilities/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/utilities/CMakeLists.txt b/libraries/utilities/CMakeLists.txt index 22decaf7..e58ff332 100644 --- a/libraries/utilities/CMakeLists.txt +++ b/libraries/utilities/CMakeLists.txt @@ -30,7 +30,7 @@ else() ${HEADERS} ) endif() -target_link_libraries( graphene_utilities fc ) +target_link_libraries( graphene_utilities fc curl ) target_include_directories( graphene_utilities PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) if (USE_PCH) From dcdf406a2d4effd4276baa4c9d2f06177154bcf7 Mon Sep 17 00:00:00 2001 From: serkixenos Date: Mon, 27 Dec 2021 00:28:29 -0400 Subject: [PATCH 69/77] Fix cli wallet memo displaying --- libraries/wallet/wallet.cpp | 44 +++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index e9962bbd..68051f2e 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -4192,27 +4192,33 @@ string operation_printer::operator()(const transfer_operation& op) const std::string memo; if( op.memo ) { - if( wallet.is_locked() ) - { - out << " -- Unlock wallet to see memo."; - } else { - try { - FC_ASSERT(wallet._keys.count(op.memo->to) || wallet._keys.count(op.memo->from), "Memo is encrypted to a key ${to} or ${from} not in this wallet.", ("to", op.memo->to)("from",op.memo->from)); - if( wallet._keys.count(op.memo->to) ) { - auto my_key = wif_to_key(wallet._keys.at(op.memo->to)); - FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted."); - memo = op.memo->get_message(*my_key, op.memo->from); - out << " -- Memo: " << memo; - } else { - auto my_key = wif_to_key(wallet._keys.at(op.memo->from)); - FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted."); - memo = op.memo->get_message(*my_key, op.memo->to); - out << " -- Memo: " << memo; + bool is_encrypted = ((op.memo->from != public_key_type()) && (op.memo->to != public_key_type())); + if (is_encrypted) { + if( wallet.is_locked() ) + { + out << " -- Unlock wallet to see memo."; + } else { + try { + FC_ASSERT(wallet._keys.count(op.memo->to) || wallet._keys.count(op.memo->from), "Memo is encrypted to a key ${to} or ${from} not in this wallet.", ("to", op.memo->to)("from",op.memo->from)); + if( wallet._keys.count(op.memo->to) ) { + auto my_key = wif_to_key(wallet._keys.at(op.memo->to)); + FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted."); + memo = op.memo->get_message(*my_key, op.memo->from); + out << " -- Memo: " << memo; + } else { + auto my_key = wif_to_key(wallet._keys.at(op.memo->from)); + FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted."); + memo = op.memo->get_message(*my_key, op.memo->to); + out << " -- Memo: " << memo; + } + } catch (const fc::exception& e) { + out << " -- could not decrypt memo"; + elog("Error when decrypting memo: ${e}", ("e", e.to_detail_string())); } - } catch (const fc::exception& e) { - out << " -- could not decrypt memo"; - elog("Error when decrypting memo: ${e}", ("e", e.to_detail_string())); } + } else { + memo = op.memo->get_message(private_key_type(), public_key_type()); + out << " -- Memo: " << memo; } } fee(op.fee); From 8c402d2e7076e087c8d4fb9235a01546a651e06b Mon Sep 17 00:00:00 2001 From: serkixenos Date: Fri, 21 Jan 2022 12:17:13 -0400 Subject: [PATCH 70/77] Fix list_active_son command output on deregistered SONs --- libraries/wallet/wallet.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 68051f2e..1f38853f 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -2210,11 +2210,8 @@ public: vector owners; for(auto obj: son_objects) { - if (obj) - { - std::string acc_id = account_id_to_string(obj->son_account); - owners.push_back(acc_id); - } + std::string acc_id = account_id_to_string(obj->son_account); + owners.push_back(acc_id); } vector< optional< account_object> > accs = _remote_db->get_accounts(owners); std::remove_if(son_objects.begin(), son_objects.end(), @@ -2224,9 +2221,7 @@ public: std::inserter(result, result.end()), [](fc::optional& acct, fc::optional son) { FC_ASSERT(acct, "Invalid active SONs list in global properties."); - if (son.valid() && son->status != son_status::deregistered) - return std::make_pair(string(acct->name), std::move(son->id)); - return std::make_pair(string(acct->name), std::move(son_id_type())); + return std::make_pair(string(acct->name), std::move(son->id)); }); return result; } FC_CAPTURE_AND_RETHROW() } From 62a553ab5f2fb6d300295ef5e0abcf8c986ff7b6 Mon Sep 17 00:00:00 2001 From: Vlad Dobromyslov Date: Fri, 28 Jan 2022 15:05:49 +0000 Subject: [PATCH 71/77] bug #267 Fix error in chain_test in gitlab autobuild --- libraries/db/include/graphene/db/undo_database.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/db/include/graphene/db/undo_database.hpp b/libraries/db/include/graphene/db/undo_database.hpp index 4b727372..0eb00f55 100644 --- a/libraries/db/include/graphene/db/undo_database.hpp +++ b/libraries/db/include/graphene/db/undo_database.hpp @@ -34,10 +34,10 @@ namespace graphene { namespace db { struct undo_state { - unordered_map > old_values; - unordered_map old_index_next_ids; - std::unordered_set new_ids; - unordered_map > removed; + unordered_map > old_values; + unordered_map old_index_next_ids; + std::set > new_ids; + unordered_map > removed; }; From 45e501b916112d0512ea86868a439913304c2859 Mon Sep 17 00:00:00 2001 From: Vlad Dobromyslov Date: Mon, 31 Jan 2022 05:25:56 +0000 Subject: [PATCH 72/77] Resolve "port ES changes from Bitshares" --- .../elasticsearch/elasticsearch_plugin.cpp | 271 +++++++++++++++--- .../elasticsearch/elasticsearch_plugin.hpp | 163 ----------- libraries/plugins/es_objects/es_objects.cpp | 158 +++++----- libraries/utilities/elasticsearch.cpp | 44 ++- .../graphene/utilities/elasticsearch.hpp | 5 +- tests/elasticsearch/main.cpp | 38 +-- 6 files changed, 376 insertions(+), 303 deletions(-) diff --git a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp index 8777c06d..491c011d 100644 --- a/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp +++ b/libraries/plugins/elasticsearch/elasticsearch_plugin.cpp @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +#include #include #include #include @@ -33,6 +34,15 @@ namespace graphene { namespace elasticsearch { namespace detail { +const std::string generateIndexName(const fc::time_point_sec& block_date, const std::string& _elasticsearch_index_prefix) +{ + auto block_date_string = block_date.to_iso_string(); + std::vector parts; + boost::split(parts, block_date_string, boost::is_any_of("-")); + std::string index_name = _elasticsearch_index_prefix + parts[0] + "-" + parts[1]; + return index_name; +} + class elasticsearch_plugin_impl { public: @@ -48,6 +58,9 @@ class elasticsearch_plugin_impl return _self.database(); } + friend class graphene::elasticsearch::elasticsearch_plugin; + + private: elasticsearch_plugin& _self; primary_index< operation_history_index >* _oho_index; @@ -75,6 +88,8 @@ class elasticsearch_plugin_impl std::string bulk_line; std::string index_name; bool is_sync = false; + bool is_es_version_7_or_above = true; + private: 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, @@ -91,6 +106,7 @@ class elasticsearch_plugin_impl void createBulkLine(const account_transaction_history_object& ath); void prepareBulk(const account_transaction_history_id_type& ath_id); void populateESstruct(); + void init_program_options(const boost::program_options::variables_map& options); }; elasticsearch_plugin_impl::~elasticsearch_plugin_impl() @@ -105,7 +121,7 @@ elasticsearch_plugin_impl::~elasticsearch_plugin_impl() bool elasticsearch_plugin_impl::update_account_histories( const signed_block& b ) { checkState(b.timestamp); - index_name = graphene::utilities::generateIndexName(b.timestamp, _elasticsearch_index_prefix); + index_name = generateIndexName(b.timestamp, _elasticsearch_index_prefix); graphene::chain::database& db = database(); const vector >& hist = db.get_applied_operations(); @@ -229,6 +245,113 @@ void elasticsearch_plugin_impl::getOperationType(const optional op.which(); } +struct adaptor_struct +{ + variant adapt(const variant_object& op) + { + fc::mutable_variant_object o(op); + vector keys_to_rename; + for (auto& i : o) + { + auto& element = i.value(); + if (element.is_object()) + { + const string& name = i.key(); + const 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("memo") != o.end()) + { + auto& memo = o["memo"]; + if (memo.is_string()) + { + o["memo_"] = o["memo"]; + o.erase("memo"); + } + else if (memo.is_object()) + { + fc::mutable_variant_object tmp(memo.get_object()); + if (tmp.find("nonce") != tmp.end()) + { + tmp["nonce"] = tmp["nonce"].as_string(); + o["memo"] = tmp; + } + } + } + if (o.find("new_parameters") != o.end()) + { + auto& tmp = o["new_parameters"]; + if (tmp.is_object()) + { + fc::mutable_variant_object tmp2(tmp.get_object()); + if (tmp2.find("current_fees") != tmp2.end()) + { + tmp2.erase("current_fees"); + o["new_parameters"] = tmp2; + } + } + } + if (o.find("owner") != o.end() && o["owner"].is_string()) + { + o["owner_"] = o["owner"].as_string(); + o.erase("owner"); + } + if (o.find("proposed_ops") != o.end()) + { + o["proposed_ops"] = fc::json::to_string(o["proposed_ops"]); + } + if (o.find("initializer") != o.end()) + { + o["initializer"] = fc::json::to_string(o["initializer"]); + } + if (o.find("policy") != o.end()) + { + o["policy"] = fc::json::to_string(o["policy"]); + } + if (o.find("predicates") != o.end()) + { + o["predicates"] = fc::json::to_string(o["predicates"]); + } + 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"]); + } + + 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(); + } + } +}; + void elasticsearch_plugin_impl::doOperationHistory(const optional & oho) { os.trx_in_block = oho->trx_in_block; @@ -255,6 +378,61 @@ void elasticsearch_plugin_impl::doBlock(uint32_t trx_in_block, const signed_bloc bs.trx_id = trx_id; } +struct operation_visitor +{ + using result_type = void; + + share_type fee_amount; + asset_id_type fee_asset; + + asset_id_type transfer_asset_id; + share_type transfer_amount; + account_id_type transfer_from; + account_id_type transfer_to; + + void operator()( const graphene::chain::transfer_operation& o ) + { + fee_asset = o.fee.asset_id; + fee_amount = o.fee.amount; + + transfer_asset_id = o.amount.asset_id; + transfer_amount = o.amount.amount; + transfer_from = o.from; + transfer_to = o.to; + } + + object_id_type fill_order_id; + account_id_type fill_account_id; + asset_id_type fill_pays_asset_id; + share_type fill_pays_amount; + asset_id_type fill_receives_asset_id; + share_type fill_receives_amount; + //double fill_fill_price; + //bool fill_is_maker; + + void operator()( const graphene::chain::fill_order_operation& o ) + { + fee_asset = o.fee.asset_id; + fee_amount = o.fee.amount; + + fill_order_id = o.order_id; + fill_account_id = o.account_id; + fill_pays_asset_id = o.pays.asset_id; + fill_pays_amount = o.pays.amount; + fill_receives_asset_id = o.receives.asset_id; + fill_receives_amount = o.receives.amount; + //fill_fill_price = o.fill_price.to_real(); + //fill_is_maker = o.is_maker; + } + + template + void operator()( const T& o ) + { + fee_asset = o.fee.asset_id; + fee_amount = o.fee.amount; + } +}; + void elasticsearch_plugin_impl::doVisitor(const optional & oho) { graphene::chain::database& db = database(); @@ -380,7 +558,8 @@ void elasticsearch_plugin_impl::prepareBulk(const account_transaction_history_id const std::string _id = fc::json::to_string(ath_id); fc::mutable_variant_object bulk_header; bulk_header["_index"] = index_name; - bulk_header["_type"] = "data"; + if( !is_es_version_7_or_above ) + bulk_header["_type"] = "_doc"; bulk_header["_id"] = fc::to_string(ath_id.space_id) + "." + fc::to_string(ath_id.type_id) + "." + fc::to_string(ath_id.instance.value); prepare = graphene::utilities::createBulk(bulk_header, std::move(bulk_line)); @@ -428,6 +607,43 @@ void elasticsearch_plugin_impl::populateESstruct() es.query = ""; } +void elasticsearch_plugin_impl::init_program_options(const boost::program_options::variables_map& options) +{ + if (options.count("elasticsearch-node-url")) { + _elasticsearch_node_url = options["elasticsearch-node-url"].as(); + } + if (options.count("elasticsearch-bulk-replay")) { + _elasticsearch_bulk_replay = options["elasticsearch-bulk-replay"].as(); + } + if (options.count("elasticsearch-bulk-sync")) { + _elasticsearch_bulk_sync = options["elasticsearch-bulk-sync"].as(); + } + if (options.count("elasticsearch-visitor")) { + _elasticsearch_visitor = options["elasticsearch-visitor"].as(); + } + if (options.count("elasticsearch-basic-auth")) { + _elasticsearch_basic_auth = options["elasticsearch-basic-auth"].as(); + } + if (options.count("elasticsearch-index-prefix")) { + _elasticsearch_index_prefix = options["elasticsearch-index-prefix"].as(); + } + if (options.count("elasticsearch-operation-object")) { + _elasticsearch_operation_object = options["elasticsearch-operation-object"].as(); + } + if (options.count("elasticsearch-start-es-after-block")) { + _elasticsearch_start_es_after_block = options["elasticsearch-start-es-after-block"].as(); + } + if (options.count("elasticsearch-operation-string")) { + _elasticsearch_operation_string = options["elasticsearch-operation-string"].as(); + } + if (options.count("elasticsearch-mode")) { + const auto option_number = options["elasticsearch-mode"].as(); + if(option_number > mode::all) + FC_THROW_EXCEPTION(graphene::chain::plugin_exception, "Elasticsearch mode not valid"); + _elasticsearch_mode = static_cast(options["elasticsearch-mode"].as()); + } +} + } // end namespace detail elasticsearch_plugin::elasticsearch_plugin() : @@ -480,42 +696,12 @@ void elasticsearch_plugin::plugin_set_program_options( void elasticsearch_plugin::plugin_initialize(const boost::program_options::variables_map& options) { + ilog("elasticsearch ACCOUNT HISTORY: plugin_initialize() begin"); + my->_oho_index = database().add_index< primary_index< operation_history_index > >(); database().add_index< primary_index< account_transaction_history_index > >(); - if (options.count("elasticsearch-node-url")) { - my->_elasticsearch_node_url = options["elasticsearch-node-url"].as(); - } - if (options.count("elasticsearch-bulk-replay")) { - my->_elasticsearch_bulk_replay = options["elasticsearch-bulk-replay"].as(); - } - if (options.count("elasticsearch-bulk-sync")) { - my->_elasticsearch_bulk_sync = options["elasticsearch-bulk-sync"].as(); - } - if (options.count("elasticsearch-visitor")) { - my->_elasticsearch_visitor = options["elasticsearch-visitor"].as(); - } - if (options.count("elasticsearch-basic-auth")) { - my->_elasticsearch_basic_auth = options["elasticsearch-basic-auth"].as(); - } - if (options.count("elasticsearch-index-prefix")) { - my->_elasticsearch_index_prefix = options["elasticsearch-index-prefix"].as(); - } - 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(); - } - if (options.count("elasticsearch-operation-string")) { - my->_elasticsearch_operation_string = options["elasticsearch-operation-string"].as(); - } - if (options.count("elasticsearch-mode")) { - const auto option_number = options["elasticsearch-mode"].as(); - if(option_number > mode::all) - FC_THROW_EXCEPTION(graphene::chain::plugin_exception, "Elasticsearch mode not valid"); - my->_elasticsearch_mode = static_cast(options["elasticsearch-mode"].as()); - } + my->init_program_options( options ); if(my->_elasticsearch_mode != mode::only_query) { if (my->_elasticsearch_mode == mode::all && !my->_elasticsearch_operation_string) @@ -528,10 +714,7 @@ void elasticsearch_plugin::plugin_initialize(const boost::program_options::varia "Error populating ES database, we are going to keep trying."); }); } -} -void elasticsearch_plugin::plugin_startup() -{ graphene::utilities::ES es; es.curl = my->curl; es.elasticsearch_url = my->_elasticsearch_node_url; @@ -539,7 +722,17 @@ void elasticsearch_plugin::plugin_startup() if(!graphene::utilities::checkES(es)) FC_THROW_EXCEPTION(fc::exception, "ES database is not up in url ${url}", ("url", my->_elasticsearch_node_url)); + + graphene::utilities::checkESVersion7OrAbove(es, my->is_es_version_7_or_above); + + ilog("elasticsearch ACCOUNT HISTORY: plugin_initialize() end"); +} + +void elasticsearch_plugin::plugin_startup() +{ ilog("elasticsearch ACCOUNT HISTORY: plugin_startup() begin"); + // Nothing to do + ilog("elasticsearch ACCOUNT HISTORY: plugin_startup() end"); } operation_history_object elasticsearch_plugin::get_operation_by_id(operation_history_id_type id) @@ -655,7 +848,7 @@ graphene::utilities::ES elasticsearch_plugin::prepareHistoryQuery(string query) es.curl = curl; es.elasticsearch_url = my->_elasticsearch_node_url; es.index_prefix = my->_elasticsearch_index_prefix; - es.endpoint = es.index_prefix + "*/data/_search"; + es.endpoint = es.index_prefix + "*/_doc/_search"; es.query = query; return es; diff --git a/libraries/plugins/elasticsearch/include/graphene/elasticsearch/elasticsearch_plugin.hpp b/libraries/plugins/elasticsearch/include/graphene/elasticsearch/elasticsearch_plugin.hpp index e1441c58..18e9b297 100644 --- a/libraries/plugins/elasticsearch/include/graphene/elasticsearch/elasticsearch_plugin.hpp +++ b/libraries/plugins/elasticsearch/include/graphene/elasticsearch/elasticsearch_plugin.hpp @@ -79,62 +79,6 @@ class elasticsearch_plugin : public graphene::app::plugin graphene::utilities::ES prepareHistoryQuery(string query); }; - -struct operation_visitor -{ - typedef void result_type; - - share_type fee_amount; - asset_id_type fee_asset; - - asset_id_type transfer_asset_id; - share_type transfer_amount; - account_id_type transfer_from; - account_id_type transfer_to; - - void operator()( const graphene::chain::transfer_operation& o ) - { - fee_asset = o.fee.asset_id; - fee_amount = o.fee.amount; - - transfer_asset_id = o.amount.asset_id; - transfer_amount = o.amount.amount; - transfer_from = o.from; - transfer_to = o.to; - } - - object_id_type fill_order_id; - account_id_type fill_account_id; - asset_id_type fill_pays_asset_id; - share_type fill_pays_amount; - asset_id_type fill_receives_asset_id; - share_type fill_receives_amount; - //double fill_fill_price; - //bool fill_is_maker; - - void operator()( const graphene::chain::fill_order_operation& o ) - { - fee_asset = o.fee.asset_id; - fee_amount = o.fee.amount; - - fill_order_id = o.order_id; - fill_account_id = o.account_id; - fill_pays_asset_id = o.pays.asset_id; - fill_pays_amount = o.pays.amount; - fill_receives_asset_id = o.receives.asset_id; - fill_receives_amount = o.receives.amount; - //fill_fill_price = o.fill_price.to_real(); - //fill_is_maker = o.is_maker; - } - - template - void operator()( const T& o ) - { - fee_asset = o.fee.asset_id; - fee_amount = o.fee.amount; - } -}; - struct operation_history_struct { int trx_in_block; int op_in_trx; @@ -197,113 +141,6 @@ struct bulk_struct { optional additional_data; }; -struct adaptor_struct { - variant adapt(const variant_object& op) - { - fc::mutable_variant_object o(op); - 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("memo") != o.end()) - { - auto& memo = o["memo"]; - if (memo.is_string()) - { - o["memo_"] = o["memo"]; - o.erase("memo"); - } - else if (memo.is_object()) - { - fc::mutable_variant_object tmp(memo.get_object()); - if (tmp.find("nonce") != tmp.end()) - { - tmp["nonce"] = tmp["nonce"].as_string(); - o["memo"] = tmp; - } - } - } - if (o.find("new_parameters") != o.end()) - { - auto& tmp = o["new_parameters"]; - if (tmp.is_object()) - { - fc::mutable_variant_object tmp2(tmp.get_object()); - if (tmp2.find("current_fees") != tmp2.end()) - { - tmp2.erase("current_fees"); - o["new_parameters"] = tmp2; - } - } - } - if (o.find("owner") != o.end() && o["owner"].is_string()) - { - o["owner_"] = o["owner"].as_string(); - o.erase("owner"); - } - if (o.find("proposed_ops") != o.end()) - { - o["proposed_ops"] = fc::json::to_string(o["proposed_ops"]); - } - if (o.find("initializer") != o.end()) - { - o["initializer"] = fc::json::to_string(o["initializer"]); - } - if (o.find("policy") != o.end()) - { - o["policy"] = fc::json::to_string(o["policy"]); - } - if (o.find("predicates") != o.end()) - { - o["predicates"] = fc::json::to_string(o["predicates"]); - } - 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"]); - } - - - 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::elasticsearch FC_REFLECT_ENUM( graphene::elasticsearch::mode, (only_save)(only_query)(all) ) diff --git a/libraries/plugins/es_objects/es_objects.cpp b/libraries/plugins/es_objects/es_objects.cpp index 4e18d1a5..8f92c391 100644 --- a/libraries/plugins/es_objects/es_objects.cpp +++ b/libraries/plugins/es_objects/es_objects.cpp @@ -66,6 +66,9 @@ class es_objects_plugin_impl bool genesis(); void remove_from_database(object_id_type id, std::string index); + friend class graphene::es_objects::es_objects_plugin; + + private: es_objects_plugin& _self; std::string _es_objects_elasticsearch_url = "http://localhost:9200/"; std::string _es_objects_auth = ""; @@ -97,10 +100,12 @@ class es_objects_plugin_impl uint32_t block_number; fc::time_point_sec block_time; + bool is_es_version_7_or_above = true; private: template void prepareTemplate(T blockchain_object, string index_name); + void init_program_options(const boost::program_options::variables_map& options); }; bool es_objects_plugin_impl::genesis() @@ -523,7 +528,8 @@ void es_objects_plugin_impl::remove_from_database( object_id_type id, std::strin fc::mutable_variant_object delete_line; delete_line["_id"] = string(id); delete_line["_index"] = _es_objects_index_prefix + index; - delete_line["_type"] = "data"; + if( !is_es_version_7_or_above ) + delete_line["_type"] = "_doc"; fc::mutable_variant_object final_delete_line; final_delete_line["delete"] = delete_line; prepare.push_back(fc::json::to_string(final_delete_line)); @@ -537,7 +543,8 @@ void es_objects_plugin_impl::prepareTemplate(T blockchain_object, string index_n { fc::mutable_variant_object bulk_header; bulk_header["_index"] = _es_objects_index_prefix + index_name; - bulk_header["_type"] = "data"; + if( !is_es_version_7_or_above ) + bulk_header["_type"] = "_doc"; if(_es_objects_keep_only_current) { bulk_header["_id"] = string(blockchain_object.id); @@ -567,6 +574,72 @@ es_objects_plugin_impl::~es_objects_plugin_impl() } return; } +void es_objects_plugin_impl::init_program_options(const boost::program_options::variables_map& options) +{ + if (options.count("es-objects-elasticsearch-url")) { + _es_objects_elasticsearch_url = options["es-objects-elasticsearch-url"].as(); + } + if (options.count("es-objects-auth")) { + _es_objects_auth = options["es-objects-auth"].as(); + } + if (options.count("es-objects-bulk-replay")) { + _es_objects_bulk_replay = options["es-objects-bulk-replay"].as(); + } + if (options.count("es-objects-bulk-sync")) { + _es_objects_bulk_sync = options["es-objects-bulk-sync"].as(); + } + if (options.count("es-objects-proposals")) { + _es_objects_proposals = options["es-objects-proposals"].as(); + } + if (options.count("es-objects-accounts")) { + _es_objects_accounts = options["es-objects-accounts"].as(); + } + if (options.count("es-objects-assets")) { + _es_objects_assets = options["es-objects-assets"].as(); + } + if (options.count("es-objects-balances")) { + _es_objects_balances = options["es-objects-balances"].as(); + } + if (options.count("es-objects-limit-orders")) { + _es_objects_limit_orders = options["es-objects-limit-orders"].as(); + } + if (options.count("es-objects-asset-bitasset")) { + _es_objects_asset_bitasset = options["es-objects-asset-bitasset"].as(); + } + if (options.count("es-objects-account-role")) { + _es_objects_balances = options["es-objects-account-role"].as(); + } + if (options.count("es-objects-committee-member")) { + _es_objects_balances = options["es-objects-committee-member"].as(); + } + if (options.count("es-objects-nft")) { + _es_objects_balances = options["es-objects-nft"].as(); + } + if (options.count("es-objects-son")) { + _es_objects_balances = options["es-objects-son"].as(); + } + if (options.count("es-objects-transaction")) { + _es_objects_balances = options["es-objects-transaction"].as(); + } + if (options.count("es-objects-vesting-balance")) { + _es_objects_balances = options["es-objects-vesting-balance"].as(); + } + if (options.count("es-objects-witness")) { + _es_objects_balances = options["es-objects-witness"].as(); + } + if (options.count("es-objects-worker")) { + _es_objects_balances = options["es-objects-worker"].as(); + } + if (options.count("es-objects-index-prefix")) { + _es_objects_index_prefix = options["es-objects-index-prefix"].as(); + } + if (options.count("es-objects-keep-only-current")) { + _es_objects_keep_only_current = options["es-objects-keep-only-current"].as(); + } + if (options.count("es-objects-start-es-after-block")) { + _es_objects_start_es_after_block = options["es-objects-start-es-after-block"].as(); + } +} } // end namespace detail @@ -627,69 +700,9 @@ void es_objects_plugin::plugin_set_program_options( void es_objects_plugin::plugin_initialize(const boost::program_options::variables_map& options) { - if (options.count("es-objects-elasticsearch-url")) { - my->_es_objects_elasticsearch_url = options["es-objects-elasticsearch-url"].as(); - } - if (options.count("es-objects-auth")) { - my->_es_objects_auth = options["es-objects-auth"].as(); - } - if (options.count("es-objects-bulk-replay")) { - my->_es_objects_bulk_replay = options["es-objects-bulk-replay"].as(); - } - if (options.count("es-objects-bulk-sync")) { - my->_es_objects_bulk_sync = options["es-objects-bulk-sync"].as(); - } - if (options.count("es-objects-proposals")) { - my->_es_objects_proposals = options["es-objects-proposals"].as(); - } - if (options.count("es-objects-accounts")) { - my->_es_objects_accounts = options["es-objects-accounts"].as(); - } - if (options.count("es-objects-assets")) { - my->_es_objects_assets = options["es-objects-assets"].as(); - } - if (options.count("es-objects-balances")) { - my->_es_objects_balances = options["es-objects-balances"].as(); - } - if (options.count("es-objects-limit-orders")) { - my->_es_objects_limit_orders = options["es-objects-limit-orders"].as(); - } - if (options.count("es-objects-asset-bitasset")) { - my->_es_objects_asset_bitasset = options["es-objects-asset-bitasset"].as(); - } - if (options.count("es-objects-account-role")) { - my->_es_objects_balances = options["es-objects-account-role"].as(); - } - if (options.count("es-objects-committee-member")) { - my->_es_objects_balances = options["es-objects-committee-member"].as(); - } - if (options.count("es-objects-nft")) { - my->_es_objects_balances = options["es-objects-nft"].as(); - } - if (options.count("es-objects-son")) { - my->_es_objects_balances = options["es-objects-son"].as(); - } - if (options.count("es-objects-transaction")) { - my->_es_objects_balances = options["es-objects-transaction"].as(); - } - if (options.count("es-objects-vesting-balance")) { - my->_es_objects_balances = options["es-objects-vesting-balance"].as(); - } - if (options.count("es-objects-witness")) { - my->_es_objects_balances = options["es-objects-witness"].as(); - } - if (options.count("es-objects-worker")) { - my->_es_objects_balances = options["es-objects-worker"].as(); - } - if (options.count("es-objects-index-prefix")) { - my->_es_objects_index_prefix = options["es-objects-index-prefix"].as(); - } - 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(); - } + ilog("elasticsearch OBJECTS: plugin_initialize() begin"); + + my->init_program_options( options ); database().applied_block.connect([this](const signed_block &b) { if(b.block_num() == 1 && my->_es_objects_start_es_after_block == 0) { @@ -721,10 +734,7 @@ void es_objects_plugin::plugin_initialize(const boost::program_options::variable "Error deleting object from ES database, we are going to keep trying."); } }); -} -void es_objects_plugin::plugin_startup() -{ graphene::utilities::ES es; es.curl = my->curl; es.elasticsearch_url = my->_es_objects_elasticsearch_url; @@ -733,7 +743,17 @@ void es_objects_plugin::plugin_startup() if(!graphene::utilities::checkES(es)) FC_THROW_EXCEPTION(fc::exception, "ES database is not up in url ${url}", ("url", my->_es_objects_elasticsearch_url)); - ilog("elasticsearch OBJECTS: plugin_startup() begin"); + + graphene::utilities::checkESVersion7OrAbove(es, my->is_es_version_7_or_above); + + ilog("elasticsearch OBJECTS: plugin_initialize() end"); +} + +void es_objects_plugin::plugin_startup() +{ + ilog("elasticsearch OBJECTS: plugin_startup() begin"); + // Nothing to do + ilog("elasticsearch OBJECTS: plugin_startup() end"); } } } diff --git a/libraries/utilities/elasticsearch.cpp b/libraries/utilities/elasticsearch.cpp index 11a9561b..df82695f 100644 --- a/libraries/utilities/elasticsearch.cpp +++ b/libraries/utilities/elasticsearch.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -47,8 +46,36 @@ bool checkES(ES& es) if(doCurl(curl_request).empty()) return false; return true; - } + +const std::string getESVersion(ES& es) +{ + graphene::utilities::CurlRequest curl_request; + curl_request.handler = es.curl; + curl_request.url = es.elasticsearch_url; + curl_request.auth = es.auth; + curl_request.type = "GET"; + + fc::variant response = fc::json::from_string(doCurl(curl_request)); + + return response["version"]["number"].as_string(); +} + +void checkESVersion7OrAbove(ES& es, bool& result) noexcept +{ + static const int64_t version_7 = 7; + try { + const auto es_version = graphene::utilities::getESVersion(es); + auto dot_pos = es_version.find('.'); + result = ( std::stoi(es_version.substr(0,dot_pos)) >= version_7 ); + } + catch( ... ) + { + wlog( "Unable to get ES version, assuming it is 7 or above" ); + result = true; + } +} + const std::string simpleQuery(ES& es) { graphene::utilities::CurlRequest curl_request; @@ -118,13 +145,13 @@ bool handleBulkResponse(long http_code, const std::string& CurlReadBuffer) return true; } -const std::vector createBulk(const fc::mutable_variant_object& bulk_header, const std::string& data) +const std::vector createBulk(const fc::mutable_variant_object& bulk_header, const std::string&& data) { std::vector bulk; fc::mutable_variant_object final_bulk_header; final_bulk_header["index"] = bulk_header; bulk.push_back(fc::json::to_string(final_bulk_header)); - bulk.push_back(data); + bulk.emplace_back(std::move(data)); return bulk; } @@ -154,15 +181,6 @@ const std::string getEndPoint(ES& es) return doCurl(curl_request); } -const std::string generateIndexName(const fc::time_point_sec& block_date, const std::string& _elasticsearch_index_prefix) -{ - auto block_date_string = block_date.to_iso_string(); - std::vector parts; - boost::split(parts, block_date_string, boost::is_any_of("-")); - std::string index_name = _elasticsearch_index_prefix + parts[0] + "-" + parts[1]; - return index_name; -} - const std::string doCurl(CurlRequest& curl) { std::string CurlReadBuffer; diff --git a/libraries/utilities/include/graphene/utilities/elasticsearch.hpp b/libraries/utilities/include/graphene/utilities/elasticsearch.hpp index 898464b1..45749e27 100644 --- a/libraries/utilities/include/graphene/utilities/elasticsearch.hpp +++ b/libraries/utilities/include/graphene/utilities/elasticsearch.hpp @@ -54,13 +54,14 @@ namespace graphene { namespace utilities { }; bool SendBulk(ES& es); - const std::vector createBulk(const fc::mutable_variant_object& bulk_header, const std::string& data); + const std::vector createBulk(const fc::mutable_variant_object& bulk_header, const std::string&& data); bool checkES(ES& es); + const std::string getESVersion(ES& es); + void checkESVersion7OrAbove(ES& es, bool& result) noexcept; const std::string simpleQuery(ES& es); bool deleteAll(ES& es); bool handleBulkResponse(long http_code, const std::string& CurlReadBuffer); const std::string getEndPoint(ES& es); - const std::string generateIndexName(const fc::time_point_sec& block_date, const std::string& _elasticsearch_index_prefix); const std::string doCurl(CurlRequest& curl); const std::string joinBulkLines(const std::vector& bulk); long getResponseCode(CURL *handler); diff --git a/tests/elasticsearch/main.cpp b/tests/elasticsearch/main.cpp index c948616f..7067e1e9 100644 --- a/tests/elasticsearch/main.cpp +++ b/tests/elasticsearch/main.cpp @@ -38,6 +38,10 @@ using namespace graphene::chain; using namespace graphene::chain::test; using namespace graphene::app; +const std::string g_es_url = "http://localhost:9200/"; +const std::string g_es_index_prefix = "peerplays-"; +const std::string g_es_ppobjects_prefix = "ppobjects-"; + BOOST_FIXTURE_TEST_SUITE( elasticsearch_tests, database_fixture ) BOOST_AUTO_TEST_CASE(elasticsearch_account_history) { @@ -48,8 +52,8 @@ BOOST_AUTO_TEST_CASE(elasticsearch_account_history) { graphene::utilities::ES es; es.curl = curl; - es.elasticsearch_url = "http://localhost:9200/"; - es.index_prefix = "peerplays-"; + es.elasticsearch_url = g_es_url; + es.index_prefix = g_es_index_prefix; //es.auth = "elastic:changeme"; // delete all first @@ -71,7 +75,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_account_history) { //int account_create_op_id = operation::tag::value; string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }"; - es.endpoint = es.index_prefix + "*/data/_count"; + es.endpoint = es.index_prefix + "*/_doc/_count"; es.query = query; auto res = graphene::utilities::simpleQuery(es); @@ -79,7 +83,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_account_history) { auto total = j["count"].as_string(); BOOST_CHECK_EQUAL(total, "5"); - es.endpoint = es.index_prefix + "*/data/_search"; + es.endpoint = es.index_prefix + "*/_doc/_search"; res = graphene::utilities::simpleQuery(es); j = fc::json::from_string(res); auto first_id = j["hits"]["hits"][size_t(0)]["_id"].as_string(); @@ -91,7 +95,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_account_history) { fc::usleep(fc::milliseconds(1000)); // index.refresh_interval - es.endpoint = es.index_prefix + "*/data/_count"; + es.endpoint = es.index_prefix + "*/_doc/_count"; res = graphene::utilities::simpleQuery(es); j = fc::json::from_string(res); @@ -114,9 +118,9 @@ BOOST_AUTO_TEST_CASE(elasticsearch_account_history) { // check the visitor data auto block_date = db.head_block_time(); - std::string index_name = graphene::utilities::generateIndexName(block_date, "peerplays-"); + std::string index_name = g_es_index_prefix + block_date.to_iso_string().substr( 0, 7 ); // yyyy-mm - es.endpoint = index_name + "/data/2.9.12"; // we know last op is a transfer of amount 300 + es.endpoint = index_name + "/_doc/2.9.12"; // we know last op is a transfer of amount 300 res = graphene::utilities::getEndPoint(es); j = fc::json::from_string(res); auto last_transfer_amount = j["_source"]["operation_history"]["op_object"]["amount_"]["amount"].as_string(); @@ -137,8 +141,8 @@ BOOST_AUTO_TEST_CASE(elasticsearch_objects) { graphene::utilities::ES es; es.curl = curl; - es.elasticsearch_url = "http://localhost:9200/"; - es.index_prefix = "ppobjects-"; + es.elasticsearch_url = g_es_url; + es.index_prefix = g_es_ppobjects_prefix; //es.auth = "elastic:changeme"; // delete all first @@ -155,7 +159,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_objects) { fc::usleep(fc::milliseconds(1000)); string query = "{ \"query\" : { \"bool\" : { \"must\" : [{\"match_all\": {}}] } } }"; - es.endpoint = es.index_prefix + "*/data/_count"; + es.endpoint = es.index_prefix + "*/_doc/_count"; es.query = query; auto res = graphene::utilities::simpleQuery(es); @@ -163,14 +167,14 @@ BOOST_AUTO_TEST_CASE(elasticsearch_objects) { auto total = j["count"].as_string(); BOOST_CHECK_EQUAL(total, "2"); - es.endpoint = es.index_prefix + "asset/data/_search"; + es.endpoint = es.index_prefix + "asset/_doc/_search"; res = graphene::utilities::simpleQuery(es); j = fc::json::from_string(res); auto first_id = j["hits"]["hits"][size_t(0)]["_source"]["symbol"].as_string(); BOOST_CHECK_EQUAL(first_id, "USD"); auto bitasset_data_id = j["hits"]["hits"][size_t(0)]["_source"]["bitasset_data_id"].as_string(); - es.endpoint = es.index_prefix + "bitasset/data/_search"; + es.endpoint = es.index_prefix + "bitasset/_doc/_search"; es.query = "{ \"query\" : { \"bool\": { \"must\" : [{ \"term\": { \"object_id\": \""+bitasset_data_id+"\"}}] } } }"; res = graphene::utilities::simpleQuery(es); j = fc::json::from_string(res); @@ -192,11 +196,11 @@ BOOST_AUTO_TEST_CASE(elasticsearch_suite) { graphene::utilities::ES es; es.curl = curl; - es.elasticsearch_url = "http://localhost:9200/"; - es.index_prefix = "peerplays-"; + es.elasticsearch_url = g_es_url; + es.index_prefix = g_es_index_prefix; auto delete_account_history = graphene::utilities::deleteAll(es); fc::usleep(fc::milliseconds(1000)); - es.index_prefix = "ppobjects-"; + es.index_prefix = g_es_ppobjects_prefix; auto delete_objects = graphene::utilities::deleteAll(es); fc::usleep(fc::milliseconds(1000)); @@ -218,8 +222,8 @@ BOOST_AUTO_TEST_CASE(elasticsearch_history_api) { graphene::utilities::ES es; es.curl = curl; - es.elasticsearch_url = "http://localhost:9200/"; - es.index_prefix = "peerplays-"; + es.elasticsearch_url = g_es_url; + es.index_prefix = g_es_index_prefix; auto delete_account_history = graphene::utilities::deleteAll(es); From 3a7187babadf905e609c8b7080d2b642327875e0 Mon Sep 17 00:00:00 2001 From: Vlad Dobromyslov Date: Mon, 31 Jan 2022 14:14:24 +0000 Subject: [PATCH 73/77] bug #245 exception seen in witness logs --- .../include/graphene/chain/exceptions.hpp | 35 +-- .../account_history_plugin.cpp | 213 ++++++++++-------- 2 files changed, 136 insertions(+), 112 deletions(-) diff --git a/libraries/chain/include/graphene/chain/exceptions.hpp b/libraries/chain/include/graphene/chain/exceptions.hpp index b8027591..26804f46 100644 --- a/libraries/chain/include/graphene/chain/exceptions.hpp +++ b/libraries/chain/include/graphene/chain/exceptions.hpp @@ -23,6 +23,7 @@ */ #pragma once +#include #include #include #include @@ -95,19 +96,27 @@ msg \ ) -#define GRAPHENE_TRY_NOTIFY( signal, ... ) \ - try \ - { \ - signal( __VA_ARGS__ ); \ - } \ - catch( const graphene::chain::plugin_exception& e ) \ - { \ - elog( "Caught plugin exception: ${e}", ("e", e.to_detail_string() ) ); \ - throw; \ - } \ - catch( ... ) \ - { \ - wlog( "Caught unexpected exception in plugin" ); \ +#define GRAPHENE_TRY_NOTIFY( signal, ... ) \ + try \ + { \ + signal( __VA_ARGS__ ); \ + } \ + catch( const graphene::chain::plugin_exception& e ) \ + { \ + elog( "Caught plugin exception: ${e}", ("e", e.to_detail_string() ) ); \ + throw; \ + } \ + catch( const boost::exception& e ) \ + { \ + elog( "Caught plugin boost::exception: ${e}", ("e", boost::diagnostic_information(e) ) ); \ + } \ + catch( const std::exception& e ) \ + { \ + elog( "Caught plugin std::exception: ${e}", ("e", e.what() ) ); \ + } \ + catch( ... ) \ + { \ + wlog( "Caught unexpected exception in plugin" ); \ } namespace graphene { namespace chain { diff --git a/libraries/plugins/account_history/account_history_plugin.cpp b/libraries/plugins/account_history/account_history_plugin.cpp index 6eb3ff0c..db3fa464 100644 --- a/libraries/plugins/account_history/account_history_plugin.cpp +++ b/libraries/plugins/account_history/account_history_plugin.cpp @@ -79,123 +79,138 @@ account_history_plugin_impl::~account_history_plugin_impl() void account_history_plugin_impl::update_account_histories( const signed_block& b ) { - graphene::chain::database& db = database(); - vector >& hist = db.get_applied_operations(); - bool is_first = true; - auto skip_oho_id = [&is_first,&db,this]() { - if( is_first && db._undo_db.enabled() ) // this ensures that the current id is rolled back on undo - { - db.remove( db.create( []( operation_history_object& obj) {} ) ); - is_first = false; - } - else - _oho_index->use_next_id(); - }; - - for( optional< operation_history_object >& o_op : hist ) - { - optional oho; - - auto create_oho = [&]() { - is_first = false; - operation_history_object result = db.create( [&]( operation_history_object& h ) + try \ + { + graphene::chain::database& db = database(); + vector >& hist = db.get_applied_operations(); + bool is_first = true; + auto skip_oho_id = [&is_first,&db,this]() { + if( is_first && db._undo_db.enabled() ) // this ensures that the current id is rolled back on undo { - if( o_op.valid() ) - h = *o_op; - } ); - o_op->id = result.id; - return optional(result); + db.remove( db.create( []( operation_history_object& obj) {} ) ); + is_first = false; + } + else + _oho_index->use_next_id(); }; - if( !o_op.valid() || ( _max_ops_per_account == 0 && _partial_operations ) ) + for( optional< operation_history_object >& o_op : hist ) { - // Note: the 2nd and 3rd checks above are for better performance, when the db is not clean, - // they will break consistency of account_stats.total_ops and removed_ops and most_recent_op - skip_oho_id(); - continue; - } - else if( !_partial_operations ) - // add to the operation history index - oho = create_oho(); + optional oho; - const operation_history_object& op = *o_op; - - // get the set of accounts this operation applies to - flat_set impacted; - vector other; - // fee payer is added here - operation_get_required_authorities( op.op, impacted, impacted, other, - MUST_IGNORE_CUSTOM_OP_REQD_AUTHS( db.head_block_time() ) ); - - if( op.op.which() == operation::tag< account_create_operation >::value ) - impacted.insert( op.result.get() ); - else - graphene::chain::operation_get_impacted_accounts( op.op, impacted, - MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(db.head_block_time()) ); - if( op.op.which() == operation::tag< lottery_end_operation >::value ) - { - auto lop = op.op.get< lottery_end_operation >(); - auto asset_object = lop.lottery( db ); - impacted.insert( asset_object.issuer ); - for( auto benefactor : asset_object.lottery_options->benefactors ) - impacted.insert( benefactor.id ); - } - - for( auto& a : other ) - for( auto& item : a.account_auths ) - impacted.insert( item.first ); - - // be here, either _max_ops_per_account > 0, or _partial_operations == false, or both - // if _partial_operations == false, oho should have been created above - // so the only case should be checked here is: - // whether need to create oho if _max_ops_per_account > 0 and _partial_operations == true - - // for each operation this account applies to that is in the config link it into the history - if( _tracked_accounts.size() == 0 ) // tracking all accounts - { - // if tracking all accounts, when impacted is not empty (although it will always be), - // still need to create oho if _max_ops_per_account > 0 and _partial_operations == true - // so always need to create oho if not done - if (!impacted.empty() && !oho.valid()) { oho = create_oho(); } - - if( _max_ops_per_account > 0 ) - { - // Note: the check above is for better performance, when the db is not clean, - // it breaks consistency of account_stats.total_ops and removed_ops and most_recent_op, - // but it ensures it's safe to remove old entries in add_account_history(...) - for( auto& account_id : impacted ) + auto create_oho = [&]() { + is_first = false; + operation_history_object result = db.create( [&]( operation_history_object& h ) { - // we don't do index_account_keys here anymore, because - // that indexing now happens in observers' post_evaluate() + if( o_op.valid() ) + h = *o_op; + } ); + o_op->id = result.id; + return optional(result); + }; - // add history - add_account_history( account_id, oho->id ); - } + if( !o_op.valid() || ( _max_ops_per_account == 0 && _partial_operations ) ) + { + // Note: the 2nd and 3rd checks above are for better performance, when the db is not clean, + // they will break consistency of account_stats.total_ops and removed_ops and most_recent_op + skip_oho_id(); + continue; } - } - else // tracking a subset of accounts - { - // whether need to create oho if _max_ops_per_account > 0 and _partial_operations == true ? - // the answer: only need to create oho if a tracked account is impacted and need to save history + else if( !_partial_operations ) + // add to the operation history index + oho = create_oho(); - if( _max_ops_per_account > 0 ) + const operation_history_object& op = *o_op; + + // get the set of accounts this operation applies to + flat_set impacted; + vector other; + // fee payer is added here + operation_get_required_authorities( op.op, impacted, impacted, other, + MUST_IGNORE_CUSTOM_OP_REQD_AUTHS( db.head_block_time() ) ); + + if( op.op.which() == operation::tag< account_create_operation >::value ) + impacted.insert( op.result.get() ); + else + graphene::chain::operation_get_impacted_accounts( op.op, impacted, + MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(db.head_block_time()) ); + if( op.op.which() == operation::tag< lottery_end_operation >::value ) { - // Note: the check above is for better performance, when the db is not clean, - // it breaks consistency of account_stats.total_ops and removed_ops and most_recent_op, - // but it ensures it's safe to remove old entries in add_account_history(...) - for( auto account_id : _tracked_accounts ) + auto lop = op.op.get< lottery_end_operation >(); + auto asset_object = lop.lottery( db ); + impacted.insert( asset_object.issuer ); + for( auto benefactor : asset_object.lottery_options->benefactors ) + impacted.insert( benefactor.id ); + } + + for( auto& a : other ) + for( auto& item : a.account_auths ) + impacted.insert( item.first ); + + // be here, either _max_ops_per_account > 0, or _partial_operations == false, or both + // if _partial_operations == false, oho should have been created above + // so the only case should be checked here is: + // whether need to create oho if _max_ops_per_account > 0 and _partial_operations == true + + // for each operation this account applies to that is in the config link it into the history + if( _tracked_accounts.size() == 0 ) // tracking all accounts + { + // if tracking all accounts, when impacted is not empty (although it will always be), + // still need to create oho if _max_ops_per_account > 0 and _partial_operations == true + // so always need to create oho if not done + if (!impacted.empty() && !oho.valid()) { oho = create_oho(); } + + if( _max_ops_per_account > 0 ) { - if( impacted.find( account_id ) != impacted.end() ) + // Note: the check above is for better performance, when the db is not clean, + // it breaks consistency of account_stats.total_ops and removed_ops and most_recent_op, + // but it ensures it's safe to remove old entries in add_account_history(...) + for( auto& account_id : impacted ) { - if (!oho.valid()) { oho = create_oho(); } + // we don't do index_account_keys here anymore, because + // that indexing now happens in observers' post_evaluate() + // add history add_account_history( account_id, oho->id ); } } } + else // tracking a subset of accounts + { + // whether need to create oho if _max_ops_per_account > 0 and _partial_operations == true ? + // the answer: only need to create oho if a tracked account is impacted and need to save history + + if( _max_ops_per_account > 0 ) + { + // Note: the check above is for better performance, when the db is not clean, + // it breaks consistency of account_stats.total_ops and removed_ops and most_recent_op, + // but it ensures it's safe to remove old entries in add_account_history(...) + for( auto account_id : _tracked_accounts ) + { + if( impacted.find( account_id ) != impacted.end() ) + { + if (!oho.valid()) { oho = create_oho(); } + // add history + add_account_history( account_id, oho->id ); + } + } + } + } + if (_partial_operations && ! oho.valid()) + skip_oho_id(); } - if (_partial_operations && ! oho.valid()) - skip_oho_id(); + } + catch( const boost::exception& e ) + { + elog( "Caught account_history_plugin::update_account_histories(...) boost::exception: ${e}", ("e", boost::diagnostic_information(e) ) ); + } + catch( const std::exception& e ) + { + elog( "Caught account_history_plugin::update_account_histories(...) std::exception: ${e}", ("e", e.what() ) ); + } + catch( ... ) + { + wlog( "Caught unexpected exception in account_history_plugin::update_account_histories(...)" ); } } From 7c7f768ce4bfb4a490ad68311321ab2cc2b5ea04 Mon Sep 17 00:00:00 2001 From: serkixenos Date: Tue, 1 Feb 2022 12:21:09 -0400 Subject: [PATCH 74/77] Replace vulnerable XML library --- programs/build_helpers/check_reflect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/build_helpers/check_reflect.py b/programs/build_helpers/check_reflect.py index 58b2851c..0e78c6b2 100755 --- a/programs/build_helpers/check_reflect.py +++ b/programs/build_helpers/check_reflect.py @@ -3,7 +3,7 @@ import json import os import re -import xml.etree.ElementTree as etree +import defusedxml.ElementTree as etree def process_node(path, node): """ From f46a223dce1d8d54a96e42733d4b7816a622d653 Mon Sep 17 00:00:00 2001 From: serkixenos Date: Tue, 1 Feb 2022 13:19:28 -0400 Subject: [PATCH 75/77] Update README for Ubuntu 20.04 --- README.md | 92 +++++++++++++++++++++---------------------------------- 1 file changed, 35 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index bc37f091..2b5b9b1c 100644 --- a/README.md +++ b/README.md @@ -2,95 +2,73 @@ Intro for new developers and witnesses ------------------------ This is a quick introduction to get new developers and witnesses up to speed on Peerplays blockchain. It is intended for witnesses plannig to join a live, already deployed blockchain. -# Building on Ubuntu 18.04 LTS and Installation Instructions - The following dependencies were necessary for a clean install of Ubuntu 18.04 LTS: - ``` - sudo apt-get install autoconf bash build-essential ca-certificates cmake \ - doxygen git graphviz libbz2-dev libcurl4-openssl-dev libncurses-dev \ - libreadline-dev libssl-dev libtool libzmq3-dev locales ntp pkg-config \ - wget +# Building and Installation Instructions + +Officially supported OS is Ubuntu 20.04. + +Following dependencies are needed for a clean install of Ubuntu 20.04: ``` -## Build Boost 1.67.0 - - -``` -mkdir $HOME/src -cd $HOME/src -export BOOST_ROOT=$HOME/src/boost_1_67_0 -sudo apt-get update -sudo apt-get install -y autotools-dev build-essential libbz2-dev libicu-dev python-dev -wget -c 'http://sourceforge.net/projects/boost/files/boost/1.67.0/boost_1_67_0.tar.bz2/download'\ - -O boost_1_67_0.tar.bz2 -tar xjf boost_1_67_0.tar.bz2 -cd boost_1_67_0/ -./bootstrap.sh "--prefix=$BOOST_ROOT" -./b2 install +sudo apt-get install \ + apt-utils autoconf bash build-essential ca-certificates cmake dnsutils \ + doxygen expect git graphviz libboost1.67-all-dev libbz2-dev libcurl4-openssl-dev \ + libncurses-dev libreadline-dev libsnappy-dev libssl-dev libtool libzip-dev \ + libzmq3-dev locales mc nano net-tools ntp openssh-server pkg-config perl \ + python3 python3-jinja2 sudo wget ``` ## Building Peerplays ``` +mkdir $HOME/src cd $HOME/src -export BOOST_ROOT=$HOME/src/boost_1_67_0 git clone https://github.com/peerplays-network/peerplays.git cd peerplays git submodule update --init --recursive # If you want to build Mainnet node -cmake -DBOOST_ROOT="$BOOST_ROOT" -DCMAKE_BUILD_TYPE=Release +cmake -DCMAKE_BUILD_TYPE=Release # If you want to build Testnet node -cmake -DBOOST_ROOT="$BOOST_ROOT" -DCMAKE_BUILD_TYPE=Release -DBUILD_PEERPLAYS_TESTNET=1 +cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_PEERPLAYS_TESTNET=1 make -j$(nproc) make install # this can install the executable files under /usr/local ``` -## Docker image +## Docker images +Install docker, and add current user to docker group. ``` -# Install docker sudo apt install docker.io - - -# Add current user to docker group sudo usermod -a -G docker $USER + # You need to restart your shell session, to apply group membership # Type 'groups' to verify that you are a member of a docker group - - -# Build docker image (from the project root, must be a docker group member) -docker build -t peerplays . - - -# Start docker image -docker start peerplays - -# Exposed ports -# # rpc service: -# EXPOSE 8090 -# # p2p service: -# EXPOSE 1776 ``` - Rest of the instructions on starting the chain remains same. +### Official docker image for Peerplas Mainnet + +``` +docker pull datasecuritynode/peerplays:latest +``` + +### Building docker image manually +``` +# Build docker image (from the project root, must be a docker group member) +docker build -t peerplays . +``` + +### Start docker image +``` +docker start peerplays +``` + +Rest of the instructions on starting the chain remains same. Starting A Peerplays Node ----------------- - -For Ubuntu 14.04 LTS and up users, see -[this](https://github.com/cryptonomex/graphene/wiki/build-ubuntu) and -then proceed with: - - git clone https://github.com/peerplays-network/peerplays.git - cd peerplays - git submodule update --init --recursive - cmake -DBOOST_ROOT="$BOOST_ROOT" -DCMAKE_BUILD_TYPE=Release . - make - ./programs/witness_node/witness_node - Launching the witness creates required directories. Next, **stop the witness** and continue. $ vi witness_node_data_dir/config.ini From c456d4ec6bae5c7c151cd37e990d00d14722fcad Mon Sep 17 00:00:00 2001 From: serkixenos Date: Thu, 3 Feb 2022 21:18:41 +0000 Subject: [PATCH 76/77] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b5b9b1c..3c5113fc 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ sudo apt-get install \ ``` mkdir $HOME/src cd $HOME/src -git clone https://github.com/peerplays-network/peerplays.git +git clone https://gitlab.com/PBSA/peerplays.git cd peerplays git submodule update --init --recursive # If you want to build Mainnet node From d2ced50bbfc2dfad964fdd5a512838b039f8e8d8 Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Tue, 8 Feb 2022 11:27:26 -0600 Subject: [PATCH 77/77] Bump FC --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 9ed3f6e3..a17b231a 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 9ed3f6e338007c039af09fd86d5e42f685f51a6b +Subproject commit a17b231acf3bbd448179ddffc63c655e9b326395