Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions epoch-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ pub struct EpochRewards {
impl EpochRewards {
pub fn distribute(&mut self, amount: u64) {
let new_distributed_rewards = self.distributed_rewards.saturating_add(amount);
assert!(new_distributed_rewards <= self.total_rewards);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joncinque is this one of those "if there's ever an issue with the lamport accounting, halt the chain as a last resort rather than create an LoF scenario"?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were discussing this briefly -- there's only one callsite for this function, so we could hoist the checks into agave to make sure or have this return an error, but I think that would just move the panic up higher into the runtime eventually.

Would that work for the fuzzer @mjain-jump ?

self.distributed_rewards = new_distributed_rewards;
}
}
Expand Down Expand Up @@ -101,11 +100,4 @@ mod tests {
assert_eq!(epoch_rewards.total_rewards, 100);
assert_eq!(epoch_rewards.distributed_rewards, 100);
}

#[test]
#[should_panic(expected = "new_distributed_rewards <= self.total_rewards")]
fn test_epoch_rewards_distribute_panic() {
let mut epoch_rewards = EpochRewards::new(100, 0, 64);
epoch_rewards.distribute(200);
}
}
Loading