weights for son accounts doesn't match with the votes received #97

Closed
opened 2021-05-12 12:30:58 +00:00 by prandnum · 14 comments
prandnum commented 2021-05-12 12:30:58 +00:00 (Migrated from gitlab.com)

Issue Seen:

Votes:
sonaccount03 - 4000
sonaccount06 - 6000
sonaccount12 - 10000
sonaccount14 - 14000

I see that the weights assigned to sons are

sonaccount03 - 48828
sonaccount06 - 36621
sonaccount12 - 61035

Which is strange, I expect the weight of sonaccount06 to be more than sonaccount03

For more details refer: logs.txt

Issue Seen: Votes: sonaccount03 - 4000 sonaccount06 - 6000 sonaccount12 - 10000 sonaccount14 - 14000 I see that the weights assigned to sons are sonaccount03 - 48828 sonaccount06 - 36621 sonaccount12 - 61035 Which is strange, I expect the weight of sonaccount06 to be more than sonaccount03 For more details refer: [logs.txt](/uploads/1fd9a439f3a8f6f44c7eef2f57ee67f9/logs.txt)
prandnum commented 2021-05-12 12:31:25 +00:00 (Migrated from gitlab.com)

@bobinson @sierra19XX @serkixenos

CC: @hbelakon

@bobinson @sierra19XX @serkixenos CC: @hbelakon
prandnum commented 2021-05-12 12:31:55 +00:00 (Migrated from gitlab.com)

mentioned in issue #89

mentioned in issue #89
sierra19XX commented 2021-05-14 13:08:28 +00:00 (Migrated from gitlab.com)

changed time estimate to 24h

changed time estimate to 24h
sierra19XX commented 2021-05-18 12:07:57 +00:00 (Migrated from gitlab.com)

assigned to @bobinson and unassigned @sierra19XX

assigned to @bobinson and unassigned @sierra19XX
sierra19XX commented 2021-05-18 12:21:04 +00:00 (Migrated from gitlab.com)
https://gitlab.com/PBSA/peerplays/-/merge_requests/20
sierra19XX commented 2021-05-18 14:23:52 +00:00 (Migrated from gitlab.com)

changed time estimate to 8h

changed time estimate to 8h
prandnum commented 2021-05-18 17:23:20 +00:00 (Migrated from gitlab.com)

@sierra19XX In addition to the bug scenario, please let me know if there is any other scenario to be covered while verifying the bug.

Note: It would be good if you could document the weights calculation logic.

@sierra19XX In addition to the bug scenario, please let me know if there is any other scenario to be covered while verifying the bug. Note: It would be good if you could document the weights calculation logic.
sierra19XX commented 2021-05-20 10:39:04 +00:00 (Migrated from gitlab.com)

@prandnum Along with the weights test case, you can also check issue #71 on the private test.

I can point you to the weight calculation logic of sons.

// total_votes is 64 bits. Subtract the number of leading low bits from 64 to get the number of useful bits,
         // then I want to keep the most significant 16 bits of what's left.
         int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(total_votes)) - 15, 0);
         for( const auto& weight : weights )
         {
            // Ensure that everyone has at least one vote. Zero weights aren't allowed.
            uint16_t votes = std::max((weight.second >> bits_to_drop), uint64_t(1) );
            a.active.account_auths[weight.first] += votes;
            a.active.weight_threshold += votes;
         }
@prandnum Along with the weights test case, you can also check issue #71 on the private test. I can point you to the weight calculation logic of sons. ``` // total_votes is 64 bits. Subtract the number of leading low bits from 64 to get the number of useful bits, // then I want to keep the most significant 16 bits of what's left. int8_t bits_to_drop = std::max(int(boost::multiprecision::detail::find_msb(total_votes)) - 15, 0); for( const auto& weight : weights ) { // Ensure that everyone has at least one vote. Zero weights aren't allowed. uint16_t votes = std::max((weight.second >> bits_to_drop), uint64_t(1) ); a.active.account_auths[weight.first] += votes; a.active.weight_threshold += votes; } ```
prandnum commented 2021-05-22 18:57:43 +00:00 (Migrated from gitlab.com)

