Omniscia Mitosis Audit
Message Code Style Findings
Message Code Style Findings
MEG-01C: Redundant Code Duplication
Type | Severity | Location |
---|---|---|
Gas Optimization | Message.sol:L48-L50, L56-L58, L70-L72, L78-L80, L92-L94, L100-L102 |
Description:
The referenced statements are common between the decode
-prefixed functions in the Message
library.
Example:
src/helpers/ccdm/Message.sol
47function decodeDeposit(bytes calldata msg_) internal pure returns (MsgDeposit memory depositMsg) {48 if (msg_.length != 97) {49 revert Error.InvalidMsgLength(97, msg_.length);50 }51
52 if (msgType(msg_) != MsgType.Deposit) {53 revert Error.InvalidMsgType(uint8(msg_[0]));54 }55
56 depositMsg.receiver = bytes32(msg_[1:33]);57 depositMsg.token = bytes32(msg_[33:65]);58 depositMsg.amount = uint256(bytes32(msg_[65:]));59
60 return depositMsg;61}62
63function encodeDeposit(MsgDeposit memory msg_) internal pure returns (bytes memory) {64 return abi.encodePacked(MsgType.Deposit, msg_.receiver, msg_.token, msg_.amount);65}66
67// MsgRefund68
69function decodeRefund(bytes calldata msg_) internal pure returns (MsgRefund memory refundMsg) {70 if (msg_.length != 97) {71 revert Error.InvalidMsgLength(97, msg_.length);72 }73
74 if (msgType(msg_) != MsgType.Refund) {75 revert Error.InvalidMsgType(uint8(msg_[0]));76 }77
78 refundMsg.receiver = bytes32(msg_[1:33]);79 refundMsg.token = bytes32(msg_[33:65]);80 refundMsg.amount = uint256(bytes32(msg_[65:]));81
82 return refundMsg;83}
Recommendation:
We advise them to be relocated to a private
utility function, optimizing the bytecode size of the contract as well as its maintainability.
Alleviation (58e8cc66dfa900c03c47df78f5170d9960005629):
The Mitosis team evaluated this exhibit but opted to acknowledge it in the current iteration of the codebase
MEG-02C: Repetitive Value Literal
Type | Severity | Location |
---|---|---|
Code Style | Message.sol:L48, L49, L70, L71, L92, L93 |
Description:
The linked value literal is repeated across the codebase multiple times.
Example:
src/helpers/ccdm/Message.sol
48if (msg_.length != 97) {
Recommendation:
We advise it to be set to a constant
variable instead optimizing the legibility of the codebase.
Alleviation (58e8cc66dfa900c03c47df78f5170d9960005629):
The referenced value literal has been replaced to three distinct instances to permit their future adjustment, thereby addressing this exhibit.