Skip to content

Commit cabf1d6

Browse files
committed
Enhance producer pay calculation by implementing a detailed multiplier system for active and standby producers. The new logic uses an arithmetic sequence to determine share values based on the number of active producers, improving accuracy in reward distribution.
1 parent f0854b0 commit cabf1d6

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

contracts/eosio.system/src/producer_pay.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,27 @@ namespace eosiosystem {
351351
break;
352352
}
353353

354-
// if we don't have standbys (21 active or less), don't attempt to calculate for standbys, just do total activecount X 2
355-
// if we have standbys, do 42 shares for the top 21 plus 1 share per standby, so 42 plus the total activecount minus 21
356-
uint32_t sharecount = activecount <= 21 ? (activecount * 2) : (42 + (activecount - 21));
357-
358-
auto shareValue = (_gstate.perblock_bucket / sharecount);
354+
// the multiplier is applied to the shares, and the shares are then multiplied by the share value
355+
// the share value is the total amount of the perblock bucket divided by the sum of the multipliers
356+
// the sum of the multipliers is the sum of the multipliers for the active producers and the standby producers
357+
// The multipliers for the active producers are 1.2, 1.18, ... , 0.82, 0.8 each multiplied by 2, and for the standby producers are 1.2, 1.18, ... , 0.82, 0.8 each multiplied by 1
358+
// The multipliers forms a arithmetic sequence with a common difference of -0.02
359+
// The sum of arithmetic sequence is given by n/2 * (2 * first term + (n-1) * common difference)
360+
// If activecount <= 21, then the sum of the multipliers is given by (activecount)/2 * (2 * 1.2 + (activecount-1) * -0.02) * 2
361+
// If activecount > 21, then the sum of the multipliers is given by 42 + ((activecount-21)/2) * (2 * 1.2 + (activecount-22) * -0.02)
362+
// 42 is the sum of the multipliers for the first 21 active producers
363+
// The sum_of_multipliers are as follows:
364+
// activecount = 1: 2.4
365+
// activecount = 2: 4.8
366+
// activecount = 3: 7.2
367+
// ...
368+
// activecount = 21: 42
369+
// activecount = 22: 43.2
370+
// ...
371+
// activecount = 42: 63
372+
double sum_of_multipliers = activecount <= 21 ? (((activecount)/2)*(2*1.2-(activecount-1)*0.02) * 2) : (42 + ((activecount-21)/2)*(2*1.2-(activecount-22)*0.02));
373+
374+
auto shareValue = (_gstate.perblock_bucket / sum_of_multipliers);
359375
int32_t index = 0;
360376

361377
for (const auto &prod : sortedprods) {

0 commit comments

Comments
 (0)