Closed wjmelements closed 3 months ago
As with #752, the savings should be even larger after they increase the sha3 gas.
My first attempt demonstrates that it is currently slightly worse (though this could change after 7667). Gonna tinker with it a bit before abandoning the branch.
My current theory is that the recursive advantage is from the mapping's ability to use the "scratch space".
Abandoning this. My WIP branch is here.
Component
Gas Optimization
Describe the suggested feature and problem it solves.
Multi-level mappings in solidity are implemented with recursive keccak. This means that each level is another hash. This is fine in situations like Pool where the intermediate storage key is useful. It is wasteful in erc20 and erc6909.
Describe the desired implementation.
I'm going to write storage key functions for the erc6909 multimappings. These storage keys will then be accessed with sload and sstore.
Describe alternatives.
No response
Additional context.
Experimentally for erc20, replacing multimappings with a single keccak can save a few hundred gas for
approve
andtransferFrom
.