Omniscia Euler Finance Audit

Dispatch Code Style Findings

Dispatch Code Style Findings

DHC-01C: Redundant Copy of Call Data

Description:

The referenced assembly statement will redundantly copy PROXY_METADATA_LENGTH bytes from the calldata that will ultimately not be relayed by the staticcall operation.

Example:

src/EVault/Dispatch.sol
112function delegateToModuleView(address module) private view {
113 assembly {
114 // Construct optimized custom call data for `this.viewDelegate()`
115 // [selector 4B][module address 32B][calldata with stripped proxy metadata]
116 // Proxy metadata will be appended back by the proxy on staticcall
117 mstore(0, 0x1fe8b95300000000000000000000000000000000000000000000000000000000)
118 mstore(4, module)
119 calldatacopy(36, 0, calldatasize())
120 // insize: calldatasize + 36 (signature and address) - proxy metadata size
121 let result := staticcall(gas(), address(), 0, sub(add(calldatasize(), 36), PROXY_METADATA_LENGTH), 0, 0)
122 returndatacopy(0, 0, returndatasize())
123 switch result
124 case 0 { revert(0, returndatasize()) }
125 default { return(0, returndatasize()) }
126 }
127}

Recommendation:

We advise the calldatacopy operation to subtract the PROXY_METADATA_LENGTH from the calldatasize() result, optimizing the code's gas cost.

Alleviation (fb2dd77a6ff9b7f710edb48e7eb5437e0db4fc1a):

The redundant calldatacopy operation has been optimized per our recommendation, reducing the code's gas cost and preventing potentially dirty bits from being read.