Merge branch 'master' into bitshares
This commit is contained in:
commit
3bc8832dde
6 changed files with 69 additions and 21 deletions
|
|
@ -352,9 +352,47 @@ namespace detail {
|
||||||
{
|
{
|
||||||
ilog("Replaying blockchain on user request.");
|
ilog("Replaying blockchain on user request.");
|
||||||
_chain_db->reindex(_data_dir/"blockchain", initial_state());
|
_chain_db->reindex(_data_dir/"blockchain", initial_state());
|
||||||
} else if( clean )
|
} else if( clean ) {
|
||||||
_chain_db->open(_data_dir / "blockchain", initial_state);
|
|
||||||
else {
|
auto is_new = [&]() -> bool
|
||||||
|
{
|
||||||
|
// directory doesn't exist
|
||||||
|
if( !fc::exists( _data_dir ) )
|
||||||
|
return true;
|
||||||
|
// if directory exists but is empty, return true; else false.
|
||||||
|
return ( fc::directory_iterator( _data_dir ) == fc::directory_iterator() );
|
||||||
|
};
|
||||||
|
|
||||||
|
auto is_outdated = [&]() -> bool
|
||||||
|
{
|
||||||
|
if( !fc::exists( _data_dir / "db_version" ) )
|
||||||
|
return true;
|
||||||
|
std::string version_str;
|
||||||
|
fc::read_file_contents( _data_dir / "db_version", version_str );
|
||||||
|
return (version_str != GRAPHENE_CURRENT_DB_VERSION);
|
||||||
|
};
|
||||||
|
if( !is_new() && is_outdated() )
|
||||||
|
{
|
||||||
|
ilog("Replaying blockchain due to version upgrade");
|
||||||
|
|
||||||
|
fc::remove_all( _data_dir / "db_version" );
|
||||||
|
_chain_db->reindex(_data_dir / "blockchain", initial_state());
|
||||||
|
|
||||||
|
// doing this down here helps ensure that DB will be wiped
|
||||||
|
// if any of the above steps were interrupted on a previous run
|
||||||
|
if( !fc::exists( _data_dir / "db_version" ) )
|
||||||
|
{
|
||||||
|
std::ofstream db_version(
|
||||||
|
(_data_dir / "db_version").generic_string().c_str(),
|
||||||
|
std::ios::out | std::ios::binary | std::ios::trunc );
|
||||||
|
std::string version_string = GRAPHENE_CURRENT_DB_VERSION;
|
||||||
|
db_version.write( version_string.c_str(), version_string.size() );
|
||||||
|
db_version.close();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_chain_db->open(_data_dir / "blockchain", initial_state);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
wlog("Detected unclean shutdown. Replaying blockchain...");
|
wlog("Detected unclean shutdown. Replaying blockchain...");
|
||||||
_chain_db->reindex(_data_dir / "blockchain", initial_state());
|
_chain_db->reindex(_data_dir / "blockchain", initial_state());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,17 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o
|
||||||
auto asset_symbol_itr = asset_indx.find( op.symbol );
|
auto asset_symbol_itr = asset_indx.find( op.symbol );
|
||||||
FC_ASSERT( asset_symbol_itr == asset_indx.end() );
|
FC_ASSERT( asset_symbol_itr == asset_indx.end() );
|
||||||
|
|
||||||
|
auto dotpos = op.symbol.find( '.' );
|
||||||
|
if( dotpos != std::string::npos ) {
|
||||||
|
auto prefix = op.symbol.substr( 0, dotpos );
|
||||||
|
auto asset_symbol_itr = asset_indx.find( op.symbol );
|
||||||
|
FC_ASSERT( asset_symbol_itr != asset_indx.end(), "Asset ${s} may only be created by issuer of ${p}, but ${p} has not been registered",
|
||||||
|
("s",op.symbol)("p",prefix) );
|
||||||
|
FC_ASSERT( asset_symbol_itr->issuer == op.issuer, "Asset ${s} may only be created by issuer of ${p}, ${i}",
|
||||||
|
("s",op.symbol)("p",prefix)("i", op.issuer(d).name) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
core_fee_paid -= core_fee_paid.value/2;
|
core_fee_paid -= core_fee_paid.value/2;
|
||||||
|
|
||||||
if( op.bitasset_opts )
|
if( op.bitasset_opts )
|
||||||
|
|
|
||||||
|
|
@ -398,7 +398,6 @@ void database::pop_block()
|
||||||
{ try {
|
{ try {
|
||||||
_pending_tx_session.reset();
|
_pending_tx_session.reset();
|
||||||
auto head_id = head_block_id();
|
auto head_id = head_block_id();
|
||||||
idump((head_id)(head_block_num()));
|
|
||||||
optional<signed_block> head_block = fetch_block_by_id( head_id );
|
optional<signed_block> head_block = fetch_block_by_id( head_id );
|
||||||
GRAPHENE_ASSERT( head_block.valid(), pop_empty_chain, "there are no blocks to pop" );
|
GRAPHENE_ASSERT( head_block.valid(), pop_empty_chain, "there are no blocks to pop" );
|
||||||
pop_undo();
|
pop_undo();
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,6 @@ void database::debug_dump()
|
||||||
edump( (total_balances[asset_id_type()].value)(core_asset_data.current_supply.value ));
|
edump( (total_balances[asset_id_type()].value)(core_asset_data.current_supply.value ));
|
||||||
}
|
}
|
||||||
|
|
||||||
edump((core_in_orders)(reported_core_in_orders));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
const auto& vbidx = db.get_index_type<simple_index<vesting_balance_object>>();
|
const auto& vbidx = db.get_index_type<simple_index<vesting_balance_object>>();
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE( call_order_update_test )
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
ACTORS((dan)(sam));
|
ACTORS((dan)(sam));
|
||||||
const auto& bitusd = create_bitasset("BITUSD", sam.id);
|
const auto& bitusd = create_bitasset("USDBIT", sam.id);
|
||||||
const auto& core = asset_id_type()(db);
|
const auto& core = asset_id_type()(db);
|
||||||
|
|
||||||
transfer(committee_account, dan_id, asset(10000000));
|
transfer(committee_account, dan_id, asset(10000000));
|
||||||
|
|
@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE( margin_call_limit_test )
|
||||||
{ try {
|
{ try {
|
||||||
ACTORS((buyer)(seller)(borrower)(borrower2)(feedproducer));
|
ACTORS((buyer)(seller)(borrower)(borrower2)(feedproducer));
|
||||||
|
|
||||||
const auto& bitusd = create_bitasset("BITUSD", feedproducer_id);
|
const auto& bitusd = create_bitasset("USDBIT", feedproducer_id);
|
||||||
const auto& core = asset_id_type()(db);
|
const auto& core = asset_id_type()(db);
|
||||||
|
|
||||||
int64_t init_balance(1000000);
|
int64_t init_balance(1000000);
|
||||||
|
|
@ -222,7 +222,7 @@ BOOST_AUTO_TEST_CASE( black_swan )
|
||||||
{ try {
|
{ try {
|
||||||
ACTORS((buyer)(seller)(borrower)(borrower2)(feedproducer));
|
ACTORS((buyer)(seller)(borrower)(borrower2)(feedproducer));
|
||||||
|
|
||||||
const auto& bitusd = create_bitasset("BITUSD", feedproducer_id);
|
const auto& bitusd = create_bitasset("USDBIT", feedproducer_id);
|
||||||
const auto& core = asset_id_type()(db);
|
const auto& core = asset_id_type()(db);
|
||||||
|
|
||||||
int64_t init_balance(1000000);
|
int64_t init_balance(1000000);
|
||||||
|
|
@ -294,7 +294,7 @@ BOOST_AUTO_TEST_CASE( black_swan_issue_346 )
|
||||||
|
|
||||||
auto setup_asset = [&]() -> const asset_object&
|
auto setup_asset = [&]() -> const asset_object&
|
||||||
{
|
{
|
||||||
const asset_object& bitusd = create_bitasset("BITUSD"+fc::to_string(trial)+"X", feeder_id);
|
const asset_object& bitusd = create_bitasset("USDBIT"+fc::to_string(trial)+"X", feeder_id);
|
||||||
update_feed_producers( bitusd, {feeder.id} );
|
update_feed_producers( bitusd, {feeder.id} );
|
||||||
BOOST_CHECK( !bitusd.bitasset_data(db).has_settlement() );
|
BOOST_CHECK( !bitusd.bitasset_data(db).has_settlement() );
|
||||||
trial++;
|
trial++;
|
||||||
|
|
@ -319,6 +319,7 @@ BOOST_AUTO_TEST_CASE( black_swan_issue_346 )
|
||||||
{
|
{
|
||||||
price_feed feed;
|
price_feed feed;
|
||||||
feed.settlement_price = settlement_price;
|
feed.settlement_price = settlement_price;
|
||||||
|
feed.core_exchange_rate = settlement_price;
|
||||||
wdump( (feed.max_short_squeeze_price()) );
|
wdump( (feed.max_short_squeeze_price()) );
|
||||||
publish_feed( bitusd, feeder, feed );
|
publish_feed( bitusd, feeder, feed );
|
||||||
};
|
};
|
||||||
|
|
@ -599,11 +600,11 @@ BOOST_AUTO_TEST_CASE( create_committee_member )
|
||||||
BOOST_AUTO_TEST_CASE( create_mia )
|
BOOST_AUTO_TEST_CASE( create_mia )
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
const asset_object& bitusd = create_bitasset( "BITUSD" );
|
const asset_object& bitusd = create_bitasset( "USDBIT" );
|
||||||
BOOST_CHECK(bitusd.symbol == "BITUSD");
|
BOOST_CHECK(bitusd.symbol == "USDBIT");
|
||||||
BOOST_CHECK(bitusd.bitasset_data(db).options.short_backing_asset == asset_id_type());
|
BOOST_CHECK(bitusd.bitasset_data(db).options.short_backing_asset == asset_id_type());
|
||||||
BOOST_CHECK(bitusd.dynamic_asset_data_id(db).current_supply == 0);
|
BOOST_CHECK(bitusd.dynamic_asset_data_id(db).current_supply == 0);
|
||||||
GRAPHENE_REQUIRE_THROW( create_bitasset("BITUSD"), fc::exception);
|
GRAPHENE_REQUIRE_THROW( create_bitasset("USDBIT"), fc::exception);
|
||||||
} catch ( const fc::exception& e ) {
|
} catch ( const fc::exception& e ) {
|
||||||
elog( "${e}", ("e", e.to_detail_string() ) );
|
elog( "${e}", ("e", e.to_detail_string() ) );
|
||||||
throw;
|
throw;
|
||||||
|
|
@ -615,7 +616,7 @@ BOOST_AUTO_TEST_CASE( update_mia )
|
||||||
try {
|
try {
|
||||||
INVOKE(create_mia);
|
INVOKE(create_mia);
|
||||||
generate_block();
|
generate_block();
|
||||||
const asset_object& bit_usd = get_asset("BITUSD");
|
const asset_object& bit_usd = get_asset("USDBIT");
|
||||||
|
|
||||||
asset_update_operation op;
|
asset_update_operation op;
|
||||||
op.issuer = bit_usd.issuer;
|
op.issuer = bit_usd.issuer;
|
||||||
|
|
@ -1123,7 +1124,7 @@ BOOST_AUTO_TEST_CASE( witness_feeds )
|
||||||
try {
|
try {
|
||||||
INVOKE( create_mia );
|
INVOKE( create_mia );
|
||||||
{
|
{
|
||||||
auto& current = get_asset( "BITUSD" );
|
auto& current = get_asset( "USDBIT" );
|
||||||
asset_update_operation uop;
|
asset_update_operation uop;
|
||||||
uop.issuer = current.issuer;
|
uop.issuer = current.issuer;
|
||||||
uop.asset_to_update = current.id;
|
uop.asset_to_update = current.id;
|
||||||
|
|
@ -1134,7 +1135,7 @@ BOOST_AUTO_TEST_CASE( witness_feeds )
|
||||||
trx.clear();
|
trx.clear();
|
||||||
}
|
}
|
||||||
generate_block();
|
generate_block();
|
||||||
const asset_object& bit_usd = get_asset("BITUSD");
|
const asset_object& bit_usd = get_asset("USDBIT");
|
||||||
auto& global_props = db.get_global_properties();
|
auto& global_props = db.get_global_properties();
|
||||||
const vector<account_id_type> active_witnesses(global_props.witness_accounts.begin(),
|
const vector<account_id_type> active_witnesses(global_props.witness_accounts.begin(),
|
||||||
global_props.witness_accounts.end());
|
global_props.witness_accounts.end());
|
||||||
|
|
@ -1369,7 +1370,7 @@ BOOST_AUTO_TEST_CASE( reserve_asset_test )
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ACTORS((alice)(bob)(sam)(judge));
|
ACTORS((alice)(bob)(sam)(judge));
|
||||||
const auto& basset = create_bitasset("BITUSD", judge_id);
|
const auto& basset = create_bitasset("USDBIT", judge_id);
|
||||||
const auto& uasset = create_user_issued_asset("TEST");
|
const auto& uasset = create_user_issued_asset("TEST");
|
||||||
const auto& passet = create_prediction_market("PMARK", judge_id);
|
const auto& passet = create_prediction_market("PMARK", judge_id);
|
||||||
const auto& casset = asset_id_type()(db);
|
const auto& casset = asset_id_type()(db);
|
||||||
|
|
@ -1454,7 +1455,7 @@ BOOST_AUTO_TEST_CASE( cover_with_collateral_test )
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ACTORS((alice)(bob)(sam));
|
ACTORS((alice)(bob)(sam));
|
||||||
const auto& bitusd = create_bitasset("BITUSD", sam_id);
|
const auto& bitusd = create_bitasset("USDBIT", sam_id);
|
||||||
const auto& core = asset_id_type()(db);
|
const auto& core = asset_id_type()(db);
|
||||||
|
|
||||||
BOOST_TEST_MESSAGE( "Setting price feed to $0.02 / 100" );
|
BOOST_TEST_MESSAGE( "Setting price feed to $0.02 / 100" );
|
||||||
|
|
|
||||||
|
|
@ -313,7 +313,7 @@ BOOST_AUTO_TEST_CASE( withdraw_permission_delete )
|
||||||
BOOST_AUTO_TEST_CASE( mia_feeds )
|
BOOST_AUTO_TEST_CASE( mia_feeds )
|
||||||
{ try {
|
{ try {
|
||||||
ACTORS((nathan)(dan)(ben)(vikram));
|
ACTORS((nathan)(dan)(ben)(vikram));
|
||||||
asset_id_type bit_usd_id = create_bitasset("BITUSD").id;
|
asset_id_type bit_usd_id = create_bitasset("USDBIT").id;
|
||||||
|
|
||||||
{
|
{
|
||||||
asset_update_operation op;
|
asset_update_operation op;
|
||||||
|
|
@ -385,7 +385,7 @@ BOOST_AUTO_TEST_CASE( mia_feeds )
|
||||||
BOOST_AUTO_TEST_CASE( feed_limit_test )
|
BOOST_AUTO_TEST_CASE( feed_limit_test )
|
||||||
{ try {
|
{ try {
|
||||||
INVOKE( mia_feeds );
|
INVOKE( mia_feeds );
|
||||||
const asset_object& bit_usd = get_asset("BITUSD");
|
const asset_object& bit_usd = get_asset("USDBIT");
|
||||||
const asset_bitasset_data_object& bitasset = bit_usd.bitasset_data(db);
|
const asset_bitasset_data_object& bitasset = bit_usd.bitasset_data(db);
|
||||||
GET_ACTOR(nathan);
|
GET_ACTOR(nathan);
|
||||||
|
|
||||||
|
|
@ -472,7 +472,7 @@ BOOST_AUTO_TEST_CASE( global_settle_test )
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
ACTORS((nathan)(ben)(valentine)(dan));
|
ACTORS((nathan)(ben)(valentine)(dan));
|
||||||
asset_id_type bit_usd_id = create_bitasset("BITUSD", nathan_id, 100, global_settle | charge_market_fee).get_id();
|
asset_id_type bit_usd_id = create_bitasset("USDBIT", nathan_id, 100, global_settle | charge_market_fee).get_id();
|
||||||
|
|
||||||
update_feed_producers( bit_usd_id(db), { nathan_id } );
|
update_feed_producers( bit_usd_id(db), { nathan_id } );
|
||||||
|
|
||||||
|
|
@ -829,7 +829,7 @@ BOOST_AUTO_TEST_CASE( force_settle_test )
|
||||||
transfer(account_id_type()(db), shorter5_id(db), asset(initial_balance));
|
transfer(account_id_type()(db), shorter5_id(db), asset(initial_balance));
|
||||||
|
|
||||||
asset_id_type bitusd_id = create_bitasset(
|
asset_id_type bitusd_id = create_bitasset(
|
||||||
"BITUSD",
|
"USDBIT",
|
||||||
nathan_id,
|
nathan_id,
|
||||||
100,
|
100,
|
||||||
disable_force_settle
|
disable_force_settle
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue