Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pauseUntil tested, coded, documented #57

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CarlosAlegreUr
Copy link

As discussed in this issue on the official OpenZeppelin repository, this PR introduces a refactor of the Pausable.sol contract to implement a pauseUntil(uint48 deadline) functionality.


Changes

1. Pausable Contract

  • Refactored to include the pauseUntil(uint48 unpauseDeadline) functionality.
    • Backwards Compatibility: The implementation ensures that the same storage slots are used, preventing conflicts between old and new data.
    • ERC6372 Compatibility: Time-based functionality has been designed with ERC6372 in mind.
    • Potential Developer Consideration:
      • Developers updating from previous Pausable versions who independently implemented both ERC6372 and Pausable (e.g., via IERC5805) might face challenges if different time measurements are needed for pausing and other features.
      • Example: A Pausable contract implementing IERC5805 might use different time units for pausing and voting.

2. New Directory Structure

  • Created a new directory utils/pausability to accommodate the refactor:
    • Pausable.sol: General implementation of Pausable without a specific time measurement tool.
    • DefaultPausable.sol: A default implementation of Pausable using ERC6372 with block.timestamp as the time unit.

3. PausableMock Updates

  • Updated the mock contract to support:
    • Calling the new pauseUntil(uint48 deadline) function.
    • Accessing the new internal view function _unpauseDeadline().

4. Unit Tests

  • Added comprehensive unit tests to validate the new pauseUntil() functionality:
    • New test flows:
      • pause() -> pauseUntil()
      • pauseUntil() -> pause() (before and after the deadline)
      • pauseUntil() -> unpause() (before and after the deadline)
      • pauseUntil() -> pauseUntil() (before and after the previous deadline)

@CarlosAlegreUr CarlosAlegreUr requested a review from a team as a code owner December 30, 2024 11:33
contracts/mocks/PausableMock.sol Outdated Show resolved Hide resolved
contracts/utils/pausability/DefaultPausable.sol Outdated Show resolved Hide resolved
contracts/utils/pausability/Pausable.sol Outdated Show resolved Hide resolved
contracts/utils/pausability/DefaultPausable.sol Outdated Show resolved Hide resolved
Comment on lines +43 to +45
/**
* @dev Emitted when the pause is triggered by `account`. `unpauseDeadline` is 0 if the pause is indefinite.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now incorrect. If unpauseDeadline is 0 (or less than block.timestamp) the contract is not paused at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants