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".
- This does not change the behavior of the
state(uint256)
functionexecute()
sets theexecuted
flag, which means the state will be returns without even looking at_timelockIds[proposalId]
- This does not change the behavior of the
proposalEta(uint256)
function- before this change, calling
proposalEta
on an executed proposal would lookup the deadline on the timelock. That returns_DONE_TIMESTAMP
(1) which is rewritten to 0 by the governor - after this change, calling
proposalEta
on an executed proposal would lookup the deadline of0x0
on the timelock, which should be 0.
- before this change, calling
PR Checklist
- Tests
- Documentation
- Changeset entry (run
npx changeset add
)