Commit 8af35358 authored by Bartek Wrona's avatar Bartek Wrona

Merge branch 'ninja_mine_to_dao_0_23_rebase' into '0.23.0'

Ninja mine to dao

See merge request hive-group/steem!5
parents ef8828e5 8b2ba151
This diff is collapsed.
......@@ -518,6 +518,11 @@ namespace steem { namespace chain {
///@}
#endif
//Clears all pending operations on account that involve balance, moves tokens to STEEM_TREASURY_ACCOUNT
void clear_account( const account_object& account,
asset* transferred_sbd_ptr = nullptr, asset* transferred_steem_ptr = nullptr,
asset* converted_vests_ptr = nullptr, asset* steem_from_vests_ptr = nullptr );
protected:
//Mark pop_undo() as protected -- we do not want outside calling pop_undo(); it should call pop_block() instead
//void pop_undo() { object_database::pop_undo(); }
......
......@@ -1008,7 +1008,7 @@ void escrow_transfer_evaluator::do_apply( const escrow_transfer_operation& o )
_db.get_account(o.to);
_db.get_account(o.agent);
FC_ASSERT( o.ratification_deadline > _db.head_block_time(), "The escorw ratification deadline must be after head block time." );
FC_ASSERT( o.ratification_deadline > _db.head_block_time(), "The escrow ratification deadline must be after head block time." );
FC_ASSERT( o.escrow_expiration > _db.head_block_time(), "The escrow expiration must be after head block time." );
asset steem_spent = o.steem_amount;
......
......@@ -284,6 +284,12 @@ struct get_impacted_account_visitor
_impacted.insert( STEEM_INIT_MINER_NAME );
}
void operator()( const hardfork_hive_operation& op )
{
_impacted.insert( STEEM_TREASURY_ACCOUNT );
_impacted.insert( op.account );
}
//void operator()( const operation& op ){}
};
......
......@@ -268,50 +268,67 @@ void update_witness_schedule4( database& db )
int witnesses_on_version = 0;
auto ver_itr = witness_versions.begin();
// The map should be sorted highest version to smallest, so we iterate until we hit the majority of witnesses on at least this version
while( ver_itr != witness_versions.end() )
{
witnesses_on_version += ver_itr->second;
if( witnesses_on_version >= wso.hardfork_required_witnesses )
{
majority_version = ver_itr->first;
break;
}
++ver_itr;
}
auto hf_itr = hardfork_version_votes.begin();
while( hf_itr != hardfork_version_votes.end() )
{
if( hf_itr->second >= wso.hardfork_required_witnesses )
{
const auto& hfp = db.get_hardfork_property_object();
if( hfp.next_hardfork != std::get<0>( hf_itr->first ) ||
hfp.next_hardfork_time != std::get<1>( hf_itr->first ) ) {
db.modify( hfp, [&]( hardfork_property_object& hpo )
{
hpo.next_hardfork = std::get<0>( hf_itr->first );
hpo.next_hardfork_time = std::get<1>( hf_itr->first );
} );
}
break;
}
++hf_itr;
}
// We no longer have a majority
if( hf_itr == hardfork_version_votes.end() )
{
db.modify( db.get_hardfork_property_object(), [&]( hardfork_property_object& hpo )
{
hpo.next_hardfork = hpo.current_hardfork_version;
});
}
const hardfork_versions& hfVersions = db.get_hardfork_versions();
const auto& hpo = db.get_hardfork_property_object();
if(hfVersions.times[STEEM_HARDFORK_0_23] < db.head_block_time() && hpo.current_hardfork_version == STEEM_HARDFORK_0_22_VERSION)
{
ilog("Forcing HF23 without need to have witness majority version");
/// Force HF23 even no witness majority.
db.modify(hpo, [&](hardfork_property_object& _hpo)
{
_hpo.next_hardfork = STEEM_HARDFORK_0_23_VERSION;
_hpo.next_hardfork_time = fc::time_point_sec(STEEM_HARDFORK_0_23_TIME);
});
}
else
{
// The map should be sorted highest version to smallest, so we iterate until we hit the majority of witnesses on at least this version
while( ver_itr != witness_versions.end() )
{
witnesses_on_version += ver_itr->second;
if( witnesses_on_version >= wso.hardfork_required_witnesses )
{
majority_version = ver_itr->first;
break;
}
++ver_itr;
}
auto hf_itr = hardfork_version_votes.begin();
while( hf_itr != hardfork_version_votes.end() )
{
if( hf_itr->second >= wso.hardfork_required_witnesses )
{
const auto& hfp = db.get_hardfork_property_object();
if( hfp.next_hardfork != std::get<0>( hf_itr->first ) ||
hfp.next_hardfork_time != std::get<1>( hf_itr->first ) ) {
db.modify( hfp, [&]( hardfork_property_object& hpo )
{
hpo.next_hardfork = std::get<0>( hf_itr->first );
hpo.next_hardfork_time = std::get<1>( hf_itr->first );
} );
}
break;
}
++hf_itr;
}
// We no longer have a majority
if( hf_itr == hardfork_version_votes.end() )
{
db.modify( db.get_hardfork_property_object(), [&]( hardfork_property_object& hpo )
{
hpo.next_hardfork = hpo.current_hardfork_version;
});
}
}
}
assert( num_elected + num_miners + num_timeshare == active_witnesses.size() );
......
......@@ -1075,6 +1075,35 @@ namespace steem { namespace plugins { namespace condenser_api {
legacy_asset additional_funds;
};
struct legacy_hardfork_hive_operation
{
legacy_hardfork_hive_operation() {}
legacy_hardfork_hive_operation( const hardfork_hive_operation& op ) :
account( op.account ),
sbd_transferred( legacy_asset::from_asset( op.sbd_transferred ) ),
steem_transferred( legacy_asset::from_asset( op.steem_transferred ) ),
vests_converted( legacy_asset::from_asset( op.vests_converted ) ),
total_steem_from_vests( legacy_asset::from_asset( op.total_steem_from_vests ) )
{}
operator hardfork_hive_operation()const
{
legacy_hardfork_hive_operation op;
op.account = account;
op.sbd_transferred = sbd_transferred;
op.steem_transferred = steem_transferred;
op.vests_converted = vests_converted;
op.total_steem_from_vests = total_steem_from_vests;
return op;
}
account_name_type account;
legacy_asset sbd_transferred;
legacy_asset steem_transferred;
legacy_asset vests_converted;
legacy_asset total_steem_from_vests;
};
typedef fc::static_variant<
legacy_vote_operation,
legacy_comment_operation,
......@@ -1140,7 +1169,8 @@ namespace steem { namespace plugins { namespace condenser_api {
legacy_producer_reward_operation,
legacy_clear_null_account_balance_operation,
legacy_proposal_pay_operation,
legacy_sps_fund_operation
legacy_sps_fund_operation,
legacy_hardfork_hive_operation
> legacy_operation;
struct legacy_operation_conversion_visitor
......@@ -1387,6 +1417,12 @@ namespace steem { namespace plugins { namespace condenser_api {
return true;
}
bool operator()( const hardfork_hive_operation& op )const
{
l_op = legacy_hardfork_hive_operation( op );
return true;
}
// Should only be SMT ops
template< typename T >
bool operator()( const T& )const { return false; }
......@@ -1568,6 +1604,11 @@ struct convert_from_legacy_operation_visitor
return operation( sps_fund_operation( op ) );
}
operation operator()( const legacy_hardfork_hive_operation& op )const
{
return operation( hardfork_hive_operation( op ) );
}
template< typename T >
operation operator()( const T& t )const
{
......@@ -1693,5 +1734,6 @@ FC_REFLECT( steem::plugins::condenser_api::legacy_claim_account_operation, (crea
FC_REFLECT( steem::plugins::condenser_api::legacy_proposal_pay_operation, (receiver)(payment)(trx_id)(op_in_trx) )
FC_REFLECT( steem::plugins::condenser_api::legacy_sps_fund_operation, (additional_funds) )
FC_REFLECT( steem::plugins::condenser_api::legacy_create_proposal_operation, (creator)(receiver)(start_date)(end_date)(daily_pay)(subject)(permlink) )
FC_REFLECT( steem::plugins::condenser_api::legacy_hardfork_hive_operation, (account)(sbd_transferred)(steem_transferred)(vests_converted)(total_steem_from_vests) )
FC_REFLECT_TYPENAME( steem::plugins::condenser_api::legacy_operation )
......@@ -394,6 +394,7 @@ struct count_operation_visitor
void operator()( const clear_null_account_balance_operation& ) const {}
void operator()( const proposal_pay_operation& ) const {}
void operator()( const sps_fund_operation& ) const {}
void operator()( const hardfork_hive_operation& ) const {}
// Optional Actions
#ifdef IS_TEST_NET
......
......@@ -13,7 +13,7 @@
#include <set>
#ifdef IS_TEST_NET
#define STEEM_NUM_HARDFORKS 23
#define STEEM_NUM_HARDFORKS 24
#else
#define STEEM_NUM_HARDFORKS 22
#define STEEM_NUM_HARDFORKS 23
#endif
......@@ -8,3 +8,31 @@
#define STEEM_HARDFORK_0_22_VERSION hardfork_version( 0, 22 )
#endif
namespace hardforkprotect
{
inline static const std::set< std::string >& get_steemit_accounts()
{
static const std::set< std::string > steemit_accounts
{
"ben",
"bitdev100",
"geos",
"goku1",
"hkdev404",
"imadev",
"joe767676",
"misterdelegation",
"pacemaker",
"steem",
"steemit",
"steemit2",
"steemitadmin",
"timothy2020"
};
return steemit_accounts;
}
}
#ifndef STEEM_HARDFORK_0_23
#define STEEM_HARDFORK_0_23 23
#define STEEM_SMT_HARDFORK STEEM_HARDFORK_0_23
#define STEEM_HARDFORK_0_23_TIME 1597970800 // Future 2020...
long hf23_time();
#define STEEM_HARDFORK_0_23_TIME hf23_time()
#define STEEM_HARDFORK_0_23_VERSION hardfork_version( 0, 23 )
......
#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
......@@ -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()) ))
......@@ -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()
......
......@@ -101,7 +101,8 @@ namespace steem { namespace protocol {
producer_reward_operation,
clear_null_account_balance_operation,
proposal_pay_operation,
sps_fund_operation
sps_fund_operation,
hardfork_hive_operation
> operation;
/*void operation_get_required_authorities( const operation& op,
......
......@@ -191,6 +191,20 @@ namespace steem { namespace protocol {
asset additional_funds;
};
// TODO : Fix legacy error itr != to_full_tag.end(): Invalid operation name: hardfork_hive {"n":"hardfork_hive"}
struct hardfork_hive_operation : public virtual_operation
{
hardfork_hive_operation() {}
hardfork_hive_operation( const account_name_type& acc, const asset& s, const asset& st, const asset& v, const asset& cs )
: account( acc ), sbd_transferred( s ), steem_transferred( st ), vests_converted( v ), total_steem_from_vests(cs) {}
account_name_type account;
asset sbd_transferred;
asset steem_transferred;
asset vests_converted; // Amount of converted vests
asset total_steem_from_vests; // Resulting STEEM from conversion
};
} } //steem::protocol
FC_REFLECT( steem::protocol::author_reward_operation, (author)(permlink)(sbd_payout)(steem_payout)(vesting_payout) )
......@@ -210,3 +224,4 @@ FC_REFLECT( steem::protocol::comment_benefactor_reward_operation, (benefactor)(a
FC_REFLECT( steem::protocol::producer_reward_operation, (producer)(vesting_shares) )
FC_REFLECT( steem::protocol::clear_null_account_balance_operation, (total_cleared) )
FC_REFLECT( steem::protocol::sps_fund_operation, (additional_funds) )
FC_REFLECT( steem::protocol::hardfork_hive_operation, (account)(sbd_transferred)(steem_transferred)(vests_converted)(total_steem_from_vests) )
......@@ -1022,6 +1022,37 @@ void sps_proposal_database_fixture::post_comment( std::string _authro, std::stri
trx.operations.clear();
}
void hf23_database_fixture::push_transaction( const operation& op, const fc::ecc::private_key& key )
{
signed_transaction tx;
tx.set_expiration( db->head_block_time() + STEEM_MAX_TIME_UNTIL_EXPIRATION );
tx.operations.push_back( op );
sign( tx, key );
db->push_transaction( tx, 0 );
}
void hf23_database_fixture::vest( const string& from, const string& to, const asset& amount, const fc::ecc::private_key& key )
{
FC_ASSERT( amount.symbol == STEEM_SYMBOL, "Can only vest TESTS" );
transfer_to_vesting_operation op;
op.from = from;
op.to = to;
op.amount = amount;
push_transaction( op, key );
}
void hf23_database_fixture::delegate_vest( const string& delegator, const string& delegatee, const asset& amount, const fc::ecc::private_key& key )
{
delegate_vesting_shares_operation op;
op.vesting_shares = amount;
op.delegator = delegator;
op.delegatee = delegatee;
push_transaction( op, key );
}
json_rpc_database_fixture::json_rpc_database_fixture()
{
try {
......
......@@ -367,6 +367,22 @@ struct sps_proposal_database_fixture_performance : public sps_proposal_database_
}
};
struct hf23_database_fixture : public clean_database_fixture
{
private:
void push_transaction( const operation& op, const fc::ecc::private_key& key );
public:
hf23_database_fixture( uint16_t shared_file_size_in_mb = 8 )
: clean_database_fixture( shared_file_size_in_mb ){}
virtual ~hf23_database_fixture(){}
void vest( const string& from, const string& to, const asset& amount, const fc::ecc::private_key& key );
void delegate_vest( const string& delegator, const string& delegatee, const asset& amount, const fc::ecc::private_key& key );
};
struct json_rpc_database_fixture : public database_fixture
{
private:
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment