Skip to content

Commit

Permalink
Implement task to deploy FxStateRootTunnel contract
Browse files Browse the repository at this point in the history
  • Loading branch information
evercoinx committed Oct 10, 2024
1 parent d0f1e98 commit 92bcf05
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 16 deletions.
60 changes: 44 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,33 @@ NETWORK_ETHEREUM := ethereum
HARDHAT_VALIDATOR_REGISTRY := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_MATIC_X := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_STAKE_MANAGER := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_CHECKPOINT_MANAGER := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_FX_ROOT := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_FX_STATE_ROOT_TUNNEL := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_MATIC_TOKEN := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_POL_TOKEN := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_MANAGER := 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
HARDHAT_TREASURY := 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

# Localhost contract addresses
LOCALHOST_VALIDATOR_REGISTRY :=
LOCALHOST_MATIC_X :=
LOCALHOST_STAKE_MANAGER :=
LOCALHOST_MATIC_TOKEN :=
LOCALHOST_POL_TOKEN :=
LOCALHOST_MANAGER :=
LOCALHOST_VALIDATOR_REGISTRY :=
LOCALHOST_MATIC_X :=
LOCALHOST_STAKE_MANAGER :=
LOCALHOST_CHECKPOINT_MANAGER :=
LOCALHOST_FX_ROOT :=
LOCALHOST_FX_STATE_ROOT_TUNNEL :=
LOCALHOST_MATIC_TOKEN :=
LOCALHOST_POL_TOKEN :=
LOCALHOST_MANAGER :=
LOCALHOST_TREASURY :=

# Sepolia contract addresses
SEPOLIA_VALIDATOR_REGISTRY := 0xE98fc808E8aE8025a1D17d6F4Fbc3Df226788438
SEPOLIA_MATIC_X := 0xB51AAb302085F436204c4B1964fBE74517B2D4b6
SEPOLIA_STAKE_MANAGER := 0x4AE8f648B1Ec892B6cc68C89cc088583964d08bE
SEPOLIA_CHECKPOINT_MANAGER := 0xbd07D7E1E93c8d4b2a261327F3C28a8EA7167209
SEPOLIA_FX_ROOT := 0x0E13EBEdDb8cf9f5987512d5E081FdC2F5b0991e
SEPOLIA_FX_STATE_ROOT_TUNNEL :=
SEPOLIA_MATIC_TOKEN := 0x3fd0A53F4Bf853985a95F4Eb3F9C9FDE1F8e2b53
SEPOLIA_POL_TOKEN := 0x44499312f493F62f2DFd3C6435Ca3603EbFCeeBa
SEPOLIA_MANAGER := 0x369B31971250859d3AD37E7cEDCF42AA5CF2C4F4
Expand All @@ -44,6 +53,9 @@ SEPOLIA_TREASURY := 0xdeb90df43BBa8FC0e2C08C54dC0F48cfc694F896
ETHEREUM_VALIDATOR_REGISTRY := 0xf556442D5B77A4B0252630E15d8BbE2160870d77
ETHEREUM_MATIC_X := 0xf03A7Eb46d01d9EcAA104558C732Cf82f6B6B645
ETHEREUM_STAKE_MANAGER := 0x5e3ef299fddf15eaa0432e6e66473ace8c13d908
ETHEREUM_CHECKPOINT_MANAGER := 0x86e4dc95c7fbdbf52e33d563bbdb00823894c287
ETHEREUM_FX_ROOT := 0xfe5e5D361b2ad62c541bAb87C45a0B9B018389a2
ETHEREUM_FX_STATE_ROOT_TUNNEL := 0x40FB804Cc07302b89EC16a9f8d040506f64dFe29
ETHEREUM_MATIC_TOKEN := 0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0
ETHEREUM_POL_TOKEN := 0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6
ETHEREUM_MANAGER := 0x80A43dd35382C4919991C5Bca7f46Dd24Fde4C67
Expand All @@ -69,6 +81,26 @@ deploy-validatorregistry-sepolia:
deploy-validatorregistry-ethereum:
$(BIN_HARDHAT) deploy:validator-registry --network $(NETWORK_ETHEREUM) --stake-manager $(ETHEREUM_STAKE_MANAGER) --matic-token $(ETHEREUM_MATIC_TOKEN) --matic-x $(ETHEREUM_MATIC_X) --manager $(ETHEREUM_MANAGER)

