v4-core
v4-core copied to clipboard
Use packed stack-based version of Slot0 structure
This pull request does not relate to any issue. In my opinion, it is more convenient to discuss this change if you have an already written implementation in a pull request.
Description of changes
The slot0 structure by design fits into one storage slot. However, when using the memory version of this structure, each field occupies a separate memory slot. In addition, the memory structure takes up more space on the solidity "stack".
The changes I propose allows to read this structure onto the stack and operate with the fields of this structure directly on the stack. As a result, the amount of memory used is reduced, which a little bit reduces gas costs and bytecode size.
Since the changes are more or less significant, I would first like to hear the opinion of the community and maintainers regarding the proposal to use a structure on the stack before adding tests and so on.
Btw in general, I do really like this change and it would be great to get tests I think! cc @hensha256
Added tests
@snreynolds anything else you wanna see before we merge?