Skip to content

fix: add overflow check for unchecked exponentiation in getNodeFeeByDemand#345

Open
Sertug17 wants to merge 1 commit into
rocket-pool:masterfrom
Sertug17:fix/unchecked-exponentiation-network-fees
Open

fix: add overflow check for unchecked exponentiation in getNodeFeeByDemand#345
Sertug17 wants to merge 1 commit into
rocket-pool:masterfrom
Sertug17:fix/unchecked-exponentiation-network-fees

Conversation

@Sertug17

Copy link
Copy Markdown

The ** 3 operator in Solidity 0.7.6 doesn't have built-in overflow protection, and SafeMath doesn't cover exponentiation either. Split the cube into three multiplications with a check that reverts on overflow.

Closes #343

…emand

The function was using ** 3 on a value that's read from contract storage.
SafeMath doesn't cover exponentiation, so in Solidity 0.7.6 the ** operator
can silently wrap on overflow. Added a manual overflow check after the
cube multiplication.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RocketNetworkFees uses Solidity 0.7.6 with unchecked exponentiation operator

1 participant