Skip to content

Commit

Permalink
Add nilcheck to commission scale in event of insufficient sp balance
Browse files Browse the repository at this point in the history
  • Loading branch information
jshufro committed Nov 25, 2024
1 parent eae26d9 commit b47a29b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions shared/services/rewards/generator-impl-v9-v10-rolling.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,9 @@ func (r *treeGeneratorImpl_v9_v10_rolling) calculateNodeRewards() (*big.Int, *bi
// Calculate the reduced bonus for each minipool
// Because of integer division, this will be less than the actual bonus by up to 1 wei
for _, mpd := range nsd.Minipools {
if mpd.MinipoolBonus == nil {
continue
}
mpd.MinipoolBonus.Mul(mpd.MinipoolBonus, remainingBalance)
mpd.MinipoolBonus.Div(mpd.MinipoolBonus, totalConsensusBonus)
}
Expand Down
3 changes: 3 additions & 0 deletions shared/services/rewards/generator-impl-v9-v10.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,9 @@ func (r *treeGeneratorImpl_v9_v10) calculateNodeRewards() (*big.Int, *big.Int, *
// Calculate the reduced bonus for each minipool
// Because of integer division, this will be less than the actual bonus by up to 1 wei
for _, mpd := range nsd.Minipools {
if mpd.MinipoolBonus == nil {
continue
}
mpd.MinipoolBonus.Mul(mpd.MinipoolBonus, remainingBalance)
mpd.MinipoolBonus.Div(mpd.MinipoolBonus, totalConsensusBonus)
}
Expand Down

0 comments on commit b47a29b

Please sign in to comment.