Cleanup timelockId on execution for gas refund by Amxx · Pull Request #4118 · OpenZeppelin/openzeppelin-contracts (original) (raw)

When calling execute, the state is checked. We expect to be in Queued. That means the state call done by execute is going to read _timelockIds[proposalId] and check the operation status. This sload makes the slot "hot".

As a consequence, cleaning it will cost 2900 and refund 4800, resulting in a theoretical 1900 gas savings. Because of the hash necessary to compute storage slot, this saving is reduced to 1825, which is still "nice to have".

PR Checklist