# Deploy the MaticX contract
deploy-maticx-hardhat:
$(BIN_HARDHAT) deploy:matic-x --network $(NETWORK_HARDHAT) --validator-registry $(HARDHAT_VALIDATOR_REGISTRY) --stake-manager $(HARDHAT_STAKE_MANAGER) --matic-token $(HARDHAT_MATIC_TOKEN) --manager $(HARDHAT_MANAGER) --treasury $(HARDHAT_TREASURY)
deploy-maticx-localhost:
$(BIN_HARDHAT) deploy:matic-x --network $(NETWORK_LOCALHOST) --validator-registry $(LOCALHOST_VALIDATOR_REGISTRY) --stake-manager $(LOCALHOST_STAKE_MANAGER) --matic-token $(LOCALHOST_MATIC_TOKEN) --manager $(LOCALHOST_MANAGER) --treasury $(LOCALHOST_TREASURY)
deploy-maticx-sepolia:
$(BIN_HARDHAT) deploy:matic-x --network $(NETWORK_SEPOLIA) --validator-registry $(SEPOLIA_VALIDATOR_REGISTRY) --stake-manager $(SEPOLIA_STAKE_MANAGER) --matic-token $(SEPOLIA_MATIC_TOKEN) --manager $(SEPOLIA_MANAGER) --treasury $(SEPOLIA_TREASURY)
deploy-maticx-ethereum:
$(BIN_HARDHAT) deploy:matic-x --network $(NETWORK_ETHEREUM) --validator-registry $(ETHEREUM_VALIDATOR_REGISTRY) --stake-manager $(ETHEREUM_STAKE_MANAGER) --matic-token $(ETHEREUM_MATIC_TOKEN) --manager $(ETHEREUM_MANAGER) --treasury $(ETHEREUM_TREASURY)

# Deploy the FxStateRootTunnel contract
deploy-fxstateroottunnel-hardhat:
$(BIN_HARDHAT) deploy:matic-x --network $(NETWORK_HARDHAT) --checkpoint-manager $(HARDHAT_CHECKPOINT_MANAGER) --fx-root $(HARDHAT_FX_ROOT) --matic-x $(HARDHAT_MATIC_X)
deploy-fxstateroottunnel-localhost:
$(BIN_HARDHAT) deploy:matic-x --network $(NETWORK_LOCALHOST) --checkpoint-manager $(LOCALHOST_CHECKPOINT_MANAGER) --fx-root $(LOCALHOST_FX_ROOT) --matic-x $(LOCALHOST_MATIC_X)
deploy-fxstateroottunnel-sepolia:
$(BIN_HARDHAT) deploy:matic-x --network $(NETWORK_SEPOLIA) --checkpoint-manager $(SEPOLIA_CHECKPOINT_MANAGER) --fx-root $(SEPOLIA_FX_ROOT) --matic-x $(SEPOLIA_MATIC_X)
deploy-fxstateroottunnel-ethereum:
$(BIN_HARDHAT) deploy:matic-x --network $(NETWORK_ETHEREUM) --checkpoint-manager $(ETHEREUM_CHECKPOINT_MANAGER) --fx-root $(ETHEREUM_FX_ROOT) --matic-x $(ETHEREUM_MATIC_X)

# Initialize v2 the ValidatorRegistry contract
initializev2-validatorregistry-sepolia:
$(BIN_HARDHAT) initialize-v2:validator-registry --network $(NETWORK_SEPOLIA) --contract $(SEPOLIA_VALIDATOR_REGISTRY) --pol-token $(SEPOLIA_POL_TOKEN)
Expand All @@ -81,16 +113,6 @@ initializev2-maticx-sepolia:
initializev2-maticx-ethereum:
$(BIN_HARDHAT) initialize-v2:matic-x --network $(NETWORK_ETHEREUM) --contract $(ESEPOLIA_MATIC_X) --pol-token $(ETHEREUM_POL_TOKEN)

# Deploy the MaticX contract
deploy-maticx-hardhat:
$(BIN_HARDHAT) deploy:matic-x --network $(NETWORK_HARDHAT) --validator-registry $(HARDHAT_VALIDATOR_REGISTRY) --stake-manager $(HARDHAT_STAKE_MANAGER) --matic-token $(HARDHAT_MATIC_TOKEN) --manager $(HARDHAT_MANAGER) --treasury $(HARDHAT_TREASURY)
deploy-maticx-localhost:
$(BIN_HARDHAT) deploy:matic-x --network $(NETWORK_LOCALHOST) --validator-registry $(LOCALHOST_VALIDATOR_REGISTRY) --stake-manager $(LOCALHOST_STAKE_MANAGER) --matic-token $(LOCALHOST_MATIC_TOKEN) --manager $(LOCALHOST_MANAGER) --treasury $(LOCALHOST_TREASURY)
deploy-maticx-sepolia:
$(BIN_HARDHAT) deploy:matic-x --network $(NETWORK_SEPOLIA) --validator-registry $(SEPOLIA_VALIDATOR_REGISTRY) --stake-manager $(SEPOLIA_STAKE_MANAGER) --matic-token $(SEPOLIA_MATIC_TOKEN) --manager $(SEPOLIA_MANAGER) --treasury $(SEPOLIA_TREASURY)
deploy-maticx-ethereum:
$(BIN_HARDHAT) deploy:matic-x --network $(NETWORK_ETHEREUM) --validator-registry $(ETHEREUM_VALIDATOR_REGISTRY) --stake-manager $(ETHEREUM_STAKE_MANAGER) --matic-token $(ETHEREUM_MATIC_TOKEN) --manager $(ETHEREUM_MANAGER) --treasury $(ETHEREUM_TREASURY)

