Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

The use of `delete` in Steets::unstake is inefficient

Summary

The use of delete to delete on a mapping is not efficient as it only results to the data been stored in the mapping been changed to its default value rather than reveal the true state of the values/data in the block chain.

POC

function test_deleteIsInefficient() public {
vm.startPrank(user);
oneShot.mintRapper();
oneShot.approve(address(streets), 0);
streets.stake(0);
(,address _owner) = streets.stakes(0);
console.log("The owner before it's unstaked is:", _owner);
streets.unstake(0);
(,address _owner1) = streets.stakes(0);
console.log("The owner after it's unstaked is:", _owner1);
console.log("Oneshot Balance of user is:", oneShot.balanceOf(user));
vm.stopPrank();
}

The logged output above for owner1 is 0x0000000000000000000000000000000000000000 and this does not show the true state of data in the blockchain which is also presented and logged above as oneShot.balanceOf(user).

Impact

Low

Tools Used

Manual Review

Recommendations

Since solidity does not currently have a built-inway to delete a mapping, its possible to use the Deletable Mapping Index which requires that a the value/data which is intended to be deleted in a struct is moved to the end and popped off.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Too generic

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.