From c95d8f80832d7867daf98dd73ae2f4ad670b970c Mon Sep 17 00:00:00 2001 From: Lei Date: Fri, 27 Oct 2023 09:41:34 -0700 Subject: [PATCH] fix solhint issues under src/v0.8/automation (#11065) --- contracts/package.json | 2 +- contracts/src/v0.8/automation/AutomationBase.sol | 5 +++-- contracts/src/v0.8/automation/AutomationCompatible.sol | 4 ++-- contracts/src/v0.8/automation/Chainable.sol | 10 ++++++---- contracts/src/v0.8/automation/ExecutionPrevention.sol | 5 +++-- contracts/src/v0.8/automation/HeartbeatRequester.sol | 6 ++++-- contracts/src/v0.8/automation/UpkeepTranscoder.sol | 6 ++++-- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/contracts/package.json b/contracts/package.json index 46b47440a6e..935c7901b6b 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -18,7 +18,7 @@ "prepublishOnly": "pnpm compile && ./scripts/prepublish_generate_abi_folder", "publish-beta": "pnpm publish --tag beta", "publish-prod": "npm dist-tag add @chainlink/contracts@0.8.0 latest", - "solhint": "solhint --max-warnings 377 \"./src/v0.8/**/*.sol\"" + "solhint": "solhint --max-warnings 350 \"./src/v0.8/**/*.sol\"" }, "files": [ "src/v0.8", diff --git a/contracts/src/v0.8/automation/AutomationBase.sol b/contracts/src/v0.8/automation/AutomationBase.sol index d91780a79f7..8267fbc6a4e 100644 --- a/contracts/src/v0.8/automation/AutomationBase.sol +++ b/contracts/src/v0.8/automation/AutomationBase.sol @@ -8,7 +8,8 @@ contract AutomationBase { * @notice method that allows it to be simulated via eth_call by checking that * the sender is the zero address. */ - function preventExecution() internal view { + function _preventExecution() internal view { + // solhint-disable-next-line avoid-tx-origin if (tx.origin != address(0)) { revert OnlySimulatedBackend(); } @@ -19,7 +20,7 @@ contract AutomationBase { * that the sender is the zero address. */ modifier cannotExecute() { - preventExecution(); + _preventExecution(); _; } } diff --git a/contracts/src/v0.8/automation/AutomationCompatible.sol b/contracts/src/v0.8/automation/AutomationCompatible.sol index 5634956ea70..65332436842 100644 --- a/contracts/src/v0.8/automation/AutomationCompatible.sol +++ b/contracts/src/v0.8/automation/AutomationCompatible.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import "./AutomationBase.sol"; -import "./interfaces/AutomationCompatibleInterface.sol"; +import {AutomationBase} from "./AutomationBase.sol"; +import {AutomationCompatibleInterface} from "./interfaces/AutomationCompatibleInterface.sol"; abstract contract AutomationCompatible is AutomationBase, AutomationCompatibleInterface {} diff --git a/contracts/src/v0.8/automation/Chainable.sol b/contracts/src/v0.8/automation/Chainable.sol index 1b446f013a0..29ac7796c4a 100644 --- a/contracts/src/v0.8/automation/Chainable.sol +++ b/contracts/src/v0.8/automation/Chainable.sol @@ -10,29 +10,31 @@ contract Chainable { /** * @dev addresses of the next contract in the chain **have to be immutable/constant** or the system won't work */ - address private immutable FALLBACK_ADDRESS; + address private immutable i_FALLBACK_ADDRESS; /** * @param fallbackAddress the address of the next contract in the chain */ constructor(address fallbackAddress) { - FALLBACK_ADDRESS = fallbackAddress; + i_FALLBACK_ADDRESS = fallbackAddress; } /** * @notice returns the address of the next contract in the chain */ function fallbackTo() external view returns (address) { - return FALLBACK_ADDRESS; + return i_FALLBACK_ADDRESS; } /** * @notice the fallback function routes the call to the next contract in the chain * @dev most of the implementation is copied directly from OZ's Proxy contract */ + // solhint-disable payable-fallback + // solhint-disable-next-line no-complex-fallback fallback() external { // copy to memory for assembly access - address next = FALLBACK_ADDRESS; + address next = i_FALLBACK_ADDRESS; // copied directly from OZ's Proxy contract assembly { // Copy msg.data. We take full control of memory in this inline assembly diff --git a/contracts/src/v0.8/automation/ExecutionPrevention.sol b/contracts/src/v0.8/automation/ExecutionPrevention.sol index a8baf55fd22..30a823c4b8d 100644 --- a/contracts/src/v0.8/automation/ExecutionPrevention.sol +++ b/contracts/src/v0.8/automation/ExecutionPrevention.sol @@ -8,7 +8,8 @@ abstract contract ExecutionPrevention { * @notice method that allows it to be simulated via eth_call by checking that * the sender is the zero address. */ - function preventExecution() internal view { + function _preventExecution() internal view { + // solhint-disable-next-line avoid-tx-origin if (tx.origin != address(0)) { revert OnlySimulatedBackend(); } @@ -19,7 +20,7 @@ abstract contract ExecutionPrevention { * that the sender is the zero address. */ modifier cannotExecute() { - preventExecution(); + _preventExecution(); _; } } diff --git a/contracts/src/v0.8/automation/HeartbeatRequester.sol b/contracts/src/v0.8/automation/HeartbeatRequester.sol index d5802a79580..aa390738001 100644 --- a/contracts/src/v0.8/automation/HeartbeatRequester.sol +++ b/contracts/src/v0.8/automation/HeartbeatRequester.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT +// solhint-disable-next-line one-contract-per-file pragma solidity 0.8.6; -import "./../interfaces/TypeAndVersionInterface.sol"; -import "../shared/access/ConfirmedOwner.sol"; +import {TypeAndVersionInterface} from "./../interfaces/TypeAndVersionInterface.sol"; +import {ConfirmedOwner} from "../shared/access/ConfirmedOwner.sol"; // defines some interfaces for type safety and reduces encoding/decoding // does not use the full interfaces intentionally because the requester only uses a fraction of them @@ -32,6 +33,7 @@ contract HeartbeatRequester is TypeAndVersionInterface, ConfirmedOwner { * - HeartbeatRequester 1.0.0: The requester fetches the latest aggregator address from proxy, and request a new round * using the aggregator address. */ + // solhint-disable-next-line chainlink-solidity/all-caps-constant-storage-variables string public constant override typeAndVersion = "HeartbeatRequester 1.0.0"; constructor() ConfirmedOwner(msg.sender) {} diff --git a/contracts/src/v0.8/automation/UpkeepTranscoder.sol b/contracts/src/v0.8/automation/UpkeepTranscoder.sol index 450da8c14a1..144a96c7e77 100644 --- a/contracts/src/v0.8/automation/UpkeepTranscoder.sol +++ b/contracts/src/v0.8/automation/UpkeepTranscoder.sol @@ -2,8 +2,9 @@ pragma solidity ^0.8.0; -import "./interfaces/UpkeepTranscoderInterface.sol"; -import "../interfaces/TypeAndVersionInterface.sol"; +import {UpkeepTranscoderInterface} from "./interfaces/UpkeepTranscoderInterface.sol"; +import {TypeAndVersionInterface} from "../interfaces/TypeAndVersionInterface.sol"; +import {UpkeepFormat} from "./UpkeepFormat.sol"; /** * @notice Transcoder for converting upkeep data from one keeper @@ -16,6 +17,7 @@ contract UpkeepTranscoder is UpkeepTranscoderInterface, TypeAndVersionInterface * @notice versions: * - UpkeepTranscoder 1.0.0: placeholder to allow new formats in the future */ + // solhint-disable-next-line chainlink-solidity/all-caps-constant-storage-variables string public constant override typeAndVersion = "UpkeepTranscoder 1.0.0"; /**