peerplays-network / peerplays

The Peerplays Blockchain
https://www.peerplays.com
MIT License
34 stars 18 forks source link

Exception when voting for witnesses "May not specify fewer witnesses or committee members than the number voted for." #372

Closed jotprabh1 closed 4 years ago

jotprabh1 commented 4 years ago

image

The below exception is received on the alice even when the num_witness + num_committee is equal to the total number of votes in the account update operation (see above image). Assert Exception: needed_witnesses == 0 && needed_committee == 0: May not specify fewer witnesses or committee members than the number voted for.

sierra19XX commented 4 years ago

num_witness = 10, num_committee = 6 in transaction provided but there are 12 Witness vote ids and 4 Committee vote ids.

Committee vote ids are 0: Witness vote ids are 1:

Validation logic checks for exact match of the num_witness and num_committee provided. Following is the code snippet.

void account_options::validate() const
{
   auto needed_witnesses = num_witness;
   auto needed_committee = num_committee;

   for( vote_id_type id : votes )
      if( id.type() == vote_id_type::witness && needed_witnesses )
         --needed_witnesses;
      else if ( id.type() == vote_id_type::committee && needed_committee )
         --needed_committee;

   FC_ASSERT( needed_witnesses == 0 && needed_committee == 0,
              "May not specify fewer witnesses or committee members than the number voted for.");
}