Skip to content

Commit ff7b01f

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

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

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
if( witness_missed.owner != b.witness )
34093410
{
34103411
//
@@ -3490,6 +3491,9 @@ void database::update_signing_witness(const witness_object& signing_witness, con
34903491
{
34913492
_wit.last_aslot = new_block_aslot;
34923493
_wit.last_confirmed_block_num = new_block.block_num();
3494+
if( _wit.current_run >= STEEM_IRREVERSIBLE_SUPPORT_MIN_RUN )
3495+
_wit.last_supported_block_num = _wit.last_confirmed_block_num;
3496+
_wit.current_run++;
34933497
} );
34943498
} FC_CAPTURE_AND_RETHROW() }
34953499

@@ -3532,10 +3536,10 @@ void database::update_last_irreversible_block()
35323536
std::nth_element( wit_objs.begin(), wit_objs.begin() + offset, wit_objs.end(),
35333537
[]( const witness_object* a, const witness_object* b )
35343538
{
3535-
return a->last_confirmed_block_num < b->last_confirmed_block_num;
3539+
return a->last_supported_block_num < b->last_supported_block_num;
35363540
} );
35373541

3538-
uint32_t new_last_irreversible_block_num = wit_objs[offset]->last_confirmed_block_num;
3542+
uint32_t new_last_irreversible_block_num = wit_objs[offset]->last_supported_block_num;
35393543

35403544
if( new_last_irreversible_block_num > dpo.last_irreversible_block_num )
35413545
{

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)