mirror of
https://github.com/vacp2p/linea-monorepo.git
synced 2026-01-09 04:08:01 -05:00
[Chore] Update current reinitialization script for all contracts (#331)
* current reinitialization script for all contracts * use shared functions consistently * add forwarding proxy * add extra logging and use fallbackOperator name * use env var for fallback operator
This commit is contained in:
28
contracts/contracts/lib/CallForwardingProxy.sol
Normal file
28
contracts/contracts/lib/CallForwardingProxy.sol
Normal file
@@ -0,0 +1,28 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0
|
||||
pragma solidity 0.8.26;
|
||||
|
||||
/**
|
||||
* @title Contract to forward calls to an underlying contract.
|
||||
* @author ConsenSys Software Inc.
|
||||
* @custom:security-contact security-report@linea.build
|
||||
*/
|
||||
contract CallForwardingProxy {
|
||||
/// @notice The underlying target address that is called.
|
||||
address public immutable target;
|
||||
|
||||
constructor(address _target) {
|
||||
target = _target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Defaults to, and forwards all calls to the target address.
|
||||
*/
|
||||
fallback() external payable {
|
||||
(bool success, bytes memory data) = target.call{ value: msg.value }(msg.data);
|
||||
require(success, "Call failed");
|
||||
|
||||
assembly {
|
||||
return(add(data, 0x20), mload(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,59 @@
|
||||
import { ethers, upgrades } from "hardhat";
|
||||
import { DeployFunction } from "hardhat-deploy/types";
|
||||
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
||||
import { LineaRollupInit__factory } from "../typechain-types";
|
||||
import {
|
||||
tryVerifyContract,
|
||||
getDeployedContractAddress,
|
||||
validateDeployBranchAndTags,
|
||||
getRequiredEnvVar,
|
||||
generateRoleAssignments,
|
||||
} from "../common/helpers";
|
||||
import { LineaRollup__factory } from "contracts/typechain-types";
|
||||
import {
|
||||
LINEA_ROLLUP_PAUSE_TYPES_ROLES,
|
||||
LINEA_ROLLUP_UNPAUSE_TYPES_ROLES,
|
||||
PAUSE_ALL_ROLE,
|
||||
PAUSE_BLOB_SUBMISSION_ROLE,
|
||||
PAUSE_FINALIZATION_ROLE,
|
||||
PAUSE_L1_L2_ROLE,
|
||||
PAUSE_L2_L1_ROLE,
|
||||
UNPAUSE_ALL_ROLE,
|
||||
UNPAUSE_BLOB_SUBMISSION_ROLE,
|
||||
UNPAUSE_FINALIZATION_ROLE,
|
||||
UNPAUSE_L1_L2_ROLE,
|
||||
UNPAUSE_L2_L1_ROLE,
|
||||
USED_RATE_LIMIT_RESETTER_ROLE,
|
||||
VERIFIER_UNSETTER_ROLE,
|
||||
} from "contracts/common/constants";
|
||||
|
||||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
||||
const { deployments } = hre;
|
||||
validateDeployBranchAndTags(hre.network.name);
|
||||
const fallbackOperatorAddress = getRequiredEnvVar("LINEA_ROLLUP_FALLBACK_OPERATOR");
|
||||
const securityCouncilAddress = getRequiredEnvVar("LINEA_ROLLUP_SECURITY_COUNCIL");
|
||||
|
||||
const contractName = "LineaRollupV6";
|
||||
const newRoles = [
|
||||
PAUSE_ALL_ROLE,
|
||||
PAUSE_L1_L2_ROLE,
|
||||
PAUSE_L2_L1_ROLE,
|
||||
UNPAUSE_ALL_ROLE,
|
||||
UNPAUSE_L1_L2_ROLE,
|
||||
UNPAUSE_L2_L1_ROLE,
|
||||
PAUSE_BLOB_SUBMISSION_ROLE,
|
||||
UNPAUSE_BLOB_SUBMISSION_ROLE,
|
||||
PAUSE_FINALIZATION_ROLE,
|
||||
UNPAUSE_FINALIZATION_ROLE,
|
||||
USED_RATE_LIMIT_RESETTER_ROLE,
|
||||
VERIFIER_UNSETTER_ROLE,
|
||||
];
|
||||
|
||||
const newRoleAddresses = generateRoleAssignments(newRoles, securityCouncilAddress, []);
|
||||
console.log("New role addresses", newRoleAddresses);
|
||||
|
||||
const { deployments } = hre;
|
||||
const contractName = "LineaRollup";
|
||||
const existingContractAddress = await getDeployedContractAddress(contractName, deployments);
|
||||
|
||||
const proxyAddress = getRequiredEnvVar("LINEA_ROLLUP_ADDRESS");
|
||||
const initialL2BlockNumber = "3";
|
||||
const initialStateRootHash = "0x3450000000000000000000000000000000000000000000000000000000000000";
|
||||
|
||||
const factory = await ethers.getContractFactory("LineaRollupV6");
|
||||
const factory = await ethers.getContractFactory(contractName);
|
||||
|
||||
if (existingContractAddress === undefined) {
|
||||
console.log(`Deploying initial version, NB: the address will be saved if env SAVE_ADDRESS=true.`);
|
||||
@@ -39,6 +72,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
||||
|
||||
// The encoding should be used through the safe.
|
||||
// THIS IS JUST A SAMPLE AND WILL BE ADJUSTED WHEN NEEDED FOR GENERATING THE CALLDATA FOR THE UPGRADE CALL
|
||||
// https://www.4byte.directory/signatures/?bytes4_signature=0x9623609d
|
||||
const upgradeCallWithReinitializationUsingSecurityCouncil = ethers.concat([
|
||||
"0x9623609d",
|
||||
ethers.AbiCoder.defaultAbiCoder().encode(
|
||||
@@ -46,9 +80,11 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
||||
[
|
||||
proxyAddress,
|
||||
newContract,
|
||||
LineaRollupInit__factory.createInterface().encodeFunctionData("initializeV2", [
|
||||
initialL2BlockNumber,
|
||||
initialStateRootHash,
|
||||
LineaRollup__factory.createInterface().encodeFunctionData("reinitializeLineaRollupV6", [
|
||||
newRoleAddresses,
|
||||
LINEA_ROLLUP_PAUSE_TYPES_ROLES,
|
||||
LINEA_ROLLUP_UNPAUSE_TYPES_ROLES,
|
||||
fallbackOperatorAddress,
|
||||
]),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
import { ethers, upgrades } from "hardhat";
|
||||
import { DeployFunction } from "hardhat-deploy/types";
|
||||
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
||||
import {
|
||||
tryVerifyContract,
|
||||
getDeployedContractAddress,
|
||||
getRequiredEnvVar,
|
||||
generateRoleAssignments,
|
||||
} from "../common/helpers";
|
||||
import { L2MessageService__factory } from "contracts/typechain-types";
|
||||
import {
|
||||
L2_MESSAGE_SERVICE_PAUSE_TYPES_ROLES,
|
||||
L2_MESSAGE_SERVICE_UNPAUSE_TYPES_ROLES,
|
||||
PAUSE_ALL_ROLE,
|
||||
PAUSE_L1_L2_ROLE,
|
||||
PAUSE_L2_L1_ROLE,
|
||||
UNPAUSE_ALL_ROLE,
|
||||
UNPAUSE_L1_L2_ROLE,
|
||||
UNPAUSE_L2_L1_ROLE,
|
||||
USED_RATE_LIMIT_RESETTER_ROLE,
|
||||
} from "contracts/common/constants";
|
||||
|
||||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
||||
const securityCouncilAddress = getRequiredEnvVar("L2MSGSERVICE_SECURITY_COUNCIL");
|
||||
|
||||
const newRoles = [
|
||||
USED_RATE_LIMIT_RESETTER_ROLE,
|
||||
PAUSE_ALL_ROLE,
|
||||
PAUSE_L1_L2_ROLE,
|
||||
PAUSE_L2_L1_ROLE,
|
||||
UNPAUSE_ALL_ROLE,
|
||||
UNPAUSE_L1_L2_ROLE,
|
||||
UNPAUSE_L2_L1_ROLE,
|
||||
];
|
||||
|
||||
const newRoleAddresses = generateRoleAssignments(newRoles, securityCouncilAddress, []);
|
||||
console.log("New role addresses", newRoleAddresses);
|
||||
|
||||
const { deployments } = hre;
|
||||
const contractName = "L2MessageService";
|
||||
const existingContractAddress = await getDeployedContractAddress(contractName, deployments);
|
||||
|
||||
const proxyAddress = getRequiredEnvVar("L2_MESSAGE_SERVICE_ADDRESS");
|
||||
|
||||
const factory = await ethers.getContractFactory(contractName);
|
||||
|
||||
if (existingContractAddress === undefined) {
|
||||
console.log(`Deploying initial version, NB: the address will be saved if env SAVE_ADDRESS=true.`);
|
||||
} else {
|
||||
console.log(`Deploying new version, NB: ${existingContractAddress} will be overwritten if env SAVE_ADDRESS=true.`);
|
||||
}
|
||||
|
||||
console.log("Deploying Contract...");
|
||||
const newContract = await upgrades.deployImplementation(factory, {
|
||||
kind: "transparent",
|
||||
});
|
||||
|
||||
const contract = newContract.toString();
|
||||
|
||||
console.log(`Contract deployed at ${contract}`);
|
||||
|
||||
// The encoding should be used through the safe.
|
||||
// THIS IS JUST A SAMPLE AND WILL BE ADJUSTED WHEN NEEDED FOR GENERATING THE CALLDATA FOR THE UPGRADE CALL
|
||||
// https://www.4byte.directory/signatures/?bytes4_signature=0x9623609d
|
||||
const upgradeCallWithReinitializationUsingSecurityCouncil = ethers.concat([
|
||||
"0x9623609d",
|
||||
ethers.AbiCoder.defaultAbiCoder().encode(
|
||||
["address", "address", "bytes"],
|
||||
[
|
||||
proxyAddress,
|
||||
newContract,
|
||||
L2MessageService__factory.createInterface().encodeFunctionData("reinitializePauseTypesAndPermissions", [
|
||||
newRoleAddresses,
|
||||
L2_MESSAGE_SERVICE_PAUSE_TYPES_ROLES,
|
||||
L2_MESSAGE_SERVICE_UNPAUSE_TYPES_ROLES,
|
||||
]),
|
||||
],
|
||||
),
|
||||
]);
|
||||
|
||||
console.log(
|
||||
"Encoded Tx Upgrade with Reinitialization from Security Council:",
|
||||
"\n",
|
||||
upgradeCallWithReinitializationUsingSecurityCouncil,
|
||||
);
|
||||
console.log("\n");
|
||||
|
||||
await tryVerifyContract(contract);
|
||||
};
|
||||
|
||||
export default func;
|
||||
func.tags = ["L2MessageServiceWithReinitialization"];
|
||||
@@ -0,0 +1,91 @@
|
||||
import { ethers, upgrades } from "hardhat";
|
||||
import { DeployFunction } from "hardhat-deploy/types";
|
||||
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
||||
import {
|
||||
tryVerifyContract,
|
||||
getDeployedContractAddress,
|
||||
getRequiredEnvVar,
|
||||
generateRoleAssignments,
|
||||
} from "../common/helpers";
|
||||
import { TokenBridge__factory } from "contracts/typechain-types";
|
||||
import {
|
||||
PAUSE_ALL_ROLE,
|
||||
PAUSE_COMPLETE_TOKEN_BRIDGING_ROLE,
|
||||
PAUSE_INITIATE_TOKEN_BRIDGING_ROLE,
|
||||
TOKEN_BRIDGE_PAUSE_TYPES_ROLES,
|
||||
TOKEN_BRIDGE_UNPAUSE_TYPES_ROLES,
|
||||
UNPAUSE_ALL_ROLE,
|
||||
UNPAUSE_COMPLETE_TOKEN_BRIDGING_ROLE,
|
||||
UNPAUSE_INITIATE_TOKEN_BRIDGING_ROLE,
|
||||
} from "contracts/common/constants";
|
||||
|
||||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
||||
const securityCouncilAddress = getRequiredEnvVar("TOKENBRIDGE_SECURITY_COUNCIL");
|
||||
|
||||
const newRoles = [
|
||||
PAUSE_ALL_ROLE,
|
||||
UNPAUSE_ALL_ROLE,
|
||||
PAUSE_INITIATE_TOKEN_BRIDGING_ROLE,
|
||||
UNPAUSE_INITIATE_TOKEN_BRIDGING_ROLE,
|
||||
PAUSE_COMPLETE_TOKEN_BRIDGING_ROLE,
|
||||
UNPAUSE_COMPLETE_TOKEN_BRIDGING_ROLE,
|
||||
];
|
||||
|
||||
const newRoleAddresses = generateRoleAssignments(newRoles, securityCouncilAddress, []);
|
||||
console.log("New role addresses", newRoleAddresses);
|
||||
|
||||
const { deployments } = hre;
|
||||
const contractName = "TokenBridge";
|
||||
const existingContractAddress = await getDeployedContractAddress(contractName, deployments);
|
||||
|
||||
const proxyAddress = getRequiredEnvVar("L2_MESSAGE_SERVICE_ADDRESS");
|
||||
|
||||
const factory = await ethers.getContractFactory(contractName);
|
||||
|
||||
if (existingContractAddress === undefined) {
|
||||
console.log(`Deploying initial version, NB: the address will be saved if env SAVE_ADDRESS=true.`);
|
||||
} else {
|
||||
console.log(`Deploying new version, NB: ${existingContractAddress} will be overwritten if env SAVE_ADDRESS=true.`);
|
||||
}
|
||||
|
||||
console.log("Deploying Contract...");
|
||||
const newContract = await upgrades.deployImplementation(factory, {
|
||||
kind: "transparent",
|
||||
});
|
||||
|
||||
const contract = newContract.toString();
|
||||
|
||||
console.log(`Contract deployed at ${contract}`);
|
||||
|
||||
// The encoding should be used through the safe.
|
||||
// THIS IS JUST A SAMPLE AND WILL BE ADJUSTED WHEN NEEDED FOR GENERATING THE CALLDATA FOR THE UPGRADE CALL
|
||||
// https://www.4byte.directory/signatures/?bytes4_signature=0x9623609d
|
||||
const upgradeCallWithReinitializationUsingSecurityCouncil = ethers.concat([
|
||||
"0x9623609d",
|
||||
ethers.AbiCoder.defaultAbiCoder().encode(
|
||||
["address", "address", "bytes"],
|
||||
[
|
||||
proxyAddress,
|
||||
newContract,
|
||||
TokenBridge__factory.createInterface().encodeFunctionData("reinitializePauseTypesAndPermissions", [
|
||||
securityCouncilAddress,
|
||||
newRoleAddresses,
|
||||
TOKEN_BRIDGE_PAUSE_TYPES_ROLES,
|
||||
TOKEN_BRIDGE_UNPAUSE_TYPES_ROLES,
|
||||
]),
|
||||
],
|
||||
),
|
||||
]);
|
||||
|
||||
console.log(
|
||||
"Encoded Tx Upgrade with Reinitialization from Security Council:",
|
||||
"\n",
|
||||
upgradeCallWithReinitializationUsingSecurityCouncil,
|
||||
);
|
||||
console.log("\n");
|
||||
|
||||
await tryVerifyContract(contract);
|
||||
};
|
||||
|
||||
export default func;
|
||||
func.tags = ["TokenBridgeWithReinitialization"];
|
||||
33
contracts/deploy/12_deploy_CallForwardingProxy.ts
Normal file
33
contracts/deploy/12_deploy_CallForwardingProxy.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { ethers } from "hardhat";
|
||||
import { DeployFunction } from "hardhat-deploy/types";
|
||||
import { deployFromFactory } from "../scripts/hardhat/utils";
|
||||
import { getRequiredEnvVar, tryVerifyContractWithConstructorArgs } from "../common/helpers";
|
||||
|
||||
const func: DeployFunction = async function () {
|
||||
const contractName = "CallForwardingProxy";
|
||||
|
||||
const provider = ethers.provider;
|
||||
|
||||
// This should be the LineaRollup
|
||||
const targetAddress = getRequiredEnvVar("LINEA_ROLLUP_ADDRESS");
|
||||
|
||||
const contract = await deployFromFactory(contractName, provider, targetAddress);
|
||||
const contractAddress = await contract.getAddress();
|
||||
|
||||
console.log(`${contractName} deployed at ${contractAddress}`);
|
||||
|
||||
const deployTx = contract.deploymentTransaction();
|
||||
if (!deployTx) {
|
||||
throw "Deployment transaction not found.";
|
||||
}
|
||||
|
||||
const args = [targetAddress];
|
||||
|
||||
await tryVerifyContractWithConstructorArgs(
|
||||
contractAddress,
|
||||
"contracts/lib/CallForwardingProxy.sol:CallForwardingProxy",
|
||||
args,
|
||||
);
|
||||
};
|
||||
export default func;
|
||||
func.tags = ["CallForwardingProxy"];
|
||||
Reference in New Issue
Block a user