OpenZeppelin / OpenZeppelin/openzeppelin-contracts
`Pausable` can be more gas efficient using a similar mechanism as in the `ReentrancyGuard`
Nobody has claimed this yet.
- Dominant language
- Solidity
- Stars
- 27.2k
- Forks
- 12.4k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 33
Description
I noticed that the Pausable contract can be optimized for gas usage by adopting a similar mechanism used in the ReentrancyGuard contract.
💻 Environment
OpenZeppelin Contracts 4.9.3
📝 Details
The ReentrancyGuard contract uses uint256 constants to avoid the extra gas costs associated with boolean operations. This mechanism can be applied to the Pausable contract to make it more gas-efficient.
🔢 Code to reproduce bug
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the Pausable and ReentrancyGuard contracts in OpenZeppelin Contracts 4.9.3, starting with how each represents and checks its state. Compare the gas impact of the existing Pausable mechanism with the proposed uint256-constant approach, then verify that pause and unpause behavior remains unchanged and gas usage improves.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- solidity
- Domain
- blockchain, performance, security
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100