# Upgrade the ValidatorRegistry contract
upgrade-validatorregistry-localhost:
$(BIN_HARDHAT) upgrade-contract --network $(NETWORK_LOCALHOST) --name ValidatorRegistry --contract $(LOCALHOST_VALIDATOR_REGISTRY)
Expand Down Expand Up @@ -119,6 +141,12 @@ verify-maticx-sepolia:
verify-maticx-ethereum:
$(BIN_HARDHAT) verify-contract --network $(NETWORK_ETHEREUM) --contract $(ETHEREUM_MATIC_X)

# Verify the FxStateRootTunnel contract
verify-fxstateroottunnel-sepolia:
$(BIN_HARDHAT) verify-contract --network $(NETWORK_SEPOLIA) --contract $(SEPOLIA_FX_STATE_ROOT_TUNNEL)
verify-fxstateroottunnel-ethereum:
$(BIN_HARDHAT) verify-contract --network $(NETWORK_ETHEREUM) --contract $(ETHEREUM_FX_STATE_ROOT_TUNNEL)

# Import the ValidatorRegistry contract
import-validatorregistry-sepolia:
$(BIN_HARDHAT) import-contract --network $(NETWORK_SEPOLIA) --name ValidatorRegistry --contract $(SEPOLIA_VALIDATOR_REGISTRY)
Expand Down
78 changes: 78 additions & 0 deletions tasks/deploy-fx-state-root-tunnel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { TASK_CLEAN, TASK_COMPILE } from "hardhat/builtin-tasks/task-names";
import { task, types } from "hardhat/config";
import { getSigner } from "../utils/account";
import { isLocalNetwork, Network } from "../utils/network";

interface TaskParams {
checkpointManager: string;
fxRoot: string;
fxStateRootTunnel: string;
}

task("deploy:fx-state-root-tunnel")
.setDescription("Deploy the FxStateRootTunnel contract")
.addParam<string>(
"checkpointManager",
"Address of the CheckpointManager contract",
undefined,
types.string
)
.addParam<string>(
"fxRoot",
"Address of the FxRoot contract",
undefined,
types.string
)
.addParam<string>(
"maticX",
"Address of the MaticX contract",
undefined,
types.string
)
.setAction(
async (
{
checkpointManager: checkpointManagerAddress,
fxRoot: fxRootAddress,
maticX: maticXAddress,

Check failure on line 37 in tasks/deploy-fx-state-root-tunnel.ts

View workflow job for this annotation

GitHub Actions / test (20.15.x, 3.12, 0.8.7)

Property 'maticX' does not exist on type 'TaskParams'.
}: TaskParams,
{ ethers, network, run }
) => {
if (!ethers.utils.isAddress(checkpointManagerAddress)) {
throw new Error("Invalid CheckpointManager address");
}
if (!ethers.utils.isAddress(fxRootAddress)) {
throw new Error("Invalid FxRootAddress address");
}
if (!ethers.utils.isAddress(maticXAddress)) {
throw new Error("Invalid MaticX address");
}

const networkName = network.name as Network;
console.log(`Network name: ${networkName}`);
if (!isLocalNetwork(networkName)) {
await run(TASK_CLEAN);
}
await run(TASK_COMPILE);

const signer = await getSigner(
ethers,
network.provider,
network.config.from
);
const FxStateRootTunnel = await ethers.getContractFactory(
"FxStateRootTunnel",
signer
);

const fxStateRootTunnel = await FxStateRootTunnel.deploy(
checkpointManagerAddress,
fxRootAddress,
maticXAddress
);
await fxStateRootTunnel.deployed();
console.log(
`FxStateRootTunnel deployed at ${fxStateRootTunnel.address}`
);
}
);
1 change: 1 addition & 0 deletions tasks/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "./deploy-fx-state-root-tunnel";
import "./deploy-matic-x";
import "./deploy-validator-registry";
import "./import-contract";
Expand Down

0 comments on commit 92bcf05

Please sign in to comment.