Skip to content

Commit b02731c

Browse files
For LIB, only count witnesses who didn't miss their last two blocks #2471
1 parent 75713e7 commit b02731c

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

libraries/chain/database.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3405,6 +3405,7 @@ void database::update_global_dynamic_data( const signed_block& b )
34053405

34063406
modify( witness_missed, [&]( witness_object& w )
34073407
{
3408+
w.current_run = 0;
34083409
w.total_missed++;
34093410
if( (_dgp.head_block_number - w.last_confirmed_block_num > STEEM_BLOCKS_PER_DAY)
34103411
&& (witness_missed.owner != b.witness)
@@ -3480,6 +3481,9 @@ void database::update_signing_witness(const witness_object& signing_witness, con
34803481
{
34813482
_wit.last_aslot = new_block_aslot;
34823483
_wit.last_confirmed_block_num = new_block.block_num();
3484+
if( _wit.current_run >= STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN )
3485+
_wit.last_supported_block_num = _wit.last_confirmed_block_num;
3486+
_wit.current_run++;
34833487
} );
34843488
} FC_CAPTURE_AND_RETHROW() }
34853489

@@ -3522,10 +3526,10 @@ void database::update_last_irreversible_block()
35223526
std::nth_element( wit_objs.begin(), wit_objs.begin() + offset, wit_objs.end(),
35233527
[]( const witness_object* a, const witness_object* b )
35243528
{
3525-
return a->last_confirmed_block_num < b->last_confirmed_block_num;
3529+
return a->last_supported_block_num < b->last_supported_block_num;
35263530
} );
35273531

3528-
uint32_t new_last_irreversible_block_num = wit_objs[offset]->last_confirmed_block_num;
3532+
uint32_t new_last_irreversible_block_num = wit_objs[offset]->last_supported_block_num;
35293533

35303534
if( new_last_irreversible_block_num > dpo.last_irreversible_block_num )
35313535
{

libraries/chain/include/steem/chain/witness_objects.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ namespace steem { namespace chain {
7676
uint32_t total_missed = 0;
7777
uint64_t last_aslot = 0;
7878
uint64_t last_confirmed_block_num = 0;
79+
/** Number of blocks produced since beginning of time or last missed block */
80+
uint64_t current_run = 0;
81+
/** Last block produced when current_run >= STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN */
82+
uint64_t last_supported_block_num = 0;
7983

8084
/**
8185
* Some witnesses have the job because they did a proof of work,
@@ -272,7 +276,8 @@ FC_REFLECT( steem::chain::witness_object,
272276
(owner)
273277
(created)
274278
(url)(votes)(schedule)(virtual_last_update)(virtual_position)(virtual_scheduled_time)(total_missed)
275-
(last_aslot)(last_confirmed_block_num)(pow_worker)(signing_key)
279+
(last_aslot)(last_confirmed_block_num)(current_run)(last_supported_block_num)
280+
(pow_worker)(signing_key)
276281
(props)
277282
(sbd_exchange_rate)(last_sbd_exchange_update)
278283
(last_work)

libraries/protocol/get_config.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ fc::variant_object get_config()
8585
#endif
8686
result["STEEM_INIT_SUPPLY"] = STEEM_INIT_SUPPLY;
8787
result["STEEM_INIT_TIME"] = STEEM_INIT_TIME;
88+
result["STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN"] = STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN;
8889
result["STEEM_IRREVERSIBLE_THRESHOLD"] = STEEM_IRREVERSIBLE_THRESHOLD;
8990
result["STEEM_LIQUIDITY_APR_PERCENT"] = STEEM_LIQUIDITY_APR_PERCENT;
9091
result["STEEM_LIQUIDITY_REWARD_BLOCKS"] = STEEM_LIQUIDITY_REWARD_BLOCKS;

libraries/protocol/include/steem/protocol/config.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@
253253
#define STEEM_MAX_URL_LENGTH 127
254254

255255
#define STEEM_IRREVERSIBLE_THRESHOLD (75 * STEEM_1_PERCENT)
256+
/** Irreversibility only counts blocks produced if wit.current_run >= STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN */
257+
#define STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN 2
256258

257259
#define STEEM_VIRTUAL_SCHEDULE_LAP_LENGTH ( fc::uint128(uint64_t(-1)) )
258260
#define STEEM_VIRTUAL_SCHEDULE_LAP_LENGTH2 ( fc::uint128::max_value() )

0 commit comments

Comments
 (0)