Refactoring fee schedule to make things more flex
- this code does not compile, there are now circular references that need to be resolved.
This commit is contained in:
parent
efc1505612
commit
90e04d0290
9 changed files with 518 additions and 582 deletions
65
libraries/chain/fee_schedule.cpp
Normal file
65
libraries/chain/fee_schedule.cpp
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#include <graphene/chain/fee_schedule.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
fee_schedule::fee_schedule()
|
||||
{
|
||||
}
|
||||
|
||||
fee_schedule fee_schedule::get_default()
|
||||
{
|
||||
fee_schedule result;
|
||||
for( uint32_t i = 0; i < fee_parameters.count(); ++i )
|
||||
{
|
||||
fee_parameters x; x.set_which(i);
|
||||
result.parameters.insert(x);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
struct fee_schedule_validate_visitor
|
||||
{
|
||||
typedef result_type void;
|
||||
|
||||
template<typename T>
|
||||
void operator()( const T& p )const
|
||||
{
|
||||
p.validate();
|
||||
}
|
||||
};
|
||||
|
||||
void fee_schedule::validate()const
|
||||
{
|
||||
for( const auto& f : parameters )
|
||||
f.visit( fee_schedule_validate_visitor() );
|
||||
}
|
||||
|
||||
struct calc_fee_visitor
|
||||
{
|
||||
typedef result_type asset;
|
||||
|
||||
const fee_parameters& param;
|
||||
calc_fee_visitor( const fee_parameters& p ):param(p){}
|
||||
|
||||
template<typename OpType>
|
||||
asset operator()( const OpType& op )const
|
||||
{
|
||||
return op.calculate_fee( param.get<typename OpType::fee_parameters_type>() );
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
scaled /= GRAPHENE_100_PERCENT;
|
||||
FC_ASSERT( scaled <= GRAPHENE_MAX_SHARE_SUPPLY );
|
||||
auto result = asset( scaled.to_uint64(), 0 ) * core_exchange_rate;
|
||||
FC_ASSERT( result.amount <= GRAPHENE_MAX_SHARE_SUPPLY );
|
||||
return result;
|
||||
}
|
||||
|
||||
} } // graphene::chain
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
#include <graphene/chain/asset.hpp>
|
||||
#include <graphene/db/generic_index.hpp>
|
||||
#include <boost/multi_index/composite_key.hpp>
|
||||
#include <graphene/chain/operations.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
class database;
|
||||
|
|
@ -156,28 +157,8 @@ class database;
|
|||
/// operations the account may perform.
|
||||
authority active;
|
||||
|
||||
/// These are the fields which can be updated by the active authority.
|
||||
struct options_type {
|
||||
/// The memo key is the key this account will typically use to encrypt/sign transaction memos and other non-
|
||||
/// validated account activities. This field is here to prevent confusion if the active authority has zero or
|
||||
/// multiple keys in it.
|
||||
public_key_type memo_key;
|
||||
/// If this field is set to an account ID other than 0, this account's votes will be ignored and its stake
|
||||
/// will be counted as voting for the referenced account's selected votes instead.
|
||||
account_id_type voting_account;
|
||||
|
||||
/// The number of active witnesses this account votes the blockchain should appoint
|
||||
/// Must not exceed the actual number of witnesses voted for in @ref votes
|
||||
uint16_t num_witness = 0;
|
||||
/// The number of active committee members this account votes the blockchain should appoint
|
||||
/// Must not exceed the actual number of committee members voted for in @ref votes
|
||||
uint16_t num_committee = 0;
|
||||
/// This is the list of vote IDs this account votes for. The weight of these votes is determined by this
|
||||
/// account's balance of core asset.
|
||||
flat_set<vote_id_type> votes;
|
||||
|
||||
void validate()const;
|
||||
} options;
|
||||
typedef account_options options_type;
|
||||
account_options options;
|
||||
|
||||
/// The reference implementation records the account's statistics in a separate object. This field contains the
|
||||
/// ID of that object.
|
||||
|
|
@ -349,8 +330,6 @@ FC_REFLECT_DERIVED( graphene::chain::account_object,
|
|||
(name)(owner)(active)(options)(statistics)(whitelisting_accounts)(blacklisting_accounts)
|
||||
(cashback_vb) )
|
||||
|
||||
FC_REFLECT(graphene::chain::account_object::options_type, (memo_key)(voting_account)(num_witness)(num_committee)(votes))
|
||||
|
||||
FC_REFLECT_DERIVED( graphene::chain::account_balance_object,
|
||||
(graphene::db::object),
|
||||
(owner)(asset_type)(balance) )
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace graphene { namespace chain {
|
|||
secret_hash_type next_secret_hash;
|
||||
secret_hash_type previous_secret;
|
||||
checksum_type transaction_merkle_root;
|
||||
vector<header_extension> extensions;
|
||||
flat_set<header_extension> extensions;
|
||||
|
||||
static uint32_t num_from_id(const block_id_type& id);
|
||||
};
|
||||
|
|
|
|||
119
libraries/chain/include/graphene/chain/chain_parameters.hpp
Normal file
119
libraries/chain/include/graphene/chain/chain_parameters.hpp
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Cryptonomex, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and
|
||||
* the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted until September 8, 2015, provided that the following conditions are met:
|
||||
*
|
||||
* 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* 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.
|
||||
*/
|
||||
#pragma once
|
||||
#include <graphene/chain/fee_schedule.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
typedef static_variant<> parameter_extension;
|
||||
struct chain_parameters
|
||||
{
|
||||
fee_schedule 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
|
||||
uint32_t genesis_proposal_review_period = GRAPHENE_DEFAULT_GENESIS_PROPOSAL_REVIEW_PERIOD_SEC; ///< minimum time in seconds that a proposed transaction requiring genesis authority may not be signed, prior to expiration
|
||||
uint32_t maximum_transaction_size = GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE; ///< maximum allowable size in bytes for a transaction
|
||||
uint32_t maximum_block_size = GRAPHENE_DEFAULT_MAX_BLOCK_SIZE; ///< maximum allowable size in bytes for a block
|
||||
uint32_t maximum_undo_history = GRAPHENE_DEFAULT_MAX_UNDO_HISTORY; ///< maximum number of undo states to keep in RAM
|
||||
uint32_t maximum_time_until_expiration = GRAPHENE_DEFAULT_MAX_TIME_UNTIL_EXPIRATION; ///< maximum lifetime in seconds for transactions to be valid, before expiring
|
||||
uint32_t maximum_proposal_lifetime = GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC; ///< maximum lifetime in seconds for proposed transactions to be kept, before expiring
|
||||
uint8_t maximum_asset_whitelist_authorities = GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES; ///< maximum number of accounts which an asset may list as authorities for its whitelist OR blacklist
|
||||
uint8_t maximum_asset_feed_publishers = GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS; ///< the maximum number of feed publishers for a given asset
|
||||
uint16_t maximum_witness_count = GRAPHENE_DEFAULT_MAX_WITNESSES; ///< maximum number of active witnesses
|
||||
uint16_t maximum_committee_count = GRAPHENE_DEFAULT_MAX_COMMITTEE; ///< maximum number of active delegates
|
||||
uint16_t maximum_authority_membership = GRAPHENE_DEFAULT_MAX_AUTHORITY_MEMBERSHIP; ///< largest number of keys/accounts an authority can have
|
||||
uint16_t reserve_percent_of_fee = GRAPHENE_DEFAULT_BURN_PERCENT_OF_FEE; ///< the percentage of the network's allocation of a fee that is taken out of circulation
|
||||
uint16_t network_percent_of_fee = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE; ///< percent of transaction fees paid to network
|
||||
uint16_t lifetime_referrer_percent_of_fee = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE; ///< percent of transaction fees paid to network
|
||||
uint32_t cashback_vesting_period_seconds = GRAPHENE_DEFAULT_CASHBACK_VESTING_PERIOD_SEC; ///< time after cashback rewards are accrued before they become liquid
|
||||
share_type cashback_vesting_threshold = GRAPHENE_DEFAULT_CASHBACK_VESTING_THRESHOLD; ///< the maximum cashback that can be received without vesting
|
||||
uint16_t max_bulk_discount_percent_of_fee = GRAPHENE_DEFAULT_MAX_BULK_DISCOUNT_PERCENT; ///< the maximum percentage discount for bulk discounts
|
||||
share_type bulk_discount_threshold_min = GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN; ///< the minimum amount of fees paid to qualify for bulk discounts
|
||||
share_type bulk_discount_threshold_max = GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MAX; ///< the amount of fees paid to qualify for the max bulk discount percent
|
||||
bool count_non_member_votes = true; ///< set to false to restrict voting privlegages to member accounts
|
||||
bool allow_non_member_whitelists = false; ///< true if non-member accounts may set whitelists and blacklists; false otherwise
|
||||
share_type witness_pay_per_block = GRAPHENE_DEFAULT_WITNESS_PAY_PER_BLOCK; ///< CORE to be allocated to witnesses (per block)
|
||||
share_type worker_budget_per_day = GRAPHENE_DEFAULT_WORKER_BUDGET_PER_DAY; ///< CORE to be allocated to workers (per day)
|
||||
uint16_t max_predicate_opcode = GRAPHENE_DEFAULT_MAX_ASSERT_OPCODE; ///< predicate_opcode must be less than this number
|
||||
share_type fee_liquidation_threshold = GRAPHENE_DEFAULT_FEE_LIQUIDATION_THRESHOLD; ///< value in CORE at which accumulated fees in blockchain-issued market assets should be liquidated
|
||||
uint16_t accounts_per_fee_scale = GRAPHENE_DEFAULT_ACCOUNTS_PER_FEE_SCALE; ///< number of accounts between fee scalings
|
||||
uint8_t account_fee_scale_bitshifts = GRAPHENE_DEFAULT_ACCOUNT_FEE_SCALE_BITSHIFTS; ///< number of times to left bitshift account registration fee at each scaling
|
||||
flat_set<parameter_extension> extensions;
|
||||
|
||||
void validate()const
|
||||
{
|
||||
FC_ASSERT( reserve_percent_of_fee <= GRAPHENE_100_PERCENT );
|
||||
FC_ASSERT( network_percent_of_fee <= GRAPHENE_100_PERCENT );
|
||||
FC_ASSERT( max_bulk_discount_percent_of_fee <= GRAPHENE_100_PERCENT );
|
||||
FC_ASSERT( lifetime_referrer_percent_of_fee <= GRAPHENE_100_PERCENT );
|
||||
FC_ASSERT( network_percent_of_fee + lifetime_referrer_percent_of_fee <= GRAPHENE_100_PERCENT );
|
||||
FC_ASSERT( bulk_discount_threshold_min <= bulk_discount_threshold_max );
|
||||
FC_ASSERT( bulk_discount_threshold_min > 0 );
|
||||
|
||||
FC_ASSERT( block_interval <= GRAPHENE_MAX_BLOCK_INTERVAL );
|
||||
FC_ASSERT( block_interval > 0 );
|
||||
FC_ASSERT( maintenance_interval > block_interval,
|
||||
"Maintenance interval must be longer than block interval" );
|
||||
FC_ASSERT( maintenance_interval % block_interval == 0,
|
||||
"Maintenance interval must be a multiple of block interval" );
|
||||
FC_ASSERT( maximum_transaction_size >= GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT,
|
||||
"Transaction size limit is too low" );
|
||||
FC_ASSERT( maximum_block_size >= GRAPHENE_MIN_BLOCK_SIZE_LIMIT,
|
||||
"Block size limit is too low" );
|
||||
FC_ASSERT( maximum_time_until_expiration > block_interval,
|
||||
"Maximum transaction expiration time must be greater than a block interval" );
|
||||
FC_ASSERT( maximum_proposal_lifetime - genesis_proposal_review_period > block_interval,
|
||||
"Genesis proposal review period must be less than the maximum proposal lifetime" );
|
||||
}
|
||||
};
|
||||
|
||||
} } // graphene::chain
|
||||
|
||||
FC_REFLECT( graphene::chain::chain_parameters,
|
||||
(current_fees)
|
||||
(block_interval)
|
||||
(maintenance_interval)
|
||||
(genesis_proposal_review_period)
|
||||
(maximum_transaction_size)
|
||||
(maximum_block_size)
|
||||
(maximum_undo_history)
|
||||
(maximum_time_until_expiration)
|
||||
(maximum_proposal_lifetime)
|
||||
(maximum_asset_whitelist_authorities)
|
||||
(maximum_asset_feed_publishers)
|
||||
(maximum_witness_count)
|
||||
(maximum_committee_count)
|
||||
(maximum_authority_membership)
|
||||
(reserve_percent_of_fee)
|
||||
(network_percent_of_fee)
|
||||
(lifetime_referrer_percent_of_fee)
|
||||
(max_bulk_discount_percent_of_fee)
|
||||
(cashback_vesting_period_seconds)
|
||||
(cashback_vesting_threshold)
|
||||
(bulk_discount_threshold_min)
|
||||
(bulk_discount_threshold_max)
|
||||
(count_non_member_votes)
|
||||
(allow_non_member_whitelists)
|
||||
(witness_pay_per_block)
|
||||
(worker_budget_per_day)
|
||||
(max_predicate_opcode)
|
||||
(fee_liquidation_threshold)
|
||||
(accounts_per_fee_scale)
|
||||
(account_fee_scale_bitshifts)
|
||||
(extensions)
|
||||
)
|
||||
52
libraries/chain/include/graphene/chain/fee_schedule.hpp
Normal file
52
libraries/chain/include/graphene/chain/fee_schedule.hpp
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#pragma once
|
||||
#include <graphene/chain/operations.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
template<typename T> struct transform_to_fee_parameters;
|
||||
template<typename ...T>
|
||||
struct transform_to_fee_parameters<fc::static_variant<T...>>
|
||||
{
|
||||
typedef fc::static_variant< typename T::fee_parameters_type... > type;
|
||||
};
|
||||
typedef transform_to_fee_parameters<operation>::type fee_parameters;
|
||||
|
||||
/**
|
||||
* @brief contains all of the parameters necessary to calculate the fee for any operation
|
||||
*/
|
||||
struct fee_schedule
|
||||
{
|
||||
fee_schedule();
|
||||
|
||||
static fee_schedule get_default();
|
||||
|
||||
/**
|
||||
* Finds the appropriate fee parameter struct for the operation
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Validates all of the parameters are present and accounted for.
|
||||
*/
|
||||
void validate()const;
|
||||
|
||||
/**
|
||||
* @note must be sorted by fee_parameters.which() and have no duplicates
|
||||
*/
|
||||
flat_set<fee_parameters> parameters;
|
||||
uint32_t scale; ///< fee * scale / GRAPHENE_100_PERCENT
|
||||
};
|
||||
|
||||
typedef fee_schedule fee_schedule_type;
|
||||
|
||||
} } // graphene::chain
|
||||
|
||||
FC_REFLECT_TYPENAME( graphene::chain::fee_parameters )
|
||||
FC_REFLECT( graphene::chain::fee_schedule, (parameters) )
|
||||
|
||||
|
||||
|
||||
|
||||
} }
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#pragma once
|
||||
#include <graphene/chain/chain_parameters.hpp>
|
||||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/chain/authority.hpp>
|
||||
#include <graphene/chain/asset.hpp>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -143,6 +143,8 @@ namespace graphene { namespace chain {
|
|||
meta_account_object_type
|
||||
};
|
||||
|
||||
struct chain_parameters;
|
||||
|
||||
|
||||
//typedef fc::unsigned_int object_id_type;
|
||||
//typedef uint64_t object_id_type;
|
||||
|
|
@ -311,112 +313,6 @@ namespace graphene { namespace chain {
|
|||
}
|
||||
};
|
||||
|
||||
struct fee_schedule_type
|
||||
{
|
||||
/// The number of bytes to charge a data fee for
|
||||
const static int BYTES_PER_DATA_FEE = 1024;
|
||||
|
||||
template <class... Ts>
|
||||
uint32_t total_data_fee(Ts... ts)const {
|
||||
return data_size(ts...) / BYTES_PER_DATA_FEE * data_fee;
|
||||
// return ((fc::uint128(data_size(ts...)) * data_fee) / BYTES_PER_DATA_FEE).to_uint64();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Standard fees
|
||||
*
|
||||
* These fees are listed because they will be updated frequently and it is lower
|
||||
* overhead than having a key/value map.
|
||||
*/
|
||||
///@{
|
||||
uint64_t key_create_fee = 270300; ///< the cost to register a public key with the blockchain
|
||||
uint64_t account_create_fee = 666666; ///< the cost to register the cheapest non-free account
|
||||
uint64_t account_update_fee = 150000; ///< the cost to update an existing account
|
||||
uint64_t account_transfer_fee = 300000; ///< the cost to transfer an account to a new owner
|
||||
uint64_t account_whitelist_fee = 300000; ///< the fee to whitelist an account
|
||||
uint64_t account_len8up_fee = 5*10000000; ///< about $1
|
||||
uint64_t account_len7_fee = 5*100000000; ///< about $10
|
||||
uint64_t account_len6_fee = 5*UINT64_C(500000000); ///< about $50
|
||||
uint64_t account_len5_fee = 5*UINT64_C(1000000000); ///< about $100
|
||||
uint64_t account_len4_fee = 5*UINT64_C(2000000000); ///< about $200
|
||||
uint64_t account_len3_fee = 5*UINT64_C(3000000000); ///< about $300
|
||||
uint64_t account_len2_fee = 5*UINT64_C(4000000000); ///< about $400
|
||||
uint64_t asset_create_fee = 5*UINT64_C(500000000); ///< about $35 for LTM, the cost to register the cheapest asset
|
||||
uint64_t asset_update_fee = 150000; ///< the cost to modify a registered asset
|
||||
uint64_t asset_issue_fee = 700000; ///< the cost to print a UIA and send it to an account
|
||||
uint64_t asset_reserve_fee = 1500000; ///< the cost to return an asset to the reserve pool
|
||||
uint64_t asset_fund_fee_pool_fee = 150000; ///< the cost to add funds to an asset's fee pool
|
||||
uint64_t asset_settle_fee = 7000000; ///< the cost to trigger a forced settlement of a market-issued asset
|
||||
uint64_t asset_global_settle_fee = 140000000; ///< the cost to trigger a global forced settlement of a market asset
|
||||
uint64_t asset_len7up_fee = 5*UINT64_C(500000000); ///< about $35 for LTM
|
||||
uint64_t asset_len6_fee = 5*5000000000; ///< about $350 for LTM
|
||||
uint64_t asset_len5_fee = 5*10000000000; ///< about $700 for LTM
|
||||
uint64_t asset_len4_fee = 5*50000000000; ///< about $3500 for LTM
|
||||
uint64_t asset_len3_fee = 5*70000000000; ///< about $5000 for LTM
|
||||
uint64_t delegate_create_fee = 680000000; ///< fee for registering as a delegate; used to discourage frivolous delegates
|
||||
uint64_t witness_create_fee = 680000000; /// < fee for registering as a witness
|
||||
uint64_t witness_withdraw_pay_fee = 1500000; ///< fee for withdrawing witness pay
|
||||
uint64_t transfer_fee = 2700000; ///< fee for transferring some asset
|
||||
uint64_t limit_order_create_fee = 666666; ///< fee for placing a limit order in the markets
|
||||
uint64_t call_order_fee = 800000; ///< fee for placing a call order in the markets
|
||||
uint64_t publish_feed_fee = 10000; ///< fee for publishing a price feed
|
||||
uint64_t data_fee = 13500000; ///< a price per BYTES_PER_DATA_FEE bytes of user data
|
||||
uint64_t global_parameters_update_fee = 1350000; ///< the cost to update the global parameters
|
||||
uint64_t membership_annual_fee = 270000000; ///< the annual cost of a membership subscription
|
||||
uint64_t membership_lifetime_fee = 1350000000; ///< the cost to upgrade to a lifetime member
|
||||
uint64_t withdraw_permission_create_fee = 2700000; ///< the cost to create a withdraw permission
|
||||
uint64_t withdraw_permission_update_fee = 150000; ///< the cost to update a withdraw permission
|
||||
uint64_t withdraw_permission_claim_fee = 700000; ///< the cost to withdraw from a withdraw permission
|
||||
uint64_t vesting_balance_create_fee = 7000000;
|
||||
uint64_t vesting_balance_withdraw_fee = 2700000;
|
||||
uint64_t worker_create_fee = 680000000; ///< the cost to create a new worker
|
||||
uint64_t assert_op_fee = 150000; ///< fee per assert operation
|
||||
uint64_t proposal_create_fee = 7000000; ///< fee for creating a proposed transaction
|
||||
uint64_t proposal_update_fee = 1500000; ///< fee for adding or removing approval of a proposed transaction
|
||||
uint64_t custom_operation_fee = 300000; ///< fee for a custom operation
|
||||
///@{
|
||||
|
||||
void set_all_fees( uint64_t v );
|
||||
|
||||
/** Advanced Fees
|
||||
*
|
||||
* THese fields are reserved for future expansion of the fee schedule without breaking the
|
||||
* protocol serialization.
|
||||
*/
|
||||
///@{
|
||||
enum extended_fee_id
|
||||
{
|
||||
withdraw_permission_delete_fee_id = 1, ///< the cost to delete a withdraw permission
|
||||
proposal_delete_fee_id = 2, ///< fee for deleting a proposed transaction
|
||||
limit_order_cancel_fee_id = 3 ///< fee for canceling a limit order
|
||||
};
|
||||
|
||||
uint64_t get_extended_fee( extended_fee_id id )const
|
||||
{
|
||||
auto itr = extended.find(id);
|
||||
if( itr == extended.end() ) return 0;
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
uint64_t withdraw_permission_delete_fee()const { return get_extended_fee( withdraw_permission_delete_fee_id ); }
|
||||
|
||||
|
||||
flat_map<unsigned_int,uint64_t> extended;
|
||||
///@}
|
||||
|
||||
protected:
|
||||
uint64_t data_size()const {
|
||||
return 0;
|
||||
}
|
||||
template <class T, class... Ts>
|
||||
uint64_t data_size(T t, Ts... ts)const {
|
||||
return fc::raw::pack_size(t) + data_size(ts...);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct public_key_type
|
||||
{
|
||||
struct binary_key
|
||||
|
|
@ -443,68 +339,6 @@ namespace graphene { namespace chain {
|
|||
bool is_valid_v1( const std::string& base58str );
|
||||
};
|
||||
|
||||
typedef static_variant<> parameter_extension;
|
||||
|
||||
struct chain_parameters
|
||||
{
|
||||
fee_schedule_type 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
|
||||
uint32_t genesis_proposal_review_period = GRAPHENE_DEFAULT_GENESIS_PROPOSAL_REVIEW_PERIOD_SEC; ///< minimum time in seconds that a proposed transaction requiring genesis authority may not be signed, prior to expiration
|
||||
uint32_t maximum_transaction_size = GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE; ///< maximum allowable size in bytes for a transaction
|
||||
uint32_t maximum_block_size = GRAPHENE_DEFAULT_MAX_BLOCK_SIZE; ///< maximum allowable size in bytes for a block
|
||||
uint32_t maximum_undo_history = GRAPHENE_DEFAULT_MAX_UNDO_HISTORY; ///< maximum number of undo states to keep in RAM
|
||||
uint32_t maximum_time_until_expiration = GRAPHENE_DEFAULT_MAX_TIME_UNTIL_EXPIRATION; ///< maximum lifetime in seconds for transactions to be valid, before expiring
|
||||
uint32_t maximum_proposal_lifetime = GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC; ///< maximum lifetime in seconds for proposed transactions to be kept, before expiring
|
||||
uint8_t maximum_asset_whitelist_authorities = GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES; ///< maximum number of accounts which an asset may list as authorities for its whitelist OR blacklist
|
||||
uint8_t maximum_asset_feed_publishers = GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS; ///< the maximum number of feed publishers for a given asset
|
||||
uint16_t maximum_witness_count = GRAPHENE_DEFAULT_MAX_WITNESSES; ///< maximum number of active witnesses
|
||||
uint16_t maximum_committee_count = GRAPHENE_DEFAULT_MAX_COMMITTEE; ///< maximum number of active delegates
|
||||
uint16_t maximum_authority_membership = GRAPHENE_DEFAULT_MAX_AUTHORITY_MEMBERSHIP; ///< largest number of keys/accounts an authority can have
|
||||
uint16_t reserve_percent_of_fee = GRAPHENE_DEFAULT_BURN_PERCENT_OF_FEE; ///< the percentage of the network's allocation of a fee that is taken out of circulation
|
||||
uint16_t network_percent_of_fee = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE; ///< percent of transaction fees paid to network
|
||||
uint16_t lifetime_referrer_percent_of_fee = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE; ///< percent of transaction fees paid to network
|
||||
uint32_t cashback_vesting_period_seconds = GRAPHENE_DEFAULT_CASHBACK_VESTING_PERIOD_SEC; ///< time after cashback rewards are accrued before they become liquid
|
||||
share_type cashback_vesting_threshold = GRAPHENE_DEFAULT_CASHBACK_VESTING_THRESHOLD; ///< the maximum cashback that can be received without vesting
|
||||
uint16_t max_bulk_discount_percent_of_fee = GRAPHENE_DEFAULT_MAX_BULK_DISCOUNT_PERCENT; ///< the maximum percentage discount for bulk discounts
|
||||
share_type bulk_discount_threshold_min = GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN; ///< the minimum amount of fees paid to qualify for bulk discounts
|
||||
share_type bulk_discount_threshold_max = GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MAX; ///< the amount of fees paid to qualify for the max bulk discount percent
|
||||
bool count_non_member_votes = true; ///< set to false to restrict voting privlegages to member accounts
|
||||
bool allow_non_member_whitelists = false; ///< true if non-member accounts may set whitelists and blacklists; false otherwise
|
||||
share_type witness_pay_per_block = GRAPHENE_DEFAULT_WITNESS_PAY_PER_BLOCK; ///< CORE to be allocated to witnesses (per block)
|
||||
share_type worker_budget_per_day = GRAPHENE_DEFAULT_WORKER_BUDGET_PER_DAY; ///< CORE to be allocated to workers (per day)
|
||||
uint16_t max_predicate_opcode = GRAPHENE_DEFAULT_MAX_ASSERT_OPCODE; ///< predicate_opcode must be less than this number
|
||||
share_type fee_liquidation_threshold = GRAPHENE_DEFAULT_FEE_LIQUIDATION_THRESHOLD; ///< value in CORE at which accumulated fees in blockchain-issued market assets should be liquidated
|
||||
uint16_t accounts_per_fee_scale = GRAPHENE_DEFAULT_ACCOUNTS_PER_FEE_SCALE; ///< number of accounts between fee scalings
|
||||
uint8_t account_fee_scale_bitshifts = GRAPHENE_DEFAULT_ACCOUNT_FEE_SCALE_BITSHIFTS; ///< number of times to left bitshift account registration fee at each scaling
|
||||
vector<parameter_extension> extensions;
|
||||
|
||||
void validate()const
|
||||
{
|
||||
FC_ASSERT( reserve_percent_of_fee <= GRAPHENE_100_PERCENT );
|
||||
FC_ASSERT( network_percent_of_fee <= GRAPHENE_100_PERCENT );
|
||||
FC_ASSERT( max_bulk_discount_percent_of_fee <= GRAPHENE_100_PERCENT );
|
||||
FC_ASSERT( lifetime_referrer_percent_of_fee <= GRAPHENE_100_PERCENT );
|
||||
FC_ASSERT( network_percent_of_fee + lifetime_referrer_percent_of_fee <= GRAPHENE_100_PERCENT );
|
||||
FC_ASSERT( bulk_discount_threshold_min <= bulk_discount_threshold_max );
|
||||
FC_ASSERT( bulk_discount_threshold_min > 0 );
|
||||
|
||||
FC_ASSERT( block_interval <= GRAPHENE_MAX_BLOCK_INTERVAL );
|
||||
FC_ASSERT( block_interval > 0 );
|
||||
FC_ASSERT( maintenance_interval > block_interval,
|
||||
"Maintenance interval must be longer than block interval" );
|
||||
FC_ASSERT( maintenance_interval % block_interval == 0,
|
||||
"Maintenance interval must be a multiple of block interval" );
|
||||
FC_ASSERT( maximum_transaction_size >= GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT,
|
||||
"Transaction size limit is too low" );
|
||||
FC_ASSERT( maximum_block_size >= GRAPHENE_MIN_BLOCK_SIZE_LIMIT,
|
||||
"Block size limit is too low" );
|
||||
FC_ASSERT( maximum_time_until_expiration > block_interval,
|
||||
"Maximum transaction expiration time must be greater than a block interval" );
|
||||
FC_ASSERT( maximum_proposal_lifetime - genesis_proposal_review_period > block_interval,
|
||||
"Genesis proposal review period must be less than the maximum proposal lifetime" );
|
||||
}
|
||||
};
|
||||
|
||||
} } // graphene::chain
|
||||
|
||||
|
|
@ -561,92 +395,6 @@ FC_REFLECT_ENUM( graphene::chain::impl_object_type,
|
|||
FC_REFLECT_ENUM( graphene::chain::meta_info_object_type, (meta_account_object_type)(meta_asset_object_type) )
|
||||
|
||||
|
||||
FC_REFLECT( graphene::chain::fee_schedule_type,
|
||||
(key_create_fee)
|
||||
(account_create_fee)
|
||||
(account_update_fee)
|
||||
(account_transfer_fee)
|
||||
(account_len8up_fee)
|
||||
(account_len7_fee)
|
||||
(account_len6_fee)
|
||||
(account_len5_fee)
|
||||
(account_len4_fee)
|
||||
(account_len3_fee)
|
||||
(account_len2_fee)
|
||||
(asset_len3_fee)
|
||||
(asset_len4_fee)
|
||||
(asset_len5_fee)
|
||||
(asset_len6_fee)
|
||||
(asset_len7up_fee)
|
||||
(account_whitelist_fee)
|
||||
(delegate_create_fee)
|
||||
(witness_create_fee)
|
||||
(witness_withdraw_pay_fee)
|
||||
(transfer_fee)
|
||||
(limit_order_create_fee)
|
||||
(call_order_fee)
|
||||
(publish_feed_fee)
|
||||
(asset_create_fee)
|
||||
(asset_update_fee)
|
||||
(asset_issue_fee)
|
||||
(asset_reserve_fee)
|
||||
(asset_fund_fee_pool_fee)
|
||||
(asset_settle_fee)
|
||||
(data_fee)
|
||||
(global_parameters_update_fee)
|
||||
(membership_annual_fee)
|
||||
(membership_lifetime_fee)
|
||||
(withdraw_permission_create_fee)
|
||||
(withdraw_permission_update_fee)
|
||||
(withdraw_permission_claim_fee)
|
||||
(vesting_balance_create_fee)
|
||||
(vesting_balance_withdraw_fee)
|
||||
(asset_global_settle_fee)
|
||||
(worker_create_fee)
|
||||
(assert_op_fee)
|
||||
(proposal_create_fee)
|
||||
(proposal_update_fee)
|
||||
(extended)
|
||||
)
|
||||
FC_REFLECT_ENUM( graphene::chain::fee_schedule_type::extended_fee_id,
|
||||
(withdraw_permission_delete_fee_id)
|
||||
(proposal_delete_fee_id)
|
||||
(limit_order_cancel_fee_id) )
|
||||
|
||||
FC_REFLECT( graphene::chain::chain_parameters,
|
||||
(current_fees)
|
||||
(block_interval)
|
||||
(maintenance_interval)
|
||||
(genesis_proposal_review_period)
|
||||
(maximum_transaction_size)
|
||||
(maximum_block_size)
|
||||
(maximum_undo_history)
|
||||
(maximum_time_until_expiration)
|
||||
(maximum_proposal_lifetime)
|
||||
(maximum_asset_whitelist_authorities)
|
||||
(maximum_asset_feed_publishers)
|
||||
(maximum_witness_count)
|
||||
(maximum_committee_count)
|
||||
(maximum_authority_membership)
|
||||
(reserve_percent_of_fee)
|
||||
(network_percent_of_fee)
|
||||
(lifetime_referrer_percent_of_fee)
|
||||
(max_bulk_discount_percent_of_fee)
|
||||
(cashback_vesting_period_seconds)
|
||||
(cashback_vesting_threshold)
|
||||
(bulk_discount_threshold_min)
|
||||
(bulk_discount_threshold_max)
|
||||
(count_non_member_votes)
|
||||
(allow_non_member_whitelists)
|
||||
(witness_pay_per_block)
|
||||
(worker_budget_per_day)
|
||||
(max_predicate_opcode)
|
||||
(fee_liquidation_threshold)
|
||||
(accounts_per_fee_scale)
|
||||
(account_fee_scale_bitshifts)
|
||||
(extensions)
|
||||
)
|
||||
|
||||
FC_REFLECT_TYPENAME( graphene::chain::share_type )
|
||||
|
||||
FC_REFLECT_TYPENAME( graphene::chain::account_id_type )
|
||||
|
|
|
|||
|
|
@ -105,35 +105,6 @@ namespace graphene { namespace chain {
|
|||
{
|
||||
return p1.key_data != p2.key_data;
|
||||
}
|
||||
/**
|
||||
* @brief The fee_set_visitor struct sets all fees to a particular value in one fell swoop
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* fee_schedule_type sch;
|
||||
* // Set all fees to 50
|
||||
* fc::reflector<fee_schedule_type>::visit(fee_schedule_type::fee_set_visitor{sch, 50});
|
||||
* @endcode
|
||||
*/
|
||||
struct fee_set_visitor {
|
||||
fee_schedule_type& f;
|
||||
uint64_t fee;
|
||||
|
||||
template<typename Member, typename Class, uint64_t (Class::*member)>
|
||||
void operator()(const char*)const
|
||||
{
|
||||
f.*member = fee;
|
||||
}
|
||||
template<typename Member, typename Class, flat_map<unsigned_int,uint64_t> (Class::*member)>
|
||||
void operator()(const char*)const
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
void fee_schedule_type::set_all_fees( uint64_t v )
|
||||
{
|
||||
fc::reflector<fee_schedule_type>::visit(fee_set_visitor{*this, v});
|
||||
}
|
||||
|
||||
} } // graphene::chain
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue