Skip to content

Commit 7b22872

Browse files
Ank4nbkchr
authored andcommitted
[Staking Async] Saturating accrue era reward points (#9186)
Replaces regular addition with saturating addition when accumulating era reward points in `pallet-staking-async` to prevent potential overflow. --------- Co-authored-by: Bastian Köcher <[email protected]>
1 parent 06c2ffa commit 7b22872

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

prdoc/pr_9186.prdoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
title: 'pallet-staking-async: Use saturating addition for era reward points'
2+
doc:
3+
- audience: Runtime Dev
4+
description: |-
5+
This PR replaces regular addition with saturating addition when accumulating era reward points in
6+
pallet-staking-async to prevent potential overflow.
7+
crates:
8+
- name: pallet-staking-async
9+
bump: patch

substrate/frame/staking-async/src/session_rotation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl<T: Config> Eras<T> {
364364
era_rewards.individual.try_insert(validator, points).defensive();
365365
},
366366
}
367-
era_rewards.total += points;
367+
era_rewards.total.saturating_accrue(points);
368368
}
369369
});
370370
}

0 commit comments

Comments
 (0)