Test1:

2021-05-22T16:10:00.000 th_a:Witness Block Production  maybe_produce_block ] slot: 1 scheduled_witness: 1.6.8 scheduled_time: 2021-05-22T16:10:00 now: 2021-05-22T16:10:00                      witness.cpp:267
2021-05-22T16:10:00.001 th_a:Witness Block Production process_dividend_ass ] In process_dividend_assets time 2021-05-22T16:10:00                        db_maint.cpp:1725
2021-05-22T16:10:00.313 th_a:Witness Block Production           operator() ] son_id = 1.33.4, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436                       db_maint.cpp:224
2021-05-22T16:10:00.313 th_a:Witness Block Production           operator() ] son_id = 1.33.5, txs_signed = 1, son_weight = 9155, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 3999301                        db_maint.cpp:224
2021-05-22T16:10:00.313 th_a:Witness Block Production           operator() ] son_id = 1.33.6, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436                       db_maint.cpp:224
2021-05-22T16:10:00.313 th_a:Witness Block Production           operator() ] son_id = 1.33.7, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436                       db_maint.cpp:224
2021-05-22T16:10:00.314 th_a:Witness Block Production           operator() ] son_id = 1.33.8, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436                       db_maint.cpp:224
2021-05-22T16:10:00.314 th_a:Witness Block Production           operator() ] son_id = 1.33.9, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436                       db_maint.cpp:224
2021-05-22T16:10:00.314 th_a:Witness Block Production           operator() ] son_id = 1.33.10, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436                      db_maint.cpp:224
2021-05-22T16:10:00.314 th_a:Witness Block Production           operator() ] son_id = 1.33.11, txs_signed = 1, son_weight = 15258, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 6665356                      db_maint.cpp:224
2021-05-22T16:10:00.315 th_a:Witness Block Production           operator() ] son_id = 1.33.12, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436                      db_maint.cpp:224
2021-05-22T16:10:00.315 th_a:Witness Block Production           operator() ] son_id = 1.33.13, txs_signed = 1, son_weight = 21362, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 9331848                      db_maint.cpp:224
2021-05-22T16:10:00.315 th_a:Witness Block Production           operator() ] son_id = 1.33.14, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436                      db_maint.cpp:224
2021-05-22T16:10:00.317 th_a:Witness Block Production   update_active_sons ] Active SONs set NOT CHANGED                        db_maint.cpp:749
2021-05-22T16:10:00.318 th_a:Witness Block Production block_production_loo ] Generated block #318905 with timestamp 2021-05-22T16:10:00 at time 2021-05-22T16:10:00                     witness.cpp:192
2021-05-22T16:10:00.818   th_a:SON Processing       son_processing ] Scheduled SON: 1.33.6 Now: 2021-05-22T16:10:01                     peerplays_sidechain_plugin.cpp:401
Test1: ``` 2021-05-22T16:10:00.000 th_a:Witness Block Production maybe_produce_block ] slot: 1 scheduled_witness: 1.6.8 scheduled_time: 2021-05-22T16:10:00 now: 2021-05-22T16:10:00 witness.cpp:267 2021-05-22T16:10:00.001 th_a:Witness Block Production process_dividend_ass ] In process_dividend_assets time 2021-05-22T16:10:00 db_maint.cpp:1725 2021-05-22T16:10:00.313 th_a:Witness Block Production operator() ] son_id = 1.33.4, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436 db_maint.cpp:224 2021-05-22T16:10:00.313 th_a:Witness Block Production operator() ] son_id = 1.33.5, txs_signed = 1, son_weight = 9155, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 3999301 db_maint.cpp:224 2021-05-22T16:10:00.313 th_a:Witness Block Production operator() ] son_id = 1.33.6, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436 db_maint.cpp:224 2021-05-22T16:10:00.313 th_a:Witness Block Production operator() ] son_id = 1.33.7, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436 db_maint.cpp:224 2021-05-22T16:10:00.314 th_a:Witness Block Production operator() ] son_id = 1.33.8, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436 db_maint.cpp:224 2021-05-22T16:10:00.314 th_a:Witness Block Production operator() ] son_id = 1.33.9, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436 db_maint.cpp:224 2021-05-22T16:10:00.314 th_a:Witness Block Production operator() ] son_id = 1.33.10, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436 db_maint.cpp:224 2021-05-22T16:10:00.314 th_a:Witness Block Production operator() ] son_id = 1.33.11, txs_signed = 1, son_weight = 15258, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 6665356 db_maint.cpp:224 2021-05-22T16:10:00.315 th_a:Witness Block Production operator() ] son_id = 1.33.12, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436 db_maint.cpp:224 2021-05-22T16:10:00.315 th_a:Witness Block Production operator() ] son_id = 1.33.13, txs_signed = 1, son_weight = 21362, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 9331848 db_maint.cpp:224 2021-05-22T16:10:00.315 th_a:Witness Block Production operator() ] son_id = 1.33.14, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 45783, pay = 436 db_maint.cpp:224 2021-05-22T16:10:00.317 th_a:Witness Block Production update_active_sons ] Active SONs set NOT CHANGED db_maint.cpp:749 2021-05-22T16:10:00.318 th_a:Witness Block Production block_production_loo ] Generated block #318905 with timestamp 2021-05-22T16:10:00 at time 2021-05-22T16:10:00 witness.cpp:192 2021-05-22T16:10:00.818 th_a:SON Processing son_processing ] Scheduled SON: 1.33.6 Now: 2021-05-22T16:10:01 peerplays_sidechain_plugin.cpp:401 ```
prandnum commented 2021-05-22 19:15:36 +00:00 (Migrated from gitlab.com)

