Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] OZ-Upgrade-Plugin + Solhint warnings #661

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
5 changes: 2 additions & 3 deletions contracts/.solhintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
node_modules
lib/forge-std
contracts/test-contracts
test/foundry
/contracts/proxies
/contracts/tokenBridge/mocks
src/_testing
src/proxies
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ethers, upgrades } from "hardhat";
import { getPermitData } from "../../../test/tokenBridge/utils/permitHelper";
import { getPermitData } from "../../../test/hardhat/bridging/token/utils/permitHelper";
import { BridgedToken, MockTokenBridge } from "../../../typechain-types";
import { deployBridgedTokenBeacon } from "../test/deployBridgedTokenBeacon";
import { deployTokens } from "../test/deployTokens";
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/_testing/mocks/tokens/TestERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

/**
* @title TestERC20
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/bridging/token/TokenBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ contract TokenBridge is
nonZeroChainId(_initializationData.targetChainId)
initializer
{
__PauseManager_init(_initializationData.pauseTypeRoles, _initializationData.unpauseTypeRoles);
__MessageServiceBase_init(_initializationData.messageService);
__ReentrancyGuard_init();
__MessageServiceBase_init(_initializationData.messageService);
__PauseManager_init(_initializationData.pauseTypeRoles, _initializationData.unpauseTypeRoles);

if (_initializationData.defaultAdmin == address(0)) {
revert ZeroAddressNotAllowed();
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/messaging/l2/L2MessageService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ contract L2MessageService is AccessControlUpgradeable, L2MessageServiceV1, L2Mes
__AccessControl_init();
__RateLimiter_init(_rateLimitPeriod, _rateLimitAmount);

__ReentrancyGuard_init();
__PauseManager_init(_pauseTypeRoles, _unpauseTypeRoles);
__ReentrancyGuard_init();

if (_defaultAdmin == address(0)) {
revert ZeroAddressNotAllowed();
Expand Down
37 changes: 18 additions & 19 deletions contracts/test/hardhat/L1MessageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,19 @@ describe("L1MessageService", () => {
let l2Sender: SignerWithAddress;

async function deployTestL1MessageServiceFixture(): Promise<TestL1MessageService> {
return deployUpgradableFromFactory("TestL1MessageService", [
ONE_DAY_IN_SECONDS,
INITIAL_WITHDRAW_LIMIT,
pauseTypeRoles,
unpauseTypeRoles,
]) as unknown as Promise<TestL1MessageService>;
return deployUpgradableFromFactory(
"TestL1MessageService",
[ONE_DAY_IN_SECONDS, INITIAL_WITHDRAW_LIMIT, pauseTypeRoles, unpauseTypeRoles],
{ unsafeAllow: ["incorrect-initializer-order"] },
) as unknown as Promise<TestL1MessageService>;
}

async function deployL1MessageServiceMerkleFixture(): Promise<TestL1MessageServiceMerkleProof> {
return deployUpgradableFromFactory("TestL1MessageServiceMerkleProof", [
ONE_DAY_IN_SECONDS,
INITIAL_WITHDRAW_LIMIT,
pauseTypeRoles,
unpauseTypeRoles,
]) as unknown as Promise<TestL1MessageServiceMerkleProof>;
return deployUpgradableFromFactory(
"TestL1MessageServiceMerkleProof",
[ONE_DAY_IN_SECONDS, INITIAL_WITHDRAW_LIMIT, pauseTypeRoles, unpauseTypeRoles],
{ unsafeAllow: ["incorrect-initializer-order"] },
) as unknown as Promise<TestL1MessageServiceMerkleProof>;
}

async function deployL1TestRevertFixture(): Promise<TestL1RevertContract> {
Expand Down Expand Up @@ -146,20 +144,21 @@ describe("L1MessageService", () => {
it("Should fail to deploy missing amount", async () => {
await expectRevertWithCustomError(
l1MessageService,
deployUpgradableFromFactory("TestL1MessageService", [ONE_DAY_IN_SECONDS, 0, pauseTypeRoles, unpauseTypeRoles]),
deployUpgradableFromFactory("TestL1MessageService", [ONE_DAY_IN_SECONDS, 0, pauseTypeRoles, unpauseTypeRoles], {
unsafeAllow: ["incorrect-initializer-order"],
}),
"LimitIsZero",
);
});

it("Should fail to deploy missing limit period", async () => {
await expectRevertWithCustomError(
l1MessageService,
deployUpgradableFromFactory("TestL1MessageService", [
0,
INITIAL_WITHDRAW_LIMIT,
pauseTypeRoles,
unpauseTypeRoles,
]),
deployUpgradableFromFactory(
"TestL1MessageService",
[0, INITIAL_WITHDRAW_LIMIT, pauseTypeRoles, unpauseTypeRoles],
{ unsafeAllow: ["incorrect-initializer-order"] },
),
"PeriodIsZero",
);
});
Expand Down
17 changes: 9 additions & 8 deletions contracts/test/hardhat/rollup/LineaRollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe("Linea Rollup contract", () => {

const lineaRollup = (await deployUpgradableFromFactory("TestLineaRollup", [initializationData], {
initializer: LINEA_ROLLUP_INITIALIZE_SIGNATURE,
unsafeAllow: ["constructor"],
unsafeAllow: ["constructor", "incorrect-initializer-order"],
})) as unknown as TestLineaRollup;

return lineaRollup;
Expand Down Expand Up @@ -198,7 +198,7 @@ describe("Linea Rollup contract", () => {

const deployCall = deployUpgradableFromFactory("src/rollup/LineaRollup.sol:LineaRollup", [initializationData], {
initializer: LINEA_ROLLUP_INITIALIZE_SIGNATURE,
unsafeAllow: ["constructor"],
unsafeAllow: ["constructor", "incorrect-initializer-order"],
});

await expectRevertWithCustomError(lineaRollup, deployCall, "ZeroAddressNotAllowed");
Expand All @@ -221,7 +221,7 @@ describe("Linea Rollup contract", () => {

const deployCall = deployUpgradableFromFactory("TestLineaRollup", [initializationData], {
initializer: LINEA_ROLLUP_INITIALIZE_SIGNATURE,
unsafeAllow: ["constructor"],
unsafeAllow: ["constructor", "incorrect-initializer-order"],
});

await expectRevertWithCustomError(lineaRollup, deployCall, "ZeroAddressNotAllowed");
Expand All @@ -244,7 +244,7 @@ describe("Linea Rollup contract", () => {

const deployCall = deployUpgradableFromFactory("TestLineaRollup", [initializationData], {
initializer: LINEA_ROLLUP_INITIALIZE_SIGNATURE,
unsafeAllow: ["constructor"],
unsafeAllow: ["constructor", "incorrect-initializer-order"],
});

await expectRevertWithCustomError(lineaRollup, deployCall, "ZeroAddressNotAllowed");
Expand All @@ -267,7 +267,7 @@ describe("Linea Rollup contract", () => {

const deployCall = deployUpgradableFromFactory("TestLineaRollup", [initializationData], {
initializer: LINEA_ROLLUP_INITIALIZE_SIGNATURE,
unsafeAllow: ["constructor"],
unsafeAllow: ["constructor", "incorrect-initializer-order"],
});

await expectRevertWithCustomError(lineaRollup, deployCall, "ZeroAddressNotAllowed");
Expand Down Expand Up @@ -313,7 +313,7 @@ describe("Linea Rollup contract", () => {
[initializationData],
{
initializer: LINEA_ROLLUP_INITIALIZE_SIGNATURE,
unsafeAllow: ["constructor"],
unsafeAllow: ["constructor", "incorrect-initializer-order"],
},
);

Expand All @@ -340,7 +340,7 @@ describe("Linea Rollup contract", () => {
[initializationData],
{
initializer: LINEA_ROLLUP_INITIALIZE_SIGNATURE,
unsafeAllow: ["constructor"],
unsafeAllow: ["constructor", "incorrect-initializer-order"],
},
);

Expand Down Expand Up @@ -1560,7 +1560,7 @@ describe("Linea Rollup contract", () => {

const betaV1LineaRollup = (await deployUpgradableFromFactory("TestLineaRollup", [initializationData], {
initializer: LINEA_ROLLUP_INITIALIZE_SIGNATURE,
unsafeAllow: ["constructor"],
unsafeAllow: ["constructor", "incorrect-initializer-order"],
})) as unknown as TestLineaRollup;

await betaV1LineaRollup.setupParentShnarf(betaV1FinalizationData.parentAggregationFinalShnarf);
Expand Down Expand Up @@ -2268,6 +2268,7 @@ describe("Linea Rollup contract", () => {
);
const newLineaRollup = await upgrades.upgradeProxy(lineaRollup, newLineaRollupFactory, {
unsafeAllowRenames: true,
unsafeAllow: ["incorrect-initializer-order"],
});

const upgradedContract = await newLineaRollup.waitForDeployment();
Expand Down
Loading