Skip to content

Commit

Permalink
Added logging for the old update_expired_feeds bug
Browse files Browse the repository at this point in the history
The old bug is cryptonomex/graphene#615 .

Due to the bug, `update_median_feeds()` and `check_call_orders()`
will be called when a feed is not actually expired, normally this
should not affect consensus since calling them should not change
any data in the state.

However, the logging indicates that `check_call_orders()` did
change some data under certain circumstances, specifically, when
multiple limit order matching issue (#453) occurred at same block.
* bitshares/bitshares-core#453
  • Loading branch information
abitmore authored and gladcow committed Nov 8, 2019
1 parent 2f4830a commit 8a9d3e7
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions libraries/chain/db_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ void database::clear_expired_orders()

void database::update_expired_feeds()
{
const auto head_num = head_block_num();
const auto head_time = head_block_time();
bool before_hf_615 = ( head_time < HARDFORK_615_TIME );
auto& asset_idx = get_index_type<asset_index>().indices().get<by_type>();
auto itr = asset_idx.lower_bound( true /** market issued */ );
while( itr != asset_idx.end() )
Expand All @@ -476,16 +479,21 @@ void database::update_expired_feeds()

const asset_bitasset_data_object& b = a.bitasset_data(*this);
bool feed_is_expired;
if( head_block_time() < HARDFORK_615_TIME )
feed_is_expired = b.feed_is_expired_before_hardfork_615( head_block_time() );
if( before_hf_615 )
feed_is_expired = b.feed_is_expired_before_hardfork_615( head_time );
else
feed_is_expired = b.feed_is_expired( head_block_time() );
feed_is_expired = b.feed_is_expired( head_time );
if( feed_is_expired )
{
modify(b, [this](asset_bitasset_data_object& a) {
a.update_median_feeds(head_block_time());
modify(b, [head_time](asset_bitasset_data_object& a) {
a.update_median_feeds(head_time);
});
check_call_orders(b.current_feed.settlement_price.base.asset_id(*this));
bool called_some = check_call_orders(b.current_feed.settlement_price.base.asset_id(*this));
if( called_some && before_hf_615 )
{
wlog( "Graphene issue #615: called some for asset ${a} on block #${b}, feed really expired: ${f}",
("a", a.symbol) ("b", head_num) ("f", b.feed_is_expired(head_time)) );
}
}
if( !b.current_feed.core_exchange_rate.is_null() &&
a.options.core_exchange_rate != b.current_feed.core_exchange_rate )
Expand Down

0 comments on commit 8a9d3e7

Please sign in to comment.