Omniscia rain protocol Audit
ERC20Pull Code Style Findings
ERC20Pull Code Style Findings
ERC-01C: Redundant Evaluation of Multiple Assertions
Type | Severity | Location |
---|---|---|
Gas Optimization | ERC20Pull.sol:L60, L61 |
Description:
One of the two linked assert
statements is performed redundantly as the function guarantees that the values of sender
and token
are simultaneously set to non-zero values.
Example:
contracts/erc20/ERC20Pull.sol
51/// Initialize the sender and token.52/// @param config_ `ERC20PullConfig` to initialize.53function initializeERC20Pull(ERC20PullConfig memory config_) internal {54 // Sender and token MUST be set in the config. MAY point at a known55 // address that cannot approve the specified token to effectively56 // disable pull functionality.57 require(config_.sender != address(0), "ZERO_SENDER");58 require(config_.token != address(0), "ZERO_TOKEN");59 // Reinitialization is a bug.60 assert(sender == address(0));61 assert(token == address(0));62 sender = config_.sender;63 token = config_.token;64 emit ERC20PullInitialize(msg.sender, config_.sender, config_.token);65}
Recommendation:
We advise one of the two to be omitted in favor of reduced gas costs.
Alleviation:
The assert
statement is now solely performed on the token
member rather than both the token
and sender
members.