Skip to content

Commit

Permalink
Use checked math for _new_from_parent (anza-xyz#2859)
Browse files Browse the repository at this point in the history
* Use checked math

* Use checked operations
  • Loading branch information
LucasSte authored Sep 30, 2024
1 parent ab0977f commit c728362
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,8 +1217,15 @@ impl Bank {
epoch_schedule,
collected_rent: AtomicU64::new(0),
rent_collector: Self::get_rent_collector_from(&parent.rent_collector, epoch),
max_tick_height: (slot + 1) * parent.ticks_per_slot,
block_height: parent.block_height + 1,
max_tick_height: slot
.checked_add(1)
.expect("max tick height addition overflowed")
.checked_mul(parent.ticks_per_slot)
.expect("max tick height multiplication overflowed"),
block_height: parent
.block_height
.checked_add(1)
.expect("block height addition overflowed"),
fee_rate_governor,
capitalization: AtomicU64::new(parent.capitalization()),
vote_only_bank,
Expand Down

0 comments on commit c728362

Please sign in to comment.