Omniscia Euler Finance Audit
ExecutionContext Code Style Findings
ExecutionContext Code Style Findings
ECT-01C: Optimization of Initialization
Type | Severity | Location |
---|---|---|
Gas Optimization | ExecutionContext.sol:L42 |
Description:
The ExecutionContext::initialize
function is solely invoked in the TransientStorage::constructor
and thus will always accept an EC
input argument that is equal to 0
.
Example:
40function initialize(EC self) internal pure returns (EC result) {41 // prepopulate the execution context storage slot to optimize gas consumption42 // (it should never be cleared again thanks to the stamp)43 result = EC.wrap(EC.unwrap(self) | (STAMP_DUMMY_VALUE << STAMP_OFFSET));44}
Recommendation:
We advise the initial value of the EC
flag to be set as library
level constant
that is assigned to the executionContext
at the TransientStorage::constructor
, optimizing the code's gas cost.
Alleviation (577d1991de):
The ExecutionContext::initialize
function has been removed from the codebase, and the instance where it was invoked within the TransientStorage::constructor
has been updated to initialize the executionContext
as a direct statement.
While functionally our recommendation has been applied, we advised the newly introduced expression (EC.wrap(1 << ExecutionContext.STAMP_OFFSET)
) to be exposed as a constant
by the ExecutionContext
library. This would ensure that the library
can be utilized in other codebases without repeating the initialization statement performed in the TransientStorage::constructor
function.
Alleviation (c943dcbbb6):
The Euler Finance team evaluated our follow-up recommendation and opted to not expose the expression as a constant
as the ExecutionContext
is meant to be utilized solely in the context of the EVC. As such, we consider this exhibit adequately addressed to the extent that it aligns with the Euler Finance team's wishes.