Pausable contract provides an emergency stop mechanism that allows authorized pausers to halt contract operations when necessary. This is a critical security feature for responding to vulnerabilities or attacks.
Contract: src/roles/Pausable.sol
Key Concepts
- Paused State: Boolean flag indicating whether the contract is paused
- Pauser Role: Authorized address that can pause and unpause the contract
- whenNotPaused Modifier: Guards functions to prevent execution when paused
State Variables
paused
true, functions with the whenNotPaused modifier cannot be executed.
Default: false
Functions
pause
whenNotPaused modifier.
Requirements:
- Caller must be the pauser
- Sets
pausedtotrue
Pause()
Source: Pausable.sol:64
unpause
- Caller must be the pauser
- Sets
pausedtofalse
Unpause()
Source: Pausable.sol:72
updatePauser
_newPauser: Address of the new pauser
- Caller must be the owner
- New pauser must be non-zero address
PauserChanged(address indexed newAddress)
Source: Pausable.sol:80
pauser
Modifiers
whenNotPaused
onlyPauser
Events
Pause
Unpause
PauserChanged
newAddress: Address of the new pauser
Internal Functions
_updatePauser
_newPauser: Address of the new pauser
- New pauser must be non-zero address
PauserChanged(address indexed newAddress)
Source: Pausable.sol:87
Usage Example
Integration with CCTP
In CCTP contracts, thewhenNotPaused modifier is applied to critical functions:
- TokenMessenger:
depositForBurn(),depositForBurnWithCaller(),replaceDepositForBurn() - MessageTransmitter:
receiveMessage(),replaceMessage()
Security Considerations
- The pauser role is separate from the owner role for operational flexibility
- Only the owner can change the pauser address
- Pausing is immediate and affects all protected functions
- The pauser should be a trusted address (e.g., multisig or DAO)
- Consider implementing monitoring to detect when pause is triggered
- Ensure the pauser key is highly secure and accessible during emergencies
Origin
Forked from Centre USDC Pausable with modifications:- Updated Solidity version from 0.6.12 to 0.7.6
- Changed pauser visibility to private with external getter
- Added internal
_updatePauserfunction