Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary Addition In Loop (PrizeDistributionBuffer.sol) #43

Open
code423n4 opened this issue Oct 13, 2021 · 2 comments
Open

Unnecessary Addition In Loop (PrizeDistributionBuffer.sol) #43

code423n4 opened this issue Oct 13, 2021 · 2 comments
Assignees
Labels
bug Warden finding G (Gas Optimization) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

Handle

ye0lde

Vulnerability details

Impact

Gas savings and code clarity

Proof of Concept

PrizeDistributionBuffer.sol:
"tiers" are summed within a for loop even when their value is zero.
Since "tiers" is uint32 and can't be below zero this is unnecessary.
https://github.com/pooltogether/v4-core/blob/35b00f710db422a6193131b7dc2de5202dc4677c/contracts/PrizeDistributionBuffer.sol#L209-L215

Tools Used

Visual Studio Code, Remix

Recommended Mitigation Steps

Replace this
https://github.com/pooltogether/v4-core/blob/35b00f710db422a6193131b7dc2de5202dc4677c/contracts/PrizeDistributionBuffer.sol#L209-L215
with this

for (uint256 index = 0; index < tiersLength; index++) {
if (_prizeDistribution.tiers[index] > 0) {

	sumTotalTiers += _prizeDistribution.tiers[index];

	nonZeroTiers++;
}

}

code423n4 added a commit that referenced this issue Oct 13, 2021
@asselstine asselstine self-assigned this Oct 14, 2021
@asselstine asselstine added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Oct 14, 2021
@asselstine
Copy link
Collaborator

Acknowledged, but not significant. This contract may be blown away later

@GalloDaSballo
Copy link
Collaborator

The finding would arguably save gas for zero value tiers, that said, it's very very minor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Warden finding G (Gas Optimization) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Projects
None yet
Development

No branches or pull requests

3 participants