Add a "sparse" `extsload` method that is able to load and return from a list of keys
Component
General design optimization (improving efficiency, cleanliness, or developer experience)
Describe the suggested feature and problem it solves.
Currently the V4 singleton has two "extsload" style methods:
extsload(bytes32 slot)which reads a single slotextsload(bytes32 startSlot, uint256 nSlots)which readsnSlotscontinuousstartSlotsfrom the given slot
Most of the storage relationships in the contract rely on mappings, which use the keccak256 function to derive their storage slots making storage very sparse. This means that the only use case for the continuous extsload is for reading structs (although this could change with #623 ). Nevertheless, most storage is sparse and calling getters multiple times is quite expensive (~1.4k of call overhead) therefore having a method that takes a list of keys bytes32[] and returns their values could aid contracts such as external fee/staking contracts to efficiently retrieve data from the contract.
Describe the desired implementation.
Add a third extsload method that takes a single bytes32[] array as an input and returns the values at the desired storage slots.
Describe alternatives.
No response
Additional context.
No response
Suggested here. https://github.com/Uniswap/v4-core/pull/559#pullrequestreview-1982030657
Suggested here. #559 (review)
Oh yeah, missed that although my implementation in #625 is more optimized than the suggested implementation in #559
Suggested here. #559 (review)
Oh yeah, missed that although my implementation in #625 is more optimized than the suggested implementation in #559
As far as I test, the impl in my comment is 154 gas cheaper on your test.