Allow witness-fed and committee-fed BitAsset feeds to be specified in flags.

This is only technically a hardfork, in order to actually desync the chain
the witness account / committee account would need to pass a proposal to do
something in their capacity as the owner of an asset_object.  It should be
fairly safe to say that this will not occur on testnet until witnesses have
upgraded.
This commit is contained in:
theoreticalbts 2015-10-09 11:07:10 -04:00
parent 7fe0e64a5e
commit f0f96d5a8f
7 changed files with 40 additions and 11 deletions

View file

@ -388,8 +388,8 @@ void_result asset_update_feed_producers_evaluator::do_evaluate(const asset_updat
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.issuer != GRAPHENE_COMMITTEE_ACCOUNT, "Cannot set feed producers on a committee-issued asset.");
FC_ASSERT(a.issuer != GRAPHENE_WITNESS_ACCOUNT, "Cannot set feed producers on a witness-issued asset.");
FC_ASSERT(!(a.options.flags & committee_fed_asset), "Cannot set feed producers on a committee-fed 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);
bitasset_to_update = &b;
@ -609,9 +609,13 @@ void_result asset_publish_feeds_evaluator::do_evaluate(const asset_publish_feed_
FC_ASSERT( o.feed.is_for( o.asset_id ) );
}
//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
{

View file

@ -497,9 +497,14 @@ void database::init_genesis(const genesis_state_type& genesis_state)
a.symbol = asset.symbol;
a.options.description = asset.description;
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.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.bitasset_data_id = bitasset_data_id;
});

View file

@ -86,9 +86,12 @@ namespace graphene { namespace chain {
transfer_restricted = 0x08, /**< require the issuer to be one party to every transfer */
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 */
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;
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( 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)
)

View file

@ -171,6 +171,8 @@ void asset_options::validate()const
FC_ASSERT( !(issuer_permissions & ~ASSET_ISSUER_PERMISSION_MASK) );
// The global_settle flag may never be set (this is a permission only)
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();
FC_ASSERT( core_exchange_rate.base.asset_id.instance.value == 0 ||
core_exchange_rate.quote.asset_id.instance.value == 0 );

View file

@ -424,6 +424,8 @@ const asset_object& database_fixture::create_bitasset(
creator.common_options.max_supply = GRAPHENE_MAX_SHARE_SUPPLY;
creator.precision = 2;
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.flags = flags & ~global_settle;
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.issuer_permissions = 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.bitasset_opts = bitasset_options();
creator.is_prediction_market = true;

View file

@ -319,6 +319,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds )
op.issuer = obj.issuer;
op.new_issuer = nathan_id;
op.new_options = obj.options;
op.new_options.flags &= ~witness_fed_asset;
trx.operations.push_back(op);
PUSH_TX( db, trx, ~0 );
generate_block();

View file

@ -44,8 +44,8 @@ BOOST_AUTO_TEST_CASE( create_advanced_uia )
creator.common_options.max_supply = 100000000;
creator.precision = 2;
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.flags = ASSET_ISSUER_PERMISSION_MASK & ~(disable_force_settle|global_settle|transfer_restricted);
creator.common_options.issuer_permissions = charge_market_fee|white_list|override_authority|transfer_restricted|disable_confidential;
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.whitelist_authorities = creator.common_options.blacklist_authorities = {account_id_type()};
trx.operations.push_back(std::move(creator));