Skip to content

Commit

Permalink
Make sure we don't overflow in reward calculation
Browse files Browse the repository at this point in the history
This makes sure we don't hand out ~2**64 Luna when our reward curve
isn't strictly monotone.

Our rewards curve should still be monotone as otherwise more than the
total supply could be handed out.
  • Loading branch information
hrxi authored and jsdanielh committed Jul 4, 2024
1 parent c1f3a1f commit 96a85e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion blockchain/src/reward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn block_reward_for_batch(
Policy::supply_at(genesis_supply_u64, genesis_timestamp, current_timestamp);

// This is the maximum rewards that we can pay for this batch
let max_rewards = current_supply - prev_supply;
let max_rewards = current_supply.saturating_sub(prev_supply);

// However, there is a penalty if the batch was not produced in time...
// First we calculate the delay producing the batch:
Expand Down

0 comments on commit 96a85e7

Please sign in to comment.