Skip to content

Commit

Permalink
resolving solhint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-de-leon-cll committed Mar 25, 2024
1 parent ab8757e commit f3e743f
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 55 deletions.
16 changes: 8 additions & 8 deletions contracts/src/v0.8/l2ep/dev/CrossDomainForwarder.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {CrossDomainOwnableInterface} from "./interfaces/CrossDomainOwnableInterface.sol";
import {ICrossDomainOwnableInterface} from "./interfaces/ICrossDomainOwnableInterface.sol";
import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol";
import {ForwarderInterface} from "./interfaces/ForwarderInterface.sol";
import {IForwarderInterface} from "./interfaces/IForwarderInterface.sol";

import {ConfirmedOwner} from "../../shared/access/ConfirmedOwner.sol";

Expand All @@ -15,8 +15,8 @@ import {Address} from "../../vendor/openzeppelin-solidity/v4.7.3/contracts/utils
/// can consider that position to be held by the `l1Owner`
abstract contract CrossDomainForwarder is
ITypeAndVersion,
ForwarderInterface,
CrossDomainOwnableInterface,
IForwarderInterface,
ICrossDomainOwnableInterface,
ConfirmedOwner
{
address internal s_l1Owner;
Expand All @@ -29,14 +29,14 @@ abstract contract CrossDomainForwarder is

/// @notice Reverts if called by anyone other than the L1 owner.
modifier onlyL1Owner() virtual {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(msg.sender == s_l1Owner, "Only callable by L1 owner");
_;
}

/// @notice Reverts if called by anyone other than the L1 owner.
modifier onlyProposedL1Owner() virtual {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(msg.sender == s_l1PendingOwner, "Only callable by proposed L1 owner");
_;
}
Expand All @@ -45,7 +45,7 @@ abstract contract CrossDomainForwarder is
function crossDomainMessenger() external view virtual returns (address);

/// @dev forwarded only if L2 Messenger calls with `xDomainMessageSender` being the L1 owner address
/// @inheritdoc ForwarderInterface
/// @inheritdoc IForwarderInterface
function forward(address target, bytes memory data) external virtual override onlyL1Owner {
Address.functionCall(target, data, "Forwarder call reverted");
}
Expand All @@ -68,7 +68,7 @@ abstract contract CrossDomainForwarder is

/// @notice validate, transfer ownership, and emit relevant events
function _transferL1Ownership(address to) internal {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(to != msg.sender, "Cannot transfer to self");

s_l1PendingOwner = to;
Expand Down
10 changes: 5 additions & 5 deletions contracts/src/v0.8/l2ep/dev/CrossDomainGovernor.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {DelegateForwarderInterface} from "./interfaces/DelegateForwarderInterface.sol";
import {IDelegateForwarderInterface} from "./interfaces/IDelegateForwarderInterface.sol";
// solhint-disable-next-line no-unused-import
import {ForwarderInterface} from "./interfaces/ForwarderInterface.sol";
import {IForwarderInterface} from "./interfaces/IForwarderInterface.sol";

import {CrossDomainForwarder} from "./CrossDomainForwarder.sol";

Expand All @@ -13,21 +13,21 @@ import {Address} from "../../vendor/openzeppelin-solidity/v4.7.3/contracts/utils
/// @notice L2 Contract which receives messages from a specific L1 address and transparently forwards them to the destination.
/// @dev Any other L2 contract which uses this contract's address as a privileged position,
/// can be considered to be simultaneously owned by the `l1Owner` and L2 `owner`
abstract contract CrossDomainGovernor is DelegateForwarderInterface, CrossDomainForwarder {
abstract contract CrossDomainGovernor is IDelegateForwarderInterface, CrossDomainForwarder {
/// @param l1OwnerAddr the L1 owner address that will be allowed to call the forward fn
constructor(address l1OwnerAddr) CrossDomainForwarder(l1OwnerAddr) {}

/// @notice The call MUST come from either the L1 owner (via cross-chain message) or the L2 owner. Reverts otherwise.
function _requireLocalOrCrossDomainOwner() internal view virtual;

/// @inheritdoc ForwarderInterface
/// @inheritdoc IForwarderInterface
/// @dev forwarded only if L2 Messenger calls with `msg.sender` being the L1 owner address, or called by the L2 owner
function forward(address target, bytes memory data) external override {
_requireLocalOrCrossDomainOwner();
Address.functionCall(target, data, "Governor call reverted");
}

/// @inheritdoc DelegateForwarderInterface
/// @inheritdoc IDelegateForwarderInterface
/// @dev forwarded only if L2 Messenger calls with `msg.sender` being the L1 owner address, or called by the L2 owner
function forwardDelegate(address target, bytes memory data) external override {
_requireLocalOrCrossDomainOwner();
Expand Down
8 changes: 6 additions & 2 deletions contracts/src/v0.8/l2ep/dev/Flags.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.19;

import {AccessControllerInterface} from "../../shared/interfaces/AccessControllerInterface.sol";
import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol";
import {FlagsInterface} from "./interfaces/FlagsInterface.sol";
import {IFlagsInterface} from "./interfaces/IFlagsInterface.sol";

import {SimpleReadAccessController} from "../../shared/access/SimpleReadAccessController.sol";

Expand All @@ -15,7 +15,7 @@ import {SimpleReadAccessController} from "../../shared/access/SimpleReadAccessCo
/// An expected pattern is to allow addresses to raise flags on themselves, so if you are subscribing to
/// FlagOn events you should filter for addresses you care about.
// solhint-disable custom-errors
contract Flags is ITypeAndVersion, FlagsInterface, SimpleReadAccessController {
contract Flags is ITypeAndVersion, IFlagsInterface, SimpleReadAccessController {
string public constant override typeAndVersion = "Flags 1.1.0";

AccessControllerInterface public raisingAccessController;
Expand Down Expand Up @@ -60,6 +60,7 @@ contract Flags is ITypeAndVersion, FlagsInterface, SimpleReadAccessController {
/// who always has access.
/// @param subject The contract address whose flag is being raised
function raiseFlag(address subject) external override {
// solhint-disable-next-line gas-custom-errors
require(_allowedToRaiseFlags(), "Not allowed to raise flags");

_tryToRaiseFlag(subject);
Expand All @@ -70,6 +71,7 @@ contract Flags is ITypeAndVersion, FlagsInterface, SimpleReadAccessController {
/// who always has access.
/// @param subjects List of the contract addresses whose flag is being raised
function raiseFlags(address[] calldata subjects) external override {
// solhint-disable-next-line gas-custom-errors
require(_allowedToRaiseFlags(), "Not allowed to raise flags");

for (uint256 i = 0; i < subjects.length; i++) {
Expand All @@ -82,6 +84,7 @@ contract Flags is ITypeAndVersion, FlagsInterface, SimpleReadAccessController {
/// who always has access.
/// @param subject The contract address whose flag is being lowered
function lowerFlag(address subject) external override {
// solhint-disable-next-line gas-custom-errors
require(_allowedToLowerFlags(), "Not allowed to lower flags");

_tryToLowerFlag(subject);
Expand All @@ -92,6 +95,7 @@ contract Flags is ITypeAndVersion, FlagsInterface, SimpleReadAccessController {
/// who always has access.
/// @param subjects List of the contract addresses whose flag is being lowered
function lowerFlags(address[] calldata subjects) external override {
// solhint-disable-next-line gas-custom-errors
require(_allowedToLowerFlags(), "Not allowed to lower flags");

for (uint256 i = 0; i < subjects.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/v0.8/l2ep/dev/Validator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ abstract contract Validator is ITypeAndVersion, AggregatorValidatorInterface, Si
/// @param l1CrossDomainMessengerAddress address the L1CrossDomainMessenger contract address
/// @param l2UptimeFeedAddr the address of the ScrollSequencerUptimeFeed contract address
constructor(address l1CrossDomainMessengerAddress, address l2UptimeFeedAddr) {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(l1CrossDomainMessengerAddress != address(0), "Invalid xDomain Messenger address");
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(l2UptimeFeedAddr != address(0), "Invalid SequencerUptimeFeed contract address");
L1_CROSS_DOMAIN_MESSENGER_ADDRESS = l1CrossDomainMessengerAddress;
L2_UPTIME_FEED_ADDR = l2UptimeFeedAddr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ contract ArbitrumCrossDomainGovernor is CrossDomainGovernor {

/// @notice The call MUST come from either the L1 owner (via cross-chain message) or the L2 owner. Reverts otherwise.
function _requireLocalOrCrossDomainOwner() internal view override {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(msg.sender == crossDomainMessenger() || msg.sender == owner(), "Sender is not the L2 messenger or owner");
}

/// @notice The call MUST come from the L1 owner (via cross-chain message.) Reverts otherwise.
modifier onlyL1Owner() override {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(msg.sender == crossDomainMessenger(), "Sender is not the L2 messenger");
_;
}

/// @notice The call MUST come from the proposed L1 owner (via cross-chain message.) Reverts otherwise.
modifier onlyProposedL1Owner() override {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(msg.sender == AddressAliasHelper.applyL1ToL2Alias(s_l1PendingOwner), "Must be proposed L1 owner");
_;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {FlagsInterface} from "../interfaces/FlagsInterface.sol";
import {IFlagsInterface} from "../interfaces/IFlagsInterface.sol";

import {SequencerUptimeFeed} from "../SequencerUptimeFeed.sol";

Expand All @@ -26,12 +26,12 @@ contract ArbitrumSequencerUptimeFeed is SequencerUptimeFeed {

/// @dev Flags contract to raise/lower flags on, during status transitions
// solhint-disable-next-line chainlink-solidity/prefix-immutable-variables-with-i
FlagsInterface public immutable FLAGS;
IFlagsInterface public immutable FLAGS;

/// @param flagsAddress Address of the Flags contract on L2
/// @param l1SenderAddress Address of the L1 contract that is permissioned to call this contract
constructor(address flagsAddress, address l1SenderAddress) SequencerUptimeFeed(l1SenderAddress, false) {
FLAGS = FlagsInterface(flagsAddress);
FLAGS = IFlagsInterface(flagsAddress);
}

/// @notice Reverts if the sender is not allowed to call `updateStatus`
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/l2ep/dev/arbitrum/ArbitrumValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ contract ArbitrumValidator is Validator {

/// @notice internal method that stores the gas configuration
function _setGasConfig(uint64 maxGas, uint256 gasPriceBid, uint256 baseFee, address gasPriceL1FeedAddr) internal {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(maxGas > 0, "Max gas is zero");
// solhint-disable-next-line gas-custom-errors
require(gasPriceBid > 0, "Gas price bid is zero");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

/// @title CrossDomainOwnableInterface - A contract with helpers for cross-domain contract ownership
interface CrossDomainOwnableInterface {
/// @title ICrossDomainOwnableInterface - A contract with helpers for cross-domain contract ownership
interface ICrossDomainOwnableInterface {
event L1OwnershipTransferRequested(address indexed from, address indexed to);

event L1OwnershipTransferred(address indexed from, address indexed to);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

/// @title DelegateForwarderInterface - forwards a delegatecall to a target, under some conditions
interface DelegateForwarderInterface {
/// @title IDelegateForwarderInterface - forwards a delegatecall to a target, under some conditions
interface IDelegateForwarderInterface {
/**
* @notice forward delegatecalls the `target` with `data`
* @param target contract address to be delegatecalled
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

interface FlagsInterface {
interface IFlagsInterface {
function getFlag(address) external view returns (bool);

function getFlags(address[] calldata) external view returns (bool[] memory);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

/// @title ForwarderInterface - forwards a call to a target, under some conditions
interface ForwarderInterface {
/// @title IForwarderInterface - forwards a call to a target, under some conditions
interface IForwarderInterface {
/// @notice forward calls the `target` with `data`
/// @param target contract address to be called
/// @param data to send to target contract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract OptimismCrossDomainForwarder is CrossDomainForwarder {
) CrossDomainForwarder(l1OwnerAddr) {
i_crossDomainMessengerAddr = address(crossDomainMessengerAddr);

// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(i_crossDomainMessengerAddr != address(0), "Invalid xDomain Messenger address");
}

Expand All @@ -35,9 +35,9 @@ contract OptimismCrossDomainForwarder is CrossDomainForwarder {

/// @notice The call MUST come from the L1 owner (via cross-chain message.) Reverts otherwise.
modifier onlyL1Owner() override {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(msg.sender == i_crossDomainMessengerAddr, "Sender is not the L2 messenger");
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(
iOVM_CrossDomainMessenger(i_crossDomainMessengerAddr).xDomainMessageSender() == l1Owner(),
"xDomain sender is not the L1 owner"
Expand All @@ -47,9 +47,9 @@ contract OptimismCrossDomainForwarder is CrossDomainForwarder {

/// @notice The call MUST come from the proposed L1 owner (via cross-chain message.) Reverts otherwise.
modifier onlyProposedL1Owner() override {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(msg.sender == i_crossDomainMessengerAddr, "Sender is not the L2 messenger");
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(
iOVM_CrossDomainMessenger(i_crossDomainMessengerAddr).xDomainMessageSender() == s_l1PendingOwner,
"Must be proposed L1 owner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract OptimismCrossDomainGovernor is CrossDomainGovernor {
) CrossDomainGovernor(l1OwnerAddr) {
i_crossDomainMessengerAddr = address(crossDomainMessengerAddr);

// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(i_crossDomainMessengerAddr != address(0), "Invalid xDomain Messenger address");
}

Expand All @@ -37,14 +37,14 @@ contract OptimismCrossDomainGovernor is CrossDomainGovernor {
/// @notice The call MUST come from either the L1 owner (via cross-chain message) or the L2 owner. Reverts otherwise.
function _requireLocalOrCrossDomainOwner() internal view override {
// 1. The delegatecall MUST come from either the L1 owner (via cross-chain message) or the L2 owner
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(
msg.sender == i_crossDomainMessengerAddr || msg.sender == owner(),
"Sender is not the L2 messenger or owner"
);
// 2. The L2 Messenger's caller MUST be the L1 Owner
if (msg.sender == i_crossDomainMessengerAddr) {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(
iOVM_CrossDomainMessenger(i_crossDomainMessengerAddr).xDomainMessageSender() == l1Owner(),
"xDomain sender is not the L1 owner"
Expand All @@ -54,9 +54,9 @@ contract OptimismCrossDomainGovernor is CrossDomainGovernor {

/// @notice The call MUST come from the L1 owner (via cross-chain message.) Reverts otherwise.
modifier onlyL1Owner() override {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(msg.sender == i_crossDomainMessengerAddr, "Sender is not the L2 messenger");
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(
iOVM_CrossDomainMessenger(i_crossDomainMessengerAddr).xDomainMessageSender() == l1Owner(),
"xDomain sender is not the L1 owner"
Expand All @@ -66,9 +66,9 @@ contract OptimismCrossDomainGovernor is CrossDomainGovernor {

/// @notice The call MUST come from the proposed L1 owner (via cross-chain message.) Reverts otherwise.
modifier onlyProposedL1Owner() override {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(msg.sender == i_crossDomainMessengerAddr, "Sender is not the L2 messenger");
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(
iOVM_CrossDomainMessenger(i_crossDomainMessengerAddr).xDomainMessageSender() == s_l1PendingOwner,
"Must be proposed L1 owner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract ScrollCrossDomainForwarder is CrossDomainForwarder {
constructor(IScrollMessenger crossDomainMessengerAddr, address l1OwnerAddr) CrossDomainForwarder(l1OwnerAddr) {
i_crossDomainMessengerAddr = address(crossDomainMessengerAddr);

// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(i_crossDomainMessengerAddr != address(0), "Invalid xDomain Messenger address");
}

Expand All @@ -31,9 +31,9 @@ contract ScrollCrossDomainForwarder is CrossDomainForwarder {

/// @notice The call MUST come from the L1 owner (via cross-chain message.) Reverts otherwise.
modifier onlyL1Owner() override {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(msg.sender == i_crossDomainMessengerAddr, "Sender is not the L2 messenger");
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(
IScrollMessenger(i_crossDomainMessengerAddr).xDomainMessageSender() == l1Owner(),
"xDomain sender is not the L1 owner"
Expand All @@ -43,9 +43,9 @@ contract ScrollCrossDomainForwarder is CrossDomainForwarder {

/// @notice The call MUST come from the proposed L1 owner (via cross-chain message.) Reverts otherwise.
modifier onlyProposedL1Owner() override {
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(msg.sender == i_crossDomainMessengerAddr, "Sender is not the L2 messenger");
// solhint-disable-next-line custom-errors
// solhint-disable-next-line gas-custom-errors
require(
IScrollMessenger(i_crossDomainMessengerAddr).xDomainMessageSender() == s_l1PendingOwner,
"Must be proposed L1 owner"
Expand Down
Loading

0 comments on commit f3e743f

Please sign in to comment.