Open Barmaley8971 opened 6 months ago
Validator Reward Payment: The current check during reward payment skips the last validator if there is still budget remaining. This is because the check uses >
instead of >=
:
epoch_boundary::process_outgoing_validators
…
if (libra_coin::value(reward_budget) > reward_per) {
let user_coin = libra_coin::extract(reward_budget, reward_per);
reward_deposited = reward_deposited + libra_coin::value(&user_coin);
rewards::process_single(root, *addr, user_coin, 1);
};
…
Subsidy Allocation Timing: proof_of_fee::reward_thermostat
executes before the subsidy allocation for the next epoch's validator payment. If the thermostat increases the reward, there may not be enough subsidy to cover payments.
Precision in Pledged Accounts: There is an issue with the precision in calculating the percentage of coins to be collected from each pledged account to form the subsidy in pledged_accounts::withdraw_from_all_pledge_accounts
. This can result in a shortfall of one coin for the last validator.
Allocation for Extra Validator: An unnecessary allocation for an extra validator intended for miners in the past is still present. This allocation is insufficient to cover all validators in the scenario of increased rewards and confuses epoch boundary status data.
Entry Fee Calculation: The entry fee is calculated using fixed_point32::multiply_u64
, resulting in a precision issue where the fee is one coin cheaper than expected due to rounding errors.
Adjust Reward Payment Check: Use >=
instead of >
to avoid skipping the last payment.
if (libra_coin::value(reward_budget) >= reward_per) {
Change Execution Order: Execute thermostat_reward
before subsidy allocation to ensure sufficient funds for validator payments.
Request Additional Amount: Request amount + 1
to address rounding issues and ensure accurate percentage sums from pledged accounts.
Remove Extra Validator Allocation: Eliminate the allocation for an extra validator.
Fix Entry Fee Calculation: Use a calculation method that avoids rounding errors and rounds down for periodic fractions.
The function proof_of_fee::reward_thermostat
has been refactored to move the reward calculation logic into a pure function. Additionally, the query proof_of_fee::query_reward_adjustment
was created to use this pure function and provide information on the reward for the next epoch.
Describe the bug The last validator to join the active set doesn't receive the daily reward.
To Reproduce Steps to reproduce the behavior:
Expected behavior In step 6 above, the validator should receive a reward.
Screenshots This validator joined the active set last epoch. No reward, just the participation fee 3.2 0L charge. This validator joined the active set 2 epochs ago. Did not receive the reward after the first epoch but did receive 320-3.2=316.8 after the second epoch.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context Add any other context about the problem here.