diff --git a/packages/protocol/.solhint.json b/packages/protocol/.solhint.json index d87ac7b79a..047afd0e5b 100644 --- a/packages/protocol/.solhint.json +++ b/packages/protocol/.solhint.json @@ -2,17 +2,17 @@ "extends": "solhint:recommended", "rules": { "avoid-low-level-calls": "off", - "compiler-version": ["error", "^0.8.24"], - "func-visibility": ["warn", { "ignoreConstructors": true }], - "max-line-length": "off", + "avoid-tx-origin": "off", + "compiler-version": ["error", "0.8.24"], + "func-name-mixedcase": "off", + "func-visibility": ["error", { "ignoreConstructors": true }], + "max-line-length": ["error", 120], "no-empty-blocks": "off", + "named-parameters-mapping": "warn", + "no-console": "off", + "no-global-import": "off", "no-inline-assembly": "off", "not-rely-on-time": "off", - "ordering": "warn", - "payable-fallback": "off", - "no-console": "off", - "avoid-tx-origin": "off", - "one-contract-per-file": "off", - "no-global-import": "off" + "one-contract-per-file": "off" } } diff --git a/packages/protocol/contracts/L1/gov/TaikoGovernor.sol b/packages/protocol/contracts/L1/gov/TaikoGovernor.sol index f5b6cd2bb6..6a44820ee5 100644 --- a/packages/protocol/contracts/L1/gov/TaikoGovernor.sol +++ b/packages/protocol/contracts/L1/gov/TaikoGovernor.sol @@ -62,8 +62,9 @@ contract TaikoGovernor is /// not check that the length of signatures equal the calldata. /// @dev See vulnerability description here: /// https://github.com/taikoxyz/taiko-mono/security/dependabot/114 - /// See fix in OZ 4.8.3 here: - /// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/0a25c1940ca220686588c4af3ec526f725fe2582/contracts/governance/compatibility/GovernorCompatibilityBravo.sol#L72 + /// See fix in OZ 4.8.3 here (URL broken down for readability): + /// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/ + /// 0a25c1940ca220686588c4af3ec526f725fe2582/contracts/governance/compatibility/GovernorCompatibilityBravo.sol#L72 /// See {GovernorCompatibilityBravoUpgradeable-propose} function propose( address[] memory _targets, diff --git a/packages/protocol/contracts/L2/CrossChainOwned.sol b/packages/protocol/contracts/L2/CrossChainOwned.sol index 1a49d900d8..f73ddae46c 100644 --- a/packages/protocol/contracts/L2/CrossChainOwned.sol +++ b/packages/protocol/contracts/L2/CrossChainOwned.sol @@ -55,7 +55,6 @@ abstract contract CrossChainOwned is EssentialContract, IMessageInvocable { /// @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 _ownerChainId The owner's deployment chain ID. - // solhint-disable-next-line func-name-mixedcase function __CrossChainOwned_init( address _owner, address _addressManager, diff --git a/packages/protocol/contracts/bridge/Bridge.sol b/packages/protocol/contracts/bridge/Bridge.sol index 7b573ba41a..8210df1a3a 100644 --- a/packages/protocol/contracts/bridge/Bridge.sol +++ b/packages/protocol/contracts/bridge/Bridge.sol @@ -18,11 +18,12 @@ contract Bridge is EssentialContract, IBridge { using LibAddress for address; using LibAddress for address payable; - // The slot in transient storage of the call context - // This is the keccak256 hash of "bridge.ctx_slot" + /// @dev The slot in transient storage of the call context. This is the keccak256 hash + /// of "bridge.ctx_slot" bytes32 private constant _CTX_SLOT = 0xe4ece82196de19aabe639620d7f716c433d1348f96ce727c9989a982dbadc2b9; - // Place holder value when not using transient storage + + /// @dev Place holder value when not using transient storage uint256 internal constant PLACEHOLDER = type(uint256).max; /// @notice The next message ID. @@ -138,8 +139,8 @@ contract Bridge is EssentialContract, IBridge { if (expectedAmount != msg.value) revert B_INVALID_VALUE(); message_ = _message; - // Configure message details and send signal to indicate message - // sending. + + // Configure message details and send signal to indicate message sending. message_.id = nextMessageId++; message_.from = msg.sender; message_.srcChainId = uint64(block.chainid); @@ -183,7 +184,6 @@ contract Bridge is EssentialContract, IBridge { proofReceipt[msgHash].receivedAt = receivedAt; } - // assert(receivedAt != 0); (uint256 invocationDelay,) = getInvocationDelays(); if (block.timestamp >= invocationDelay + receivedAt) { @@ -535,6 +535,9 @@ contract Bridge is EssentialContract, IBridge { } /// @notice Stores the call context + /// @param _msgHash The message hash. + /// @param _from The sender's address. + /// @param _srcChainId The source chain ID. function _storeContext(bytes32 _msgHash, address _from, uint64 _srcChainId) private { if (block.chainid == 1) { assembly { @@ -547,7 +550,8 @@ contract Bridge is EssentialContract, IBridge { } } - /// @notice Loads the call context + /// @notice Loads and returns the call context. + /// @return ctx_ The call context. function _loadContext() private view returns (Context memory) { if (block.chainid == 1) { bytes32 msgHash; @@ -565,9 +569,9 @@ contract Bridge is EssentialContract, IBridge { } /// @notice Checks if the signal was received. - /// @param _signalService The signalService + /// @param _signalService The signal service address. /// @param _signal The signal. - /// @param _chainId The ID of the chain the signal is stored on + /// @param _chainId The ID of the chain the signal is stored on. /// @param _proof The merkle inclusion proof. /// @return success_ True if the message was received. function _proveSignalReceived( diff --git a/packages/protocol/contracts/common/AddressManager.sol b/packages/protocol/contracts/common/AddressManager.sol index 89d9fe80fa..dae2e26cad 100644 --- a/packages/protocol/contracts/common/AddressManager.sol +++ b/packages/protocol/contracts/common/AddressManager.sol @@ -8,7 +8,9 @@ import "./EssentialContract.sol"; /// @notice See the documentation in {IAddressManager}. /// @custom:security-contact security@taiko.xyz contract AddressManager is EssentialContract, IAddressManager { + /// @dev Mapping of chainId to mapping of name to address. mapping(uint256 chainId => mapping(bytes32 name => address addr)) private __addresses; + uint256[49] private __gap; /// @notice Emitted when an address is set. diff --git a/packages/protocol/contracts/common/AddressResolver.sol b/packages/protocol/contracts/common/AddressResolver.sol index 4b89f19cb0..122e93fe03 100644 --- a/packages/protocol/contracts/common/AddressResolver.sol +++ b/packages/protocol/contracts/common/AddressResolver.sol @@ -55,7 +55,6 @@ abstract contract AddressResolver is IAddressResolver, Initializable { /// @dev Initialization method for setting up AddressManager reference. /// @param _addressManager Address of the AddressManager. - // solhint-disable-next-line func-name-mixedcase function __AddressResolver_init(address _addressManager) internal virtual onlyInitializing { if (block.chainid > type(uint64).max) { revert RESOLVER_UNEXPECTED_CHAINID(); diff --git a/packages/protocol/contracts/common/EssentialContract.sol b/packages/protocol/contracts/common/EssentialContract.sol index 4dbe1073ce..3f27aa40fd 100644 --- a/packages/protocol/contracts/common/EssentialContract.sol +++ b/packages/protocol/contracts/common/EssentialContract.sol @@ -9,15 +9,19 @@ import "./AddressResolver.sol"; /// @custom:security-contact security@taiko.xyz abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, AddressResolver { uint8 private constant _FALSE = 1; + uint8 private constant _TRUE = 2; - // The slot in transient storage of the reentry lock - // This is the keccak256 hash of "ownerUUPS.reentry_slot" + /// @dev The slot in transient storage of the reentry lock. This is the keccak256 hash + /// of "ownerUUPS.reentry_slot" bytes32 private constant _REENTRY_SLOT = 0xa5054f728453d3dbe953bdc43e4d0cb97e662ea32d7958190f3dc2da31d9721a; - uint8 private __reentry; // slot 1 + /// @dev Slot 1. + uint8 private __reentry; + uint8 private __paused; + uint256[49] private __gap; /// @notice Emitted when the contract is paused. @@ -88,7 +92,6 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, /// @notice Initializes the contract. /// @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. - // solhint-disable-next-line func-name-mixedcase function __Essential_init( address _owner, address _addressManager @@ -103,13 +106,13 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable, __AddressResolver_init(_addressManager); } - // solhint-disable-next-line func-name-mixedcase function __Essential_init(address _owner) internal virtual { _transferOwnership(_owner == address(0) ? msg.sender : _owner); __paused = _FALSE; } function _authorizeUpgrade(address) internal virtual override onlyOwner { } + function _authorizePause(address) internal virtual onlyOwner { } // Stores the reentry lock diff --git a/packages/protocol/contracts/team/airdrop/MerkleClaimable.sol b/packages/protocol/contracts/team/airdrop/MerkleClaimable.sol index a6f5653b74..df5e3bd9d1 100644 --- a/packages/protocol/contracts/team/airdrop/MerkleClaimable.sol +++ b/packages/protocol/contracts/team/airdrop/MerkleClaimable.sol @@ -53,7 +53,6 @@ abstract contract MerkleClaimable is EssentialContract { _setConfig(_claimStart, _claimEnd, _merkleRoot); } - // solhint-disable-next-line func-name-mixedcase function __MerkleClaimable_init( uint64 _claimStart, uint64 _claimEnd,