Skip to content

Commit

Permalink
Added hardhat config for L1 testnet and mainnet Alchemy as a provider
Browse files Browse the repository at this point in the history
Fixing a mistake

Quick undo

Latest changes for L1 mainnet deploy

L1testnet run details

Added a dummy transfer script

A minor tidy up of step 0 and step 1

Further fixes to the deployment README

Added a step0.ts
  • Loading branch information
shirren committed Nov 18, 2024
1 parent 12f1ef2 commit 7072634
Show file tree
Hide file tree
Showing 22 changed files with 199 additions and 21 deletions.
8 changes: 8 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,18 @@ const config: HardhatUserConfig = {
url: 'https://rpc.testnet.immutable.com',
accounts: []
},
l1testnet: {
url: 'https://eth-sepolia.g.alchemy.com/v2/<CHANGE_ME>',
accounts: []
},
mainnet: {
url: 'https://rpc.immutable.com',
accounts: []
},
l1mainnet: {
url: 'https://eth-mainnet.g.alchemy.com/v2/<CHANGE_ME>',
accounts: []
},
},
mocha: {
timeout: process.env.COVERAGE ? 15 * 60 * 1000 : 30 * 1000
Expand Down
17 changes: 15 additions & 2 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,26 @@ Create a `.env` file. Use the `env.example` as a template. Set the following val

## Execution steps

### `step0.ts`

In this step we deploy the `MultiCallDeploy` only. We use the standard deployment key (Orange key) for this deployment, as the address of the MultiCallDeploy strictly does
not need to be the same across all the environments.

* Set the value of RELAYER_SUBMITTER_EOA_PUB_KEY to match the EOA of the primary Relayer submitter. The Submitter EOA is granted execute permission on the MultiCallDeploy.
* Set the value of MULTICALL_ADMIN_PUB_KEY
* Set the `accountIndex` to 0 in `wallet-options.ts`.
* Execute the command `npx hardhat run scripts/step0.ts --network <ENV>`

### `step1.ts`

In this step we deploy the `MultiCallDeploy`, and the `Factory` contracts. We use the Passport Nonce reserver
In this step we deploy the `Factory` contract. We use the Passport Nonce reserver
in this step because we want the `Factory` contract to have the same address across all our chains, as
this address is used to produce a deterministic counter factual address for the smart contract wallets across
all the chains.

* Set the value of RELAYER_SUBMITTER_EOA_PUB_KEY to match the EOA of the primary Relayer submitter.
* Set the value of the FACTORY_ADMIN_PUB_KEY to the privileged mulstisig pub key (Purple ledger)
* Set the value of `multiCallDeployAddress` to match the address of the contract deployed in Step0.
* Set the `accountIndex` to 10 in `wallet-options.ts`.
* Execute the command `npx hardhat run scripts/step1.ts --network <ENV>`

Expand All @@ -64,7 +76,8 @@ all the chains.
In this step we deploy the contract that tracks the location of the latest wallet implementation. As this step
just uses the CREATE2 contract factory we use the standard deployment key (Orange Key!!!).

* Set the value of WALLET_IMPL_LOCATOR_ADMIN, and WALLET_IMPL_CHANGER_ADMIN environment variables to the public key of the Priveleged key.
* Set the value of DEPLOYER_CONTRACT_ADDRESS to the address of the CREATE2 factory contract.
* Set the value of WALLET_IMPL_LOCATOR_ADMIN, and WALLET_IMPL_CHANGER_ADMIN environment variables to the public key of the Privileged key.
* Set the `accountIndex` to 0.
* Execute the command `npx hardhat run scripts/step2.ts --network <ENV>`

Expand Down
6 changes: 3 additions & 3 deletions scripts/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export async function deployContract(
constructorArgs: Array<string | undefined>): Promise<Contract> {
const contractFactory: ContractFactory = await newContractFactory(walletsOptions.getWallet(), contractName);
const contract: Contract = await contractFactory.connect(walletsOptions.getWallet()).deploy(...constructorArgs, {
gasLimit: 30000000,
maxFeePerGas: 10000000000,
maxPriorityFeePerGas: 10000000000,
gasLimit: 100000,
maxFeePerGas: 30000000000,
maxPriorityFeePerGas: 1000000000,
});
console.log(`[${env.network}] Deployed ${contractName} to ${contract.address}`);
return contract;
Expand Down
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/l1mainnet_deploy/step0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"multiCallAdminPubKey": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"multiCallDeploy": "0x9129211efEcAf4A1cD76104f5A4082220a783078",
"submitterAddress": "0xa45a81EA5AE3ad978C176A6E54e41Df1cff4DF3a"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/l1mainnet_deploy/step1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"factoryAdminPubKey": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"multiCallDeploy": "0x9129211efEcAf4A1cD76104f5A4082220a783078",
"factory": "0x8Fa5088dF65855E0DaF87FA6591659893b24871d"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/l1mainnet_deploy/step2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"walletImplLocatorAdmin": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"walletImplChangerAdmin": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"latestWalletImplLocator": "0xDB4b8F9D2C0C731A345a405b6335b3750d197b6C"
}
4 changes: 4 additions & 0 deletions scripts/deployment_artefacts/l1mainnet_deploy/step3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"walletImplLocatorAddress": "0xDB4b8F9D2C0C731A345a405b6335b3750d197b6C",
"startupWalletImpl": "0x8FD900677aabcbB368e0a27566cCd0C7435F1926"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/l1mainnet_deploy/step4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"factoryAddress": "0x8Fa5088dF65855E0DaF87FA6591659893b24871d",
"startupWalletImplAddress": "0x8FD900677aabcbB368e0a27566cCd0C7435F1926",
"mainModuleDynamicAuth": "0xC2d54E4D795469f8616612CC343af078A892F36F"
}
6 changes: 6 additions & 0 deletions scripts/deployment_artefacts/l1mainnet_deploy/step5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"signerRootAdminPubKey": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"signerAdminPubKey": "0x3aF5DE2846aB3195BCD7b8880483E63D21261c49",
"signerAddress": "0x71639470D21D69456D6e98e7Cc877ABA671ab7fA",
"immutableSigner": "0xcff469E561D9dCe5B1185CD2AC1Fa961F8fbDe61"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/l1mainnet_deploy/step6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"mainModuleDynamicAuth": "0xC2d54E4D795469f8616612CC343af078A892F36F",
"walletImplLocatorContractAddress": "0xDB4b8F9D2C0C731A345a405b6335b3750d197b6C",
"signerAddress": "0x71639470D21D69456D6e98e7Cc877ABA671ab7fA"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/l1testnet_deploy/step0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"multiCallAdminPubKey": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"multiCallDeploy": "0x0039Ae5ae1Dc345508b859d40903dDBA0C36Fc90",
"submitterAddress": "0x92fdaB84b46D49A5f999425c06D31A40C7d9E386"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/l1testnet_deploy/step1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"factoryAdminPubKey": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"multiCallDeploy": "0x0039Ae5ae1Dc345508b859d40903dDBA0C36Fc90",
"factory": "0x8Fa5088dF65855E0DaF87FA6591659893b24871d"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/l1testnet_deploy/step2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"walletImplLocatorAdmin": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"walletImplChangerAdmin": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"latestWalletImplLocator": "0xDB4b8F9D2C0C731A345a405b6335b3750d197b6C"
}
4 changes: 4 additions & 0 deletions scripts/deployment_artefacts/l1testnet_deploy/step3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"walletImplLocatorAddress": "0xDB4b8F9D2C0C731A345a405b6335b3750d197b6C",
"startupWalletImpl": "0x8FD900677aabcbB368e0a27566cCd0C7435F1926"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/l1testnet_deploy/step4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"factoryAddress": "0x8Fa5088dF65855E0DaF87FA6591659893b24871d",
"startupWalletImplAddress": "0x8FD900677aabcbB368e0a27566cCd0C7435F1926",
"mainModuleDynamicAuth": "0xC2d54E4D795469f8616612CC343af078A892F36F"
}
6 changes: 6 additions & 0 deletions scripts/deployment_artefacts/l1testnet_deploy/step5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"signerRootAdminPubKey": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"signerAdminPubKey": "0xB3533118Ff0f823fAF916AC499bB2a3E9054A698",
"signerAddress": "0x1cE50560686b1297B6311F36B47dbe5d6E04D0f8",
"immutableSigner": "0xcff469E561D9dCe5B1185CD2AC1Fa961F8fbDe61"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/l1testnet_deploy/step6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"mainModuleDynamicAuth": "0xC2d54E4D795469f8616612CC343af078A892F36F",
"walletImplLocatorContractAddress": "0xDB4b8F9D2C0C731A345a405b6335b3750d197b6C",
"signerAddress": "0x1cE50560686b1297B6311F36B47dbe5d6E04D0f8"
}
41 changes: 41 additions & 0 deletions scripts/dummy-transfer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as hre from 'hardhat';
import { EnvironmentInfo, loadEnvironmentInfo } from './environment';
import { newWalletOptions, WalletOptions } from './wallet-options';
import { waitForInput } from './helper-functions';

async function dummyTransfer(): Promise<EnvironmentInfo> {
const env = loadEnvironmentInfo(hre.network.name);
const { network } = env;

console.log(`[${network}] Consuming nonce, PROCEED WITH CARE!...`);

await waitForInput();

// Setup wallet
const wallets: WalletOptions = await newWalletOptions(env);
const signer = wallets.getWallet();
const signerAddress = await signer.getAddress();

console.log(`[${env.network}] Starting a 0 value transfer from ${signerAddress} to ${signerAddress}`);

const tx = await signer.sendTransaction({
to: signerAddress,
value: 0,
})
await tx.wait();
console.log(`[${env.network}] Transfer completed with hash ${tx.hash}`);

return env;
}

// Call primary function
dummyTransfer()
.then((env: EnvironmentInfo) => {
console.log(`[${env.network}] Transfer successful...`);
process.exit(0);
})
.catch(err => {
console.error(err.message);
process.exit(1);
});

51 changes: 51 additions & 0 deletions scripts/step0.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import * as fs from 'fs';
import * as hre from 'hardhat';
import { EnvironmentInfo, loadEnvironmentInfo } from './environment';
import { newWalletOptions, WalletOptions } from './wallet-options';
import { deployContract } from './contract';
import { waitForInput } from './helper-functions';

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

/**
* Step 0.
**/
async function step0(): Promise<EnvironmentInfo> {
const env = loadEnvironmentInfo(hre.network.name);
const { network, submitterAddress } = env;
const multiCallAdminPubKey = process.env.MULTICALL_ADMIN_PUB_KEY;

console.log(`[${network}] Starting deployment...`);
console.log(`[${network}] Submitter address ${submitterAddress}`);
console.log(`[${network}] multiCallAdminPubKey ${multiCallAdminPubKey}`);

await waitForInput();

// Setup wallet
const wallets: WalletOptions = await newWalletOptions(env);

// --- STEP 0: Deployed using deployer key (Orange Key)
const multiCallDeploy = await deployContract(env, wallets, 'MultiCallDeploy', [multiCallAdminPubKey, submitterAddress]);

fs.writeFileSync('step0.json', JSON.stringify({
multiCallAdminPubKey: multiCallAdminPubKey,
multiCallDeploy: multiCallDeploy.address,
submitterAddress: submitterAddress,
}, null, 1));

return env;
}

// Call primary function
step0()
.then((env: EnvironmentInfo) => {
console.log(`[${env.network}] Contracts deployment successful...`);
process.exit(0);
})
.catch(err => {
console.error(err.message);
process.exit(1);
});
15 changes: 5 additions & 10 deletions scripts/step1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,26 @@ import { waitForInput } from './helper-functions';
**/
async function step1(): Promise<EnvironmentInfo> {
const env = loadEnvironmentInfo(hre.network.name);
const { network, submitterAddress } = env;
const multiCallAdminPubKey = process.env.MULTICALL_ADMIN_PUB_KEY;
const { network } = env;
const factoryAdminPubKey = process.env.FACTORY_ADMIN_PUB_KEY;
const multiCallDeployAddress = '0x9129211efEcAf4A1cD76104f5A4082220a783078';

console.log(`[${network}] Starting deployment...`);
console.log(`[${network}] Submitter address ${submitterAddress}`);
console.log(`[${network}] multiCallAdminPubKey ${multiCallAdminPubKey}`);
console.log(`[${network}] factoryAdminPubKey ${factoryAdminPubKey}`);
console.log(`[${network}] multiCallDeployAddress ${multiCallDeployAddress}`);

await waitForInput();

// Setup wallet
const wallets: WalletOptions = await newWalletOptions(env);

// --- STEP 1: Deployed using Passport Nonce Reserver.
// Deploy multi call deploy (PNR)
const multiCallDeploy = await deployContract(env, wallets, 'MultiCallDeploy', [multiCallAdminPubKey, submitterAddress]);

// Deploy factory with multi call deploy address as deployer role EST (PNR)
const factory = await deployContract(env, wallets, 'Factory', [factoryAdminPubKey, multiCallDeploy.address]);
const factory = await deployContract(env, wallets, 'Factory', [factoryAdminPubKey, multiCallDeployAddress]);

fs.writeFileSync('step1.json', JSON.stringify({
multiCallAdminPubKey: multiCallAdminPubKey,
factoryAdminPubKey: factoryAdminPubKey,
multiCallDeploy: multiCallDeploy.address,
multiCallDeploy: multiCallDeployAddress,
factory: factory.address,
}, null, 1));

Expand Down
2 changes: 1 addition & 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 = '0x889b5e1B25351AB543bf6D81bFD0777EA02EC879';
const walletImplLocatorAddress = '0xDB4b8F9D2C0C731A345a405b6335b3750d197b6C';

console.log(`[${network}] Starting deployment...`);
console.log(`[${network}] WalletImplLocator address ${walletImplLocatorAddress}`);
Expand Down
10 changes: 5 additions & 5 deletions scripts/step6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { newWalletOptions, WalletOptions } from './wallet-options';
async function step6(): Promise<EnvironmentInfo> {
const env = loadEnvironmentInfo(hre.network.name);
const { network, signerAddress, } = env;
const mainModuleDynamicAuthAddress = '0x9e9Ee944fEB02F4D05B02950ca118027D2Db3cF2';
const walletImplLocatorContractAddress = '0x889b5e1B25351AB543bf6D81bFD0777EA02EC879';
const mainModuleDynamicAuthAddress = '0xC2d54E4D795469f8616612CC343af078A892F36F';
const walletImplLocatorContractAddress = '0xDB4b8F9D2C0C731A345a405b6335b3750d197b6C';

console.log(`[${network}] Starting deployment...`);
console.log(`[${network}] mainModuleDynamicAuth address ${mainModuleDynamicAuthAddress}`);
Expand All @@ -34,9 +34,9 @@ async function step6(): Promise<EnvironmentInfo> {
const tx = await walletImplLocator
.connect(wallets.getWallet())
.changeWalletImplementation(mainModuleDynamicAuthAddress, {
gasLimit: 10000000,
maxFeePerGas: 10000000000,
maxPriorityFeePerGas: 10000000000,
gasLimit: 1_000_000,
maxFeePerGas: 30000000000,
maxPriorityFeePerGas: 1000000000,
});
await tx.wait();
console.log(`[${network}] Wallet Impl Locator implementation changed to: ${mainModuleDynamicAuthAddress}`);
Expand Down

0 comments on commit 7072634

Please sign in to comment.