Not checking the length of the provided merkleProof calldata for known bad proofs (zero length) and reverting early increases the gas cost for transactions that are guaranteed to revert by 567 gas units, while only increasing the gas cost for valid proofs by 27 gas units.
Not checking the length of the provided merkleProof calldata for known bad proofs (zero length) and reverting early still makes the contract calculate a leaf and attempt to verify the proof.
MerkleAirdrop.solTemporarily add the following functions to the MerkleAirdrop contract.
MerkleAirdropTest.t.solCompare gas costs of each MerkleAirdrop::merkleWithCheck and MerkleAirdrop::merkleWithoutCheck call.
Not reverting early for proofs with a length of zero increase the gas cost for transactions that are guaranteed to revert.
| Proof is Empty? | Checks for Length? | Gas Cost | Net Loss/Gain |
|---|---|---|---|
| Yes | No | 1167 | |
| Yes | Yes | 600 | 567 |
| No | No | 1656 | |
| No | Yes | 1683 | -27 |
Implementing this check saves 567 gas units when an empty proof is provided, and only marginally increases gas prices for valid proofs by 27 units.
Manual Analysis, Foundry Tests
Check the length of provided merkleProof calldata length in MerkleAirdrop::claim is not zero. If it is zero, revert early with MerkleAirdrop::MerkleAirdrop__InvalidProof.
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.