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

Proposal hf23 special power down steemit accounts #3625

Closed
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
44 changes: 43 additions & 1 deletion libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4890,10 +4890,13 @@ void database::init_hardforks()
FC_ASSERT( STEEM_HARDFORK_0_22 == 22, "Invalid hardfork configuration" );
_hardfork_versions.times[ STEEM_HARDFORK_0_22 ] = fc::time_point_sec( STEEM_HARDFORK_0_22_TIME );
_hardfork_versions.versions[ STEEM_HARDFORK_0_22 ] = STEEM_HARDFORK_0_22_VERSION;
#ifdef IS_TEST_NET
FC_ASSERT( STEEM_HARDFORK_0_23 == 23, "Invalid hardfork configuration" );
_hardfork_versions.times[ STEEM_HARDFORK_0_23 ] = fc::time_point_sec( STEEM_HARDFORK_0_23_TIME );
_hardfork_versions.versions[ STEEM_HARDFORK_0_23 ] = STEEM_HARDFORK_0_23_VERSION;
#ifdef IS_TEST_NET
FC_ASSERT( STEEM_HARDFORK_0_24 == 24, "Invalid hardfork configuration" );
_hardfork_versions.times[ STEEM_HARDFORK_0_24 ] = fc::time_point_sec( STEEM_HARDFORK_0_24_TIME );
_hardfork_versions.versions[ STEEM_HARDFORK_0_24 ] = STEEM_HARDFORK_0_24_VERSION;
#endif


