RabbitHole Quest Protocol contest - dharma09's results

A protocol to distribute token rewards for completing on-chain tasks.

General Information

Platform: Code4rena

Start Date: 25/01/2023

Pot Size: $36,500 USDC

Total HM: 11

Participants: 173

Period: 5 days

Judge: kirk-baird

Total Solo HM: 1

Id: 208

League: ETH

RabbitHole

Findings Distribution

Researcher Performance

Rank: 140/173

Findings: 1

Award: $11.33

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

[G-01] Use Immutable instead of constant for keccak256

Constant expressions are re-calculated each time it is in use, costing an extra 97 gas than a constant every time they are called.

Mark these as  immutable  instead of  constant

There are 1 instances of this issue:

Affected source code:

17:  bytes32 public constant CREATE_QUEST_ROLE = keccak256('CREATE_QUEST_ROLE');

[G-02] State variables only set in the constructor should be declared IMMUTABLE

Avoids a Gsset (20000 gas) in the constructor, and replaces the first access in each transaction (Gcoldsload - 2100 gas) and each access thereafter (Gwarmacces - 100 gas) with a PUSH32 (3 gas).

There are 1 instances of this issue:

Affected source code:

21: string public questId;

[G-03] Comparing to a constant (true or false) is a bit more expensive

Comparing to a constant (true or false) is a bit more expensive than directly checking the returned boolean value.I suggest using if(directValue) instead of if(directValue == true) and if(!directValue) instead of if(directValue == false) 

There are 1 instances of this issue:

Affected source code:

[G-04] Help the optimizer by declaring a storage variable instead of repeatedly fetching the value

To help the optimizer, go from:

220: if (quests[questId_].numberMinted + 1 > quests[questId_].totalParticipants) revert OverMaxAllowedToMint();
221:        if (quests[questId_].addressMinted[msg.sender] == true) revert AddressAlreadyMinted();
222:        if (keccak256(abi.encodePacked(msg.sender, questId_)) != hash_) revert InvalidHash();
223:    if (recoverSigner(hash_, signature_) != claimSignerAddress) revert AddressNotSigned();
224:
225:    quests[questId_].addressMinted[msg.sender] = true;
226:    quests[questId_].numberMinted++;

to

220:	     bool storage _checkAddress = quests[questId_].addressMinted[msg.sender];
221:       uint storage _checkMax	= quests[questId_].numberMinted;
222:        if ( _checkMax + 1 > quests[questId_].totalParticipants) revert OverMaxAllowedToMint();
223:        if ( _checkAddress == true) revert AddressAlreadyMinted();
224:        if (keccak256(abi.encodePacked(msg.sender, questId_)) != hash_) revert InvalidHash();
225:        if (recoverSigner(hash_, signature_) != claimSignerAddress) revert AddressNotSigned();
226:
227:    _checkAddress = true;
228:  unchecked {  
229:       _checkMax++;
230:       }

and mark _checkMax unchecked

[G-05] X = X + Y costs less gass than X += Y

X = X + Y costs less gass than X += Y for state variables

There are 1 instances of this issue:

Affected source code:

/Quest.sol
115: redeemedTokens += redeemableTokenCount; 

#0 - c4-judge

2023-02-05T04:30:35Z

kirk-baird marked the issue as grade-b

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter