mirror of
https://github.com/vacp2p/linea-monorepo.git
synced 2026-01-08 03:43:56 -05:00
[Fix] OZ-Upgrade-Plugin + Solhint warnings (#661)
* fix tokenbridge init ordering given oz plugin warnings * adjust solhint linting * fix scripts/tokenBridge/gasEstimation/gasEstimation.ts * added /// @custom:oz-upgrades-unsafe-allow incorrect-initializer-order * fix for L2MessageService * remove warning silencer for demo purpose * Revert "remove warning silencer for demo purpose" This reverts commit 4eccc3d0fc32501ab0e99f737e7b25daa8214601. * add incorrect-initializer-flag to upgrades constructor function
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
node_modules
|
||||
lib/forge-std
|
||||
contracts/test-contracts
|
||||
test/foundry
|
||||
/contracts/proxies
|
||||
/contracts/tokenBridge/mocks
|
||||
src/_testing
|
||||
src/proxies
|
||||
@@ -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";
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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> {
|
||||
@@ -146,7 +144,9 @@ 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",
|
||||
);
|
||||
});
|
||||
@@ -154,12 +154,11 @@ describe("L1MessageService", () => {
|
||||
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",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
@@ -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");
|
||||
@@ -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");
|
||||
@@ -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");
|
||||
@@ -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");
|
||||
@@ -313,7 +313,7 @@ describe("Linea Rollup contract", () => {
|
||||
[initializationData],
|
||||
{
|
||||
initializer: LINEA_ROLLUP_INITIALIZE_SIGNATURE,
|
||||
unsafeAllow: ["constructor"],
|
||||
unsafeAllow: ["constructor", "incorrect-initializer-order"],
|
||||
},
|
||||
);
|
||||
|
||||
@@ -340,7 +340,7 @@ describe("Linea Rollup contract", () => {
|
||||
[initializationData],
|
||||
{
|
||||
initializer: LINEA_ROLLUP_INITIALIZE_SIGNATURE,
|
||||
unsafeAllow: ["constructor"],
|
||||
unsafeAllow: ["constructor", "incorrect-initializer-order"],
|
||||
},
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user