Merge branch 'master' of github.com:cryptonomex/graphene
This commit is contained in:
commit
b3e9874ece
9 changed files with 66 additions and 18 deletions
|
|
@ -73,7 +73,11 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o
|
||||||
|
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
||||||
#warning HARDFORK remove this check after HARDFORK_359_TIME and rename is_valid_symbol_old -> is_valid_symbol
|
#ifdef _MSC_VER
|
||||||
|
# pragma message ("WARNING:HARDFORK remove this check after HARDFORK_359_TIME and rename is_valid_symbol_old -> is_valid_symbol")
|
||||||
|
#else
|
||||||
|
# warning HARDFORK remove this check after HARDFORK_359_TIME and rename is_valid_symbol_old -> is_valid_symbol
|
||||||
|
#endif
|
||||||
if( d.head_block_time() <= HARDFORK_359_TIME )
|
if( d.head_block_time() <= HARDFORK_359_TIME )
|
||||||
{
|
{
|
||||||
FC_ASSERT( is_valid_symbol_old( op.symbol ) );
|
FC_ASSERT( is_valid_symbol_old( op.symbol ) );
|
||||||
|
|
@ -384,8 +388,8 @@ void_result asset_update_feed_producers_evaluator::do_evaluate(const asset_updat
|
||||||
const asset_object& a = o.asset_to_update(d);
|
const asset_object& a = o.asset_to_update(d);
|
||||||
|
|
||||||
FC_ASSERT(a.is_market_issued(), "Cannot update feed producers on a non-BitAsset.");
|
FC_ASSERT(a.is_market_issued(), "Cannot update feed producers on a non-BitAsset.");
|
||||||
FC_ASSERT(a.issuer != GRAPHENE_COMMITTEE_ACCOUNT, "Cannot set feed producers on a committee-issued asset.");
|
FC_ASSERT(!(a.options.flags & committee_fed_asset), "Cannot set feed producers on a committee-fed asset.");
|
||||||
FC_ASSERT(a.issuer != GRAPHENE_WITNESS_ACCOUNT, "Cannot set feed producers on a witness-issued asset.");
|
FC_ASSERT(!(a.options.flags & witness_fed_asset), "Cannot set feed producers on a witness-fed asset.");
|
||||||
|
|
||||||
const asset_bitasset_data_object& b = a.bitasset_data(d);
|
const asset_bitasset_data_object& b = a.bitasset_data(d);
|
||||||
bitasset_to_update = &b;
|
bitasset_to_update = &b;
|
||||||
|
|
@ -507,7 +511,11 @@ void_result asset_publish_feeds_evaluator::do_evaluate(const asset_publish_feed_
|
||||||
const asset_bitasset_data_object& bitasset = base.bitasset_data(d);
|
const asset_bitasset_data_object& bitasset = base.bitasset_data(d);
|
||||||
FC_ASSERT( !bitasset.has_settlement(), "No further feeds may be published after a settlement event" );
|
FC_ASSERT( !bitasset.has_settlement(), "No further feeds may be published after a settlement event" );
|
||||||
|
|
||||||
#warning Remove this check when starting a new network
|
#ifdef _MSC_VER
|
||||||
|
# pragma message ("WARNING: Remove this check when starting a new network")
|
||||||
|
#else
|
||||||
|
# warning Remove this check when starting a new network
|
||||||
|
#endif
|
||||||
if( d.head_block_time() <= HARDFORK_357_TIME )
|
if( d.head_block_time() <= HARDFORK_357_TIME )
|
||||||
{
|
{
|
||||||
FC_ASSERT(o.feed.settlement_price.quote.asset_id == bitasset.options.short_backing_asset);
|
FC_ASSERT(o.feed.settlement_price.quote.asset_id == bitasset.options.short_backing_asset);
|
||||||
|
|
@ -564,7 +572,11 @@ void_result asset_publish_feeds_evaluator::do_evaluate(const asset_publish_feed_
|
||||||
wdump( (e) );
|
wdump( (e) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#warning Remove this check when starting a new network
|
#ifdef _MSC_VER
|
||||||
|
# pragma message ("WARNING: Remove this check when starting a new network")
|
||||||
|
#else
|
||||||
|
# warning Remove this check when starting a new network
|
||||||
|
#endif
|
||||||
if( d.head_block_num() > 59300 )
|
if( d.head_block_num() > 59300 )
|
||||||
{
|
{
|
||||||
FC_ASSERT(
|
FC_ASSERT(
|
||||||
|
|
@ -597,9 +609,13 @@ void_result asset_publish_feeds_evaluator::do_evaluate(const asset_publish_feed_
|
||||||
FC_ASSERT( o.feed.is_for( o.asset_id ) );
|
FC_ASSERT( o.feed.is_for( o.asset_id ) );
|
||||||
}
|
}
|
||||||
//Verify that the publisher is authoritative to publish a feed
|
//Verify that the publisher is authoritative to publish a feed
|
||||||
if( (base.issuer == GRAPHENE_WITNESS_ACCOUNT) || (base.issuer == GRAPHENE_COMMITTEE_ACCOUNT) )
|
if( base.options.flags & witness_fed_asset )
|
||||||
{
|
{
|
||||||
FC_ASSERT( d.get(base.issuer).active.account_auths.count(o.publisher) );
|
FC_ASSERT( d.get(GRAPHENE_WITNESS_ACCOUNT).active.account_auths.count(o.publisher) );
|
||||||
|
}
|
||||||
|
else if( base.options.flags & committee_fed_asset )
|
||||||
|
{
|
||||||
|
FC_ASSERT( d.get(GRAPHENE_COMMITTEE_ACCOUNT).active.account_auths.count(o.publisher) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -612,7 +628,11 @@ void_result asset_publish_feeds_evaluator::do_evaluate(const asset_publish_feed_
|
||||||
void_result asset_publish_feeds_evaluator::do_apply(const asset_publish_feed_operation& o)
|
void_result asset_publish_feeds_evaluator::do_apply(const asset_publish_feed_operation& o)
|
||||||
{ try {
|
{ try {
|
||||||
|
|
||||||
#warning Remove this check when preparing for new network release
|
#ifdef _MSC_VER
|
||||||
|
# pragma message ("WARNING: Remove this check when preparing for new network release")
|
||||||
|
#else
|
||||||
|
# warning Remove this check when preparing for new network release
|
||||||
|
#endif
|
||||||
if( !o.feed.is_for( o.asset_id ) )
|
if( !o.feed.is_for( o.asset_id ) )
|
||||||
{
|
{
|
||||||
wlog( "Ignoring bad feed" );
|
wlog( "Ignoring bad feed" );
|
||||||
|
|
|
||||||
|
|
@ -458,6 +458,7 @@ void database::apply_block( const signed_block& next_block, uint32_t skip )
|
||||||
|
|
||||||
void database::_apply_block( const signed_block& next_block )
|
void database::_apply_block( const signed_block& next_block )
|
||||||
{ try {
|
{ try {
|
||||||
|
uint32_t next_block_num = next_block.block_num();
|
||||||
uint32_t skip = get_node_properties().skip_flags;
|
uint32_t skip = get_node_properties().skip_flags;
|
||||||
_applied_ops.clear();
|
_applied_ops.clear();
|
||||||
|
|
||||||
|
|
@ -468,7 +469,7 @@ void database::_apply_block( const signed_block& next_block )
|
||||||
const auto& dynamic_global_props = get<dynamic_global_property_object>(dynamic_global_property_id_type());
|
const auto& dynamic_global_props = get<dynamic_global_property_object>(dynamic_global_property_id_type());
|
||||||
bool maint_needed = (dynamic_global_props.next_maintenance_time <= next_block.timestamp);
|
bool maint_needed = (dynamic_global_props.next_maintenance_time <= next_block.timestamp);
|
||||||
|
|
||||||
_current_block_num = next_block.block_num();
|
_current_block_num = next_block_num;
|
||||||
_current_trx_in_block = 0;
|
_current_trx_in_block = 0;
|
||||||
|
|
||||||
for( const auto& trx : next_block.transactions )
|
for( const auto& trx : next_block.transactions )
|
||||||
|
|
|
||||||
|
|
@ -497,9 +497,14 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
||||||
a.symbol = asset.symbol;
|
a.symbol = asset.symbol;
|
||||||
a.options.description = asset.description;
|
a.options.description = asset.description;
|
||||||
a.precision = asset.precision;
|
a.precision = asset.precision;
|
||||||
a.issuer = get_account_id(asset.issuer_name);
|
string issuer_name = asset.issuer_name;
|
||||||
|
#warning Remove this check doing real network, change BitAsset owners to be committee-account in genesis.
|
||||||
|
if( issuer_name == "witness-account" )
|
||||||
|
issuer_name = "committee-account";
|
||||||
|
a.issuer = get_account_id(issuer_name);
|
||||||
a.options.max_supply = asset.max_supply;
|
a.options.max_supply = asset.max_supply;
|
||||||
|
a.options.flags = witness_fed_asset;
|
||||||
|
a.options.issuer_permissions = charge_market_fee | global_settle | witness_fed_asset | committee_fed_asset;
|
||||||
a.dynamic_asset_data_id = dynamic_data_id;
|
a.dynamic_asset_data_id = dynamic_data_id;
|
||||||
a.bitasset_data_id = bitasset_data_id;
|
a.bitasset_data_id = bitasset_data_id;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,6 @@ void database::globally_settle_asset( const asset_object& mia, const price& sett
|
||||||
void database::cancel_order(const force_settlement_object& order, bool create_virtual_op)
|
void database::cancel_order(const force_settlement_object& order, bool create_virtual_op)
|
||||||
{
|
{
|
||||||
adjust_balance(order.owner, order.balance);
|
adjust_balance(order.owner, order.balance);
|
||||||
remove(order);
|
|
||||||
|
|
||||||
if( create_virtual_op )
|
if( create_virtual_op )
|
||||||
{
|
{
|
||||||
|
|
@ -99,6 +98,7 @@ void database::cancel_order(const force_settlement_object& order, bool create_vi
|
||||||
vop.amount = order.balance;
|
vop.amount = order.balance;
|
||||||
push_applied_operation( vop );
|
push_applied_operation( vop );
|
||||||
}
|
}
|
||||||
|
remove(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
void database::cancel_order( const limit_order_object& order, bool create_virtual_op )
|
void database::cancel_order( const limit_order_object& order, bool create_virtual_op )
|
||||||
|
|
@ -361,7 +361,6 @@ bool database::fill_order(const force_settlement_object& settle, const asset& pa
|
||||||
});
|
});
|
||||||
filled = false;
|
filled = false;
|
||||||
} else {
|
} else {
|
||||||
remove(settle);
|
|
||||||
filled = true;
|
filled = true;
|
||||||
}
|
}
|
||||||
adjust_balance(settle.owner, receives - issuer_fees);
|
adjust_balance(settle.owner, receives - issuer_fees);
|
||||||
|
|
@ -369,6 +368,9 @@ bool database::fill_order(const force_settlement_object& settle, const asset& pa
|
||||||
assert( pays.asset_id != receives.asset_id );
|
assert( pays.asset_id != receives.asset_id );
|
||||||
push_applied_operation( fill_order_operation{ settle.id, settle.owner, pays, receives, issuer_fees } );
|
push_applied_operation( fill_order_operation{ settle.id, settle.owner, pays, receives, issuer_fees } );
|
||||||
|
|
||||||
|
if (filled)
|
||||||
|
remove(settle);
|
||||||
|
|
||||||
return filled;
|
return filled;
|
||||||
} FC_CAPTURE_AND_RETHROW( (settle)(pays)(receives) ) }
|
} FC_CAPTURE_AND_RETHROW( (settle)(pays)(receives) ) }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,9 +86,12 @@ namespace graphene { namespace chain {
|
||||||
transfer_restricted = 0x08, /**< require the issuer to be one party to every transfer */
|
transfer_restricted = 0x08, /**< require the issuer to be one party to every transfer */
|
||||||
disable_force_settle = 0x10, /**< disable force settling */
|
disable_force_settle = 0x10, /**< disable force settling */
|
||||||
global_settle = 0x20, /**< allow the bitasset issuer to force a global settling -- this may be set in permissions, but not flags */
|
global_settle = 0x20, /**< allow the bitasset issuer to force a global settling -- this may be set in permissions, but not flags */
|
||||||
disable_confidential = 0x40 /**< allow the asset to be used with confidential transactions */
|
disable_confidential = 0x40, /**< allow the asset to be used with confidential transactions */
|
||||||
|
witness_fed_asset = 0x80, /**< allow the asset to be fed by witnesses */
|
||||||
|
committee_fed_asset = 0x100 /**< allow the asset to be fed by the committee */
|
||||||
};
|
};
|
||||||
const static uint32_t ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_force_settle|global_settle|disable_confidential;
|
const static uint32_t ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_force_settle|global_settle|disable_confidential
|
||||||
|
|witness_fed_asset|committee_fed_asset;
|
||||||
const static uint32_t UIA_ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_confidential;
|
const static uint32_t UIA_ASSET_ISSUER_PERMISSION_MASK = charge_market_fee|white_list|override_authority|transfer_restricted|disable_confidential;
|
||||||
|
|
||||||
enum reserved_spaces
|
enum reserved_spaces
|
||||||
|
|
@ -314,4 +317,14 @@ FC_REFLECT_TYPENAME( graphene::chain::account_transaction_history_id_type )
|
||||||
FC_REFLECT_TYPENAME( graphene::chain::budget_record_id_type )
|
FC_REFLECT_TYPENAME( graphene::chain::budget_record_id_type )
|
||||||
FC_REFLECT( graphene::chain::void_t, )
|
FC_REFLECT( graphene::chain::void_t, )
|
||||||
|
|
||||||
FC_REFLECT_ENUM( graphene::chain::asset_issuer_permission_flags, (charge_market_fee)(white_list)(transfer_restricted)(override_authority)(disable_force_settle)(global_settle)(disable_confidential) )
|
FC_REFLECT_ENUM( graphene::chain::asset_issuer_permission_flags,
|
||||||
|
(charge_market_fee)
|
||||||
|
(white_list)
|
||||||
|
(transfer_restricted)
|
||||||
|
(override_authority)
|
||||||
|
(disable_force_settle)
|
||||||
|
(global_settle)
|
||||||
|
(disable_confidential)
|
||||||
|
(witness_fed_asset)
|
||||||
|
(committee_fed_asset)
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,8 @@ void asset_options::validate()const
|
||||||
FC_ASSERT( !(issuer_permissions & ~ASSET_ISSUER_PERMISSION_MASK) );
|
FC_ASSERT( !(issuer_permissions & ~ASSET_ISSUER_PERMISSION_MASK) );
|
||||||
// The global_settle flag may never be set (this is a permission only)
|
// The global_settle flag may never be set (this is a permission only)
|
||||||
FC_ASSERT( !(flags & global_settle) );
|
FC_ASSERT( !(flags & global_settle) );
|
||||||
|
// the witness_fed and committee_fed flags cannot be set simultaneously
|
||||||
|
FC_ASSERT( (flags & (witness_fed_asset | committee_fed_asset)) != (witness_fed_asset | committee_fed_asset) );
|
||||||
core_exchange_rate.validate();
|
core_exchange_rate.validate();
|
||||||
FC_ASSERT( core_exchange_rate.base.asset_id.instance.value == 0 ||
|
FC_ASSERT( core_exchange_rate.base.asset_id.instance.value == 0 ||
|
||||||
core_exchange_rate.quote.asset_id.instance.value == 0 );
|
core_exchange_rate.quote.asset_id.instance.value == 0 );
|
||||||
|
|
|
||||||
|
|
@ -424,6 +424,8 @@ const asset_object& database_fixture::create_bitasset(
|
||||||
creator.common_options.max_supply = GRAPHENE_MAX_SHARE_SUPPLY;
|
creator.common_options.max_supply = GRAPHENE_MAX_SHARE_SUPPLY;
|
||||||
creator.precision = 2;
|
creator.precision = 2;
|
||||||
creator.common_options.market_fee_percent = market_fee_percent;
|
creator.common_options.market_fee_percent = market_fee_percent;
|
||||||
|
if( issuer == GRAPHENE_WITNESS_ACCOUNT )
|
||||||
|
flags |= witness_fed_asset;
|
||||||
creator.common_options.issuer_permissions = flags;
|
creator.common_options.issuer_permissions = flags;
|
||||||
creator.common_options.flags = flags & ~global_settle;
|
creator.common_options.flags = flags & ~global_settle;
|
||||||
creator.common_options.core_exchange_rate = price({asset(1,1),asset(1)});
|
creator.common_options.core_exchange_rate = price({asset(1,1),asset(1)});
|
||||||
|
|
@ -451,6 +453,8 @@ const asset_object& database_fixture::create_prediction_market(
|
||||||
creator.common_options.market_fee_percent = market_fee_percent;
|
creator.common_options.market_fee_percent = market_fee_percent;
|
||||||
creator.common_options.issuer_permissions = flags | global_settle;
|
creator.common_options.issuer_permissions = flags | global_settle;
|
||||||
creator.common_options.flags = flags & ~global_settle;
|
creator.common_options.flags = flags & ~global_settle;
|
||||||
|
if( issuer == GRAPHENE_WITNESS_ACCOUNT )
|
||||||
|
creator.common_options.flags |= witness_fed_asset;
|
||||||
creator.common_options.core_exchange_rate = price({asset(1,1),asset(1)});
|
creator.common_options.core_exchange_rate = price({asset(1,1),asset(1)});
|
||||||
creator.bitasset_opts = bitasset_options();
|
creator.bitasset_opts = bitasset_options();
|
||||||
creator.is_prediction_market = true;
|
creator.is_prediction_market = true;
|
||||||
|
|
|
||||||
|
|
@ -319,6 +319,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds )
|
||||||
op.issuer = obj.issuer;
|
op.issuer = obj.issuer;
|
||||||
op.new_issuer = nathan_id;
|
op.new_issuer = nathan_id;
|
||||||
op.new_options = obj.options;
|
op.new_options = obj.options;
|
||||||
|
op.new_options.flags &= ~witness_fed_asset;
|
||||||
trx.operations.push_back(op);
|
trx.operations.push_back(op);
|
||||||
PUSH_TX( db, trx, ~0 );
|
PUSH_TX( db, trx, ~0 );
|
||||||
generate_block();
|
generate_block();
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,8 @@ BOOST_AUTO_TEST_CASE( create_advanced_uia )
|
||||||
creator.common_options.max_supply = 100000000;
|
creator.common_options.max_supply = 100000000;
|
||||||
creator.precision = 2;
|
creator.precision = 2;
|
||||||
creator.common_options.market_fee_percent = GRAPHENE_MAX_MARKET_FEE_PERCENT/100; /*1%*/
|
creator.common_options.market_fee_percent = GRAPHENE_MAX_MARKET_FEE_PERCENT/100; /*1%*/
|
||||||
creator.common_options.issuer_permissions = ASSET_ISSUER_PERMISSION_MASK & ~(disable_force_settle|global_settle);
|
creator.common_options.issuer_permissions = charge_market_fee|white_list|override_authority|transfer_restricted|disable_confidential;
|
||||||
creator.common_options.flags = ASSET_ISSUER_PERMISSION_MASK & ~(disable_force_settle|global_settle|transfer_restricted);
|
creator.common_options.flags = charge_market_fee|white_list|override_authority|disable_confidential;
|
||||||
creator.common_options.core_exchange_rate = price({asset(2),asset(1,1)});
|
creator.common_options.core_exchange_rate = price({asset(2),asset(1,1)});
|
||||||
creator.common_options.whitelist_authorities = creator.common_options.blacklist_authorities = {account_id_type()};
|
creator.common_options.whitelist_authorities = creator.common_options.blacklist_authorities = {account_id_type()};
|
||||||
trx.operations.push_back(std::move(creator));
|
trx.operations.push_back(std::move(creator));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue