Omniscia DAFI Protocol Audit
EthBridgeOptimized Code Style Findings
EthBridgeOptimized Code Style Findings
EBO-01C: Inexistent Error Message
Type | Severity | Location |
---|---|---|
Code Style | Informational | EthBridgeOptimized.sol:L187 |
Description:
The linked require
check has no error message explicitly defined.
Example:
187require(sig.length == 65);
Recommendation:
We advise it to be set so to aid in the validation of the require
's condition as well as the legibility of the codebase.
Alleviation:
A proper error message was introduced for the linked require
instance.
EBO-02C: Redundant keccak256
Re-Execution
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | EthBridgeOptimized.sol:L134, L143, L144, L152 |
Description:
The linked statements perform the keccak256
operation on the same payload multiple times redundantly.
Example:
129function unlockTokens(130 bytes32 messageHash,131 bytes calldata message,132 bytes[] calldata claimedSig133) external {134 if (txStore[keccak256(message)] == true) revert DoubleClaimDetected();135 if (message.length <= 32) revert InvalidMessage();136 (137 uint256 amount,138 uint256 _nonce,139 uint32 chainID,140 address to141 ) = abi.decode(message, (uint256, uint256, uint32, address));142 if (chainID !=block.chainid) revert InvalidChainID(chainID,uint32(block.chainid));143 if (messageHash != prefixed(keccak256(message)))144 revert HashMismatched(messageHash, prefixed(keccak256(message)));145 //signature check146 if (signaturesVerifier(claimedSig, messageHash) == true)147 _unlockTokens(148 amount,149 _nonce,150 chainID,151 to,152 keccak256(message)153 );154}
Recommendation:
We advise the operation to be performed once, stored in-memory and consequently utilized to optimize the code.
Alleviation:
The code has been optimized according to our recommendation caching the keccak256(message)
operation.
EBO-03C: Suboptimal Conditionals
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | EthBridgeOptimized.sol:L87, L111 |
Description:
The linked conditionals negate a comparator and as such can be optimized by moving the negation to the comparator itself (i.e. !(a > 0)
becomes (a <= 0)
or (a == 0)
if a
is guaranteed to be positive).
Example:
111if (!(amount > 0)) revert ZeroAmount();
Recommendation:
We advise this to be done so to simplify the code and optimize its gas cost.
Alleviation:
The code was optimized only for the last linked instance thereby partially alleviating this exhibit.
EBO-04C: Variable Mutability Specifiers
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | EthBridgeOptimized.sol:L39, L41, L59, L60 |
Description:
The linked variables are assigned to only once during the contract's constructor
.
Example:
48constructor(49 address[] memory _validators,50 address _ETHTOKEN,51 address _owner,52 uint256 _multiSigThreshold53) {54 if (_multiSigThreshold < 2)55 revert ThresholdNotMet(_multiSigThreshold, 2);56
57
58 threshold = _multiSigThreshold;59 ETHTOKEN = _ETHTOKEN;60 owner = _owner;61
62
63 for (uint256 i = 0; i < _validators.length; i++) {64 validators[_validators[i]] = true;65 }66}
Recommendation:
We advise them to be set as immutable
greatly optimizing the codebase.
Alleviation:
Both linked variables were properly set as immutable
optimizing the codebase.