Store hash of type(ZeroExStorage).creationCode
rather than recalculating it on each call
#35
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
TomFrench
Vulnerability details
Impact
Deployment + runtime gas cost increase
Proof of Concept
On each time we calculate the address of
ZeroExStorage
we hash the entirety of the creation code forZeroExStorage
. This means that not only do we have to perform a large hash operation over the entire creation bytecode of this contract, we need to store all of this bytecode in theZeroExOperator
's deployed bytecode.https://github.com/code-423n4/2021-11-nested/blob/5d113967cdf7c9ee29802e1ecb176c656386fe9b/contracts/operators/ZeroEx/ZeroExOperator.sol#L61
This hash could be calculated once at deployment and then have this used cheaply each time, reducing both deployment and runtime costs.
Recommended Mitigation Steps
Store
keccak256(type(ZeroExStorage).creationCode)
in animmutable
(notconstant
as this still results in hashing being applied each time) variable.The text was updated successfully, but these errors were encountered: