Skip to content

Commit

Permalink
Fixed committee member update issue
Browse files Browse the repository at this point in the history
  • Loading branch information
srpatel19590 committed Sep 18, 2019
1 parent 96161db commit 00ccd7e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
22 changes: 21 additions & 1 deletion libraries/chain/db_maint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,13 @@ void database::update_active_witnesses()
void database::update_active_committee_members()
{ try {
assert( _committee_count_histogram_buffer.size() > 0 );
share_type stake_target = (_total_voting_stake-_witness_count_histogram_buffer[0]) / 2;
share_type stake_target = (_total_voting_stake-_committee_count_histogram_buffer[0]) / 2;
share_type old_stake_target = (_total_voting_stake-_witness_count_histogram_buffer[0]) / 2;
// TODO
// all the stuff about old_stake_target can *hopefully* be removed after the
// hardfork date has passed
if( stake_target != old_stake_target )
ilog( "Different stake targets: ${old} / ${new}", ("old",old_stake_target)("new",stake_target) );

/// accounts that vote for 0 or 1 witness do not get to express an opinion on
/// the number of witnesses to have (they abstain and are non-voting accounts)
Expand All @@ -264,6 +270,20 @@ void database::update_active_committee_members()
&& (stake_tally <= stake_target) )
stake_tally += _committee_count_histogram_buffer[++committee_member_count];

if( stake_target != old_stake_target && old_stake_target > 0 && head_block_time() < fc::time_point_sec(HARDFORK_1002_TIME) )
{
uint64_t old_stake_tally = 0;
size_t old_committee_member_count = 0;
while( (old_committee_member_count < _committee_count_histogram_buffer.size() - 1)
&& (old_stake_tally <= old_stake_target) )
old_stake_tally += _committee_count_histogram_buffer[++old_committee_member_count];
if( old_committee_member_count != committee_member_count )
{
ilog( "Committee member count mismatch ${old} / ${new}", ("old",old_committee_member_count)("new", committee_member_count) );
committee_member_count = old_committee_member_count;
}
}

const chain_property_object& cpo = get_chain_properties();
auto committee_members = sort_votable_objects<committee_member_index>(std::max(committee_member_count*2+1, (size_t)cpo.immutable_parameters.min_committee_member_count));

Expand Down
4 changes: 4 additions & 0 deletions libraries/chain/hardfork.d/1002.hf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Bug fix of update commitee member update
#ifndef HARDFORK_1002_TIME
#define HARDFORK_1002_TIME (fc::time_point_sec( 1566893013 )) //Tuesday, 27 August 2019 08:03:33 GMT
#endif

0 comments on commit 00ccd7e

Please sign in to comment.