From ba7b6e2eb895a41b664b76586ada234e6f72c3c4 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 28 Apr 2024 10:57:38 +0800 Subject: [PATCH 1/4] fix a deployment issue --- packages/protocol/contracts/L1/TaikoL1.sol | 6 ++--- .../contracts/common/EssentialContract.sol | 22 +++++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/protocol/contracts/L1/TaikoL1.sol b/packages/protocol/contracts/L1/TaikoL1.sol index 8134f9ce6fc..8268e6ad2c1 100644 --- a/packages/protocol/contracts/L1/TaikoL1.sol +++ b/packages/protocol/contracts/L1/TaikoL1.sol @@ -43,19 +43,19 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents, TaikoErrors { /// @param _owner The owner of this contract. msg.sender will be used if this value is zero. /// @param _addressManager The address of the {AddressManager} contract. /// @param _genesisBlockHash The block hash of the genesis block. - /// @param _pause true to pause the contract by default. + /// @param _toPause true to pause the contract by default. function init( address _owner, address _addressManager, bytes32 _genesisBlockHash, - bool _pause + bool _toPause ) external initializer { __Essential_init(_owner, _addressManager); LibVerifying.init(state, getConfig(), _genesisBlockHash); - if (_pause) pause(); + if (_toPause) _pause(); } function init2() external onlyOwner reinitializer(2) { diff --git a/packages/protocol/contracts/common/EssentialContract.sol b/packages/protocol/contracts/common/EssentialContract.sol index a4758fd3919..ecfe8a00344 100644 --- a/packages/protocol/contracts/common/EssentialContract.sol +++ b/packages/protocol/contracts/common/EssentialContract.sol @@ -70,19 +70,16 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, } /// @notice Pauses the contract. - function pause() public virtual whenNotPaused { - __paused = _TRUE; - emit Paused(msg.sender); + function pause() public virtual whenNotPaused onlyOwner { + _pause(); // We call the authorize function here to avoid: // Warning (5740): Unreachable code. _authorizePause(msg.sender, true); } /// @notice Unpauses the contract. - function unpause() public virtual whenPaused { - __paused = _FALSE; - lastUnpausedAt = uint64(block.timestamp); - emit Unpaused(msg.sender); + function unpause() public virtual whenPaused onlyOwner { + _unpause(); // We call the authorize function here to avoid: // Warning (5740): Unreachable code. _authorizePause(msg.sender, false); @@ -108,6 +105,17 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, __paused = _FALSE; } + function _pause() internal { + __paused = _TRUE; + emit Paused(msg.sender); + } + + function _unpause() internal { + __paused = _FALSE; + lastUnpausedAt = uint64(block.timestamp); + emit Unpaused(msg.sender); + } + function _authorizeUpgrade(address) internal virtual override onlyOwner { } function _authorizePause(address, bool) internal virtual onlyOwner { } From ffe0be6191d40bc5df08d1e4097ec2a7e034b8b2 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 28 Apr 2024 11:10:14 +0800 Subject: [PATCH 2/4] Update EssentialContract.sol --- packages/protocol/contracts/common/EssentialContract.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/protocol/contracts/common/EssentialContract.sol b/packages/protocol/contracts/common/EssentialContract.sol index ecfe8a00344..cc86dc5dab3 100644 --- a/packages/protocol/contracts/common/EssentialContract.sol +++ b/packages/protocol/contracts/common/EssentialContract.sol @@ -70,7 +70,7 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, } /// @notice Pauses the contract. - function pause() public virtual whenNotPaused onlyOwner { + function pause() public virtual onlyOwner { _pause(); // We call the authorize function here to avoid: // Warning (5740): Unreachable code. @@ -78,7 +78,7 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, } /// @notice Unpauses the contract. - function unpause() public virtual whenPaused onlyOwner { + function unpause() public virtual onlyOwner { _unpause(); // We call the authorize function here to avoid: // Warning (5740): Unreachable code. @@ -105,12 +105,12 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, __paused = _FALSE; } - function _pause() internal { + function _pause() internal whenNotPaused { __paused = _TRUE; emit Paused(msg.sender); } - function _unpause() internal { + function _unpause() internal whenPaused { __paused = _FALSE; lastUnpausedAt = uint64(block.timestamp); emit Unpaused(msg.sender); From 1f5c9fc1963712612c9cc945f258a35def8bfa22 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 28 Apr 2024 11:12:31 +0800 Subject: [PATCH 3/4] Update EssentialContract.sol --- packages/protocol/contracts/common/EssentialContract.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/protocol/contracts/common/EssentialContract.sol b/packages/protocol/contracts/common/EssentialContract.sol index cc86dc5dab3..be5c6bab13c 100644 --- a/packages/protocol/contracts/common/EssentialContract.sol +++ b/packages/protocol/contracts/common/EssentialContract.sol @@ -70,7 +70,7 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, } /// @notice Pauses the contract. - function pause() public virtual onlyOwner { + function pause() external virtual { _pause(); // We call the authorize function here to avoid: // Warning (5740): Unreachable code. @@ -78,7 +78,7 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, } /// @notice Unpauses the contract. - function unpause() public virtual onlyOwner { + function unpause() external virtual { _unpause(); // We call the authorize function here to avoid: // Warning (5740): Unreachable code. From c9e69acb710c5795dee90ae4ebf90c62d113c372 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Sun, 28 Apr 2024 11:13:30 +0800 Subject: [PATCH 4/4] Update EssentialContract.sol --- packages/protocol/contracts/common/EssentialContract.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/protocol/contracts/common/EssentialContract.sol b/packages/protocol/contracts/common/EssentialContract.sol index be5c6bab13c..8e4d000f9d1 100644 --- a/packages/protocol/contracts/common/EssentialContract.sol +++ b/packages/protocol/contracts/common/EssentialContract.sol @@ -70,7 +70,7 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, } /// @notice Pauses the contract. - function pause() external virtual { + function pause() public virtual { _pause(); // We call the authorize function here to avoid: // Warning (5740): Unreachable code. @@ -78,7 +78,7 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, } /// @notice Unpauses the contract. - function unpause() external virtual { + function unpause() public virtual { _unpause(); // We call the authorize function here to avoid: // Warning (5740): Unreachable code.