Skip to content

Commit

Permalink
Implement task to deploy FxStateChildTunnel contract
Browse files Browse the repository at this point in the history
  • Loading branch information
evercoinx committed Nov 4, 2024
1 parent dd1a7f4 commit 3b5d779
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ HARDHAT_CHILD_POOL := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_STAKE_MANAGER := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_CHECKPOINT_MANAGER := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_FX_ROOT := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_FX_CHILD := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_FX_STATE_ROOT_TUNNEL := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_FX_STATE_CHILD_TUNNEL := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
HARDHAT_MATIC_TOKEN := 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
Expand All @@ -35,6 +36,7 @@ LOCALHOST_CHILD_POOL :=
LOCALHOST_STAKE_MANAGER :=
LOCALHOST_CHECKPOINT_MANAGER :=
LOCALHOST_FX_ROOT :=
LOCALHOST_FX_CHILD :=
LOCALHOST_FX_STATE_ROOT_TUNNEL :=
LOCALHOST_FX_STATE_CHILD_TUNNEL :=
LOCALHOST_MATIC_TOKEN :=
Expand All @@ -58,6 +60,7 @@ SEPOLIA_TREASURY := 0xdeb90df43BBa8FC0e2C08C54dC0F48cfc694F896
# Amoy contract addresses
AMOY_MATIC_X :=
AMOY_CHILD_POOL :=
AMOY_FX_CHILD := 0xE5930336866d0388f0f745A2d9207C7781047C0f
AMOY_FX_STATE_CHLID_TUNNEL :=
AMOY_MANAGER :=
AMOY_TREASURY :=
Expand All @@ -78,6 +81,7 @@ ETHEREUM_TREASURY := 0x01422247a1d15BB4FcF91F5A077Cf25BA6460130
# Polygon contract addresses
POLYGON_MATIC_X := 0xfa68FB4628DFF1028CFEc22b4162FCcd0d45efb6
POLYGON_CHILD_POOL := 0xfd225C9e6601C9d38d8F98d8731BF59eFcF8C0E3
POLYGON_FX_CHILD := 0x8397259c983751DAf40400790063935a11afa28a
POLYGON_FX_STATE_CHILD_TUNNEL := 0x97E58a6950D86d751082D5e1d350e74c19047570
POLYGON_MANAGER := 0x80A43dd35382C4919991C5Bca7f46Dd24Fde4C67
POLYGON_TREASURY := 0x80A43dd35382C4919991C5Bca7f46Dd24Fde4C67
Expand All @@ -89,9 +93,9 @@ CONTRACT_PATH_MATIC_X := contracts/MaticX.sol

all: hardhat

hardhat: deploy-validatorregistry-hardhat
hardhat: deploy-validatorregistry-hardhat deploy-childpool-hardhat deploy-fxstateroottunnel-hardhat deploy-fxstatechildtunnel-hardhat

localhost: deploy-validatorregistry-localhost
localhost: deploy-validatorregistry-localhost deploy-childpool-localhost deploy-fxstateroottunnel-localhost deploy-fxstatechildtunnel-localhost

# Deploy the ValidatorRegistry contract
deploy-validatorregistry-hardhat:
Expand Down Expand Up @@ -133,6 +137,16 @@ deploy-fxstateroottunnel-sepolia:
deploy-fxstateroottunnel-ethereum:
$(BIN_HARDHAT) deploy:fx-state-root-tunnel --network $(NETWORK_ETHEREUM) --checkpoint-manager $(ETHEREUM_CHECKPOINT_MANAGER) --fx-root $(ETHEREUM_FX_ROOT) --matic-x $(ETHEREUM_MATIC_X)

# Deploy the FxStateChildTunnel contract
deploy-fxstatechildtunnel-hardhat:
$(BIN_HARDHAT) deploy:fx-state-child-tunnel --network $(NETWORK_HARDHAT) --fx-child $(HARDHAT_FX_CHILD)
deploy-fxstatechildtunnel-localhost:
$(BIN_HARDHAT) deploy:fx-state-child-tunnel --network $(NETWORK_LOCALHOST) --fx-child $(LOCALHOST_FX_CHILD)
deploy-fxstatechildtunnel-amoy:
$(BIN_HARDHAT) deploy:fx-state-child-tunnel --network $(NETWORK_AMOY) --fx-child $(AMOY_FX_CHILD)
deploy-fxstatechildtunnel-polygon:
$(BIN_HARDHAT) deploy:fx-state-child-tunnel --network $(NETWORK_POLYGON) --fx-child $(POLYGON_FX_CHILD)

# 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 Down Expand Up @@ -179,6 +193,12 @@ verify-fxstateroottunnel-sepolia:
verify-fxstateroottunnel-ethereum:
$(BIN_HARDHAT) verify-contract --network $(NETWORK_ETHEREUM) --contract $(ETHEREUM_FX_STATE_ROOT_TUNNEL) "$(ETHEREUM_CHECKPOINT_MANAGER)" "$(ETHEREUM_FX_ROOT)" "$(ETHEREUM_MATIC_X)"

