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

Feat/smr 2372 #64

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# /prod/imx-evm-relayer/EOA_SUBMITTER
RELAYER_SUBMITTER_EOA_PUB_KEY=0x4bb20797f395Fa9a5eF02A5CB92256B4327F63Ce
# /prod/imx-evm-relayer/IMMUTABLE_SIGNER_CONTRACT
IMMUTABLE_SIGNER_PUB_KEY=0x71639470D21D69456D6e98e7Cc877ABA671ab7fA
# Public key of primary Relayer submitter
RELAYER_SUBMITTER_EOA_PUB_KEY=<CHANGE_ME>
# Public key of the Immutable signer loaded from SM
IMMUTABLE_SIGNER_PUB_KEY=<CHANGE_ME>

# Change this to match the address of the CREATE2 contract factory
DEPLOYER_CONTRACT_ADDRESS=<CHANGE_ME>
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ scripts/*_output*.json

# Ignore any environmental files with sensitive data
.env
.env.l1dev
.env.localhost
.env.devnet
.env.testnet
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.17.0
12 changes: 12 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,26 @@ const config: HardhatUserConfig = {
url: 'https://rpc.dev.immutable.com',
accounts: []
},
l1devnet: {
url: 'https://rpc.ankr.com/eth_holesky',
accounts: []
},
testnet: {
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
48 changes: 34 additions & 14 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,64 +41,84 @@ in the `contract.ts` file.

## Step 5

Create a `.env` file. Use the `env.example` as a template.
Create a `.env` file. Use the `env.example` as a template. Set the following values in the `.env`

* Set the DEPLOYER_CONTRACT_ADDRESS to match the address of the OwnableCreate2Deployer factory.
* Set the MULTICALL_ADMIN_PUB_KEY and FACTORY_ADMIN_PUB_KEY to match the address of the address of the privileged transaction multisig. This address for reference should be `0x0E2D55943f4EF07c336C12A85d083c20FF189182`.

## 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 `accountIndex` to 10.
* 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>`

### `step2.ts`

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.
just uses the CREATE2 contract factory we use the standard deployment key (Orange 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>`

### `step3.ts`

In this step we deploy the startup wallet. This wallet address is used to generate the CFA, and hence like the Factory
uses a Passport nonce reserver key.
In this step we deploy the startup wallet. This wallet address is used to generate the CFA, and hence like the Factory uses a Passport nonce reserver key.

* Set the `accountIndex` to 10.
* WARNING: COPY the `LatestWalletImplLocator` address into the `step3.ts` script from step2.
* 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`

In this step we deploy the `MainModuleDynamicAuth` module, and it can simply use the standard deployment key.
In this step we deploy the `MainModuleDynamicAuth` module, and it should use the standard deployment key (Orange Key!!!)

* Set the `accountIndex` to 0.
* WARNING: COPY the `FactoryAddress` address into the `step4.ts` script from step1.
* WARNING: COPY the `StartupWalletImpl` address into the `step4.ts` script from step3.
* 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`

In this step we deploy the Signer contract, which is also used to generate the CFA, and hence like the Factory, and
Startup wallet implementation, we use the Passport nonce reserver key in this step.
Startup wallet implementation, we use the Passport nonce reserver key (Black Key!!!) in this step.

* Set the `accountIndex` to 10.
* Set the SIGNER_ROOT_ADMIN_PUB_KEY to the Privileged public key.
* Set the SIGNER_ADMIN_PUB_KEY to the relevant Breakglass public key.
* Set the IMMUTABLE_SIGNER_PUB_KEY
* Execute the command `npx hardhat run scripts/step5.ts --network <ENV>`

### `step6.ts`

In this step we point the `LatestWalletImplLocator` to the `MainModuleDynamicAuth` module address. In this step
we use the privileged deployment key, as we gave this key authority to alter the implementation address in `step2.ts`
we use the privileged deployment key (Purple Key!!!), as we gave this key authority to alter the implementation address in `step2.ts`.
above.

* Set the `accountIndex` to 10.
* WARNING: COPY the `MainModuleDynamicAuth` address into the `step6.ts` script from step4.
* WARNING: COPY the `LatestWalletImplLocator` address into the `step6.ts` script from step2.
* 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

Expand Down
12 changes: 6 additions & 6 deletions scripts/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const getSaltFromKey = (): string => {
};

/**
* Load the OwnableCreate2Deployer
* Load the OwnableCreate2Deployer
*/
const loadDeployerContract = async (env: EnvironmentInfo, walletOptions: WalletOptions): Promise<Contract> => {
return new Contract(env.deployerContractAddress, ContractDeployerInterface.abi, walletOptions.getWallet());
Expand All @@ -39,8 +39,8 @@ export async function deployContractViaCREATE2(

// Deploy the contract
let tx = await deployer.deploy(bytecode, salt, {
gasLimit: 30000000,
maxFeePerGas: 10000000000,
gasLimit: 10_000_000,
maxFeePerGas: 40000000000,
Comment on lines +42 to +43

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to check these again for the Sepolia deployment

maxPriorityFeePerGas: 10000000000,
});
await tx.wait();
Expand All @@ -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
6 changes: 6 additions & 0 deletions scripts/deployment_artefacts/l1devnet_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/l1devnet_deploy/step2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"walletImplLocatorAdmin": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"walletImplChangerAdmin": "0x0E2D55943f4EF07c336C12A85d083c20FF189182",
"latestWalletImplLocator": "0x889b5e1B25351AB543bf6D81bFD0777EA02EC879"
}
4 changes: 4 additions & 0 deletions scripts/deployment_artefacts/l1devnet_deploy/step3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"walletImplLocatorAddress": "0x889b5e1B25351AB543bf6D81bFD0777EA02EC879",
"startupWalletImpl": "0x8FD900677aabcbB368e0a27566cCd0C7435F1926"
}
5 changes: 5 additions & 0 deletions scripts/deployment_artefacts/l1devnet_deploy/step4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"factoryAddress": "0x8Fa5088dF65855E0DaF87FA6591659893b24871d",
"startupWalletImplAddress": "0x8FD900677aabcbB368e0a27566cCd0C7435F1926",
"mainModuleDynamicAuth": "0x9e9Ee944fEB02F4D05B02950ca118027D2Db3cF2"
}
6 changes: 6 additions & 0 deletions scripts/deployment_artefacts/l1devnet_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/l1devnet_deploy/step6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"mainModuleDynamicAuth": "0x9e9Ee944fEB02F4D05B02950ca118027D2Db3cF2",
"walletImplLocatorContractAddress": "0x889b5e1B25351AB543bf6D81bFD0777EA02EC879",
"signerAddress": "0x1cE50560686b1297B6311F36B47dbe5d6E04D0f8"
}
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);
});

2 changes: 2 additions & 0 deletions scripts/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface EnvironmentInfo {
deployerContractAddress: string;
network: string;
multiCallDeployContractAddress: string;
multiCallAdminPK: string;
}

/**
Expand All @@ -27,5 +28,6 @@ export function loadEnvironmentInfo(hreNetworkName: string): EnvironmentInfo {
deployerContractAddress: process.env.DEPLOYER_CONTRACT_ADDRESS || '',
network: hreNetworkName,
multiCallDeployContractAddress: process.env.MULTICALLDEPLOY_CONTRACT_ADDRESS || '',
multiCallAdminPK: process.env.MULTICALL_ADMIN_PK || '',
};
}
Loading
Loading