Omniscia AllianceBlock Audit
MerkleDistributor Code Style Findings
MerkleDistributor Code Style Findings
MDR-01C: Potential Error Practicality Enhancement
Type | Severity | Location |
---|---|---|
Language Specific | MerkleDistributor.sol:L9, L48 |
Description:
The InvalidProof
error is meant to be yielded whenever a Merkle proof verification fails, however, it does not yield the merkleRoot
which the verification failed for.
Example:
39function claim(uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof)40 public41 virtual42 override43{44 if (isClaimed(index)) revert AlreadyClaimed();45
46 // Verify the merkle proof.47 bytes32 node = keccak256(abi.encodePacked(index, account, amount));48 if (!MerkleProof.verify(merkleProof, merkleRoot, node)) revert InvalidProof();49
50 // Mark it claimed and send the token.51 _setClaimed(index);52 IERC20(token).safeTransfer(account, amount);53
54 emit Claimed(index, account, amount);55}
Recommendation:
We advise a bytes32
argument to be added to the InvalidProof
error which signals the merkleRoot
the proof failed for, enhancing its off-chain usability.
Alleviation:
The InvalidProof
error was expanded to contain a bytes32
variable representing the merkleRoot
the validation failed for as per our recommendation.
MDR-02C: Repetitive Value Literal
Type | Severity | Location |
---|---|---|
Code Style | MerkleDistributor.sol:L26, L27, L34, L35 |
Description:
The linked value literal is repeated across the codebase multiple times.
Example:
26uint256 claimedWordIndex = index / 256;
Recommendation:
We advise it to be set to a constant
variable instead optimizing the legibility of the codebase.
Alleviation:
The 256
value literal was relocated to an aptly named WORD_SIZE
contract-level constant
variable, increasing the legibility of the codebase.