Expand Down Expand Up @@ -5304,6 +5307,45 @@ void database::apply_hardfork( uint32_t hardfork )
break;
case STEEM_HARDFORK_0_22:
break;
case STEEM_HARDFORK_0_23:
{
// Update Steemit Accounts
for( const std::string& acc : hardfork23::get_steemit_accounts() ){
const auto& account = get_account( acc );

// remove witness votes
std::array<share_type, STEEM_MAX_PROXY_RECURSION_DEPTH+1> delta;
delta[0] = -account.vesting_shares.amount;
for( int i = 0; i < STEEM_MAX_PROXY_RECURSION_DEPTH; ++i )
delta[i+1] = -account.proxied_vsf_votes[i];
adjust_proxied_witness_votes( account, delta );
clear_witness_votes( account );

modify( account , [&]( account_object& a )
{
// decline voting rights
a.can_vote = false;
a.proxy = STEEM_PROXY_TO_SELF_ACCOUNT;

// stop current power down
a.vesting_withdraw_rate = asset( 0, VESTS_SYMBOL );
a.next_vesting_withdrawal = time_point_sec::maximum();
a.to_withdraw = 0;
a.withdrawn = 0;
} );

// remove SPS votes
const auto& pvidx = get_index< proposal_vote_index >().indices().get< by_voter_proposal >();
auto itr = pvidx.lower_bound( boost::make_tuple( acc, 0 ) );
while( itr != pvidx.end() && itr->voter == acc )
{
const auto& current = *itr;
++itr;
remove(current);
}
}
}
break;
case STEEM_SMT_HARDFORK:
{
#ifdef STEEM_ENABLE_SMT
Expand Down
6 changes: 6 additions & 0 deletions libraries/chain/sps_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ void update_proposal_votes_evaluator::do_apply( const update_proposal_votes_oper
{
FC_ASSERT( _db.has_hardfork( STEEM_PROPOSALS_HARDFORK ), "Proposals functionality not enabled until hardfork ${hf}", ("hf", STEEM_PROPOSALS_HARDFORK) );

if( _db.has_hardfork( STEEM_HARDFORK_0_23 ) )
{
const auto& account = _db.get_account( o.voter );
FC_ASSERT( account.can_vote, "Account has declined its voting rights." );
}

const auto& pidx = _db.get_index< proposal_index >().indices().get< by_proposal_id >();
const auto& pvidx = _db.get_index< proposal_vote_index >().indices().get< by_voter_proposal >();

Expand Down
9 changes: 9 additions & 0 deletions libraries/chain/steem_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,9 +1253,18 @@ void withdraw_vesting_evaluator::do_apply( const withdraw_vesting_operation& o )
}
else
{
bool is_special_case_hf23 = false;
if ( _db.head_block_time() < STEEM_HARDFORK_0_23_TIME_NO_EFFECT )
{
if( hardfork23::get_steemit_accounts().count( o.account ) )
is_special_case_hf23 = true;
}

int vesting_withdraw_intervals = STEEM_VESTING_WITHDRAW_INTERVALS_PRE_HF_16;
if( _db.has_hardfork( STEEM_HARDFORK_0_16__551 ) )
vesting_withdraw_intervals = STEEM_VESTING_WITHDRAW_INTERVALS; /// 13 weeks = 1 quarter of a year
if( _db.has_hardfork( STEEM_HARDFORK_0_23 ) && is_special_case_hf23 )
vesting_withdraw_intervals = STEEM_VESTING_WITHDRAW_INTERVALS_SPECIAL_CASE_HF_23;

_db.modify( account, [&]( account_object& a )
{
Expand Down
23 changes: 22 additions & 1 deletion libraries/protocol/hardfork.d/0_23.hf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,29 @@
#define STEEM_HARDFORK_0_23 23
#define STEEM_SMT_HARDFORK STEEM_HARDFORK_0_23

#define STEEM_HARDFORK_0_23_TIME 1597970800 // Future 2020...
#define STEEM_HARDFORK_0_23_TIME 1591876800 // Thursday, June 11, 2020 12:00:00 PM

#define STEEM_HARDFORK_0_23_VERSION hardfork_version( 0, 23 )

#define STEEM_HARDFORK_0_23_TIME_NO_EFFECT 1704067200 // Monday, January 1, 2024 12:00:00 AM

namespace hardfork23
{

inline static const std::set< std::string >& get_steemit_accounts()
{
static const std::set< std::string > steemit_accounts
{
"misterdelegation",
"steem",
"steemit",
"steemit2",
"steemitadmin"
};

return steemit_accounts;
}

}

#endif
9 changes: 9 additions & 0 deletions libraries/protocol/hardfork.d/0_24.hf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef STEEM_HARDFORK_0_24
#define STEEM_HARDFORK_0_24 24
#define STEEM_SMT_HARDFORK STEEM_HARDFORK_0_24

#define STEEM_HARDFORK_0_24_TIME 1597970800 // Future 2020...

#define STEEM_HARDFORK_0_24_VERSION hardfork_version( 0, 24 )

#endif
5 changes: 3 additions & 2 deletions libraries/protocol/include/steem/protocol/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// This is checked by get_config_check.sh called from Dockerfile

#ifdef IS_TEST_NET
#define STEEM_BLOCKCHAIN_VERSION ( version(0, 23, 0) )
#define STEEM_BLOCKCHAIN_VERSION ( version(0, 24, 0) )

#define STEEM_INIT_PRIVATE_KEY (fc::ecc::private_key::regenerate(fc::sha256::hash(std::string("init_key"))))
#define STEEM_INIT_PUBLIC_KEY_STR (std::string( steem::protocol::public_key_type(STEEM_INIT_PRIVATE_KEY.get_public_key()) ))
Expand Down Expand Up @@ -44,7 +44,7 @@

#else // IS LIVE STEEM NETWORK

#define STEEM_BLOCKCHAIN_VERSION ( version(0, 22, 1) )
#define STEEM_BLOCKCHAIN_VERSION ( version(0, 23, 0) )

#define STEEM_INIT_PUBLIC_KEY_STR "STM8GC13uCZbP44HzMLV6zPZGwVQ8Nt4Kji8PapsPiNq1BK153XTX"
#define STEEM_CHAIN_ID fc::sha256()
Expand Down Expand Up @@ -108,6 +108,7 @@
#define STEEM_MAX_MEMO_SIZE 2048
#define STEEM_MAX_PROXY_RECURSION_DEPTH 4
#define STEEM_VESTING_WITHDRAW_INTERVALS_PRE_HF_16 104
#define STEEM_VESTING_WITHDRAW_INTERVALS_SPECIAL_CASE_HF_23 104
#define STEEM_VESTING_WITHDRAW_INTERVALS 13
#define STEEM_VESTING_WITHDRAW_INTERVAL_SECONDS (60*60*24*7) /// 1 week per interval
#define STEEM_MAX_WITHDRAW_ROUTES 10
Expand Down