diff --git a/docs b/docs index d0d1fd5b..f3012a73 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit d0d1fd5b5e7eaab29d94b6b0388c5d6673f1a134 +Subproject commit f3012a7328227e90da6ded944c3c4bf2a4ab94a0 diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index c72af05b..bde65975 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 1a9a932c..463f5138 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -24,6 +24,8 @@ #include #include +#include +#include #include #include @@ -58,7 +60,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.set_all_fees(GRAPHENE_BLOCKCHAIN_PRECISION); + initial_state.initial_parameters.current_fees = fee_schedule::get_default();//->set_all_fees(GRAPHENE_BLOCKCHAIN_PRECISION); initial_state.initial_active_witnesses = 10; for( int i = 0; i < initial_state.initial_active_witnesses; ++i ) { diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 3f8ecb7f..1c86caba 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -16,13 +16,12 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once -#include +#include #include #include #include #include -#include -#include +#include #include #include #include diff --git a/libraries/app/plugin.cpp b/libraries/app/plugin.cpp index b52a53d6..4b665d6e 100644 --- a/libraries/app/plugin.cpp +++ b/libraries/app/plugin.cpp @@ -17,6 +17,7 @@ */ #include +#include namespace graphene { namespace app { diff --git a/libraries/chain/CMakeLists.txt b/libraries/chain/CMakeLists.txt index 08b0aec2..303fd11b 100644 --- a/libraries/chain/CMakeLists.txt +++ b/libraries/chain/CMakeLists.txt @@ -5,6 +5,7 @@ add_library( graphene_chain protocol/types.cpp protocol/address.cpp protocol/asset.cpp + protocol/assert.cpp protocol/account.cpp protocol/transfer.cpp protocol/delegate.cpp @@ -19,6 +20,7 @@ add_library( graphene_chain protocol/operations.cpp protocol/transaction.cpp protocol/block.cpp + protocol/fee_schedule.cpp pts_address.cpp diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index 122ab994..2e4ce662 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -1,4 +1,5 @@ /// This file combines these sources to perform a partial unity build +#include #include "db_balance.cpp" #include "db_block.cpp" #include "db_debug.cpp" diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 88cb28ac..448f3229 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -297,7 +297,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) p.parameters = genesis_state.initial_parameters; // Set fees to zero initially, so that genesis initialization needs not pay them // We'll fix it at the end of the function - p.parameters.current_fees->set_all_fees(0); + p.parameters.current_fees->zero_all_fees(); }); create( [&](dynamic_global_property_object& p) { diff --git a/libraries/chain/include/graphene/chain/database.hpp b/libraries/chain/include/graphene/chain/database.hpp index 4c901c42..4919bb0d 100644 --- a/libraries/chain/include/graphene/chain/database.hpp +++ b/libraries/chain/include/graphene/chain/database.hpp @@ -17,7 +17,6 @@ */ #pragma once #include -#include #include #include #include @@ -31,6 +30,8 @@ #include #include +#include + #include #include diff --git a/libraries/chain/include/graphene/chain/protocol/account.hpp b/libraries/chain/include/graphene/chain/protocol/account.hpp index 8d35daf8..178dd27b 100644 --- a/libraries/chain/include/graphene/chain/protocol/account.hpp +++ b/libraries/chain/include/graphene/chain/protocol/account.hpp @@ -60,6 +60,14 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return registrar; } void validate()const; share_type calculate_fee(const fee_parameters_type& )const; + + void get_impacted_accounts( flat_set& i )const + { + i.insert(registrar); + i.insert(referrer); + add_authority_accounts( i, owner ); + add_authority_accounts( i, active ); + } }; /** @@ -91,6 +99,16 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return account; } void validate()const; share_type calculate_fee( const fee_parameters_type& k )const; + + void get_required_owner_authorities( flat_set& a )const + { if( owner || active ) a.insert( account ); } + + void get_impacted_accounts( flat_set& i )const + { + i.insert(account); + if( owner ) add_authority_accounts( i, *owner ); + if( active ) add_authority_accounts( i, *active ); + } }; @@ -135,6 +153,10 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return authorizing_account; } void validate()const { FC_ASSERT( fee.amount >= 0 ); FC_ASSERT(new_listing < 0x4); } + + void get_impacted_accounts( flat_set& i )const + { i.insert(account_to_list); } + }; @@ -193,6 +215,11 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return account_id; } void validate()const; + void get_impacted_accounts( flat_set& i )const + { + i.insert(new_owner); + } + }; } } diff --git a/libraries/chain/include/graphene/chain/protocol/assert.hpp b/libraries/chain/include/graphene/chain/protocol/assert.hpp index b6e2a575..61d9d765 100644 --- a/libraries/chain/include/graphene/chain/protocol/assert.hpp +++ b/libraries/chain/include/graphene/chain/protocol/assert.hpp @@ -53,7 +53,7 @@ namespace graphene { namespace chain { */ struct assert_operation : public base_operation { - struct fee_parameters_type { share_type fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; + struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; asset fee; account_id_type fee_paying_account; @@ -62,6 +62,7 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return fee_paying_account; } void validate()const; + share_type calculate_fee(const fee_parameters_type& k)const; }; } } // graphene::chain diff --git a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp b/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp index 0e345001..7439555c 100644 --- a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp +++ b/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp @@ -239,6 +239,8 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return issuer; } void validate()const; share_type calculate_fee(const fee_parameters_type& k)const; + void get_impacted_accounts( flat_set& i)const + { if( new_issuer ) i.insert( *new_issuer ); } }; /** @@ -349,6 +351,8 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return issuer; } void validate()const; share_type calculate_fee(const fee_parameters_type& k)const; + void get_impacted_accounts( flat_set& i)const + { i.insert( issue_to_account ); } }; /** diff --git a/libraries/chain/include/graphene/chain/protocol/base.hpp b/libraries/chain/include/graphene/chain/protocol/base.hpp index d146eac2..da66e876 100644 --- a/libraries/chain/include/graphene/chain/protocol/base.hpp +++ b/libraries/chain/include/graphene/chain/protocol/base.hpp @@ -74,6 +74,11 @@ namespace graphene { namespace chain { void validate()const{} static uint64_t calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte ); + static void add_authority_accounts( flat_set& i, const authority& a ) + { + for( auto& item : a.account_auths ) + i.insert( item.first ); + } }; ///@} diff --git a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp index 3d7a671d..ee9ffe85 100644 --- a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp +++ b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp @@ -25,9 +25,9 @@ namespace graphene { namespace chain { * and then calculates the appropriate fee. */ asset calculate_fee( const operation& op, const price& core_exchange_rate = price::unit_price() )const; - void set_fee( operation& op, const price& core_exchange_rate = price::unit_price() )const; + asset set_fee( operation& op, const price& core_exchange_rate = price::unit_price() )const; - void set_all_fees( uint64_t fee_amount ); + void zero_all_fees(); /** * Validates all of the parameters are present and accounted for. diff --git a/libraries/chain/include/graphene/chain/protocol/market.hpp b/libraries/chain/include/graphene/chain/protocol/market.hpp index 2a10e1d3..670418cd 100644 --- a/libraries/chain/include/graphene/chain/protocol/market.hpp +++ b/libraries/chain/include/graphene/chain/protocol/market.hpp @@ -130,6 +130,8 @@ namespace graphene { namespace chain { /// This is a virtual operation; there is no fee share_type calculate_fee(const fee_parameters_type& k)const { return 0; } + void get_impacted_accounts( flat_set& i)const + { i.insert( account_id ); } }; } } // graphene::chain diff --git a/libraries/chain/include/graphene/chain/protocol/proposal.hpp b/libraries/chain/include/graphene/chain/protocol/proposal.hpp index acefb19b..cb3ef24f 100644 --- a/libraries/chain/include/graphene/chain/protocol/proposal.hpp +++ b/libraries/chain/include/graphene/chain/protocol/proposal.hpp @@ -63,6 +63,8 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return fee_paying_account; } void validate()const; share_type calculate_fee(const fee_parameters_type& k)const; + + void get_impacted_accounts( flat_set& )const; }; /** diff --git a/libraries/chain/include/graphene/chain/protocol/protocol.hpp b/libraries/chain/include/graphene/chain/protocol/protocol.hpp new file mode 100644 index 00000000..c995fe12 --- /dev/null +++ b/libraries/chain/include/graphene/chain/protocol/protocol.hpp @@ -0,0 +1,3 @@ +#pragma once +#include +#include diff --git a/libraries/chain/include/graphene/chain/protocol/transfer.hpp b/libraries/chain/include/graphene/chain/protocol/transfer.hpp index 5080884e..3caa8332 100644 --- a/libraries/chain/include/graphene/chain/protocol/transfer.hpp +++ b/libraries/chain/include/graphene/chain/protocol/transfer.hpp @@ -39,6 +39,8 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return from; } void validate()const; share_type calculate_fee(const fee_parameters_type& k)const; + void get_impacted_accounts( flat_set& i )const + { i.insert(to); } }; /** @@ -71,6 +73,12 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return issuer; } void validate()const; share_type calculate_fee(const fee_parameters_type& k)const; + void get_impacted_accounts( flat_set& i )const + { + i.insert(to); + i.insert(from); + i.insert(issuer); + } }; }} // graphene::chain diff --git a/libraries/chain/include/graphene/chain/protocol/vesting.hpp b/libraries/chain/include/graphene/chain/protocol/vesting.hpp index 9cd2323c..c3674a6c 100644 --- a/libraries/chain/include/graphene/chain/protocol/vesting.hpp +++ b/libraries/chain/include/graphene/chain/protocol/vesting.hpp @@ -56,6 +56,9 @@ namespace graphene { namespace chain { FC_ASSERT( fee.amount >= 0 ); FC_ASSERT( amount.amount > 0 ); } + void get_impacted_accounts( flat_set& i )const + { i.insert(owner); } + }; /** diff --git a/libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp b/libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp index 13712c5f..a6d7582e 100644 --- a/libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp +++ b/libraries/chain/include/graphene/chain/protocol/withdraw_permission.hpp @@ -43,6 +43,9 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return withdraw_from_account; } void validate()const; + + void get_impacted_accounts( flat_set& i)const + { i.insert( authorized_account ); } }; /** @@ -78,6 +81,8 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return withdraw_from_account; } void validate()const; + void get_impacted_accounts( flat_set& i)const + { i.insert( authorized_account ); } }; /** @@ -116,6 +121,8 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return withdraw_to_account; } void validate()const; share_type calculate_fee(const fee_parameters_type& k)const; + void get_impacted_accounts( flat_set& i)const + { i.insert( withdraw_from_account ); } }; /** @@ -140,6 +147,8 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return withdraw_from_account; } void validate()const; + void get_impacted_accounts( flat_set& i)const + { i.insert( authorized_account ); } }; } } // graphene::chain diff --git a/libraries/chain/protocol/assert.cpp b/libraries/chain/protocol/assert.cpp index fddb5545..020fbad6 100644 --- a/libraries/chain/protocol/assert.cpp +++ b/libraries/chain/protocol/assert.cpp @@ -1,32 +1,17 @@ +#include -#include -#include -#include -#include -#include +namespace graphene { namespace chain { -namespace graphene { namespace chain { namespace pred { - -bool account_name_eq_lit::validate()const +bool account_name_eq_lit_predicate::validate()const { return is_valid_name( name ); } -bool account_name_eq_lit::evaluate( const database& db )const -{ - return account_id(db).name == name; -} - -bool asset_symbol_eq_lit::validate()const +bool asset_symbol_eq_lit_predicate::validate()const { return is_valid_symbol( symbol ); } -bool asset_symbol_eq_lit::evaluate( const database& db )const -{ - return asset_id(db).symbol == symbol; -} - struct predicate_validator { typedef void result_type; @@ -55,4 +40,4 @@ share_type assert_operation::calculate_fee(const fee_parameters_type& k)const } -} } } +} } // namespace graphene::chain diff --git a/libraries/chain/protocol/asset_ops.cpp b/libraries/chain/protocol/asset_ops.cpp index ff512b58..c46495e4 100644 --- a/libraries/chain/protocol/asset_ops.cpp +++ b/libraries/chain/protocol/asset_ops.cpp @@ -42,6 +42,10 @@ bool is_valid_symbol( const string& symbol ) return true; } +share_type asset_issue_operation::calculate_fee(const fee_parameters_type& k)const +{ + return k.fee + calculate_data_fee( fc::raw::pack_size(memo), k.price_per_kbyte ); +} share_type asset_create_operation::calculate_fee(const asset_create_operation::fee_parameters_type& param)const { diff --git a/libraries/chain/protocol/fee_schedule.cpp b/libraries/chain/protocol/fee_schedule.cpp index fe47a764..50665465 100644 --- a/libraries/chain/protocol/fee_schedule.cpp +++ b/libraries/chain/protocol/fee_schedule.cpp @@ -1,7 +1,10 @@ -#include +#include +#include namespace graphene { namespace chain { + typedef fc::smart_ref smart_fee_schedule; + fee_schedule::fee_schedule() { } @@ -9,7 +12,7 @@ namespace graphene { namespace chain { fee_schedule fee_schedule::get_default() { fee_schedule result; - for( uint32_t i = 0; i < fee_parameters.count(); ++i ) + for( uint32_t i = 0; i < fee_parameters().count(); ++i ) { fee_parameters x; x.set_which(i); result.parameters.insert(x); @@ -19,12 +22,12 @@ namespace graphene { namespace chain { struct fee_schedule_validate_visitor { - typedef result_type void; + typedef void result_type; template void operator()( const T& p )const { - p.validate(); + //p.validate(); } }; @@ -36,25 +39,57 @@ namespace graphene { namespace chain { struct calc_fee_visitor { - typedef result_type asset; + typedef uint64_t result_type; const fee_parameters& param; calc_fee_visitor( const fee_parameters& p ):param(p){} template - asset operator()( const OpType& op )const + result_type operator()( const OpType& op )const { - return op.calculate_fee( param.get() ); + return op.calculate_fee( param.get() ).value; } }; + struct set_fee_visitor + { + typedef void result_type; + asset _fee; + + set_fee_visitor( asset f ):_fee(f){} + + template + void operator()( OpType& op )const + { + op.fee = _fee; + } + }; + + struct zero_fee_visitor + { + typedef void result_type; + + template + result_type operator()( ParamType& op )const + { + memset( (char*)&op, sizeof(op), 0 ); + } + }; + + void fee_schedule::zero_all_fees() + { + *this = get_default(); + for( auto& i : parameters ) + i.visit( zero_fee_visitor() ); + } + asset fee_schedule::calculate_fee( const operation& op, const price& core_exchange_rate )const { fee_parameters params; params.set_which(op.which()); auto itr = parameters.find(params); if( itr != parameters.end() ) params = *itr; - share_type base_value op.visit( calc_fee_visitor( params ) ); - auto scaled = fc::uint128(base_value.value) * scale_factor; + auto base_value = op.visit( calc_fee_visitor( params ) ); + auto scaled = fc::uint128(base_value) * scale; scaled /= GRAPHENE_100_PERCENT; FC_ASSERT( scaled <= GRAPHENE_MAX_SHARE_SUPPLY ); auto result = asset( scaled.to_uint64(), 0 ) * core_exchange_rate; @@ -62,4 +97,11 @@ namespace graphene { namespace chain { return result; } + asset fee_schedule::set_fee( operation& op, const price& core_exchange_rate )const + { + auto f = calculate_fee( op, core_exchange_rate ); + op.visit( set_fee_visitor( f ) ); + return f; + } + } } // graphene::chain diff --git a/libraries/chain/protocol/operations.cpp b/libraries/chain/protocol/operations.cpp index ce9a6184..168b3b7b 100644 --- a/libraries/chain/protocol/operations.cpp +++ b/libraries/chain/protocol/operations.cpp @@ -156,10 +156,40 @@ struct operation_validator void operator()( const T& v )const { v.validate(); } }; +struct operation_get_required_auth +{ + typedef void result_type; + + flat_set& active; + flat_set& owner; + vector& other; + + + operation_get_required_auth( flat_set& a, + flat_set& own, + vector& oth ):active(a),owner(own),other(oth){} + + template + void operator()( const T& v )const + { + active.insert( v.fee_payer() ); + v.get_required_active_authorities( active ); + v.get_required_owner_authorities( owner ); + v.get_required_authorities( other ); + } +}; + void operation_validate( const operation& op ) { op.visit( operation_validator() ); } +void operation_get_required_authorities( const operation& op, + flat_set& active, + flat_set& owner, + vector& other ) +{ + +} } } // namespace graphene::chain diff --git a/libraries/chain/protocol/proposal.cpp b/libraries/chain/protocol/proposal.cpp index d9a5e1df..cbfc5362 100644 --- a/libraries/chain/protocol/proposal.cpp +++ b/libraries/chain/protocol/proposal.cpp @@ -55,5 +55,12 @@ share_type proposal_update_operation::calculate_fee(const fee_parameters_type& k { return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte ); } - +void proposal_create_operation::get_impacted_accounts( flat_set& i )const +{ + vector other; + for( const auto& op : proposed_ops ) + operation_get_required_authorities( op.op, i, i, other ); + for( auto& o : other ) + add_authority_accounts( i, o ); +} } } // graphene::chain diff --git a/libraries/fc b/libraries/fc index 1ce9f4c3..8d13f292 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 1ce9f4c37e6d3b7672ca9cfb152d236085f31f74 +Subproject commit 8d13f292b8ad47d4055bba8721731d73acd0561f diff --git a/libraries/net/include/graphene/net/core_messages.hpp b/libraries/net/include/graphene/net/core_messages.hpp index db6580f0..5e84e090 100644 --- a/libraries/net/include/graphene/net/core_messages.hpp +++ b/libraries/net/include/graphene/net/core_messages.hpp @@ -18,7 +18,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 7dfbe190..b5bfdeb7 100644 --- a/libraries/net/include/graphene/net/node.hpp +++ b/libraries/net/include/graphene/net/node.hpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index 0e17e4c5..6a07ec6c 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -71,6 +71,7 @@ #include #include +#include #include diff --git a/libraries/net/peer_connection.cpp b/libraries/net/peer_connection.cpp index 76b87625..a7766e8a 100644 --- a/libraries/net/peer_connection.cpp +++ b/libraries/net/peer_connection.cpp @@ -19,6 +19,7 @@ #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 0c1016d3..cf9d12f5 100644 --- a/libraries/plugins/account_history/account_history_plugin.cpp +++ b/libraries/plugins/account_history/account_history_plugin.cpp @@ -73,117 +73,15 @@ struct operation_get_impacted_accounts _impacted.insert( item.first ); } - void operator()( const transfer_operation& o )const { - _impacted.insert( o.to ); - } - - void operator()( const limit_order_create_operation& o )const { } - void operator()( const limit_order_cancel_operation& o )const { } - void operator()( const call_order_update_operation& o )const { } - void operator()( const custom_operation& o )const { } - void operator()( const account_create_operation& o )const { _impacted.insert( _op_history.result.get() ); } - void operator()( const account_update_operation& o )const { - if( o.owner ) - { - add_authority( *o.owner ); - } - if( o.active ) - { - add_authority( *o.active ); - } - } - void operator()( const account_upgrade_operation& )const {} - void operator()( const account_transfer_operation& o )const + template + void operator()( const T& o )const { - _impacted.insert( o.new_owner ); + o.get_impacted_accounts( _impacted ); } - - void operator()( const account_whitelist_operation& o )const { - _impacted.insert( o.account_to_list ); - } - - void operator()( const asset_create_operation& o )const { } - - void operator()( const asset_update_operation& o )const { - if( o.new_issuer ) - _impacted.insert(*o.new_issuer); - } - void operator()( const asset_update_bitasset_operation& o )const { - } - void operator()( const asset_update_feed_producers_operation& o )const { - for( auto id : o.new_feed_producers ) - _impacted.insert(id); - } - - void operator()( const asset_issue_operation& o )const { - _impacted.insert( o.issue_to_account ); - } - - void operator()( const asset_reserve_operation& o )const { } - void operator()( const asset_global_settle_operation& o )const { } - void operator()( const asset_settle_operation& o )const { } - - void operator()( const asset_fund_fee_pool_operation& o )const { } - void operator()( const asset_publish_feed_operation& o )const { } - void operator()( const delegate_create_operation& o )const { } - - void operator()( const withdraw_permission_create_operation& o )const{ - _impacted.insert(o.authorized_account); - } - void operator()( const withdraw_permission_claim_operation& o )const{ - _impacted.insert( o.withdraw_from_account ); - } - void operator()( const withdraw_permission_update_operation& o )const{ - _impacted.insert( o.authorized_account ); - } - void operator()( const withdraw_permission_delete_operation& o )const{ - _impacted.insert( o.authorized_account ); - } - - void operator()( const witness_create_operation& o )const { - _impacted.insert(o.witness_account); - } - - void operator()( const witness_withdraw_pay_operation& o )const { } - - void operator()( const proposal_create_operation& o )const { - for( auto op : o.proposed_ops ) - { - operation_get_required_active_authorities( op.op, _impacted ); - operation_get_required_owner_authorities( op.op, _impacted ); - } - } - - void operator()( const proposal_update_operation& o )const { } - void operator()( const proposal_delete_operation& o )const { } - - void operator()( const fill_order_operation& o )const { - _impacted.insert( o.account_id ); - } - - void operator()(const global_parameters_update_operation& )const { - _impacted.insert( account_id_type() ); - } - - void operator()( const vesting_balance_create_operation& o )const - { - _impacted.insert( o.creator ); - _impacted.insert( o.owner ); - } - - void operator()( const vesting_balance_withdraw_operation& o )const - { - _impacted.insert( o.owner ); - } - - void operator()( const worker_create_operation& )const {} - void operator()( const assert_operation& )const {} - void operator()( const balance_claim_operation& )const {} - void operator()( const override_transfer_operation& )const {} }; @@ -207,10 +105,14 @@ void account_history_plugin_impl::update_account_histories( const signed_block& // get the set of accounts this operation applies to flat_set impacted; - operation_get_required_active_authorities( op.op, impacted ); - operation_get_required_owner_authorities( op.op, impacted ); + vector other; + operation_get_required_authorities( op.op, impacted, impacted, other ); op.op.visit( operation_get_impacted_accounts( oho, _self, impacted ) ); + for( auto& a : other ) + for( auto& item : a.account_auths ) + impacted.insert( item.first ); + // for each operation this account applies to that is in the config link it into the history if( _tracked_accounts.size() == 0 ) { diff --git a/libraries/plugins/market_history/market_history_plugin.cpp b/libraries/plugins/market_history/market_history_plugin.cpp index 75b0006f..4a76b89b 100644 --- a/libraries/plugins/market_history/market_history_plugin.cpp +++ b/libraries/plugins/market_history/market_history_plugin.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include diff --git a/libraries/wallet/cache.cpp b/libraries/wallet/cache.cpp index 51e99664..051058a9 100644 --- a/libraries/wallet/cache.cpp +++ b/libraries/wallet/cache.cpp @@ -20,8 +20,7 @@ #include #include #include -#include -#include +#include #include #include #include diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 7eed481e..52f79647 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -18,7 +18,6 @@ #pragma once #include -#include #include using namespace graphene::app; @@ -606,8 +605,8 @@ class wallet_api signed_transaction create_asset(string issuer, string symbol, uint8_t precision, - asset_object::asset_options common, - fc::optional bitasset_opts, + asset_options common, + fc::optional bitasset_opts, bool broadcast = false); /** Issue new shares of an asset. @@ -642,7 +641,7 @@ class wallet_api */ signed_transaction update_asset(string symbol, optional new_issuer, - asset_object::asset_options new_options, + asset_options new_options, bool broadcast = false); /** Update the options specific to a BitAsset. @@ -659,7 +658,7 @@ class wallet_api * @returns the signed transaction updating the bitasset */ signed_transaction update_bitasset(string symbol, - asset_object::bitasset_options new_options, + bitasset_options new_options, bool broadcast = false); /** Update the set of feed-producing accounts for a BitAsset. diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index ec50756b..2d98dc2c 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -41,11 +41,11 @@ #include #include -#include #include #include #include #include +#include #ifndef WIN32 # include @@ -76,13 +76,13 @@ public: template void operator()(const T& op)const { - balance_accumulator acc; - op.get_balance_delta( acc, result ); + //balance_accumulator acc; + //op.get_balance_delta( acc, result ); string op_name = fc::get_typename::name(); if( op_name.find_last_of(':') != string::npos ) op_name.erase(0, op_name.find_last_of(':')+1); out << op_name <<" "; - out << "balance delta: " << fc::json::to_string(acc.balance) <<" "; + // out << "balance delta: " << fc::json::to_string(acc.balance) <<" "; out << fc::json::to_string(op.fee_payer()) << " fee: " << fc::json::to_string(op.fee); } void operator()(const transfer_operation& op)const; @@ -378,6 +378,12 @@ public: return ob.template as(); } + void set_operation_fees( signed_transaction& tx, const fee_schedule& s ) + { + for( auto& op : tx.operations ) + s.set_fee(op); + } + variant info() const { auto global_props = get_global_properties(); @@ -612,12 +618,12 @@ public: _builder_transactions[transaction_handle].operations.emplace_back(op); } void replace_operation_in_builder_transaction(transaction_handle_type handle, - unsigned operation_index, + uint32_t operation_index, const operation& new_op) { FC_ASSERT(_builder_transactions.count(handle)); signed_transaction& trx = _builder_transactions[handle]; - FC_ASSERT(operation_index >= 0 && operation_index < trx.operations.size()); + FC_ASSERT( operation_index < trx.operations.size()); trx.operations[operation_index] = new_op; } asset set_fees_on_builder_transaction(transaction_handle_type handle, string fee_asset = GRAPHENE_SYMBOL) @@ -626,24 +632,20 @@ public: auto fee_asset_obj = get_asset(fee_asset); asset total_fee = fee_asset_obj.amount(0); + + auto gprops = _remote_db->get_global_properties().parameters; if( fee_asset_obj.get_id() != asset_id_type() ) { - _builder_transactions[handle].visit( - operation_set_fee(_remote_db->get_global_properties().parameters.current_fees, - fee_asset_obj.options.core_exchange_rate, - &total_fee.amount) - ); + for( auto& op : _builder_transactions[handle].operations ) + 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, "Cannot pay fees in ${asset}, as this asset's fee pool is insufficiently funded.", ("asset", fee_asset_obj.symbol)); } else { - _builder_transactions[handle].visit( - operation_set_fee(_remote_db->get_global_properties().parameters.current_fees, - price::unit_price(), - &total_fee.amount) - ); + for( auto& op : _builder_transactions[handle].operations ) + total_fee += gprops.current_fees->set_fee( op ); } return total_fee; @@ -671,8 +673,8 @@ public: [](const operation& op) -> op_wrapper { return op; }); if( review_period_seconds ) op.review_period_seconds = review_period_seconds; - op.fee = op.calculate_fee(_remote_db->get_global_properties().parameters.current_fees); trx.operations = {op}; + _remote_db->get_global_properties().parameters.current_fees->set_fee( trx.operations.front() ); return trx = sign_transaction(trx, broadcast); } @@ -681,6 +683,7 @@ public: _builder_transactions.erase(handle); } + signed_transaction register_account(string name, public_key_type owner, public_key_type active, @@ -716,7 +719,8 @@ public: tx.operations.push_back( account_create_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + auto current_fees = _remote_db->get_global_properties().parameters.current_fees; + set_operation_fees( tx, current_fees ); vector paying_keys = registrar_account_object.active.get_keys(); @@ -741,6 +745,7 @@ public: return tx; } FC_CAPTURE_AND_RETHROW( (name)(owner)(active)(registrar_account)(referrer_account)(referrer_percent)(broadcast) ) } + signed_transaction upgrade_account(string name, bool broadcast) { try { FC_ASSERT( !self.is_locked() ); @@ -752,7 +757,7 @@ public: op.account_to_upgrade = account_obj.get_id(); op.upgrade_to_lifetime_member = true; tx.operations = {op}; - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees ); tx.validate(); return sign_transaction( tx, broadcast ); @@ -838,7 +843,7 @@ public: tx.operations.push_back( account_create_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); vector paying_keys = registrar_account_object.active.get_keys(); @@ -884,8 +889,8 @@ public: signed_transaction create_asset(string issuer, string symbol, uint8_t precision, - asset_object::asset_options common, - fc::optional bitasset_opts, + asset_options common, + fc::optional bitasset_opts, bool broadcast = false) { try { account_object issuer_account = get_account( issuer ); @@ -900,7 +905,7 @@ public: signed_transaction tx; tx.operations.push_back( create_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -908,7 +913,7 @@ public: signed_transaction update_asset(string symbol, optional new_issuer, - asset_object::asset_options new_options, + asset_options new_options, bool broadcast /* = false */) { try { optional asset_to_update = find_asset(symbol); @@ -929,14 +934,14 @@ public: signed_transaction tx; tx.operations.push_back( update_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); } FC_CAPTURE_AND_RETHROW( (symbol)(new_issuer)(new_options)(broadcast) ) } signed_transaction update_bitasset(string symbol, - asset_object::bitasset_options new_options, + bitasset_options new_options, bool broadcast /* = false */) { try { optional asset_to_update = find_asset(symbol); @@ -950,7 +955,7 @@ public: signed_transaction tx; tx.operations.push_back( update_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -974,7 +979,7 @@ public: signed_transaction tx; tx.operations.push_back( update_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -996,7 +1001,7 @@ public: signed_transaction tx; tx.operations.push_back( publish_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1020,7 +1025,7 @@ public: signed_transaction tx; tx.operations.push_back( fund_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1042,7 +1047,7 @@ public: signed_transaction tx; tx.operations.push_back( reserve_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1063,7 +1068,7 @@ public: signed_transaction tx; tx.operations.push_back( settle_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1084,7 +1089,7 @@ public: signed_transaction tx; tx.operations.push_back( settle_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1102,7 +1107,7 @@ public: signed_transaction tx; tx.operations.push_back( whitelist_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1120,7 +1125,7 @@ public: signed_transaction tx; tx.operations.push_back( delegate_create_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1221,7 +1226,7 @@ public: signed_transaction tx; tx.operations.push_back( witness_create_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); _wallet.pending_witness_registrations[owner_account] = key_to_wif(witness_private_key); @@ -1257,7 +1262,7 @@ public: signed_transaction tx; tx.operations.push_back( account_update_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1291,7 +1296,7 @@ public: signed_transaction tx; tx.operations.push_back( account_update_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1322,7 +1327,7 @@ public: signed_transaction tx; tx.operations.push_back( account_update_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1348,7 +1353,7 @@ public: signed_transaction tx; tx.operations.push_back( account_update_op ); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1472,7 +1477,7 @@ public: signed_transaction tx; tx.operations.push_back(op); - tx.visit( operation_set_fee( _remote_db->get_global_properties().parameters.current_fees ) ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction( tx, broadcast ); @@ -1493,7 +1498,7 @@ public: signed_transaction trx; trx.operations = {op}; - trx.visit(operation_set_fee(_remote_db->get_global_properties().parameters.current_fees)); + set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees); trx.validate(); idump((broadcast)); @@ -1509,7 +1514,7 @@ public: limit_order_cancel_operation op; op.fee_paying_account = get_object(order_id).seller; op.order = order_id; - op.fee = op.calculate_fee(_remote_db->get_global_properties().parameters.current_fees); + set_operation_fees( trx, _remote_db->get_global_properties().parameters.current_fees); trx.operations = {op}; trx.validate(); @@ -1545,7 +1550,7 @@ public: signed_transaction tx; tx.operations.push_back(xfer_op); - tx.visit(operation_set_fee(_remote_db->get_global_properties().parameters.current_fees)); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction(tx, broadcast); @@ -1575,7 +1580,7 @@ public: signed_transaction tx; tx.operations.push_back(issue_op); - tx.visit(operation_set_fee(_remote_db->get_global_properties().parameters.current_fees)); + set_operation_fees(tx,_remote_db->get_global_properties().parameters.current_fees); tx.validate(); return sign_transaction(tx, broadcast); @@ -1631,7 +1636,7 @@ public: void dbg_make_uia(string creator, string symbol) { - asset_object::asset_options opts; + asset_options opts; opts.flags &= ~(white_list | disable_force_settle | global_settle); opts.issuer_permissions = opts.flags; opts.core_exchange_rate = price(asset(1), asset(1,1)); @@ -1640,11 +1645,11 @@ public: void dbg_make_mia(string creator, string symbol) { - asset_object::asset_options opts; + asset_options opts; opts.flags &= ~white_list; opts.issuer_permissions = opts.flags; opts.core_exchange_rate = price(asset(1), asset(1,1)); - asset_object::bitasset_options bopts; + bitasset_options bopts; create_asset(get_account(creator).name, symbol, 2, opts, bopts, true); } @@ -1984,8 +1989,8 @@ signed_transaction wallet_api::transfer(string from, string to, string amount, signed_transaction wallet_api::create_asset(string issuer, string symbol, uint8_t precision, - asset_object::asset_options common, - fc::optional bitasset_opts, + asset_options common, + fc::optional bitasset_opts, bool broadcast) { @@ -1994,14 +1999,14 @@ signed_transaction wallet_api::create_asset(string issuer, signed_transaction wallet_api::update_asset(string symbol, optional new_issuer, - asset_object::asset_options new_options, + asset_options new_options, bool broadcast /* = false */) { return my->update_asset(symbol, new_issuer, new_options, broadcast); } signed_transaction wallet_api::update_bitasset(string symbol, - asset_object::bitasset_options new_options, + bitasset_options new_options, bool broadcast /* = false */) { return my->update_bitasset(symbol, new_options, broadcast); @@ -2158,8 +2163,8 @@ operation wallet_api::get_prototype_operation(string operation_name) return graphene::chain::witness_create_operation(); if (operation_name == "witness_withdraw_pay_operation") return graphene::chain::witness_withdraw_pay_operation(); - if (operation_name == "global_parameters_update_operation") - return graphene::chain::global_parameters_update_operation(); + if (operation_name == "delegate_update_global_parameters_operation") + return graphene::chain::delegate_update_global_parameters_operation(); if (operation_name == "transfer_operation") return graphene::chain::transfer_operation(); if (operation_name == "override_transfer_operation") @@ -2304,9 +2309,9 @@ string wallet_api::gethelp(const string& method)const ss << "usage: ISSUER SYMBOL PRECISION_DIGITS OPTIONS BITASSET_OPTIONS BROADCAST\n\n"; ss << "PRECISION_DIGITS: the number of digits after the decimal point\n\n"; ss << "Example value of OPTIONS: \n"; - ss << fc::json::to_pretty_string( graphene::chain::asset_object::asset_options() ); + ss << fc::json::to_pretty_string( graphene::chain::asset_options() ); ss << "\nExample value of BITASSET_OPTIONS: \n"; - ss << fc::json::to_pretty_string( graphene::chain::asset_object::bitasset_options() ); + ss << fc::json::to_pretty_string( graphene::chain::bitasset_options() ); ss << "\nBITASSET_OPTIONS may be null\n"; } else @@ -2423,7 +2428,7 @@ signed_transaction wallet_api::import_balance( string name_or_id, const vector_remote_db->get_global_properties().parameters.current_fees ) ); + my->set_operation_fees( trx, my->_remote_db->get_global_properties().parameters.current_fees ); trx.validate(); auto tx = sign_transaction( trx, false ); diff --git a/programs/CMakeLists.txt b/programs/CMakeLists.txt index 36fc915c..90a6f7b0 100644 --- a/programs/CMakeLists.txt +++ b/programs/CMakeLists.txt @@ -1,5 +1,4 @@ add_subdirectory( cli_wallet ) -add_subdirectory( cli_full_wallet ) add_subdirectory( witness_node ) add_subdirectory( js_operation_serializer ) add_subdirectory( size_checker ) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 65b1cbc1..fd246571 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include diff --git a/programs/js_operation_serializer/main.cpp b/programs/js_operation_serializer/main.cpp index 19751220..dfa7eb56 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -15,16 +15,14 @@ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include #include #include #include -#include -#include +#include #include #include -#include #include using namespace graphene::chain; @@ -368,7 +366,6 @@ int main( int argc, char** argv ) detail_ns::js_name::name("operation_result"); detail_ns::js_name::name("header_extension"); detail_ns::js_name::name("parameter_extension"); - detail_ns::js_name>::name("worker_initializer"); detail_ns::js_name>::name("vesting_policy_initializer"); detail_ns::serializer::init(); detail_ns::serializer::init(); diff --git a/programs/size_checker/main.cpp b/programs/size_checker/main.cpp index d81f469a..89151d83 100644 --- a/programs/size_checker/main.cpp +++ b/programs/size_checker/main.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include diff --git a/tests/app/main.cpp b/tests/app/main.cpp index c1d00537..fa923e87 100644 --- a/tests/app/main.cpp +++ b/tests/app/main.cpp @@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE( two_node_network ) assert_operation op; op.fee_paying_account = GRAPHENE_TEMP_ACCOUNT; - op.predicates.push_back( fc::raw::pack( graphene::chain::pred::asset_symbol_eq_lit{ asset_id_type(), "CORE" } ) ); + op.predicates.push_back( graphene::chain::asset_symbol_eq_lit_predicate{ asset_id_type(), "CORE" } ); trx.operations.push_back( std::move( op ) ); diff --git a/tests/benchmarks/genesis_allocation.cpp b/tests/benchmarks/genesis_allocation.cpp index 7c3fade4..476360ed 100644 --- a/tests/benchmarks/genesis_allocation.cpp +++ b/tests/benchmarks/genesis_allocation.cpp @@ -16,7 +16,6 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include #include #include @@ -88,15 +87,17 @@ BOOST_AUTO_TEST_CASE( genesis_and_persistence_bench ) auto b = db.generate_block( db.get_slot_time( 1 ), db.get_scheduled_witness( 1 ).first, delegate_priv_key, ~0 ); start_time = fc::time_point::now(); + /* TODO: get this buliding again for( int i = 0; i < blocks_to_produce; ++i ) { signed_transaction trx; - trx.operations.emplace_back(transfer_operation({asset(1), account_id_type(i + 11), account_id_type(), asset(1), memo_data()})); + trx.operations.emplace_back(transfer_operation(asset(1), account_id_type(i + 11), account_id_type(), asset(1), memo_data())); db.push_transaction(trx, ~0); aw = db.get_global_properties().active_witnesses; b = db.generate_block( db.get_slot_time( 1 ), db.get_scheduled_witness( 1 ).first, delegate_priv_key, ~0 ); } + */ ilog("Pushed ${c} blocks (1 op each, no validation) in ${t} milliseconds.", ("c", blocks_out)("t", (fc::time_point::now() - start_time).count() / 1000)); diff --git a/tests/common/database_fixture.cpp b/tests/common/database_fixture.cpp index 9e9579c6..7e307493 100644 --- a/tests/common/database_fixture.cpp +++ b/tests/common/database_fixture.cpp @@ -26,8 +26,7 @@ #include #include #include -#include -#include +#include #include #include