The contract contains several assembly blocks that unnecessarily store zero values (0x00) to memory locations before reverting or returning. These operations consume extra gas without providing any functional benefit. Memory slots are already initialized to zero by default in the EVM, making these explicit zero stores redundant.
The issue is particularly evident in error handling paths and return statements where memory is unnecessarily zeroed before reverting or returning data.
Likelihood:HIGH
The code is always present in the contract
Impact:LOW
Gas inefficiency: Unnecessary gas costs for users
Code bloat: Additional operations that serve no purpose
Minor performance impact: Extra EVM operations slow down execution
Run the current test suite Token.t.sol with forge test in terminal. We can get each function gas list
[PASS] test_allowance() (gas: 91933)
[PASS] test_approveRevert() (gas: 12744)
[PASS] test_burn() (gas: 47459)
[PASS] test_burnRevert() (gas: 9900)
[PASS] test_metadata() (gas: 20271)
[PASS] test_mint() (gas: 58836)
[PASS] test_mintRevert() (gas: 9836)
[PASS] test_spendallowanceRevert() (gas: 93551)
[PASS] test_transfer() (gas: 93646)
[PASS] test_transferFrom() (gas: 104014)
[PASS] test_transferRevert() (gas: 62946)
[PASS] test_transferRevert2() (gas: 65918)
If we remove all line with mstore(location, 0x00) and we run the same test suite
[PASS] test_allowance() (gas: 91919)
[PASS] test_approveRevert() (gas: 12730)
[PASS] test_burn() (gas: 47436)
[PASS] test_burnRevert() (gas: 9887)
[PASS] test_metadata() (gas: 20271)
[PASS] test_mint() (gas: 58822)
[PASS] test_mintRevert() (gas: 9823)
[PASS] test_spendallowanceRevert() (gas: 93551)
[PASS] test_transfer() (gas: 93604)
[PASS] test_transferFrom() (gas: 103986)
[PASS] test_transferRevert() (gas: 62919)
[PASS] test_transferRevert2() (gas: 65904)
Remove all unnecessary codes inside contract
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.
The contest is complete and the rewards are being distributed.