8000 Woof software/rewards v2 multiple rewards audit fixes by vitalii-woof-software · Pull Request #147 · woof-software/comet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Woof software/rewards v2 multiple rewards audit fixes #147

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

Conversation

vitalii-woof-software
Copy link
Collaborator

No description provided.

if(msg.sender != governor) revert NotPermitted(msg.sender);
if(startRoot == bytes32(0)) revert BadData();
if(assets.length == 0) revert BadData();
if(duration > MAX_CAMPAIGN_DURATION) revert BadData();

uint64 accrualScale = CometInterface(comet).baseAccrualScale();
Campaign storage $ = campaigns[comet].push();
campaignId = campaigns[comet].length - 1;
uint256 campaignId = campaigns[comet].length - 1;

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.security.basic-arithmetic-underflow Note

Possible arithmetic underflow
for(uint256 j = 0; j < claimedAmounts[i].length; j++){
emit RewardsClaimedSet(campaignId, users[i], comet, tokens[i][j], claimedAmounts[i][j]);
$.claimed[users[i]][tokens[i][j]] = claimedAmounts[i][j];
if(assets.length != claimedAmounts[i].length) revert BadData();

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.performance.array-length-outside-loop Note

Caching the array length outside a loop saves reading it on each iteration, as long as the array's length is not changed during the loop.
for(uint256 j = 0; j < claimedAmounts[i].length; j++){
emit RewardsClaimedSet(campaignId, users[i], comet, tokens[i][j], claimedAmounts[i][j]);
$.claimed[users[i]][tokens[i][j]] = claimedAmounts[i][j];
if(assets.length != claimedAmounts[i].length) revert BadData();

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.performance.array-length-outside-loop Note

Caching the array length outside a loop saves reading it on each iteration, as long as the array's length is not changed during the loop.
$.claimed[users[i]][tokens[i][j]] = claimedAmounts[i][j];
if(assets.length != claimedAmounts[i].length) revert BadData();

for(uint256 j = 0; j < assets.length; j++){

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.performance.array-length-outside-loop Note

Caching the array length outside a loop saves reading it on each iteration, as long as the array's length is not changed during the loop.
$.claimed[users[i]][tokens[i][j]] = claimedAmounts[i][j];
if(assets.length != claimedAmounts[i].length) revert BadData();

for(uint256 j = 0; j < assets.length; j++){

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.performance.unnecessary-checked-arithmetic-in-loop Note

A lot of times there is no risk that the loop counter can overflow.
Using Solidity's unchecked block saves the overflow checks.
$.claimed[users[i]][tokens[i][j]] = claimedAmounts[i][j];
if(assets.length != claimedAmounts[i].length) revert BadData();

for(uint256 j = 0; j < assets.length; j++){

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.performance.use-prefix-increment-not-postfix Note

Consider using the prefix increment expression whenever the return value is not needed.
The prefix increment expression is cheaper in terms of gas.
verifyNewMember(comet, src, campaignIDs[i], neighbors[i], multiProofs[i].proofs);
if(!CometInterface(comet).hasPermission(src, msg.sender))
revert NotPermitted(msg.sender);
for (uint256 i; i < campaignIds.length; i++) {

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.performance.unnecessary-checked-arithmetic-in-loop Note

A lot of times there is no risk that the loop counter can overflow.
Using Solidity's unchecked block saves the overflow checks.
verifyNewMember(comet, src, campaignIDs[i], neighbors[i], multiProofs[i].proofs);
if(!CometInterface(comet).hasPermission(src, msg.sender))
revert NotPermitted(msg.sender);
for (uint256 i; i < campaignIds.length; i++) {

Check notice

Code scanning / Semgrep OSS

Semgrep Finding: rules.solidity.performance.use-prefix-increment-not-postfix Note

Consider using the prefix increment expression whenever the return value is not needed.
The prefix increment expression is cheaper in terms of gas.
@vitalii-woof-software vitalii-woof-software merged commit 93b06a3 into woof-software/rewards-v2-multiple-rewards Apr 3, 2025
6 of 41 checks passed
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.

1 participant
0