Skip to content
Open
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
1 change: 1 addition & 0 deletions libraries/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ add_library( graphene_chain
protocol/fee_schedule.cpp
protocol/confidential.cpp
protocol/vote.cpp
protocol/version.cpp

genesis_state.cpp
get_config.cpp
Expand Down
18 changes: 9 additions & 9 deletions libraries/chain/account_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void verify_account_votes( const database& db, const account_options& options )
has_worker_votes |= (id.type() == vote_id_type::worker);
}

if( has_worker_votes && (db.head_block_time() >= HARDFORK_607_TIME) )
if( has_worker_votes && (db.head_block_time() >= HARDFORK_607_VERSION) )
{
const auto& against_worker_idx = db.get_index_type<worker_index>().indices().get<by_vote_against>();
for( auto id : options.votes )
Expand All @@ -93,7 +93,7 @@ void verify_account_votes( const database& db, const account_options& options )
}
}
}
if ( db.head_block_time() >= HARDFORK_CORE_143_TIME ) {
if ( db.head_block_time() >= HARDFORK_CORE_143_VERSION ) {
const auto& approve_worker_idx = db.get_index_type<worker_index>().indices().get<by_vote_for>();
const auto& committee_idx = db.get_index_type<committee_member_index>().indices().get<by_vote_id>();
const auto& witness_idx = db.get_index_type<witness_index>().indices().get<by_vote_id>();
Expand Down Expand Up @@ -123,12 +123,12 @@ void verify_account_votes( const database& db, const account_options& options )
void_result account_create_evaluator::do_evaluate( const account_create_operation& op )
{ try {
database& d = db();
if( d.head_block_time() < HARDFORK_516_TIME )
if( d.head_block_time() < HARDFORK_516_VERSION )
{
FC_ASSERT( !op.extensions.value.owner_special_authority.valid() );
FC_ASSERT( !op.extensions.value.active_special_authority.valid() );
}
if( d.head_block_time() < HARDFORK_599_TIME )
if( d.head_block_time() < HARDFORK_599_VERSION )
{
FC_ASSERT( !op.extensions.value.null_ext.valid() );
FC_ASSERT( !op.extensions.value.owner_special_authority.valid() );
Expand Down Expand Up @@ -172,7 +172,7 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio
database& d = db();
uint16_t referrer_percent = o.referrer_percent;
bool has_small_percent = (
(db().head_block_time() <= HARDFORK_453_TIME)
(db().head_block_time() <= HARDFORK_453_VERSION)
&& (o.referrer != o.registrar )
&& (o.referrer_percent != 0 )
&& (o.referrer_percent <= 0x100)
Expand Down Expand Up @@ -278,12 +278,12 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio
void_result account_update_evaluator::do_evaluate( const account_update_operation& o )
{ try {
database& d = db();
if( d.head_block_time() < HARDFORK_516_TIME )
if( d.head_block_time() < HARDFORK_516_VERSION )
{
FC_ASSERT( !o.extensions.value.owner_special_authority.valid() );
FC_ASSERT( !o.extensions.value.active_special_authority.valid() );
}
if( d.head_block_time() < HARDFORK_599_TIME )
if( d.head_block_time() < HARDFORK_599_VERSION )
{
FC_ASSERT( !o.extensions.value.null_ext.valid() );
FC_ASSERT( !o.extensions.value.owner_special_authority.valid() );
Expand Down Expand Up @@ -439,13 +439,13 @@ void_result account_upgrade_evaluator::do_apply(const account_upgrade_evaluator:
a.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT - a.network_fee_percentage;
} else if( a.is_annual_member(d.head_block_time()) ) {
// Renew an annual subscription that's still in effect.
FC_ASSERT( d.head_block_time() <= HARDFORK_613_TIME );
FC_ASSERT( d.head_block_time() <= HARDFORK_613_VERSION );
FC_ASSERT(a.membership_expiration_date - d.head_block_time() < fc::days(3650),
"May not extend annual membership more than a decade into the future.");
a.membership_expiration_date += fc::days(365);
} else {
// Upgrade from basic account.
FC_ASSERT( d.head_block_time() <= HARDFORK_613_TIME );
FC_ASSERT( d.head_block_time() <= HARDFORK_613_VERSION );
a.statistics(d).process_fees(a, d);
assert(a.is_basic_account(d.head_block_time()));
a.referrer = a.get_id();
Expand Down
36 changes: 18 additions & 18 deletions libraries/chain/asset_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o
auto asset_symbol_itr = asset_indx.find( op.symbol );
FC_ASSERT( asset_symbol_itr == asset_indx.end() );

if( d.head_block_time() > HARDFORK_385_TIME )
if( d.head_block_time() > HARDFORK_385_VERSION )
{
auto dotpos = op.symbol.rfind( '.' );
if( dotpos != std::string::npos )
Expand All @@ -68,7 +68,7 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o
("s",op.symbol)("p",prefix)("i", op.issuer(d).name) );
}

if(d.head_block_time() <= HARDFORK_CORE_620_TIME ) { // TODO: remove this check after hf_620
if(d.head_block_time() <= HARDFORK_CORE_620_VERSION ) { // TODO: remove this check after hf_620
static const std::locale& loc = std::locale::classic();
FC_ASSERT(isalpha(op.symbol.back(), loc), "Asset ${s} must end with alpha character before hardfork 620", ("s",op.symbol));
}
Expand Down Expand Up @@ -117,7 +117,7 @@ object_id_type asset_create_evaluator::do_apply( const asset_create_operation& o
{ try {
database& d = db();

bool hf_429 = fee_is_odd && d.head_block_time() > HARDFORK_CORE_429_TIME;
bool hf_429 = fee_is_odd && d.head_block_time() > HARDFORK_CORE_429_VERSION;

const asset_dynamic_data_object& dyn_asset =
d.create<asset_dynamic_data_object>( [hf_429,this]( asset_dynamic_data_object& a ) {
Expand Down Expand Up @@ -272,12 +272,12 @@ void_result asset_update_evaluator::do_evaluate(const asset_update_operation& o)

if( o.new_issuer )
{
FC_ASSERT( d.head_block_time() < HARDFORK_CORE_199_TIME,
FC_ASSERT( d.head_block_time() < HARDFORK_CORE_199_VERSION,
"Since Hardfork #199, updating issuer requires the use of asset_update_issuer_operation.");
validate_new_issuer( d, a, *o.new_issuer );
}

if( (d.head_block_time() < HARDFORK_572_TIME) || (a.dynamic_asset_data_id(d).current_supply != 0) )
if( (d.head_block_time() < HARDFORK_572_VERSION) || (a.dynamic_asset_data_id(d).current_supply != 0) )
{
// new issuer_permissions must be subset of old issuer permissions
FC_ASSERT(!(o.new_options.issuer_permissions & ~a.options.issuer_permissions),
Expand Down Expand Up @@ -357,9 +357,9 @@ void_result asset_update_issuer_evaluator::do_evaluate(const asset_update_issuer
"Incorrect issuer for asset! (${o.issuer} != ${a.issuer})",
("o.issuer", o.issuer)("a.issuer", a.issuer) );

if( d.head_block_time() < HARDFORK_CORE_199_TIME )
if( d.head_block_time() < HARDFORK_CORE_199_VERSION )
{
// TODO: remove after HARDFORK_CORE_199_TIME has passed
// TODO: remove after HARDFORK_CORE_199_VERSION has passed
FC_ASSERT(false, "Not allowed until hardfork 199");
}

Expand Down Expand Up @@ -459,7 +459,7 @@ void_result asset_update_bitasset_evaluator::do_evaluate(const asset_update_bita

FC_ASSERT( !current_bitasset_data.has_settlement(), "Cannot update a bitasset after a global settlement has executed" );

bool after_hf_core_922_931 = ( d.get_dynamic_global_properties().next_maintenance_time > HARDFORK_CORE_922_931_TIME );
bool after_hf_core_922_931 = ( d.get_dynamic_global_properties().next_maintenance_time > HARDFORK_CORE_922_931_VERSION );

// Are we changing the backing asset?
if( op.new_options.short_backing_asset != current_bitasset_data.options.short_backing_asset )
Expand Down Expand Up @@ -639,7 +639,7 @@ static bool update_bitasset_object_options(
asset_bitasset_data_object& bdo, const asset_object& asset_to_update )
{
const fc::time_point_sec& next_maint_time = db.get_dynamic_global_properties().next_maintenance_time;
bool after_hf_core_868_890 = ( next_maint_time > HARDFORK_CORE_868_890_TIME );
bool after_hf_core_868_890 = ( next_maint_time > HARDFORK_CORE_868_890_VERSION );

// If the minimum number of feeds to calculate a median has changed, we need to recalculate the median
bool should_update_feeds = false;
Expand Down Expand Up @@ -696,7 +696,7 @@ static bool update_bitasset_object_options(
// 2. if wlog did not actually get called

// We need to call check_call_orders if the price feed changes after hardfork core-935
if( next_maint_time > HARDFORK_CORE_935_TIME )
if( next_maint_time > HARDFORK_CORE_935_VERSION )
return ( !( old_feed == bdo.current_feed ) );

// We need to call check_call_orders if the settlement price changes after hardfork core-868-890
Expand Down Expand Up @@ -840,7 +840,7 @@ void_result asset_settle_evaluator::do_evaluate(const asset_settle_evaluator::op
if( bitasset.is_prediction_market )
FC_ASSERT( bitasset.has_settlement(), "global settlement must occur before force settling a prediction market" );
else if( bitasset.current_feed.settlement_price.is_null()
&& ( d.head_block_time() <= HARDFORK_CORE_216_TIME
&& ( d.head_block_time() <= HARDFORK_CORE_216_VERSION
|| !bitasset.has_settlement() ) )
FC_THROW_EXCEPTION(insufficient_feeds, "Cannot force settle with no price feed.");
FC_ASSERT(d.get_balance(d.get(op.account), *asset_to_settle) >= op.amount);
Expand All @@ -865,7 +865,7 @@ operation_result asset_settle_evaluator::do_apply(const asset_settle_evaluator::

if( settled_amount.amount == 0 && !bitasset.is_prediction_market )
{
if( d.get_dynamic_global_properties().next_maintenance_time > HARDFORK_CORE_184_TIME )
if( d.get_dynamic_global_properties().next_maintenance_time > HARDFORK_CORE_184_VERSION )
FC_THROW( "Settle amount is too small to receive anything due to rounding" );
else // TODO remove this warning after hard fork core-184
wlog( "Something for nothing issue (#184, variant F) occurred at block #${block}", ("block",d.head_block_num()) );
Expand All @@ -874,7 +874,7 @@ operation_result asset_settle_evaluator::do_apply(const asset_settle_evaluator::
asset pays = op.amount;
if( op.amount.amount != mia_dyn.current_supply
&& settled_amount.amount != 0
&& d.get_dynamic_global_properties().next_maintenance_time > HARDFORK_CORE_342_TIME )
&& d.get_dynamic_global_properties().next_maintenance_time > HARDFORK_CORE_342_VERSION )
{
pays = settled_amount.multiply_and_round_up( bitasset.settlement_price );
}
Expand Down Expand Up @@ -916,7 +916,7 @@ void_result asset_publish_feeds_evaluator::do_evaluate(const asset_publish_feed_
FC_ASSERT( base.is_market_issued(), "Can only publish price feeds for market-issued assets" );

const asset_bitasset_data_object& bitasset = base.bitasset_data(d);
if( bitasset.is_prediction_market || d.head_block_time() <= HARDFORK_CORE_216_TIME )
if( bitasset.is_prediction_market || d.head_block_time() <= HARDFORK_CORE_216_VERSION )
{
FC_ASSERT( !bitasset.has_settlement(), "No further feeds may be published after a settlement event" );
}
Expand All @@ -925,7 +925,7 @@ void_result asset_publish_feeds_evaluator::do_evaluate(const asset_publish_feed_
FC_ASSERT( o.feed.settlement_price.quote.asset_id == bitasset.options.short_backing_asset,
"Quote asset type in settlement price should be same as backing asset of this asset" );

if( d.head_block_time() > HARDFORK_480_TIME )
if( d.head_block_time() > HARDFORK_480_VERSION )
{
if( !o.feed.core_exchange_rate.is_null() )
{
Expand Down Expand Up @@ -982,7 +982,7 @@ void_result asset_publish_feeds_evaluator::do_apply(const asset_publish_feed_ope

if( !(old_feed == bad.current_feed) )
{
if( bad.has_settlement() ) // implies head_block_time > HARDFORK_CORE_216_TIME
if( bad.has_settlement() ) // implies head_block_time > HARDFORK_CORE_216_VERSION
{
const auto& mia_dyn = base.dynamic_asset_data_id(d);
if( !bad.current_feed.settlement_price.is_null()
Expand All @@ -1003,7 +1003,7 @@ void_result asset_publish_feeds_evaluator::do_apply(const asset_publish_feed_ope

void_result asset_claim_fees_evaluator::do_evaluate( const asset_claim_fees_operation& o )
{ try {
FC_ASSERT( db().head_block_time() > HARDFORK_413_TIME );
FC_ASSERT( db().head_block_time() > HARDFORK_413_VERSION );
FC_ASSERT( o.amount_to_claim.asset_id(db()).issuer == o.issuer, "Asset fees may only be claimed by the issuer" );
return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) }
Expand All @@ -1029,7 +1029,7 @@ void_result asset_claim_fees_evaluator::do_apply( const asset_claim_fees_operati

void_result asset_claim_pool_evaluator::do_evaluate( const asset_claim_pool_operation& o )
{ try {
FC_ASSERT( db().head_block_time() >= HARDFORK_CORE_188_TIME,
FC_ASSERT( db().head_block_time() >= HARDFORK_CORE_188_VERSION,
"This operation is only available after Hardfork #188!" );
FC_ASSERT( o.asset_id(db()).issuer == o.issuer, "Asset fee pool may only be claimed by the issuer" );

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/buyback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace graphene { namespace chain {

void evaluate_buyback_account_options( const database& db, const buyback_account_options& bbo )
{
FC_ASSERT( db.head_block_time() >= HARDFORK_538_TIME );
FC_ASSERT( db.head_block_time() >= HARDFORK_538_VERSION );
const asset_object& a = bbo.asset_to_buy(db);
GRAPHENE_ASSERT( a.issuer == bbo.asset_to_buy_issuer,
account_create_buyback_incorrect_issuer, "Incorrect asset issuer specified in buyback_account_options", ("asset", a)("bbo", bbo) );
Expand Down
6 changes: 3 additions & 3 deletions libraries/chain/confidential_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void_result transfer_to_blind_evaluator::do_apply( const transfer_to_blind_opera

void transfer_to_blind_evaluator::pay_fee()
{
if( db().head_block_time() >= HARDFORK_563_TIME )
if( db().head_block_time() >= HARDFORK_563_VERSION )
pay_fba_fee( fba_accumulator_id_transfer_to_blind );
else
generic_evaluator::pay_fee();
Expand Down Expand Up @@ -117,7 +117,7 @@ void_result transfer_from_blind_evaluator::do_apply( const transfer_from_blind_o

void transfer_from_blind_evaluator::pay_fee()
{
if( db().head_block_time() >= HARDFORK_563_TIME )
if( db().head_block_time() >= HARDFORK_563_VERSION )
pay_fba_fee( fba_accumulator_id_transfer_from_blind );
else
generic_evaluator::pay_fee();
Expand Down Expand Up @@ -174,7 +174,7 @@ void_result blind_transfer_evaluator::do_apply( const blind_transfer_operation&

void blind_transfer_evaluator::pay_fee()
{
if( db().head_block_time() >= HARDFORK_563_TIME )
if( db().head_block_time() >= HARDFORK_563_VERSION )
pay_fba_fee( fba_accumulator_id_blind_transfer );
else
generic_evaluator::pay_fee();
Expand Down
31 changes: 28 additions & 3 deletions libraries/chain/db_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ processed_transaction database::push_proposal(const proposal_object& proposal)
remove(proposal);
session.merge();
} catch ( const fc::exception& e ) {
if( head_block_time() <= HARDFORK_483_TIME )
if( head_block_time() <= HARDFORK_483_VERSION )
{
for( size_t i=old_applied_ops_size,n=_applied_ops.size(); i<n; i++ )
{
Expand Down Expand Up @@ -449,7 +449,18 @@ signed_block database::_generate_block(
pending_block.timestamp = when;
pending_block.transaction_merkle_root = pending_block.calculate_merkle_root();
pending_block.witness = witness_id;


// TODO change to next hardfork version
if( when >= HARDFORK_TEST_VERSION )
{
// inserts the version in to the block if the witness running_version changed
if( witness_obj.running_version != GRAPHENE_BLOCKCHAIN_VERSION )
{
pending_block.extensions.value.witness_running_version = optional<version>(GRAPHENE_BLOCKCHAIN_VERSION);
}
}


if( !(skip & skip_witness_signature) )
pending_block.sign( block_signing_private_key );

Expand Down Expand Up @@ -559,6 +570,20 @@ void database::_apply_block( const signed_block& next_block )

_issue_453_affected_assets.clear();

// TODO change HARDFORK_TEST_VERSION to next HF version
if( next_block.timestamp >= HARDFORK_TEST_VERSION )
{
// modifies the witness running version and sets it to the new one
if( signing_witness.running_version != GRAPHENE_BLOCKCHAIN_VERSION )
{
modify( signing_witness, [&] ( witness_object& wit_obj )
{
// witness_running_version was set in _generate_block()
wit_obj.running_version = *(next_block.extensions.value.witness_running_version);
} );
}
}

for( const auto& trx : next_block.transactions )
{
/* We do not need to push the undo state for each transaction
Expand Down Expand Up @@ -683,7 +708,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
}
ptrx.operation_results = std::move(eval_state.operation_results);

if( head_block_time() < HARDFORK_CORE_1040_TIME ) // TODO totally remove this code block after hard fork
if( head_block_time() < HARDFORK_CORE_1040_VERSION ) // TODO totally remove this code block after hard fork
{
//Make sure the temp account has no non-zero balances
const auto& index = get_index_type<account_balance_index>().indices().get<by_account_asset>();
Expand Down
Loading