Test2:

2021-05-22T19:09:57.501   th_a:SON Processing       son_processing ] Scheduled SON: 1.33.10 Now: 2021-05-22T19:09:58                    peerplays_sidechain_plugin.cpp:401
2021-05-22T19:10:00.000 th_a:Witness Block Production  maybe_produce_block ] slot: 1 scheduled_witness: 1.6.1 scheduled_time: 2021-05-22T19:10:00 now: 2021-05-22T19:10:00                      witness.cpp:267
2021-05-22T19:10:00.001 th_a:Witness Block Production process_dividend_ass ] In process_dividend_assets time 2021-05-22T19:10:00                        db_maint.cpp:1725
2021-05-22T19:10:00.315 th_a:Witness Block Production           operator() ] son_id = 1.33.0, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310                      db_maint.cpp:224
2021-05-22T19:10:00.315 th_a:Witness Block Production           operator() ] son_id = 1.33.1, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310                      db_maint.cpp:224
2021-05-22T19:10:00.315 th_a:Witness Block Production           operator() ] son_id = 1.33.2, txs_signed = 1, son_weight = 6103, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 7995021                        db_maint.cpp:224
2021-05-22T19:10:00.315 th_a:Witness Block Production           operator() ] son_id = 1.33.3, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310                      db_maint.cpp:224
2021-05-22T19:10:00.316 th_a:Witness Block Production           operator() ] son_id = 1.33.4, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310                      db_maint.cpp:224
2021-05-22T19:10:00.316 th_a:Witness Block Production           operator() ] son_id = 1.33.5, txs_signed = 1, son_weight = 9155, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 11993187                       db_maint.cpp:224
2021-05-22T19:10:00.316 th_a:Witness Block Production           operator() ] son_id = 1.33.6, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310                      db_maint.cpp:224
2021-05-22T19:10:00.316 th_a:Witness Block Production           operator() ] son_id = 1.33.7, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310                      db_maint.cpp:224
2021-05-22T19:10:00.316 th_a:Witness Block Production           operator() ] son_id = 1.33.8, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310                      db_maint.cpp:224
2021-05-22T19:10:00.316 th_a:Witness Block Production           operator() ] son_id = 1.33.9, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310                      db_maint.cpp:224
2021-05-22T19:10:00.317 th_a:Witness Block Production           operator() ] son_id = 1.33.14, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310                     db_maint.cpp:224
2021-05-22T19:10:00.319 th_a:Witness Block Production   update_active_sons ] Active SONs set NOT CHANGED                        db_maint.cpp:749
2021-05-22T19:10:00.320 th_a:Witness Block Production block_production_loo ] Generated block #322451 with timestamp 2021-05-22T19:10:00 at time 2021-05-22T19:10:00                     witness.cpp:192
2021-05-22T19:10:00.820   th_a:SON Processing       son_processing ] Scheduled SON: 1.33.0 Now: 2021-05-22T19:10:01                     peerplays_sidechain_plugin.cpp:401
2021-05-22T19:10:12.000 th_a:Witness Block Production  maybe_produce_block ] slot: 1 scheduled_witness: 1.6.7 scheduled_time: 2021-05-22T19:10:12 now: 2021-05-22T19:10:12                      witness.cpp:267
2021-05-22T19:10:12.001 th_a:Witness Block Production block_production_loo ] Generated block #322452 with timestamp 2021-05-22T19:10:12 at time 2021-05-22T19:10:12                     witness.cpp:192
2021-05-22T19:10:12.501   th_a:SON Processing       son_processing ] Scheduled SON: 1.33.11 Now: 2021-05-22T19:10:13                    peerplays_sidechain_plugin.cpp:401
2021-05-22T19:10:15.000 th_a:Witness Block Production  maybe_produce_block ] slot: 1 scheduled_witness: 1.6.9 scheduled_time: 2021-05-22T19:10:15 now: 2021-05-22T19:10:15                      witness.cpp:267
2021-05-22T19:10:15.001 th_a:Witness Block Production block_production_loo ] Generated block #322453 with timestamp 2021-05-22T19:10:15 at time 2021-05-22T19:10:15                     witness.cpp:192
2021-05-22T19:10:15.501   th_a:SON Processing       son_processing ] Scheduled SON: 1.33.2 Now: 2021-05-22T19:10:16                     peerplays_sidechain_plugin.cpp:401
Test2: ``` 2021-05-22T19:09:57.501 th_a:SON Processing son_processing ] Scheduled SON: 1.33.10 Now: 2021-05-22T19:09:58 peerplays_sidechain_plugin.cpp:401 2021-05-22T19:10:00.000 th_a:Witness Block Production maybe_produce_block ] slot: 1 scheduled_witness: 1.6.1 scheduled_time: 2021-05-22T19:10:00 now: 2021-05-22T19:10:00 witness.cpp:267 2021-05-22T19:10:00.001 th_a:Witness Block Production process_dividend_ass ] In process_dividend_assets time 2021-05-22T19:10:00 db_maint.cpp:1725 2021-05-22T19:10:00.315 th_a:Witness Block Production operator() ] son_id = 1.33.0, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310 db_maint.cpp:224 2021-05-22T19:10:00.315 th_a:Witness Block Production operator() ] son_id = 1.33.1, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310 db_maint.cpp:224 2021-05-22T19:10:00.315 th_a:Witness Block Production operator() ] son_id = 1.33.2, txs_signed = 1, son_weight = 6103, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 7995021 db_maint.cpp:224 2021-05-22T19:10:00.315 th_a:Witness Block Production operator() ] son_id = 1.33.3, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310 db_maint.cpp:224 2021-05-22T19:10:00.316 th_a:Witness Block Production operator() ] son_id = 1.33.4, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310 db_maint.cpp:224 2021-05-22T19:10:00.316 th_a:Witness Block Production operator() ] son_id = 1.33.5, txs_signed = 1, son_weight = 9155, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 11993187 db_maint.cpp:224 2021-05-22T19:10:00.316 th_a:Witness Block Production operator() ] son_id = 1.33.6, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310 db_maint.cpp:224 2021-05-22T19:10:00.316 th_a:Witness Block Production operator() ] son_id = 1.33.7, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310 db_maint.cpp:224 2021-05-22T19:10:00.316 th_a:Witness Block Production operator() ] son_id = 1.33.8, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310 db_maint.cpp:224 2021-05-22T19:10:00.316 th_a:Witness Block Production operator() ] son_id = 1.33.9, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310 db_maint.cpp:224 2021-05-22T19:10:00.317 th_a:Witness Block Production operator() ] son_id = 1.33.14, txs_signed = 1, son_weight = 1, son_budget = 20000000, weighted_total_txs_signed = 15267, pay = 1310 db_maint.cpp:224 2021-05-22T19:10:00.319 th_a:Witness Block Production update_active_sons ] Active SONs set NOT CHANGED db_maint.cpp:749 2021-05-22T19:10:00.320 th_a:Witness Block Production block_production_loo ] Generated block #322451 with timestamp 2021-05-22T19:10:00 at time 2021-05-22T19:10:00 witness.cpp:192 2021-05-22T19:10:00.820 th_a:SON Processing son_processing ] Scheduled SON: 1.33.0 Now: 2021-05-22T19:10:01 peerplays_sidechain_plugin.cpp:401 2021-05-22T19:10:12.000 th_a:Witness Block Production maybe_produce_block ] slot: 1 scheduled_witness: 1.6.7 scheduled_time: 2021-05-22T19:10:12 now: 2021-05-22T19:10:12 witness.cpp:267 2021-05-22T19:10:12.001 th_a:Witness Block Production block_production_loo ] Generated block #322452 with timestamp 2021-05-22T19:10:12 at time 2021-05-22T19:10:12 witness.cpp:192 2021-05-22T19:10:12.501 th_a:SON Processing son_processing ] Scheduled SON: 1.33.11 Now: 2021-05-22T19:10:13 peerplays_sidechain_plugin.cpp:401 2021-05-22T19:10:15.000 th_a:Witness Block Production maybe_produce_block ] slot: 1 scheduled_witness: 1.6.9 scheduled_time: 2021-05-22T19:10:15 now: 2021-05-22T19:10:15 witness.cpp:267 2021-05-22T19:10:15.001 th_a:Witness Block Production block_production_loo ] Generated block #322453 with timestamp 2021-05-22T19:10:15 at time 2021-05-22T19:10:15 witness.cpp:192 2021-05-22T19:10:15.501 th_a:SON Processing son_processing ] Scheduled SON: 1.33.2 Now: 2021-05-22T19:10:16 peerplays_sidechain_plugin.cpp:401 ```
prandnum commented 2021-05-22 19:16:25 +00:00 (Migrated from gitlab.com)

@bobinson @sierra19XX In the local testnet I see that the weights and ultimately payout is proportional to the votes received.

@bobinson @sierra19XX In the local testnet I see that the weights and ultimately payout is proportional to the votes received.
sierra19XX commented 2021-05-25 12:24:13 +00:00 (Migrated from gitlab.com)

@prandnum Looks good to me, proportional weights are expected as seen in the logs. You can close this.

@prandnum Looks good to me, proportional weights are expected as seen in the logs. You can close this.
prandnum commented 2021-05-26 16:10:41 +00:00 (Migrated from gitlab.com)

Thanks. closing the ticket.

Thanks. closing the ticket.
prandnum (Migrated from gitlab.com) closed this issue 2021-05-26 16:10:42 +00:00
sierra19XX commented 2021-07-27 05:00:45 +00:00 (Migrated from gitlab.com)

mentioned in merge request !25

mentioned in merge request !25
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Peerplays_Blockchain/peerplays_migrated#97
No description provided.