Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GRPH-64] Fixed committee member update issue #88

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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