diff --git a/packages/protocol/contracts/layer1/based/TaikoL1.sol b/packages/protocol/contracts/layer1/based/TaikoL1.sol index 9864fd037fc..a7a33982dc6 100644 --- a/packages/protocol/contracts/layer1/based/TaikoL1.sol +++ b/packages/protocol/contracts/layer1/based/TaikoL1.sol @@ -49,13 +49,14 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents { bool _toPause ) external - reinitializer(2) + initializer { __Essential_init(_owner, _rollupAddressManager); LibUtils.init(state, getConfig(), _genesisBlockHash); if (_toPause) _pause(); } + /// @notice This function shall be called by previously deployed contracts. function init2() external onlyOwner reinitializer(2) { // reset some previously used slots for future reuse state.slotB.__reservedB1 = 0; diff --git a/packages/protocol/contracts/shared/bridge/Bridge.sol b/packages/protocol/contracts/shared/bridge/Bridge.sol index 813445ef678..9805db23013 100644 --- a/packages/protocol/contracts/shared/bridge/Bridge.sol +++ b/packages/protocol/contracts/shared/bridge/Bridge.sol @@ -104,10 +104,11 @@ contract Bridge is EssentialContract, IBridge { /// @notice Initializes the contract. /// @param _owner The owner of this contract. msg.sender will be used if this value is zero. /// @param _sharedAddressManager The address of the {AddressManager} contract. - function init(address _owner, address _sharedAddressManager) external reinitializer(2) { + function init(address _owner, address _sharedAddressManager) external initializer { __Essential_init(_owner, _sharedAddressManager); } + /// @notice This function shall be called by previously deployed contracts. function init2() external onlyOwner reinitializer(2) { // reset some previously used slots for future reuse __reserved1 = 0; diff --git a/packages/protocol/contracts/shared/common/AddressManager.sol b/packages/protocol/contracts/shared/common/AddressManager.sol index d16e9f97c55..0fe5dddc5c7 100644 --- a/packages/protocol/contracts/shared/common/AddressManager.sol +++ b/packages/protocol/contracts/shared/common/AddressManager.sol @@ -25,10 +25,11 @@ contract AddressManager is EssentialContract, IAddressManager { /// @notice Initializes the contract. /// @param _owner The owner of this contract. - function init(address _owner) external reinitializer(2) { + function init(address _owner) external initializer { __Essential_init(_owner, address(this)); } + /// @notice This function shall be called by previously deployed contracts. function init2() external onlyOwner reinitializer(2) { addressManager = address(this); } diff --git a/packages/protocol/contracts/shared/tokenvault/BridgedERC20V2.sol b/packages/protocol/contracts/shared/tokenvault/BridgedERC20V2.sol index cc2b58ffa76..85cdfafefc6 100644 --- a/packages/protocol/contracts/shared/tokenvault/BridgedERC20V2.sol +++ b/packages/protocol/contracts/shared/tokenvault/BridgedERC20V2.sol @@ -29,7 +29,9 @@ contract BridgedERC20V2 is BridgedERC20, IERC20PermitUpgradeable, EIP712Upgradea error BTOKEN_INVALID_SIG(); /// @inheritdoc IBridgedERC20Initializable - /// @dev Calling this function will change the initialized version to 2. + /// @dev This function is called when the bridge deploys a new bridged ERC20 token, so this + /// function must also cover the logic in init2(), we use + /// `reinitializer(2)` instead of `initializer`. function init( address _owner, address _sharedAddressManager, @@ -48,31 +50,27 @@ contract BridgedERC20V2 is BridgedERC20, IERC20PermitUpgradeable, EIP712Upgradea LibBridgedToken.validateInputs(_srcToken, _srcChainId); __Essential_init(_owner, _sharedAddressManager); __ERC20_init(_name, _symbol); - __EIP712_init_unchained(_name, "1"); - // Set contract properties srcToken = _srcToken; srcChainId = _srcChainId; __srcDecimals = _decimals; + + // Cover logics from `init2()` + __EIP712_init_unchained(_name, "1"); } - /// @dev This function shall be called when upgrading a deployed contract from {BridgedERC20} to - /// {BridgedERC20V2}. + /// @notice This function shall be called by previously deployed contracts. function init2() external reinitializer(2) { __EIP712_init_unchained(name(), "1"); } - /** - * @inheritdoc IERC20PermitUpgradeable - */ - // solhint-disable-next-line func-name-mixedcase + /// @inheritdoc IERC20PermitUpgradeable + // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } - /** - * @inheritdoc IERC20PermitUpgradeable - */ + /// @inheritdoc IERC20PermitUpgradeable function permit( address owner, address spender, @@ -100,9 +98,7 @@ contract BridgedERC20V2 is BridgedERC20, IERC20PermitUpgradeable, EIP712Upgradea _approve(owner, spender, value); } - /** - * @inheritdoc IERC20PermitUpgradeable - */ + /// @inheritdoc IERC20PermitUpgradeable function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } @@ -113,11 +109,7 @@ contract BridgedERC20V2 is BridgedERC20, IERC20PermitUpgradeable, EIP712Upgradea || super.supportsInterface(_interfaceId); } - /** - * @dev "Consume a nonce": return the current value and increment. - * - * _Available since v4.1._ - */ + /// @dev "Consume a nonce": return the current value and increment. function _useNonce(address owner) internal virtual returns (uint256 current) { CountersUpgradeable.Counter storage nonce = _nonces[owner]; current = nonce.current(); diff --git a/packages/protocol/test/shared/thirdparty/Multicall3.sol b/packages/protocol/test/shared/thirdparty/Multicall3.sol index 2b15bc3d116..38b96a3e872 100644 --- a/packages/protocol/test/shared/thirdparty/Multicall3.sol +++ b/packages/protocol/test/shared/thirdparty/Multicall3.sol @@ -1,7 +1,3 @@ -/** - * Submitted for verification at taikoscan.io on 2024-05-30 - */ - // SPDX-License-Identifier: MIT pragma solidity ^0.8.24;