Skip to content

Commit

Permalink
Revert "improve comments"
Browse files Browse the repository at this point in the history
This reverts commit be3384d.
  • Loading branch information
dantaik committed Oct 27, 2024
1 parent 64b627d commit 1565b0c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
4 changes: 1 addition & 3 deletions packages/protocol/contracts/layer1/based/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
bool _toPause
)
external
initializer
reinitializer(3)
{
__Essential_init(_owner, _rollupAddressManager);
LibUtils.init(state, _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;
Expand All @@ -63,7 +62,6 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
state.__reserve1 = 0;
}

/// @notice This function shall be called by previously deployed contracts.
function init3() external onlyOwner reinitializer(3) {
// this value from EssentialContract is no longer used.
__lastUnpausedAt = 0;
Expand Down
3 changes: 1 addition & 2 deletions packages/protocol/contracts/shared/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ 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 initializer {
function init(address _owner, address _sharedAddressManager) external reinitializer(2) {
__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;
Expand Down
3 changes: 1 addition & 2 deletions packages/protocol/contracts/shared/common/AddressManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ contract AddressManager is EssentialContract, IAddressManager {

/// @notice Initializes the contract.
/// @param _owner The owner of this contract.
function init(address _owner) external initializer {
function init(address _owner) external reinitializer(2) {
__Essential_init(_owner, address(this));
}

/// @notice This function shall be called by previously deployed contracts.
function init2() external onlyOwner reinitializer(2) {
addressManager = address(this);
}
Expand Down
32 changes: 20 additions & 12 deletions packages/protocol/contracts/shared/tokenvault/BridgedERC20V2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ contract BridgedERC20V2 is BridgedERC20, IERC20PermitUpgradeable, EIP712Upgradea
error BTOKEN_INVALID_SIG();

/// @inheritdoc IBridgedERC20Initializable
/// @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`.
/// @dev Calling this function will change the initialized version to 2.
function init(
address _owner,
address _sharedAddressManager,
Expand All @@ -50,27 +48,31 @@ 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");
}

/// @notice This function shall be called by previously deployed contracts.
/// @dev This function shall be called when upgrading a deployed contract from {BridgedERC20} to
/// {BridgedERC20V2}.
function init2() external reinitializer(2) {
__EIP712_init_unchained(name(), "1");
}

/// @inheritdoc IERC20PermitUpgradeable
/**
* @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,
Expand Down Expand Up @@ -98,7 +100,9 @@ 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();
}
Expand All @@ -109,7 +113,11 @@ contract BridgedERC20V2 is BridgedERC20, IERC20PermitUpgradeable, EIP712Upgradea
|| super.supportsInterface(_interfaceId);
}

/// @dev "Consume a nonce": return the current value and increment.
/**
* @dev "Consume a nonce": return the current value and increment.
*
* _Available since v4.1._
*/
function _useNonce(address owner) internal virtual returns (uint256 current) {
CountersUpgradeable.Counter storage nonce = _nonces[owner];
current = nonce.current();
Expand Down

0 comments on commit 1565b0c

Please sign in to comment.