Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #2140 - Update SBD Print Rate #2603

Merged
merged 5 commits into from
Jul 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2843,6 +2843,8 @@ void database::init_genesis( uint64_t init_supply )
p.virtual_supply = p.current_supply;
p.maximum_block_size = STEEM_MAX_BLOCK_SIZE;
p.reverse_auction_seconds = STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF6;
p.sbd_stop_percent = STEEM_SBD_STOP_PERCENT_HF14;
p.sbd_start_percent = STEEM_SBD_START_PERCENT_HF14;
} );

// Nothing to do
Expand Down Expand Up @@ -3658,12 +3660,12 @@ void database::update_virtual_supply()
auto percent_sbd = uint16_t( ( ( fc::uint128_t( ( dgp.current_sbd_supply * get_feed_history().current_median_history ).amount.value ) * STEEM_100_PERCENT )
/ dgp.virtual_supply.amount.value ).to_uint64() );

if( percent_sbd <= STEEM_SBD_START_PERCENT )
if( percent_sbd <= dgp.sbd_start_percent )
dgp.sbd_print_rate = STEEM_100_PERCENT;
else if( percent_sbd >= STEEM_SBD_STOP_PERCENT )
else if( percent_sbd >= dgp.sbd_stop_percent )
dgp.sbd_print_rate = 0;
else
dgp.sbd_print_rate = ( ( STEEM_SBD_STOP_PERCENT - percent_sbd ) * STEEM_100_PERCENT ) / ( STEEM_SBD_STOP_PERCENT - STEEM_SBD_START_PERCENT );
dgp.sbd_print_rate = ( ( dgp.sbd_stop_percent - percent_sbd ) * STEEM_100_PERCENT ) / ( dgp.sbd_stop_percent - dgp.sbd_start_percent );
}
});
} FC_CAPTURE_AND_RETHROW() }
Expand Down Expand Up @@ -4846,6 +4848,8 @@ void database::apply_hardfork( uint32_t hardfork )
{
gpo.delegation_return_period = STEEM_DELEGATION_RETURN_PERIOD_HF20;
gpo.reverse_auction_seconds = STEEM_REVERSE_AUCTION_WINDOW_SECONDS_HF20;
gpo.sbd_stop_percent = STEEM_SBD_STOP_PERCENT_HF20;
gpo.sbd_start_percent = STEEM_SBD_START_PERCENT_HF20;
});

const auto& wso = get_witness_schedule_object();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ namespace steem { namespace chain {

uint64_t available_account_subsidies = 0;

uint16_t sbd_stop_percent = 0;
uint16_t sbd_start_percent = 0;
#ifdef STEEM_ENABLE_SMT
asset smt_creation_fee = asset( 1000000, SBD_SYMBOL );
#endif
Expand Down Expand Up @@ -166,6 +168,8 @@ FC_REFLECT( steem::chain::dynamic_global_property_object,
(delegation_return_period)
(reverse_auction_seconds)
(available_account_subsidies)
(sbd_stop_percent)
(sbd_start_percent)
#ifdef STEEM_ENABLE_SMT
(smt_creation_fee)
#endif
Expand Down
6 changes: 4 additions & 2 deletions libraries/protocol/get_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@ fc::variant_object get_config()
result["STEEM_ROOT_POST_PARENT"] = STEEM_ROOT_POST_PARENT;
result["STEEM_SAVINGS_WITHDRAW_REQUEST_LIMIT"] = STEEM_SAVINGS_WITHDRAW_REQUEST_LIMIT;
result["STEEM_SAVINGS_WITHDRAW_TIME"] = STEEM_SAVINGS_WITHDRAW_TIME;
result["STEEM_SBD_START_PERCENT"] = STEEM_SBD_START_PERCENT;
result["STEEM_SBD_STOP_PERCENT"] = STEEM_SBD_STOP_PERCENT;
result["STEEM_SBD_START_PERCENT_HF14"] = STEEM_SBD_START_PERCENT_HF14;
result["STEEM_SBD_START_PERCENT_HF20"] = STEEM_SBD_START_PERCENT_HF20;
result["STEEM_SBD_STOP_PERCENT_HF14"] = STEEM_SBD_STOP_PERCENT_HF14;
result["STEEM_SBD_STOP_PERCENT_HF20"] = STEEM_SBD_STOP_PERCENT_HF20;
result["STEEM_SECOND_CASHOUT_WINDOW"] = STEEM_SECOND_CASHOUT_WINDOW;
result["STEEM_SOFT_MAX_COMMENT_DEPTH"] = STEEM_SOFT_MAX_COMMENT_DEPTH;
result["STEEM_START_MINER_VOTING_BLOCK"] = STEEM_START_MINER_VOTING_BLOCK;
Expand Down
6 changes: 4 additions & 2 deletions libraries/protocol/include/steem/protocol/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@

#define STEEM_MIN_PAYOUT_SBD (asset(20,SBD_SYMBOL))

#define STEEM_SBD_STOP_PERCENT (5*STEEM_1_PERCENT ) // Stop printing SBD at 5% Market Cap
#define STEEM_SBD_START_PERCENT (2*STEEM_1_PERCENT) // Start reducing printing of SBD at 2% Market Cap
#define STEEM_SBD_STOP_PERCENT_HF14 (5*STEEM_1_PERCENT ) // Stop printing SBD at 5% Market Cap
#define STEEM_SBD_STOP_PERCENT_HF20 (10*STEEM_1_PERCENT ) // Stop printing SBD at 10% Market Cap
#define STEEM_SBD_START_PERCENT_HF14 (2*STEEM_1_PERCENT) // Start reducing printing of SBD at 2% Market Cap
#define STEEM_SBD_START_PERCENT_HF20 (9*STEEM_1_PERCENT) // Start reducing printing of SBD at 9% Market Cap

#define STEEM_MIN_ACCOUNT_NAME_LENGTH 3
#define STEEM_MAX_ACCOUNT_NAME_LENGTH 16
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@
"STEEM_SAVINGS_WITHDRAW_REQUEST_LIMIT": 100,
"STEEM_SAVINGS_WITHDRAW_TIME": "259200000000",
"STEEM_SBD_INTEREST_COMPOUND_INTERVAL_SEC": 2592000,
"STEEM_SBD_START_PERCENT": 200,
"STEEM_SBD_STOP_PERCENT": 500,
"STEEM_SBD_START_PERCENT_HF14": 200,
"STEEM_SBD_START_PERCENT_HF20": 900,
"STEEM_SBD_STOP_PERCENT_HF14": 500,
"STEEM_SBD_STOP_PERCENT_HF20": 1000,
"STEEM_SECONDS_PER_YEAR": 31536000,
"STEEM_SECOND_CASHOUT_WINDOW": 259200,
"STEEM_SOFT_MAX_BLOCK_SIZE": 2097152,
Expand All @@ -158,4 +160,4 @@
"STEEM_VOTE_DUST_THRESHOLD": 50000000,
"STEEM_VOTE_REGENERATION_SECONDS": 432000,
"VESTS_SYMBOL": "VESTS"
}
}
12 changes: 6 additions & 6 deletions tests/tests/operation_time_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2732,7 +2732,7 @@ BOOST_AUTO_TEST_CASE( sbd_stability )

BOOST_TEST_MESSAGE( "Changing sam and gpo to set up market cap conditions" );

asset sbd_balance = asset( ( gpo.virtual_supply.amount * ( STEEM_SBD_STOP_PERCENT + 30 ) ) / STEEM_100_PERCENT, STEEM_SYMBOL ) * exchange_rate;
asset sbd_balance = asset( ( gpo.virtual_supply.amount * ( gpo.sbd_stop_percent + 112 ) ) / STEEM_100_PERCENT, STEEM_SYMBOL ) * exchange_rate;
db_plugin->debug_update( [=]( database& db )
{
db.modify( db.get_account( "sam" ), [&]( account_object& a )
Expand Down Expand Up @@ -2771,22 +2771,22 @@ BOOST_AUTO_TEST_CASE( sbd_stability )
BOOST_REQUIRE( db->get_account( "alice" ).sbd_balance + db->get_account( "alice" ).reward_sbd_balance == alice_sbd );
BOOST_REQUIRE( db->get_account( "alice" ).balance + db->get_account( "alice" ).reward_steem_balance > alice_steem );

BOOST_TEST_MESSAGE( "Letting percent market cap fall to 2% to verify printing of SBD turns back on" );
BOOST_TEST_MESSAGE( "Letting percent market cap fall to sbd_start_percent to verify printing of SBD turns back on" );

// Get close to 1.5% for printing SBD to start again, but not all the way
// Get close to sbd_start_percent for printing SBD to start again, but not all the way
db_plugin->debug_update( [=]( database& db )
{
db.modify( db.get_account( "sam" ), [&]( account_object& a )
{
a.sbd_balance = asset( ( 194 * sbd_balance.amount ) / 500, SBD_SYMBOL );
a.sbd_balance = asset( ( ( gpo.sbd_start_percent - 6 ) * sbd_balance.amount ) / gpo.sbd_stop_percent, SBD_SYMBOL );
});
}, database::skip_witness_signature );

db_plugin->debug_update( [=]( database& db )
{
db.modify( db.get_dynamic_global_properties(), [&]( dynamic_global_property_object& gpo )
{
gpo.current_sbd_supply = alice_sbd + asset( ( 194 * sbd_balance.amount ) / 500, SBD_SYMBOL );
gpo.current_sbd_supply = alice_sbd + asset( ( ( gpo.sbd_start_percent - 6 ) * sbd_balance.amount ) / gpo.sbd_stop_percent, SBD_SYMBOL );
});
}, database::skip_witness_signature );

Expand All @@ -2798,7 +2798,7 @@ BOOST_AUTO_TEST_CASE( sbd_stability )
auto last_print_rate = db->get_dynamic_global_properties().sbd_print_rate;

// Keep producing blocks until printing SBD is back
while( ( db->get_dynamic_global_properties().current_sbd_supply * exchange_rate ).amount >= ( db->get_dynamic_global_properties().virtual_supply.amount * STEEM_SBD_START_PERCENT ) / STEEM_100_PERCENT )
while( ( db->get_dynamic_global_properties().current_sbd_supply * exchange_rate ).amount >= ( db->get_dynamic_global_properties().virtual_supply.amount * db->get_dynamic_global_properties().sbd_start_percent ) / STEEM_100_PERCENT )
{
auto& gpo = db->get_dynamic_global_properties();
BOOST_REQUIRE( gpo.sbd_print_rate >= last_print_rate );
Expand Down