Skip to content

Commit

Permalink
Updated post deployment to Devnet, and Testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
shirren committed Dec 20, 2023
1 parent bd4db8b commit 6d39448
Show file tree
Hide file tree
Showing 23 changed files with 206 additions and 82 deletions.
128 changes: 87 additions & 41 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,87 @@
# Steps for deploying to hardhat

1. Startup a Hardhat node.
2. Transfer funds to the ledger.
3. Deploy the `OwnableCreate2Deployer` contract using the ledger. The Ledger is now the owner of the contract, and the
only entity allowed to call the deploy function on the contract;
1. forge create --rpc-url <http://127.0.0.1:8545> --constructor-args "<ADDRESS_OF_LEDGER_ACCOUNT>" --legacy --hd-path "m/44'/60'/0'/0/0" src/OwnableCreate2Deployer.sol:OwnableCreate2Deployer.
4. Set the value of DEPLOYER_CONTRACT_ADDRESS in the environment to equal the address of the OwnableCreate2Deployer contract deployed of step 3 above.
5. Set the deployer key to be a unique value for the run.
6. Copy the relevant `.env.X` file to `.env`. For example in the case of Devnet `cp .env.devnet .env`
7. Execute the command `npx hardhat run scripts/step1.ts --network <ENV>`
8. Execute the command `npx hardhat run scripts/step2.ts --network <ENV>`
9. Execute the command `npx hardhat run scripts/step3.ts --network <ENV>`
1. WARNING: COPY the `LatestWalletImplLocator` address into the `step3.ts` script from step2.
10. Execute the command `npx hardhat run scripts/step4.ts --network <ENV>`
1. WARNING: COPY the `FactoryAddress` address into the `step4.ts` script from step1.
2. WARNING: COPY the `StartupWalletImpl` address into the `step4.ts` script from step3.
11. Execute the command `npx hardhat run scripts/step5.ts --network <ENV>`
12. Execute the command `npx hardhat run scripts/step6.ts --network <ENV>`
1. WARNING: COPY the `MainModuleDynamicAuth` address into the `step6.ts` script from step4.
1. WARNING: COPY the `LatestWalletImplLocator` address into the `step6.ts` script from step2.
13. Edit the following environment variables in the Relayer in the `.env.local` and `local-deployment.yaml` files
1. DEPLOY_AND_EXECUTE_ADDRESS to equal the address of the `MultiCallDeploy`
2. FACTORY_ADDRESS to equal the address of the `Factory`
3. MAIN_MODULE_ADDRESS to equal the address of the `StartupWalletImpl`
4. IMMUTABLE_SIGNER_CONTRACT_ADDRESS to equal the address of the `ImmutableSigner`

# Steps for deploying to Devnet

1. If the `OwnableCreate2Deployer` contract has not been deployed, deploy it using the ledger. The Ledger is now the owner of the contract, and the
only entity allowed to call the deploy function on the contract;
1. forge create --rpc-url <https://rpc.dev.immutable.com> --constructor-args "<ADDRESS_OF_LEDGER_ACCOUNT>" --legacy --hd-path "m/44'/60'/0'/0/0" src/OwnableCreate2Deployer.sol:OwnableCreate2Deployer.
2. Set the value of DEPLOYER_CONTRACT_ADDRESS in the environment to equal the address of the OwnableCreate2Deployer contract deployed of step 1 above.
3. Set the deployer key to be a unique value for the run.
4. Execute the command `npx npm run deployToDevnet`.
1. IMPORTANT: Remember to copy the correct `.env.X` file into `.env` before execution.
5. Edit the following environment variables in the Relayer in the `.env.local` and `local-deployment.yaml` files
1. DEPLOY_AND_EXECUTE_ADDRESS to equal the address of the `MultiCallDeploy`
2. FACTORY_ADDRESS to equal the address of the `Factory`
3. MAIN_MODULE_ADDRESS to equal the address of the `StartupWalletImpl`
4. IMMUTABLE_SIGNER_CONTRACT_ADDRESS to equal the address of the `ImmutableSigner`
# Steps for deploying

The smart contract wallets require 3 ledgers for deployment. The first ledger uses the Passport nonce reserver. The second ledger is a deployment ledger, and the third ledger is the priviledged ledger. Some of the steps below need to signed using the Passport nonce reserver, whilst use the standard deployment ledger, and finally the priviledged ledger. The corresponding ledgers are labelled in each step.

The ledgers used in the deployment have the following public keys;

* Passport Nonce Reserver - `0x5780B22CCd5830595C9EC79a8E273ee83Be79d17`
* Deployment Key - `0xdDA0d9448Ebe3eA43aFecE5Fa6401F5795c19333`
* Priviledged Key - `0x0E2D55943f4EF07c336C12A85d083c20FF189182`

## Step 1

Startup a Hardhat node if testing locally.

## Step 2

Transfer funds to the 3 ledgers used for the procedure. ~10 IMX will suffice for the operation.

## Step 3

Deploy the `OwnableCreate2Deployer` contract using the deployment ledger. Remember to set the correct owner of the contract during the deployment. For example the contract can be deployed using the command below;

`forge create --rpc-url <http://127.0.0.1:8545> --constructor-args "<ADDRESS_OF_LEDGER_ACCOUNT>" --legacy --hd-path "m/44'/60'/0'/0/0" src/OwnableCreate2Deployer.sol:OwnableCreate2Deployer`

The contract factory repo is located [here](https://github.com/immutable/contract-deployer). Please note that you shouldn't deploy the contract factory for Testnet, or Mainnet. Instead use the pre-existing deployments, the addresses for which are located [here]().:whilst

Set the value of DEPLOYER_CONTRACT_ADDRESS in the environment to equal the address of the OwnableCreate2Deployer contract deployed above.

## Step 4

Set the deployer key to be a unique value for the run.

## Step 5

Copy the relevant `.env.X` file to `.env`. For example in the case of Devnet `cp .env.devnet .env`

## Execution steps

### `step1.ts`

Use the Passport Nonce Reserver Key

* Execute the command `npx hardhat run scripts/step1.ts --network <ENV>`

### `step2.ts`

Use a deployer key. This key will have privileges to change the implementation address.

* Execute the command `npx hardhat run scripts/step2.ts --network <ENV>`

### `step3.ts`

Use the Passport Nonce Reserver Key

* Execute the command `npx hardhat run scripts/step3.ts --network <ENV>`
* WARNING: COPY the `LatestWalletImplLocator` address into the `step3.ts` script from step2.

### `step4.ts`

Use a deployer key

* Execute the command `npx hardhat run scripts/step4.ts --network <ENV>`
* WARNING: COPY the `FactoryAddress` address into the `step4.ts` script from step1.
* WARNING: COPY the `StartupWalletImpl` address into the `step4.ts` script from step3.

### `step5.ts`

Use the Passport Nonce Reserver Key

* Execute the command `npx hardhat run scripts/step5.ts --network <ENV>`

### `step6.ts`

Use the priviledged key for this step.

* Execute the command `npx hardhat run scripts/step6.ts --network <ENV>`
* WARNING: COPY the `MainModuleDynamicAuth` address into the `step6.ts` script from step4.
* WARNING: COPY the `LatestWalletImplLocator` address into the `step6.ts` script from step2.

## Update Relayer and Passport Environment

Edit the following environment variables in the Relayer in the `.env.local` and `local-deployment.yaml` files

* DEPLOY_AND_EXECUTE_ADDRESS to equal the address of the `MultiCallDeploy`
* FACTORY_ADDRESS to equal the address of the `Factory`
* MAIN_MODULE_ADDRESS to equal the address of the `StartupWalletImpl`
* IMMUTABLE_SIGNER_CONTRACT_ADDRESS to equal the address of the `ImmutableSigner`
7 changes: 5 additions & 2 deletions scripts/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ export async function deployContract(
walletsOptions: WalletOptions,
contractName: string,
constructorArgs: Array<string | undefined>): Promise<Contract> {

const contractFactory: ContractFactory = await newContractFactory(walletsOptions.getWallet(), contractName);
const contract: Contract = await contractFactory.connect(walletsOptions.getWallet()).deploy(...constructorArgs);
const contract: Contract = await contractFactory.connect(walletsOptions.getWallet()).deploy(...constructorArgs, {
gasLimit: 30000000,
maxFeePerGas: 10000000000,
maxPriorityFeePerGas: 10000000000,
});
console.log(`[${env.network}] Deployed ${contractName} to ${contract.address}`);
return contract;
}
6 changes: 6 additions & 0 deletions scripts/deployment_artefacts/devnet_deploy/step1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"multiCallAdminPubKey": "0x575be326c482a487add43974e0eaf232e3366e13",
"factoryAdminPubKey": "0xddb70ddcd14dbd57ae18ec591f47454e4fc818bb",
"multiCallDeploy": "0x307d214799D3B1625D1eC70F83d170d5fd0ee5A1",
"factory": "0x8Fa5088dF65855E0DaF87FA6591659893b24871d"
}
4 changes: 4 additions & 0 deletions scripts/deployment_artefacts/devnet_deploy/step2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"walletImplLocatorAdmin": "0xb49c99a17776c10350c2be790e13d4d8dfb1c578",
"latestWalletImplLocator": "0x1E1bB567c106B7D52710b3cD9553F84061355904"
}
4 changes: 4 additions & 0 deletions scripts/deployment_artefacts/devnet_deploy/step3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"walletImplLocatorAddress": "0x1E1bB567c106B7D52710b3cD9553F84061355904",
"startupWalletImpl": "0x8FD900677aabcbB368e0a27566cCd0C7435F1926"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/devnet_deploy/step4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"factoryAddress": "0x8Fa5088dF65855E0DaF87FA6591659893b24871d",
"startupWalletImplAddress": "0x8FD900677aabcbB368e0a27566cCd0C7435F1926",
"mainModuleDynamicAuth": "0x9e9Ee944fEB02F4D05B02950ca118027D2Db3cF2"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/devnet_deploy/step5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"signerRootAdminPubKey": "0x65af83f71a05d7f6d06ef9a57c9294b4128ccc2c",
"signerAdminPubKey": "0x69d09644159e7327dbfd0af9a66f8e332c593e79",
"immutableSigner": "0xcff469E561D9dCe5B1185CD2AC1Fa961F8fbDe61"
}
6 changes: 6 additions & 0 deletions scripts/deployment_artefacts/hardhdat_deploy/step1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"multiCallAdminPubKey": "0x575be326c482a487add43974e0eaf232e3366e13",
"factoryAdminPubKey": "0xddb70ddcd14dbd57ae18ec591f47454e4fc818bb",
"multiCallDeploy": "0x307d214799D3B1625D1eC70F83d170d5fd0ee5A1",
"factory": "0x8Fa5088dF65855E0DaF87FA6591659893b24871d"
}
4 changes: 4 additions & 0 deletions scripts/deployment_artefacts/hardhdat_deploy/step2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"walletImplLocatorAdmin": "0xb49c99a17776c10350c2be790e13d4d8dfb1c578",
"latestWalletImplLocator": "0x36d1c7aB8856aB2E8262fb9789c673EFBCE33f57"
}
4 changes: 4 additions & 0 deletions scripts/deployment_artefacts/hardhdat_deploy/step3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"walletImplLocatorAddress": "0x36d1c7aB8856aB2E8262fb9789c673EFBCE33f57",
"startupWalletImpl": "0x8FD900677aabcbB368e0a27566cCd0C7435F1926"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/hardhdat_deploy/step4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"factoryAddress": "0x8Fa5088dF65855E0DaF87FA6591659893b24871d",
"startupWalletImplAddress": "0x8FD900677aabcbB368e0a27566cCd0C7435F1926",
"mainModuleDynamicAuth": "0x1Af03254dc160616F7bFFBDe55Bb26799eF2b51C"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/hardhdat_deploy/step5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"signerRootAdminPubKey": "0x65af83f71a05d7f6d06ef9a57c9294b4128ccc2c",
"signerAdminPubKey": "0x69d09644159e7327dbfd0af9a66f8e332c593e79",
"immutableSigner": "0xcff469E561D9dCe5B1185CD2AC1Fa961F8fbDe61"
}
6 changes: 6 additions & 0 deletions scripts/deployment_artefacts/testnet_deploy/step1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"multiCallAdminPubKey": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"factoryAdminPubKey": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"multiCallDeploy": "0x307d214799D3B1625D1eC70F83d170d5fd0ee5A1",
"factory": "0x8Fa5088dF65855E0DaF87FA6591659893b24871d"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/testnet_deploy/step2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"walletImplLocatorAdmin": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"walletImplChangerAdmin": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"latestWalletImplLocator": "0xDF3d36188b561F621B0aA993eA89FB95d3761356"
}
4 changes: 4 additions & 0 deletions scripts/deployment_artefacts/testnet_deploy/step3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"walletImplLocatorAddress": "0xDF3d36188b561F621B0aA993eA89FB95d3761356",
"startupWalletImpl": "0x8FD900677aabcbB368e0a27566cCd0C7435F1926"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/testnet_deploy/step4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"factoryAddress": "0x8Fa5088dF65855E0DaF87FA6591659893b24871d",
"startupWalletImplAddress": "0x8FD900677aabcbB368e0a27566cCd0C7435F1926",
"mainModuleDynamicAuth": "0x0649E0E24d498B0DF987c4AAa18E95D9879e9fcF"
}
6 changes: 6 additions & 0 deletions scripts/deployment_artefacts/testnet_deploy/step5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"signerRootAdminPubKey": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"signerAdminPubKey": "0x3aF5DE2846aB3195BCD7b8880483E63D21261c49",
"signerAddress": "0x1cE50560686b1297B6311F36B47dbe5d6E04D0f8",
"immutableSigner": "0xcff469E561D9dCe5B1185CD2AC1Fa961F8fbDe61"
}
8 changes: 6 additions & 2 deletions scripts/step1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import { waitForInput } from './helper-functions';
async function step1(): Promise<EnvironmentInfo> {
const env = loadEnvironmentInfo(hre.network.name);
const { network, submitterAddress, signerAddress, } = env;
const multiCallAdminPubKey = '0x575be326c482a487add43974e0eaf232e3366e13';
const factoryAdminPubKey = '0xddb70ddcd14dbd57ae18ec591f47454e4fc818bb';
// const multiCallAdminPubKey = '0x575be326c482a487add43974e0eaf232e3366e13';
// const factoryAdminPubKey = '0xddb70ddcd14dbd57ae18ec591f47454e4fc818bb';
const multiCallAdminPubKey = process.env.MULTICALL_ADMIN_PUB_KEY;
const factoryAdminPubKey = process.env.FACTORY_ADMIN_PUB_KEY;

console.log(`[${network}] Starting deployment...`);
console.log(`[${network}] Submitter address ${submitterAddress}`);
Expand All @@ -38,6 +40,8 @@ async function step1(): Promise<EnvironmentInfo> {
const factory = await deployContract(env, wallets, 'Factory', [factoryAdminPubKey, multiCallDeploy.address]);

fs.writeFileSync('step1.json', JSON.stringify({
multiCallAdminPubKey: multiCallAdminPubKey,
factoryAdminPubKey: factoryAdminPubKey,
multiCallDeploy: multiCallDeploy.address,
factory: factory.address,
}, null, 1));
Expand Down
18 changes: 10 additions & 8 deletions scripts/step2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,30 @@ import { waitForInput } from './helper-functions';
async function step2(): Promise<EnvironmentInfo> {
const env = loadEnvironmentInfo(hre.network.name);
const { network, deployerContractAddress } = env;
// Administration accounts
// Is this correct for Mainnet?
// const walletImplLocatorAdmin = '0xb49c99a17776c10350c2be790e13d4d8dfb1c578';
const walletImplLocatorAdmin = process.env.WALLET_IMPL_LOCATOR_ADMIN;
const walletImplChangerAdmin = process.env.WALLET_IMPL_CHANGER_ADMIN;

console.log(`[${network}] Starting deployment...`);
console.log(`[${network}] CREATE2 Factory address ${deployerContractAddress}`);
console.log(`[${network}] Wallet ImplLocator Admin address ${walletImplLocatorAdmin}`);
console.log(`[${network}] Wallet ImplLocator Changer address ${walletImplChangerAdmin}`);

await waitForInput();

// Administration accounts
// Is this correct for Mainnet?
let walletImplLocatorAdmin = '0xb49c99a17776c10350c2be790e13d4d8dfb1c578';

// Setup wallet
const wallets: WalletOptions = await newWalletOptions(env);
console.log(
`[${network}] Wallet Impl Locator Changer Address: ${await wallets.getWalletImplLocatorChanger().getAddress()}`
);

// --- Step 2: Deployed using CREATE2 Factory
const latestWalletImplLocator = await deployContractViaCREATE2(env, wallets, 'LatestWalletImplLocator', [
walletImplLocatorAdmin, await wallets.getWalletImplLocatorChanger().getAddress()
walletImplLocatorAdmin, walletImplChangerAdmin
]);

fs.writeFileSync('step2.json', JSON.stringify({
walletImplLocatorAdmin: walletImplLocatorAdmin,
walletImplChangerAdmin: walletImplChangerAdmin,
latestWalletImplLocator: latestWalletImplLocator.address,
}, null, 1));

Expand Down
3 changes: 2 additions & 1 deletion scripts/step3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { waitForInput } from './helper-functions';
async function step3(): Promise<EnvironmentInfo> {
const env = loadEnvironmentInfo(hre.network.name);
const { network } = env;
const walletImplLocatorAddress = '<CHANGE_ME>';
const walletImplLocatorAddress = '0xDF3d36188b561F621B0aA993eA89FB95d3761356';

console.log(`[${network}] Starting deployment...`);
console.log(`[${network}] WalletImplLocator address ${walletImplLocatorAddress}`);
Expand All @@ -26,6 +26,7 @@ async function step3(): Promise<EnvironmentInfo> {
const startupWalletImpl = await deployContract(env, wallets, 'StartupWalletImpl', [walletImplLocatorAddress]);

fs.writeFileSync('step3.json', JSON.stringify({
walletImplLocatorAddress: walletImplLocatorAddress,
startupWalletImpl: startupWalletImpl.address,
}, null, 1));

Expand Down
11 changes: 4 additions & 7 deletions scripts/step4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { deployContractViaCREATE2 } from './contract';
async function step4(): Promise<EnvironmentInfo> {
const env = loadEnvironmentInfo(hre.network.name);
const { network } = env;
const factoryAddress = '<CHANGE_ME>';
const startupWalletImplAddress = '<CHANGE_ME>';
const factoryAddress = '0x8Fa5088dF65855E0DaF87FA6591659893b24871d';
const startupWalletImplAddress = '0x8FD900677aabcbB368e0a27566cCd0C7435F1926';

console.log(`[${network}] Starting deployment...`);
console.log(`[${network}] Factory address ${factoryAddress}`);
Expand All @@ -23,16 +23,13 @@ async function step4(): Promise<EnvironmentInfo> {
// Setup wallet
const wallets: WalletOptions = await newWalletOptions(env);

// Addresses that need to be pre-determined
// 1. Factory
// 2. StartupWalletImpl
// 3. SignerContract

// --- Step 4: Deployed using CREATE2 Factory.
// Deploy main module dynamic auth (CFC)
const mainModuleDynamicAuth = await deployContractViaCREATE2(env, wallets, 'MainModuleDynamicAuth', [factoryAddress, startupWalletImplAddress]);

fs.writeFileSync('step4.json', JSON.stringify({
factoryAddress: factoryAddress,
startupWalletImplAddress: startupWalletImplAddress,
mainModuleDynamicAuth: mainModuleDynamicAuth.address,
}, null, 1));

Expand Down
11 changes: 8 additions & 3 deletions scripts/step5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import { waitForInput } from './helper-functions';
**/
async function step5(): Promise<EnvironmentInfo> {
const env = loadEnvironmentInfo(hre.network.name);
const { network, submitterAddress, signerAddress, } = env;
const signerRootAdminPubKey = '0x65af83f71a05d7f6d06ef9a57c9294b4128ccc2c';
const signerAdminPubKey = '0x69d09644159e7327dbfd0af9a66f8e332c593e79';
const { network, signerAddress, } = env;
// const signerRootAdminPubKey = '0x65af83f71a05d7f6d06ef9a57c9294b4128ccc2c';
// const signerAdminPubKey = '0x69d09644159e7327dbfd0af9a66f8e332c593e79';
const signerRootAdminPubKey = process.env.SIGNER_ROOT_ADMIN_PUB_KEY;
const signerAdminPubKey = process.env.SIGNER_ADMIN_PUB_KEY;

console.log(`[${network}] Starting deployment...`);
console.log(`[${network}] SignerRootAdmin address ${signerRootAdminPubKey}`);
Expand All @@ -29,6 +31,9 @@ async function step5(): Promise<EnvironmentInfo> {
const immutableSigner = await deployContract(env, wallets, 'ImmutableSigner', [signerRootAdminPubKey, signerAdminPubKey, signerAddress]);

fs.writeFileSync('step5.json', JSON.stringify({
signerRootAdminPubKey: signerRootAdminPubKey,
signerAdminPubKey: signerAdminPubKey,
signerAddress: signerAddress,
immutableSigner: immutableSigner.address,
}, null, 1));

Expand Down
Loading

0 comments on commit 6d39448

Please sign in to comment.