core/vm: optimize opCreate and opCreate2 by not copy memory#32918
core/vm: optimize opCreate and opCreate2 by not copy memory#32918cuiweixie wants to merge 1 commit intoethereum:masterfrom
Conversation
cuiweixie
commented
Oct 15, 2025
|
It seems like it could be okay. But also could potentially be a very dangerous change. contract creation happens relatively less often and isn't a bottleneck in the EVM. So based on the risk/reward tradeoff here, I'd be inclined to close this. |
|
gballet
left a comment
There was a problem hiding this comment.
I have digged into this, and even though this thing looks wrong, I am convinced that it is ok:
- the input data would be a reference, but accessing it from the contract would cause a copy as
CALLDATALOADcallsgetData, which makes a copy. There is no way for the caller to directly modify the input slice. - the data that would be saved to disk is also copied from memory, so there is no issue there
- As the author notes, this optimization is already used in
opCalland it works
Nonetheless, I think it's a bad idea because although it works today, we are not protected from future modifications that would somehow uncover that problem. I'm going to approve but let Gary have the final say.
|
I agree with Guillaume, and I prefer not to accept it, for the following reasons: The benefit is negligible. CREATE and CREATE2 are far less common than CALL*, so the allocation savings are typically insignificant at the overall level. Although the contract code is currently treated as an immutable variable (since during CALLDATACOPY, the data is deep-copied into memory), there's no guarantee that this assumption will hold in the future. For example, in Verkle, we may need to chunkify the code. Compare with the limited gain and the potential risk, i don't think it's worthwhile to have this change. |
|
I agree that this is dangerous. may cause some thing like https://github.com/ethereum/go-ethereum/blob/6f2cbb7a27ba7e62b0bdb2090755ef0d271714be/docs/postmortems/2021-08-22-split-postmortem.md |