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

Nojira update scripts #58

Merged
merged 48 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
48c1051
Support ledger & switch to ts
wcgcyx Nov 27, 2023
68faca9
Fix mocha issue
wcgcyx Nov 27, 2023
5543823
Merge pull request #57 from immutable/1993-Hardware-Wallet-Integration
wcgcyx Nov 28, 2023
ac227d3
Fix issues
wcgcyx Dec 2, 2023
d90f3b4
Fix ledge issue with multiple accounts
wcgcyx Dec 4, 2023
acdade4
Fix role control
wcgcyx Dec 5, 2023
5b7ced7
Add create2 contract deployer with access control
ermyas Dec 5, 2023
81747bd
Accept intended owner in constructor
ermyas Dec 5, 2023
3418986
Merge pull request #63 from immutable/add/create2-contract-deployer
ermyas Dec 6, 2023
5608a4e
Merge branch 'develop' into NOJIRA_UPDATE_SCRIPTS
wcgcyx Dec 6, 2023
42debb9
Fix issue
wcgcyx Dec 6, 2023
9e5dddc
Fix defaults
wcgcyx Dec 6, 2023
6e04ccb
Update root_initialisation.ts
wcgcyx Dec 8, 2023
6384295
Fix e2e
wcgcyx Dec 8, 2023
56672af
Fix CI
wcgcyx Dec 8, 2023
e90aa43
Update bootstrap
wcgcyx Dec 8, 2023
d2d9273
Merge branch 'main' into NOJIRA_UPDATE_SCRIPTS
wcgcyx Dec 13, 2023
f9f1c8a
Fix CI
wcgcyx Dec 13, 2023
e5e48a8
Add role on L2
wcgcyx Dec 13, 2023
78ac63d
Update e2e.yml
wcgcyx Dec 13, 2023
b58a234
Add verification of contracts
wcgcyx Dec 13, 2023
3ea5908
Fix CI
wcgcyx Dec 13, 2023
25a5a75
Delete verify.txt
wcgcyx Dec 14, 2023
44cf804
Update helpers.ts
wcgcyx Dec 14, 2023
e989792
Update helpers.ts
wcgcyx Dec 14, 2023
156005a
Improve stability
wcgcyx Dec 14, 2023
bcac3a9
Improve stability again
wcgcyx Dec 14, 2023
11359b3
Update verification
wcgcyx Dec 15, 2023
480d7da
Use Retry provider & Improve stability
wcgcyx Dec 19, 2023
6f5d84a
Update rate configuration
wcgcyx Dec 19, 2023
49f7af9
Fix rate limit for USDC
wcgcyx Dec 19, 2023
52130e5
Merge branch 'main' into NOJIRA_UPDATE_SCRIPTS
wcgcyx Jan 22, 2024
b8a2603
Add more e2e test cases
wcgcyx Jan 29, 2024
1f3db34
Fix CI
wcgcyx Jan 29, 2024
2a730d2
Lint
wcgcyx Jan 29, 2024
9cfd57f
Add test case
wcgcyx Jan 31, 2024
33cbe5c
Merge branch 'main' into NOJIRA_UPDATE_SCRIPTS
wcgcyx Jan 31, 2024
ba85766
Update e2e.yml
wcgcyx Jan 31, 2024
4692803
Merge branch 'main' into NOJIRA_UPDATE_SCRIPTS
wcgcyx Jan 31, 2024
9a678f6
Delete OwnableCreate2Deployer.sol
wcgcyx Feb 11, 2024
f4c7278
Delete OwnableCreate2Deployer.t.sol
wcgcyx Feb 11, 2024
1e83d42
Refactor
wcgcyx Feb 12, 2024
f102a3e
Update e2e.ts
wcgcyx Feb 12, 2024
b3bd113
Update e2e.ts
wcgcyx Feb 12, 2024
ece2260
Update e2e.ts
wcgcyx Feb 12, 2024
e7f5e37
Fix e2e
wcgcyx Feb 12, 2024
edc3b75
Fix e2e
wcgcyx Feb 12, 2024
e79a3f9
Merge branch 'main' into NOJIRA_UPDATE_SCRIPTS
wcgcyx Feb 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix defaults
  • Loading branch information
wcgcyx committed Dec 6, 2023
commit 9e5dddc4fcb1e53ebc840a2229e0f2ec7ec1f2bd
4 changes: 2 additions & 2 deletions scripts/bootstrap/0_pre_validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ async function run() {
if (axelarRequiredIMX.lt(ethers.utils.parseEther("500.0"))) {
tryThrow("Axelar on child chain should request at least 500 IMX, got" + ethers.utils.formatEther(axelarRequiredIMX));
}
if (deployerRequiredIMX.lt(ethers.utils.parseEther("500.0"))) {
if (deployerRequiredIMX.lt(ethers.utils.parseEther("250.0"))) {
tryThrow("Deployer on child chain should request at least 500 IMX, got" + ethers.utils.formatEther(deployerRequiredIMX));
}
if (reservedDeployerRequiredIMX.lt(ethers.utils.parseEther("10.0"))) {
if (reservedDeployerRequiredIMX.lt(ethers.utils.parseEther("250.0"))) {
tryThrow("Reserved deployer on child chain should request at least 10 IMX, got" + ethers.utils.formatEther(reservedDeployerRequiredIMX));
}
let extraIMX = ethers.utils.parseEther("100.0");
Expand Down
152 changes: 84 additions & 68 deletions scripts/deploy/child_deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,72 @@ export async function deployChildContracts() {
let childContracts = getChildContracts();

const childProvider = new ethers.providers.JsonRpcProvider(childRPCURL, Number(childChainID));

// Get deployer address
let childDeployerWallet;
if (deployerSecret == "ledger") {
let index = requireEnv("DEPLOYER_LEDGER_INDEX");
const derivationPath = `m/44'/60'/${parseInt(index)}'/0/0`;
childDeployerWallet = new LedgerSigner(childProvider, derivationPath);
} else {
childDeployerWallet = new ethers.Wallet(deployerSecret, childProvider);
}
let deployerAddr = await childDeployerWallet.getAddress();
console.log("Deployer address is: ", deployerAddr);

// Execute
console.log("Deploy child contracts in...");
await waitForConfirmation();

// Deploy wrapped IMX
let wrappedIMX;
if (childContracts.WRAPPED_IMX_ADDRESS != "") {
console.log("Wrapped IMX has already been deployed to: " + childContracts.WRAPPED_IMX_ADDRESS + ", skip.");
wrappedIMX = getContract("WIMX", childContracts.WRAPPED_IMX_ADDRESS, childProvider);
} else {
console.log("Deploy wrapped IMX...");
wrappedIMX = await deployChildContract("WIMX", childDeployerWallet, null);
console.log("Transaction submitted: ", JSON.stringify(wrappedIMX.deployTransaction, null, 2));
await waitForReceipt(wrappedIMX.deployTransaction.hash, childProvider);
}
childContracts.WRAPPED_IMX_ADDRESS = wrappedIMX.address;
saveChildContracts(childContracts);
console.log("Deployed to WRAPPED_IMX_ADDRESS: ", wrappedIMX.address);

// Deploy child bridge impl
let childBridgeImpl;
if (childContracts.CHILD_BRIDGE_IMPL_ADDRESS != "") {
console.log("Child bridge impl has already been deployed to: " + childContracts.CHILD_BRIDGE_IMPL_ADDRESS + ", skip.");
childBridgeImpl = getContract("ChildERC20Bridge", childContracts.CHILD_BRIDGE_IMPL_ADDRESS, childProvider);
} else {
console.log("Deploy child bridge impl...");
childBridgeImpl = await deployChildContract("ChildERC20Bridge", childDeployerWallet, null);
console.log("Transaction submitted: ", JSON.stringify(childBridgeImpl.deployTransaction, null, 2));
await waitForReceipt(childBridgeImpl.deployTransaction.hash, childProvider);
}
childContracts.CHILD_BRIDGE_IMPL_ADDRESS = childBridgeImpl.address;
saveChildContracts(childContracts);
console.log("Deployed to CHILD_BRIDGE_IMPL_ADDRESS: ", childBridgeImpl.address);

// Deploy child adaptor impl
let childAdaptorImpl;
if (childContracts.CHILD_ADAPTOR_IMPL_ADDRESS != "") {
console.log("Child adaptor impl has already been deployed to: " + childContracts.CHILD_ADAPTOR_IMPL_ADDRESS + ", skip.");
childAdaptorImpl = getContract("ChildAxelarBridgeAdaptor", childContracts.CHILD_ADAPTOR_IMPL_ADDRESS, childProvider);
} else {
console.log("Deploy child adaptor impl...");
childAdaptorImpl = await deployChildContract("ChildAxelarBridgeAdaptor", childDeployerWallet, null, childGatewayAddr);
console.log("Transaction submitted: ", JSON.stringify(childAdaptorImpl.deployTransaction, null, 2));
await waitForReceipt(childAdaptorImpl.deployTransaction.hash, childProvider);
}
childContracts.CHILD_ADAPTOR_IMPL_ADDRESS = childAdaptorImpl.address;
saveChildContracts(childContracts);
console.log("Deployed to CHILD_ADAPTOR_IMPL_ADDRESS: ", childAdaptorImpl.address);

if (childDeployerWallet instanceof LedgerSigner) {
childDeployerWallet.close();
}

// Get reserved wallet
let reservedDeployerWallet;
if (nonceReservedDeployerSecret == "ledger") {
Expand All @@ -30,10 +96,6 @@ export async function deployChildContracts() {
let reservedDeployerAddr = await reservedDeployerWallet.getAddress();
console.log("Reserved deployer address is: ", reservedDeployerAddr);

// Execute
console.log("Deploy child contracts in...");
await waitForConfirmation();

// Deploy child token template
let childTokenTemplate;
if (childContracts.CHILD_TOKEN_TEMPLATE != "") {
Expand Down Expand Up @@ -69,105 +131,59 @@ export async function deployChildContracts() {
}
console.log("Initialised CHILD_TOKEN_TEMPLATE at: ", childTokenTemplate.address);

if (reservedDeployerWallet instanceof LedgerSigner) {
reservedDeployerWallet.close();
}

// Get deployer address
let childDeployerWallet;
if (deployerSecret == "ledger") {
let index = requireEnv("DEPLOYER_LEDGER_INDEX");
const derivationPath = `m/44'/60'/${parseInt(index)}'/0/0`;
childDeployerWallet = new LedgerSigner(childProvider, derivationPath);
} else {
childDeployerWallet = new ethers.Wallet(deployerSecret, childProvider);
}
let deployerAddr = await childDeployerWallet.getAddress();
console.log("Deployer address is: ", deployerAddr);

// Deploy wrapped IMX
let wrappedIMX;
if (childContracts.WRAPPED_IMX_ADDRESS != "") {
console.log("Wrapped IMX has already been deployed to: " + childContracts.WRAPPED_IMX_ADDRESS + ", skip.");
wrappedIMX = getContract("WIMX", childContracts.WRAPPED_IMX_ADDRESS, childProvider);
} else {
console.log("Deploy wrapped IMX...");
wrappedIMX = await deployChildContract("WIMX", childDeployerWallet, null);
console.log("Transaction submitted: ", JSON.stringify(wrappedIMX.deployTransaction, null, 2));
await waitForReceipt(wrappedIMX.deployTransaction.hash, childProvider);
}
childContracts.WRAPPED_IMX_ADDRESS = wrappedIMX.address;
saveChildContracts(childContracts);
console.log("Deployed to WRAPPED_IMX_ADDRESS: ", wrappedIMX.address);

// Deploy proxy admin
let proxyAdmin;
if (childContracts.CHILD_PROXY_ADMIN != "") {
console.log("Proxy admin has already been deployed to: " + childContracts.CHILD_PROXY_ADMIN + ", skip.");
proxyAdmin = getContract("ProxyAdmin", childContracts.CHILD_PROXY_ADMIN, childProvider);
} else {
// Check the current nonce matches the reserved nonce
let currentNonce = await childProvider.getTransactionCount(reservedDeployerAddr);
if (nonceReserved + 2 != currentNonce) {
throw("Nonce mismatch, expected " + (nonceReserved + 2) + " actual " + currentNonce);
}
console.log("Deploy proxy admin...");
proxyAdmin = await deployChildContract("ProxyAdmin", childDeployerWallet, null);
proxyAdmin = await deployChildContract("ProxyAdmin", reservedDeployerWallet, null);
console.log("Transaction submitted: ", JSON.stringify(proxyAdmin.deployTransaction, null, 2));
await waitForReceipt(proxyAdmin.deployTransaction.hash, childProvider);
}
childContracts.CHILD_PROXY_ADMIN = proxyAdmin.address;
saveChildContracts(childContracts);
console.log("Deployed to CHILD_PROXY_ADMIN: ", proxyAdmin.address);

// Deploy child bridge impl
let childBridgeImpl;
if (childContracts.CHILD_BRIDGE_IMPL_ADDRESS != "") {
console.log("Child bridge impl has already been deployed to: " + childContracts.CHILD_BRIDGE_IMPL_ADDRESS + ", skip.");
childBridgeImpl = getContract("ChildERC20Bridge", childContracts.CHILD_BRIDGE_IMPL_ADDRESS, childProvider);
} else {
console.log("Deploy child bridge impl...");
childBridgeImpl = await deployChildContract("ChildERC20Bridge", childDeployerWallet, null);
console.log("Transaction submitted: ", JSON.stringify(childBridgeImpl.deployTransaction, null, 2));
await waitForReceipt(childBridgeImpl.deployTransaction.hash, childProvider);
}
childContracts.CHILD_BRIDGE_IMPL_ADDRESS = childBridgeImpl.address;
saveChildContracts(childContracts);
console.log("Deployed to CHILD_BRIDGE_IMPL_ADDRESS: ", childBridgeImpl.address);

// Deploy child bridge proxy
let childBridgeProxy;
if (childContracts.CHILD_BRIDGE_PROXY_ADDRESS != "") {
console.log("Child bridge proxy has already been deployed to: " + childContracts.CHILD_BRIDGE_PROXY_ADDRESS + ", skip.");
childBridgeProxy = getContract("TransparentUpgradeableProxy", childContracts.CHILD_BRIDGE_PROXY_ADDRESS, childProvider);
} else {
// Check the current nonce matches the reserved nonce
let currentNonce = await childProvider.getTransactionCount(reservedDeployerAddr);
if (nonceReserved + 3 != currentNonce) {
throw("Nonce mismatch, expected " + (nonceReserved + 3) + " actual " + currentNonce);
}
console.log("Deploy child bridge proxy...");
childBridgeProxy = await deployChildContract("TransparentUpgradeableProxy", childDeployerWallet, null, childBridgeImpl.address, proxyAdmin.address, []);
childBridgeProxy = await deployChildContract("TransparentUpgradeableProxy", reservedDeployerWallet, null, childBridgeImpl.address, proxyAdmin.address, []);
console.log("Transaction submitted: ", JSON.stringify(childBridgeProxy.deployTransaction, null, 2));
await waitForReceipt(childBridgeProxy.deployTransaction.hash, childProvider);
}
childContracts.CHILD_BRIDGE_PROXY_ADDRESS = childBridgeProxy.address;
saveChildContracts(childContracts);
console.log("Deployed to CHILD_BRIDGE_PROXY_ADDRESS: ", childBridgeProxy.address);

// Deploy child adaptor impl
let childAdaptorImpl;
if (childContracts.CHILD_ADAPTOR_IMPL_ADDRESS != "") {
console.log("Child adaptor impl has already been deployed to: " + childContracts.CHILD_ADAPTOR_IMPL_ADDRESS + ", skip.");
childAdaptorImpl = getContract("ChildAxelarBridgeAdaptor", childContracts.CHILD_ADAPTOR_IMPL_ADDRESS, childProvider);
} else {
console.log("Deploy child adaptor impl...");
childAdaptorImpl = await deployChildContract("ChildAxelarBridgeAdaptor", childDeployerWallet, null, childGatewayAddr);
console.log("Transaction submitted: ", JSON.stringify(childAdaptorImpl.deployTransaction, null, 2));
await waitForReceipt(childAdaptorImpl.deployTransaction.hash, childProvider);
}
childContracts.CHILD_ADAPTOR_IMPL_ADDRESS = childAdaptorImpl.address;
saveChildContracts(childContracts);
console.log("Deployed to CHILD_ADAPTOR_IMPL_ADDRESS: ", childAdaptorImpl.address);

// Deploy child adaptor proxy
let childAdaptorProxy;
if (childContracts.CHILD_ADAPTOR_PROXY_ADDRESS != "") {
console.log("Child adaptor proxy has already been deployed to: " + childContracts.CHILD_ADAPTOR_PROXY_ADDRESS + ", skip.");
childAdaptorProxy = getContract("TransparentUpgradeableProxy", childContracts.CHILD_ADAPTOR_PROXY_ADDRESS, childProvider);
} else {
// Check the current nonce matches the reserved nonce
let currentNonce = await childProvider.getTransactionCount(reservedDeployerAddr);
if (nonceReserved + 4 != currentNonce) {
throw("Nonce mismatch, expected " + (nonceReserved + 4) + " actual " + currentNonce);
}
console.log("Deploy child adaptor proxy...");
childAdaptorProxy = await deployChildContract("TransparentUpgradeableProxy", childDeployerWallet, null, childAdaptorImpl.address, proxyAdmin.address, []);
childAdaptorProxy = await deployChildContract("TransparentUpgradeableProxy", reservedDeployerWallet, null, childAdaptorImpl.address, proxyAdmin.address, []);
console.log("Transaction submitted: ", JSON.stringify(childAdaptorProxy.deployTransaction, null, 2));
await waitForReceipt(childAdaptorProxy.deployTransaction.hash, childProvider);
}
Expand Down
Loading