diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index 237dc0c7b0..20ec10ea35 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -3405,6 +3405,7 @@ void database::update_global_dynamic_data( const signed_block& b ) modify( witness_missed, [&]( witness_object& w ) { + w.current_run = 0; if( witness_missed.owner != b.witness ) { // @@ -3490,6 +3491,9 @@ void database::update_signing_witness(const witness_object& signing_witness, con { _wit.last_aslot = new_block_aslot; _wit.last_confirmed_block_num = new_block.block_num(); + if( _wit.current_run >= STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN ) + _wit.last_supported_block_num = _wit.last_confirmed_block_num; + _wit.current_run++; } ); } FC_CAPTURE_AND_RETHROW() } @@ -3532,10 +3536,10 @@ void database::update_last_irreversible_block() std::nth_element( wit_objs.begin(), wit_objs.begin() + offset, wit_objs.end(), []( const witness_object* a, const witness_object* b ) { - return a->last_confirmed_block_num < b->last_confirmed_block_num; + return a->last_supported_block_num < b->last_supported_block_num; } ); - uint32_t new_last_irreversible_block_num = wit_objs[offset]->last_confirmed_block_num; + uint32_t new_last_irreversible_block_num = wit_objs[offset]->last_supported_block_num; if( new_last_irreversible_block_num > dpo.last_irreversible_block_num ) { diff --git a/libraries/chain/include/steem/chain/witness_objects.hpp b/libraries/chain/include/steem/chain/witness_objects.hpp index 62bfe73dd2..28e5c448c3 100644 --- a/libraries/chain/include/steem/chain/witness_objects.hpp +++ b/libraries/chain/include/steem/chain/witness_objects.hpp @@ -76,6 +76,10 @@ namespace steem { namespace chain { uint32_t total_missed = 0; uint64_t last_aslot = 0; uint64_t last_confirmed_block_num = 0; + /** Number of blocks produced since beginning of time or last missed block */ + uint64_t current_run = 0; + /** Last block produced when current_run >= STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN */ + uint64_t last_supported_block_num = 0; /** * Some witnesses have the job because they did a proof of work, @@ -272,7 +276,8 @@ FC_REFLECT( steem::chain::witness_object, (owner) (created) (url)(votes)(schedule)(virtual_last_update)(virtual_position)(virtual_scheduled_time)(total_missed) - (last_aslot)(last_confirmed_block_num)(pow_worker)(signing_key) + (last_aslot)(last_confirmed_block_num)(current_run)(last_supported_block_num) + (pow_worker)(signing_key) (props) (sbd_exchange_rate)(last_sbd_exchange_update) (last_work) diff --git a/libraries/protocol/get_config.cpp b/libraries/protocol/get_config.cpp index 179c5b4e32..033647bc1c 100644 --- a/libraries/protocol/get_config.cpp +++ b/libraries/protocol/get_config.cpp @@ -85,6 +85,7 @@ fc::variant_object get_config() #endif result["STEEM_INIT_SUPPLY"] = STEEM_INIT_SUPPLY; result["STEEM_INIT_TIME"] = STEEM_INIT_TIME; + result["STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN"] = STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN; result["STEEM_IRREVERSIBLE_THRESHOLD"] = STEEM_IRREVERSIBLE_THRESHOLD; result["STEEM_LIQUIDITY_APR_PERCENT"] = STEEM_LIQUIDITY_APR_PERCENT; result["STEEM_LIQUIDITY_REWARD_BLOCKS"] = STEEM_LIQUIDITY_REWARD_BLOCKS; diff --git a/libraries/protocol/include/steem/protocol/config.hpp b/libraries/protocol/include/steem/protocol/config.hpp index 3c48d9d376..8396bf1e6a 100644 --- a/libraries/protocol/include/steem/protocol/config.hpp +++ b/libraries/protocol/include/steem/protocol/config.hpp @@ -253,6 +253,8 @@ #define STEEM_MAX_URL_LENGTH 127 #define STEEM_IRREVERSIBLE_THRESHOLD (75 * STEEM_1_PERCENT) +/** Irreversibility only counts blocks produced if wit.current_run >= STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN */ +#define STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN 2 #define STEEM_VIRTUAL_SCHEDULE_LAP_LENGTH ( fc::uint128(uint64_t(-1)) ) #define STEEM_VIRTUAL_SCHEDULE_LAP_LENGTH2 ( fc::uint128::max_value() )