The idea is pretty simple, introduce a DELEGATECALL like functionality that restricts state mutations on EVM level just like a STATICCALL does. The idea seems simple and surprised it doesn’t already exist. So I am wondering if there’s any reason this hasn’t already been done? I am no EL dev, but I think the work should be very similar to all other type of calls and could use a lot of reuse(DELEGATECALL + STATICCALL).
This also opens up a very simple way to allow users to write custom views on a foreign contract if the said contract chooses to expose a function that does arbitrary delegatestaticcall
s. Would also allow contracts to only keep the core state mutating + necessary view functions and in turn give more room for more code given the code size limits. Could also serve as a poor man’s opt-in workaround for EXTSLOADs too.
contract SomeContract {
function extview(address _impl, bytes calldata _data) external view returns (bool _success, bytes memory _ret) {
(_success, _ret) = _impl.delegatestaticcall(_data);
}
}