Skip to content

Commit

Permalink
chore(protocol): tighten up solhint (#16192)
Browse files Browse the repository at this point in the history
  • Loading branch information
dionysuzx authored Mar 1, 2024
1 parent c021d40 commit e547418
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 28 deletions.
18 changes: 9 additions & 9 deletions packages/protocol/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
5 changes: 3 additions & 2 deletions packages/protocol/contracts/L1/gov/TaikoGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion packages/protocol/contracts/L2/CrossChainOwned.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 13 additions & 9 deletions packages/protocol/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -183,7 +184,6 @@ contract Bridge is EssentialContract, IBridge {
proofReceipt[msgHash].receivedAt = receivedAt;
}

// assert(receivedAt != 0);
(uint256 invocationDelay,) = getInvocationDelays();

if (block.timestamp >= invocationDelay + receivedAt) {
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions packages/protocol/contracts/common/AddressManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import "./EssentialContract.sol";
/// @notice See the documentation in {IAddressManager}.
/// @custom:security-contact [email protected]
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.
Expand Down
1 change: 0 additions & 1 deletion packages/protocol/contracts/common/AddressResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
13 changes: 8 additions & 5 deletions packages/protocol/contracts/common/EssentialContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ import "./AddressResolver.sol";
/// @custom:security-contact [email protected]
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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e547418

Please sign in to comment.