Last Man Standing

First Flight #45
Beginner FriendlyFoundrySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

[O-1] Replace `require` Statements with Custom Errors, only if solc version is 0.8.4 or higher.

Root + Impact

[O-1] Replace require Statements with Custom Errors, only if solc version is 0.8.4 or higher.

Description

As stated in the official release of (Solidity 0.8.4)[https://soliditylang.org/blog/2021/04/21/custom-errors/], utilizing custom errors can reduce runtime and deployment costs, as indicated by the following benchmark, while also improving clarity in error handling.

Risk

Likelihood: Low

Impact: None

Proof of Concept

Lets take the Game::nonReentrant modifier as example:

modifier nonReentrant() {
require(!_locked, "ReentrancyGuard: reentrant call");
_locked = true;
_;
_locked = false;
}

This modifier requires the _locked value to be false in order to continue its logic.

Recommended Mitigation

Consider update to solidity version 0.8.4 or higher and replacing all require statements with custom errors.

Then you can add a custom error like this:

+ error Game__ReentrancyGuardReentrantCall();
modifier nonReentrant() {
- require(!_locked, "ReentrancyGuard: reentrant call");
+ if(_locked){
+ revert Game__ReentrancyGuardReentrantCall();
+ }
_locked = true;
_;
_locked = false;
}

Consider to apply this methodology to replace all require conditionals using the example above.

Updates

Appeal created

inallhonesty Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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