[SON-313] - Limit SON functionality when min no. of sons are not present
This commit is contained in:
parent
210e72f843
commit
867ed50333
13 changed files with 35 additions and 30 deletions
|
|
@ -111,6 +111,11 @@ void_result account_create_evaluator::do_evaluate( const account_create_operatio
|
|||
if( d.head_block_time() < HARDFORK_999_TIME )
|
||||
FC_ASSERT( !op.extensions.value.affiliate_distributions.valid(), "Affiliate reward distributions not allowed yet" );
|
||||
|
||||
if( d.head_block_time() < HARDFORK_SON_TIME )
|
||||
{
|
||||
FC_ASSERT( op.name != "son-account", "Preventive check to not allow son-account before SON HF" );
|
||||
}
|
||||
|
||||
FC_ASSERT( fee_paying_account->is_lifetime_member(), "Only Lifetime members may register an account." );
|
||||
FC_ASSERT( op.referrer(d).is_member(d.head_block_time()), "The referrer must be either a lifetime or annual subscriber." );
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,11 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o
|
|||
wlog( "Asset ${s} has a name which requires hardfork 385", ("s",op.symbol) );
|
||||
}
|
||||
|
||||
if( d.head_block_time() < HARDFORK_SON_TIME )
|
||||
{
|
||||
FC_ASSERT( op.symbol != "BTC", "Preventive check to not allow BTC asset before SON HF" );
|
||||
}
|
||||
|
||||
// core_fee_paid -= core_fee_paid.value/2;
|
||||
|
||||
if( op.bitasset_opts )
|
||||
|
|
|
|||
|
|
@ -170,8 +170,6 @@ void database::pay_sons()
|
|||
if(s.txs_signed > 0){
|
||||
auto son_params = get_global_properties().parameters;
|
||||
share_type pay = (s.txs_signed * son_budget.value)/total_txs_signed;
|
||||
// TODO: Remove me after QA
|
||||
ilog( "pay ${p} to ${s} for ${t} transactions signed", ("p", pay.value)("s", s.id)("t",s.txs_signed) );
|
||||
const auto& idx = get_index_type<son_index>().indices().get<by_id>();
|
||||
auto son_obj = idx.find( s.owner );
|
||||
modify( *son_obj, [&]( son_object& _son_obj)
|
||||
|
|
@ -339,6 +337,8 @@ void database::update_son_wallet(const vector<son_info>& new_active_sons)
|
|||
}
|
||||
}
|
||||
|
||||
should_recreate_pw = should_recreate_pw && (new_active_sons.size() >= get_chain_properties().immutable_parameters.min_son_count);
|
||||
|
||||
if (should_recreate_pw) {
|
||||
// Create new son_wallet_object, to initiate wallet recreation
|
||||
create<son_wallet_object>( [&]( son_wallet_object& obj ) {
|
||||
|
|
@ -830,7 +830,7 @@ void database::process_budget()
|
|||
pay_sons();
|
||||
rec.leftover_son_funds = dpo.son_budget;
|
||||
available_funds += rec.leftover_son_funds;
|
||||
son_budget = gpo.parameters.son_pay_daily_max();
|
||||
son_budget = gpo.parameters.son_pay_max();
|
||||
son_budget = std::min(son_budget, available_funds);
|
||||
rec.son_budget = son_budget;
|
||||
available_funds -= son_budget;
|
||||
|
|
|
|||
|
|
@ -229,14 +229,13 @@
|
|||
#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 MIN_SON_MEMBER_COUNT 15
|
||||
#define SON_VESTING_AMOUNT (50*GRAPHENE_BLOCKCHAIN_PRECISION) // 50 PPY
|
||||
#define SON_VESTING_PERIOD (60*60*24*2) // 2 days
|
||||
#define SON_DEREGISTER_TIME (60*60*12) // 12 Hours in seconds
|
||||
#define SON_HEARTBEAT_FREQUENCY (60*3) // 3 minutes in seconds
|
||||
#define SON_DOWN_TIME (60*3*2) // 2 Heartbeats in seconds
|
||||
#define SON_PAY_TIME (60*60*24) // 1 day
|
||||
#define MIN_SON_PAY_DAILY_MAX (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t(200))
|
||||
#define SON_PAY_MAX (GRAPHENE_BLOCKCHAIN_PRECISION * int64_t(200))
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -50,10 +50,9 @@ namespace graphene { namespace chain {
|
|||
optional < uint32_t > gpos_period_start = HARDFORK_GPOS_TIME.sec_since_epoch();
|
||||
optional < uint32_t > gpos_vesting_lockin_period = GPOS_VESTING_LOCKIN_PERIOD;
|
||||
|
||||
optional < uint16_t > son_count;
|
||||
optional < uint32_t > son_vesting_amount;
|
||||
optional < uint32_t > son_vesting_period;
|
||||
optional < uint32_t > son_pay_daily_max;
|
||||
optional < uint32_t > son_pay_max;
|
||||
optional < uint32_t > son_pay_time;
|
||||
optional < uint32_t > son_deregister_time;
|
||||
optional < uint32_t > son_heartbeat_frequency;
|
||||
|
|
@ -139,17 +138,14 @@ namespace graphene { namespace chain {
|
|||
inline account_id_type sweeps_vesting_accumulator_account()const {
|
||||
return extensions.value.sweeps_vesting_accumulator_account.valid() ? *extensions.value.sweeps_vesting_accumulator_account : SWEEPS_ACCUMULATOR_ACCOUNT;
|
||||
}
|
||||
inline uint16_t son_count()const {
|
||||
return extensions.value.son_count.valid() ? *extensions.value.son_count : MIN_SON_MEMBER_COUNT;
|
||||
}
|
||||
inline uint32_t son_vesting_amount()const {
|
||||
return extensions.value.son_vesting_amount.valid() ? *extensions.value.son_vesting_amount : SON_VESTING_AMOUNT; /// current period start date
|
||||
}
|
||||
inline uint32_t son_vesting_period()const {
|
||||
return extensions.value.son_vesting_period.valid() ? *extensions.value.son_vesting_period : SON_VESTING_PERIOD; /// current period start date
|
||||
}
|
||||
inline uint16_t son_pay_daily_max()const {
|
||||
return extensions.value.son_pay_daily_max.valid() ? *extensions.value.son_pay_daily_max : MIN_SON_PAY_DAILY_MAX;
|
||||
inline uint16_t son_pay_max()const {
|
||||
return extensions.value.son_pay_max.valid() ? *extensions.value.son_pay_max : SON_PAY_MAX;
|
||||
}
|
||||
inline uint16_t son_pay_time()const {
|
||||
return extensions.value.son_pay_time.valid() ? *extensions.value.son_pay_time : SON_PAY_TIME;
|
||||
|
|
@ -188,7 +184,6 @@ FC_REFLECT( graphene::chain::parameter_extension,
|
|||
(betting_rake_fee_percentage)
|
||||
(permitted_betting_odds_increments)
|
||||
(live_betting_delay_time)
|
||||
(son_count)
|
||||
(sweeps_distribution_percentage)
|
||||
(sweeps_distribution_asset)
|
||||
(sweeps_vesting_accumulator_account)
|
||||
|
|
@ -198,7 +193,7 @@ FC_REFLECT( graphene::chain::parameter_extension,
|
|||
(gpos_vesting_lockin_period)
|
||||
(son_vesting_amount)
|
||||
(son_vesting_period)
|
||||
(son_pay_daily_max)
|
||||
(son_pay_max)
|
||||
(son_pay_time)
|
||||
(son_deregister_time)
|
||||
(son_heartbeat_frequency)
|
||||
|
|
|
|||
|
|
@ -141,8 +141,6 @@ object_id_type son_heartbeat_evaluator::do_apply(const son_heartbeat_operation&
|
|||
{
|
||||
sso.current_interval_downtime += op.ts.sec_since_epoch() - sso.last_down_timestamp.sec_since_epoch();
|
||||
sso.last_active_timestamp = op.ts;
|
||||
// TODO: Remove me after sidechain tx signing is finished
|
||||
sso.txs_signed = sso.txs_signed + 1;
|
||||
} );
|
||||
|
||||
db().modify(*itr, [&is_son_active](son_object &so) {
|
||||
|
|
@ -156,8 +154,6 @@ object_id_type son_heartbeat_evaluator::do_apply(const son_heartbeat_operation&
|
|||
db().modify( itr->statistics( db() ), [&]( son_statistics_object& sso )
|
||||
{
|
||||
sso.last_active_timestamp = op.ts;
|
||||
// TODO: Remove me after sidechain tx signing is finished
|
||||
sso.txs_signed = sso.txs_signed + 1;
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <graphene/chain/son_wallet_deposit_evaluator.hpp>
|
||||
|
||||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/chain/chain_property_object.hpp>
|
||||
#include <graphene/chain/is_authorized_asset.hpp>
|
||||
#include <graphene/chain/son_object.hpp>
|
||||
#include <graphene/chain/son_wallet_deposit_object.hpp>
|
||||
|
|
@ -130,6 +131,7 @@ void_result process_son_wallet_deposit_evaluator::do_evaluate(const son_wallet_d
|
|||
{ try{
|
||||
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
|
||||
FC_ASSERT( op.payer == db().get_global_properties().parameters.son_account(), "SON paying account must be set as payer." );
|
||||
FC_ASSERT(db().get_global_properties().active_sons.size() >= db().get_chain_properties().immutable_parameters.min_son_count, "Min required voted SONs not present");
|
||||
|
||||
const auto& idx = db().get_index_type<son_wallet_deposit_index>().indices().get<by_id>();
|
||||
const auto& itr = idx.find(op.son_wallet_deposit_id);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <graphene/chain/son_wallet_withdraw_evaluator.hpp>
|
||||
|
||||
#include <graphene/chain/database.hpp>
|
||||
#include <graphene/chain/chain_property_object.hpp>
|
||||
#include <graphene/chain/is_authorized_asset.hpp>
|
||||
#include <graphene/chain/son_object.hpp>
|
||||
#include <graphene/chain/son_wallet_withdraw_object.hpp>
|
||||
|
|
@ -128,6 +129,7 @@ void_result process_son_wallet_withdraw_evaluator::do_evaluate(const son_wallet_
|
|||
{ try{
|
||||
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
|
||||
FC_ASSERT( op.payer == db().get_global_properties().parameters.son_account(), "SON paying account must be set as payer." );
|
||||
FC_ASSERT(db().get_global_properties().active_sons.size() >= db().get_chain_properties().immutable_parameters.min_son_count, "Min required voted SONs not present");
|
||||
|
||||
const auto& idx = db().get_index_type<son_wallet_withdraw_index>().indices().get<by_id>();
|
||||
const auto& itr = idx.find(op.son_wallet_withdraw_id);
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ void sidechain_net_handler::process_deposits() {
|
|||
proposal_op.fee_paying_account = plugin.get_current_son_object().son_account;
|
||||
proposal_op.proposed_ops.emplace_back(swdp_op);
|
||||
proposal_op.proposed_ops.emplace_back(t_op);
|
||||
uint32_t lifetime = (gpo.parameters.block_interval * gpo.active_witnesses.size()) * 3;
|
||||
uint32_t lifetime = gpo.parameters.maintenance_interval * 3;
|
||||
proposal_op.expiration_time = time_point_sec(database.head_block_time().sec_since_epoch() + lifetime);
|
||||
|
||||
signed_transaction trx = database.create_signed_transaction(plugin.get_private_key(plugin.get_current_son_id()), proposal_op);
|
||||
|
|
@ -210,7 +210,7 @@ void sidechain_net_handler::process_withdrawals() {
|
|||
proposal_create_operation proposal_op;
|
||||
proposal_op.fee_paying_account = plugin.get_current_son_object().son_account;
|
||||
proposal_op.proposed_ops.emplace_back(swwp_op);
|
||||
uint32_t lifetime = (gpo.parameters.block_interval * gpo.active_witnesses.size()) * 3;
|
||||
uint32_t lifetime = gpo.parameters.maintenance_interval * 3;
|
||||
proposal_op.expiration_time = time_point_sec(database.head_block_time().sec_since_epoch() + lifetime);
|
||||
|
||||
signed_transaction trx = database.create_signed_transaction(plugin.get_private_key(plugin.get_current_son_id()), proposal_op);
|
||||
|
|
|
|||
|
|
@ -344,6 +344,7 @@
|
|||
"maximum_asset_feed_publishers": 10,
|
||||
"maximum_witness_count": 1001,
|
||||
"maximum_committee_count": 1001,
|
||||
"maximum_son_count": 15,
|
||||
"maximum_authority_membership": 10,
|
||||
"reserve_percent_of_fee": 2000,
|
||||
"network_percent_of_fee": 2000,
|
||||
|
|
@ -383,7 +384,7 @@
|
|||
"gpos_vesting_lockin_period": 2592000,
|
||||
"son_vesting_amount": 5000000,
|
||||
"son_vesting_period": 172800,
|
||||
"son_pay_daily_max": 20000000,
|
||||
"son_pay_max": 20000000,
|
||||
"son_pay_time": 86400,
|
||||
"son_deregister_time": 43200,
|
||||
"son_heartbeat_frequency": 180,
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ BOOST_AUTO_TEST_CASE( affiliate_payout_helper_test )
|
|||
{
|
||||
ACTORS( (irene) );
|
||||
|
||||
const asset_id_type btc_id = create_user_issued_asset( "BTC", irene, 0 ).id;
|
||||
const asset_id_type btc_id = create_user_issued_asset( "BTCT", irene, 0 ).id;
|
||||
issue_uia( irene, asset( 100000, btc_id ) );
|
||||
|
||||
affiliate_test_helper ath( *this );
|
||||
|
|
@ -517,7 +517,7 @@ BOOST_AUTO_TEST_CASE( bookie_payout_test )
|
|||
{ try {
|
||||
ACTORS( (irene) );
|
||||
|
||||
const asset_id_type btc_id = create_user_issued_asset( "BTC", irene, 0 ).id;
|
||||
const asset_id_type btc_id = create_user_issued_asset( "BTCT", irene, 0 ).id;
|
||||
|
||||
affiliate_test_helper ath( *this );
|
||||
|
||||
|
|
@ -616,7 +616,7 @@ BOOST_AUTO_TEST_CASE( statistics_test )
|
|||
|
||||
INVOKE(bookie_payout_test);
|
||||
|
||||
const asset_id_type btc_id = get_asset( "BTC" ).id;
|
||||
const asset_id_type btc_id = get_asset( "BTCT" ).id;
|
||||
|
||||
transfer( ath.alice_id, ath.ann_id, asset( 100, btc_id ), asset(0) );
|
||||
transfer( ath.alice_id, ath.audrey_id, asset( 100, btc_id ), asset(0) );
|
||||
|
|
@ -625,12 +625,12 @@ BOOST_AUTO_TEST_CASE( statistics_test )
|
|||
|
||||
{
|
||||
const auto& idx = db.get_index_type<graphene::affiliate_stats::referral_reward_index>().indices().get<graphene::affiliate_stats::by_asset>();
|
||||
BOOST_CHECK_EQUAL( 2, idx.size() ); // penny 216+60 CORE, paula 600 BTC
|
||||
BOOST_CHECK_EQUAL( 2, idx.size() ); // penny 216+60 CORE, paula 600 BTCT
|
||||
}
|
||||
|
||||
{
|
||||
const auto& idx = db.get_index_type<graphene::affiliate_stats::app_reward_index>().indices().get<graphene::affiliate_stats::by_asset>();
|
||||
BOOST_CHECK_EQUAL( 3, idx.size() ); // rps 216 CORE, bookie 60 CORE + 600 BTC
|
||||
BOOST_CHECK_EQUAL( 3, idx.size() ); // rps 216 CORE, bookie 60 CORE + 600 BTCT
|
||||
}
|
||||
|
||||
graphene::affiliate_stats::affiliate_stats_api stats( app );
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(get_account_history_additional) {
|
|||
const account_object& dan = create_account("dan"); // create op 1
|
||||
|
||||
create_bitasset("CNY", dan.id); // create op 2
|
||||
create_bitasset("BTC", account_id_type()); // create op 3
|
||||
create_bitasset("BTCT", account_id_type()); // create op 3
|
||||
create_bitasset("XMR", dan.id); // create op 4
|
||||
create_bitasset("EUR", account_id_type()); // create op 5
|
||||
create_bitasset("OIL", dan.id); // create op 6
|
||||
|
|
@ -454,7 +454,7 @@ BOOST_AUTO_TEST_CASE(track_account) {
|
|||
BOOST_CHECK_EQUAL(histories[1].id.instance(), 3u);
|
||||
|
||||
// create more ops, starting with an untracked account
|
||||
create_bitasset( "BTC", account_id_type() );
|
||||
create_bitasset( "BTCT", account_id_type() );
|
||||
create_bitasset( "GBP", dan_id );
|
||||
|
||||
generate_block( ~database::skip_fork_db );
|
||||
|
|
@ -468,7 +468,7 @@ BOOST_AUTO_TEST_CASE(track_account) {
|
|||
db.pop_block();
|
||||
|
||||
// Try again, should result in same object IDs
|
||||
create_bitasset( "BTC", account_id_type() );
|
||||
create_bitasset( "BTCT", account_id_type() );
|
||||
create_bitasset( "GBP", dan_id );
|
||||
|
||||
generate_block();
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE( son_pay_test )
|
|||
// Make witness budget zero so that amount can be allocated to SON
|
||||
db.modify( db.get_global_properties(), [&]( global_property_object& _gpo )
|
||||
{
|
||||
_gpo.parameters.extensions.value.son_pay_daily_max = 200;
|
||||
_gpo.parameters.extensions.value.son_pay_max = 200;
|
||||
_gpo.parameters.witness_pay_per_block = 0;
|
||||
} );
|
||||
// Upgrades pay fee and this goes to reserve
|
||||
|
|
|
|||
Loading…
Reference in a new issue