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

feat(protocol): improve _authorizePause for Bridge #16544

Merged
merged 17 commits into from
Mar 28, 2024
8 changes: 6 additions & 2 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents, TaikoErrors {
/// @notice Pause block proving.
/// @param _pause True if paused.
function pauseProving(bool _pause) external {
_authorizePause(msg.sender);
_authorizePause(msg.sender, _pause);
LibProving.pauseProving(state, _pause);
}

Expand Down Expand Up @@ -216,7 +216,11 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents, TaikoErrors {
});
}

function _authorizePause(address)
/// @dev chain_pauser is supposed to be a cold wallet.
function _authorizePause(
address,
bool
)
internal
view
virtual
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L2/DelegateOwner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ contract DelegateOwner is EssentialContract, IMessageInvocable {
emit OwnershipAccepted(target);
}

function _authorizePause(address) internal pure override {
function _authorizePause(address, bool) internal pure override {
revert DO_UNSUPPORTED();
}
}
20 changes: 12 additions & 8 deletions packages/protocol/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -442,14 +442,18 @@ contract Bridge is EssentialContract, IBridge {
return _msgHash ^ bytes32(uint256(Status.FAILED));
}

/// @notice Checks if the given address can pause and unpause the bridge.
function _authorizePause(address)
internal
view
virtual
override
onlyFromOwnerOrNamed("bridge_pauser")
{ }
/// @notice Checks if the given address can pause and/or unpause the bridge.
/// @dev Considering that the watchdog is a hot wallet, in case its private key is leaked, we
/// only allow watchdog to pause the bridge, but does not allow it to unpause the bridge.
function _authorizePause(address addr, bool toPause) internal view virtual override {
// Owenr and chain_pauser can pause/unpause the bridge.
if (addr == owner() || addr == resolve("chain_pauser", true)) return;

// bridge_watchdog can pause the bridge, but cannot unpause it.
if (toPause && addr == resolve("bridge_watchdog", true)) return;

revert RESOLVER_DENIED();
}

/// @notice Invokes a call message on the Bridge.
/// @param _message The call message to be invoked.
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/common/AddressManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ contract AddressManager is EssentialContract, IAddressManager {
return __addresses[_chainId][_name];
}

function _authorizePause(address) internal pure override {
function _authorizePause(address, bool) internal pure override {
revert AM_UNSUPPORTED();
}
}
6 changes: 3 additions & 3 deletions packages/protocol/contracts/common/EssentialContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable,
emit Paused(msg.sender);
// We call the authorize function here to avoid:
// Warning (5740): Unreachable code.
_authorizePause(msg.sender);
_authorizePause(msg.sender, true);
}

/// @notice Unpauses the contract.
Expand All @@ -81,7 +81,7 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable,
emit Unpaused(msg.sender);
// We call the authorize function here to avoid:
// Warning (5740): Unreachable code.
_authorizePause(msg.sender);
_authorizePause(msg.sender, false);
}

/// @notice Returns true if the contract is paused, and false otherwise.
Expand Down Expand Up @@ -114,7 +114,7 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable,

function _authorizeUpgrade(address) internal virtual override onlyOwner { }

function _authorizePause(address) internal virtual onlyOwner { }
function _authorizePause(address, bool) internal virtual onlyOwner { }

// Stores the reentry lock
function _storeReentryLock(uint8 _reentry) internal virtual {
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/signal/SignalService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ contract SignalService is EssentialContract, ISignalService {
);
}

function _authorizePause(address) internal pure override {
function _authorizePause(address, bool) internal pure override {
revert SS_UNSUPPORTED();
}

Expand Down
Loading