# Verify the FxStateChildTunnel contract
verify-fxstatechildtunnel-amoy:
$(BIN_HARDHAT) verify-contract --network $(NETWORK_AMOY) --contract $(AMOY_FX_STATE_CHILD_TUNNEL) "$(AMOY_FX_CHILD)"
verify-fxstatechildtunnel-polygon:
$(BIN_HARDHAT) verify-contract --network $(NETWORK_POLYGON) --contract $(POLYGON_FX_STATE_CHILD_TUNNEL) "$(POLYGON_FX_CHILD)"

# Import the ValidatorRegistry contract
import-validatorregistry-sepolia:
$(BIN_HARDHAT) import-contract --network $(NETWORK_SEPOLIA) --name ValidatorRegistry --contract $(SEPOLIA_VALIDATOR_REGISTRY)
Expand Down
7 changes: 7 additions & 0 deletions docs/Amoy-Testnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Deployment Information

## Amoy Testnet

### Fx Child

- Address: [0xE5930336866d0388f0f745A2d9207C7781047C0f](https://amoy.polygonscan.com/address/0xE5930336866d0388f0f745A2d9207C7781047C0f)
8 changes: 8 additions & 0 deletions docs/Ethereum-Mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@

- Address: [0x40FB804Cc07302b89EC16a9f8d040506f64dFe29](https://etherscan.io/address/0x40FB804Cc07302b89EC16a9f8d040506f64dFe29)

### Checkpoint Manager

- Address: [0x86e4dc95c7fbdbf52e33d563bbdb00823894c287](https://etherscan.io/address/0x86e4dc95c7fbdbf52e33d563bbdb00823894c287)

### Fx Root

- Address: [0xfe5e5D361b2ad62c541bAb87C45a0B9B018389a2](https://etherscan.io/address/0xfe5e5D361b2ad62c541bAb87C45a0B9B018389a2)

### Matic Token

- Address: [0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0](https://etherscan.io/address/0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0)
Expand Down
4 changes: 4 additions & 0 deletions docs/Polygon-Mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

- Address: [0x97E58a6950D86d751082D5e1d350e74c19047570](https://polygonscan.com/address/0x97E58a6950D86d751082D5e1d350e74c19047570)

### Fx Child

- Address: [0x8397259c983751DAf40400790063935a11afa28a](https://amoy.polygonscan.com/address/0x8397259c983751DAf40400790063935a11afa28a)

### Rate Provider

- Address: [0xeE652bbF72689AA59F0B8F981c9c90e2A8Af8d8f](https://polygonscan.com/address/0xeE652bbF72689AA59F0B8F981c9c90e2A8Af8d8f)
Expand Down
8 changes: 8 additions & 0 deletions docs/Sepolia-Testnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@

- Address: [0x1316e16f56a5A05538277906E12b77F2B39B4d79](https://sepolia.etherscan.io/address/0x1316e16f56a5A05538277906E12b77F2B39B4d79)

### Checkpoint Manager

- Address: [0xbd07D7E1E93c8d4b2a261327F3C28a8EA7167209](https://sepolia.etherscan.io/address/0xbd07D7E1E93c8d4b2a261327F3C28a8EA7167209)

### Fx Root

- Address: [0x0E13EBEdDb8cf9f5987512d5E081FdC2F5b0991e](https://sepolia.etherscan.io/address/0x0E13EBEdDb8cf9f5987512d5E081FdC2F5b0991e)

### Matic Token

- Address: [0x3fd0A53F4Bf853985a95F4Eb3F9C9FDE1F8e2b53](https://sepolia.etherscan.io/address/0x3fd0A53F4Bf853985a95F4Eb3F9C9FDE1F8e2b53)
Expand Down
51 changes: 51 additions & 0 deletions tasks/deploy-fx-state-child-tunnel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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 {
fxChild: string;
}

task("deploy:fx-state-child-tunnel")
.setDescription("Deploy the FxStateChildTunnel contract")
.addParam<string>(
"fxChild",
"Address of the FxChild contract",
undefined,
types.string
)
.setAction(
async (
{ fxChild: fxChildAddress }: TaskParams,
{ ethers, network, run }
) => {
if (!ethers.utils.isAddress(fxChildAddress)) {
throw new Error("Invalid FxChildAddress 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 FxStateChildTunnel = await ethers.getContractFactory(
"FxStateChildTunnel",
signer
);

const fxStateChildTunnel =
await FxStateChildTunnel.deploy(fxChildAddress);
await fxStateChildTunnel.deployed();
console.log(
`fxStateChildTunnel deployed at ${fxStateChildTunnel.address}`
);
}
);
1 change: 1 addition & 0 deletions tasks/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "./deploy-child-pool";
import "./deploy-fx-state-child-tunnel";
import "./deploy-fx-state-root-tunnel";
import "./deploy-matic-x";
import "./deploy-validator-registry";
Expand Down

0 comments on commit 3b5d779

Please sign in to comment.