Skip to content

Commit 4294cc2

Browse files
feat: Add EP0.7 audited MSCA contracts testnet deployment logs and update scripts (#6)
## Summary Update deployment scripts and add deployment logs for audited MSCA EP0.7 contracts. ### Checklist - [ ] Did you add new tests and confirm all tests pass? (`yarn test`) - [x] Did you update relevant docs? (docs are found in the `docs` folder) - [ ] Do your commits follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard? - [x] Does your PR title also follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard? - [ ] If you have a breaking change, is it [correctly reflected in your commit message](https://www.conventionalcommits.org/en/v1.0.0/#examples)? (e.g. `feat!: breaking change`) - [x] Did you run lint (`yarn lint`) and fix any issues? - [x] Did you run formatter (`yarn format:check`) and fix any issues (`yarn format:write`)? ## Testing All the script changes were tested locally in the process of deploying the new contracts. Any edits made during the PR review process were tested by simulating the script and verifying that there were no errors. I tested the `cast send` commands on a local networks and verified that contracts were deployed at the same addresses as those deployed using the `forge script` command.
1 parent 01ece52 commit 4294cc2

File tree

67 files changed

+2710
-341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2710
-341
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
########### General settings with defaults ###########
2-
ENTRY_POINT=0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789
32
VERIFYING_SIGNER=0xf...6
43
PAYMASTER_OWNER=0x7...C
54
RPC_URL=http://127.0.0.1:8545
65

76

87
########### Wallet info & secrets ###########
98
MSCA_FACTORY_OWNER_PRIVATE_KEY=0x9...2
9+
MSCA_FACTORY_OWNER_ADDRESS=0x0...5
1010
DEPLOYER_PRIVATE_KEY=0x8...6
1111
DEPLOYER_ADDRESS=0xB...E
1212

README.md

Lines changed: 86 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,38 @@ This repository includes support for both the Hardhat and Foundry frameworks. Go
55
- `src/account/v1`
66
- `src/paymaster/v1/permissioned`
77

8-
## Prerequisites
9-
- Run `git submodule update --init --recursive` to update/download all libraries.
10-
- Run `yarn install` to install any additional dependencies.
11-
- Create a `.env` file and provide the required API keys, wallets (can be generated for deployment), and configuration values. You can look at the `.env.example` for reference.
8+
## Setup
9+
1. Run `git submodule update --init --recursive` to update/download all libraries.
10+
2. Run `yarn install` to install any additional dependencies.
11+
3. Run `curl -L https://foundry.paradigm.xyz | bash` and follow the outputted instructions to source env file.
12+
4. Run `foundryup`
13+
5. Create a `.env` file and provide the required API keys, wallets (can be generated for deployment), and configuration values. You can look at the `.env.example` for reference.
1214

13-
## Install Foundry CLI
14-
- Run `curl -L https://foundry.paradigm.xyz | bash`
15-
- Follow the instructions of that command to source env file and then run `foundryup`
15+
## Development
1616

17-
## Test
17+
### Lint
18+
Run `yarn lint` to lint all `.sol` files in the `src` and `test` directories.
19+
20+
### Test
1821
To run tests using Foundry, follow the steps below:
1922
1. Run `yarn build`
2023
2. Run `yarn test`
2124

22-
## Test Coverage
25+
### Test Coverage
2326
To generate a viewable test coverage report, run:
2427
- `brew install lcov` if not yet installed
2528
- `forge coverage --ir-minimum --report lcov && genhtml lcov.info -o report --branch-coverage && open report/index.html`
2629
(Note: some contracts like WeightedMultisigPlugin require using --ir-minimum because of stack depth. To build coverage
2730
faster locally, comment out this and dependent contracts and omit --ir-minimum flag.)
2831

32+
33+
### Continuous Integration
34+
We use Github actions to run linter and all the tests. The workflow configuration can be found in [.github/workflows/ci.yml](.github/workflows/ci.yml)
35+
36+
37+
### Release
38+
We are using [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) structure to automatically generate releases.
39+
2940
## Export Interface
3041
To export contract bytecode & ABI for programmable wallet:
3142
1. Execute `forge build src/msca/6900/v0.7 --force --extra-output-files abi evm`. Replace v0.7 with v0.8 if you want v0.8.
@@ -36,10 +47,7 @@ To export contract bytecode & ABI for programmable wallet:
3647

3748
For running integration tests in Anvil node, run `make anvil-tests`. This runs the python tests in [test/anvil](test/anvil/)
3849

39-
### Linting
40-
Run `yarn lint` to lint all `.sol` files in the `src` and `test` directories.
41-
42-
### Gas report
50+
## Gas Report
4351
### Function report
4452
* Run `yarn build`
4553
* Run `yarn gasreport`
@@ -54,85 +62,98 @@ Run `yarn lint` to lint all `.sol` files in the `src` and `test` directories.
5462

5563
* `cast code $address`
5664

57-
## Deployment
58-
### Deployment Metadata
59-
#### ECDSAAccountFactory
60-
The ECDSAAcountFactory deployment is based on abi and bytecode to ensure the same address across all EVM-compatible chains. The abi and bytecode is:
61-
* stored in `deploy/metadata/ECDSAAccountFactory.json`.
62-
* generated from the first deployment and remove all other fields except `abi` and `bytecode`.
63-
#### SponsorPaymaster_Implementation
64-
The SponsorPaymaster_Implementation deployment is based on abi and bytecode to ensure the same address across all EVM-compatible chains. The abi and bytecode is:
65-
* stored in `deploy/metadata/SponsorPaymaster_Implementation.json`.
66-
* generated from the first deployment and remove all other fields except `abi` and `bytecode`.
67-
#### SponsorPaymaster_Proxy
68-
The SponsorPaymaster_Proxy deployment is based on abi and bytecode to ensure the same address across all EVM-compatible chains. The abi and bytecode is:
69-
* stored in `deploy/metadata/SponsorPaymaster_Proxy.json`.
70-
* generated from the first deployment and remove all other fields except `abi` and `bytecode`.
71-
### Local
72-
#### Start a local node
65+
## On-chain Deployment & Verification
66+
67+
### Start a Local Network (optional, for testing)
68+
7369
`npx hardhat node` (if using hardhat stack)
7470

7571
`make anvil` (if using foundry stack). To get a list of pre-funded addresses, you can look at the beginning of the logs in the `anvil` Docker container, or reference <https://github.com/foundry-rs/foundry/blob/0d8302880b79fa9c3c4aa52ab446583dece19a34/crates/anvil/README.md?plain=1#L48>.
7672

77-
#### Deploy & verify smart contract
78-
* SCA and Paymaster
79-
* Deployment
80-
* Mumbai - `env $(grep -v '^#' .env) yarn hardhat deploy --network mumbai`
81-
* Goerli - `env $(grep -v '^#' .env) yarn hardhat deploy --network goerli`
82-
83-
If you only want to deploy a specific set of smart contracts, you can run
84-
`env $(grep -v '^#' .env) yarn harthat deploy --tags tagName --network networkName`,
85-
for example, `env $(grep -v '^#' .env) yarn hardhat deploy --tags SponsorPaymaster --network goerli`
86-
* Verification
87-
* ECDSA wallet factory `env $(grep -v '^#' .env) npx hardhat verify --network mumbai --constructor-args script/ecdsa_account_factory_constructor_args.js ECDSA_ACCOUNT_FACTORY_ADDRESS`
88-
* Sponsor paymaster `env $(grep -v '^#' .env) npx hardhat verify --network goerli --constructor-args script/sponsor_paymaster_constructor_args.js STABLECOIN_PAYMASTER_ADDRESS`
89-
* Fallback: If the verification commands do not work for contracts deployed through the hardhat deployment scripts, you can still verify manually through etherscan's UI by submitting the standard input json. You can find this file under `deployments/polygon/solcInputs` (you can try different blockchain but I'm unsure of results). Then submit the file that you think is the one for the contract your trying to verify. It's a bit of guessing, but you can look at the source code to try and figure it out. You may also need to verify the proxies manually through etherscan after having verified the implementation.
90-
* MSCA
91-
* Deployment & Verification
92-
1. Set up `DEPLOYER_PRIVATE_KEY`, `RPC_URL` and `ETHERSCAN_API_KEY` in .env
93-
2. Run `source .env`
94-
3. Run the desired numbered scripts inside the `script/` folder using the below command format:
73+
### Deploy & Verify
74+
#### SCA and Paymaster
75+
1. Deployment
76+
* Run the command `env $(grep -v '^#' .env) yarn hardhat deploy --network <chain>` where `<chain>` is one of {`mumbai`, `goerli`}.
77+
78+
If you only want to deploy a specific set of smart contracts, you can add the `--tags` flag, for example: `env $(grep -v '^#' .env) yarn hardhat deploy --tags SponsorPaymaster --network goerli`
79+
2. Verification
80+
* ECDSA wallet factory `env $(grep -v '^#' .env) npx hardhat verify --network mumbai --constructor-args script/ecdsa_account_factory_constructor_args.js ECDSA_ACCOUNT_FACTORY_ADDRESS`
81+
* Sponsor paymaster `env $(grep -v '^#' .env) npx hardhat verify --network goerli --constructor-args script/sponsor_paymaster_constructor_args.js STABLECOIN_PAYMASTER_ADDRESS`
82+
* Fallback: If the verification commands do not work for contracts deployed through the hardhat deployment scripts, you can still verify manually through etherscan's UI by submitting the standard input json.
83+
84+
You can find this file under `deployments/polygon/solcInputs` (you can try different blockchain but I'm unsure of results). Then submit the file that you think is the one for the contract your trying to verify. It's a bit of guessing, but you can look at the source code to try and figure it out. You may also need to verify the proxies manually through etherscan after having verified the implementation.
85+
#### MSCA
86+
1. Set up `DEPLOYER_PRIVATE_KEY`, `RPC_URL` and `ETHERSCAN_API_KEY` in .env
87+
2. Run `source .env`
88+
3. Run the desired numbered scripts inside the `script/` folder using the below command format. Make sure any environment variable values from previous steps are updated if needed as you progress through the scripts.
9589
* `forge script script/<SCRIPT_NAME> --rpc-url $RPC_URL --broadcast --verify -vvvv`
9690

9791
Example: `forge script script/001_DeployPluginManager.s.sol --rpc-url $RPC_URL --broadcast --verify -vvvv`
92+
93+
Tip: before executing the above command, verify the simulation works as expected by running the above command without the `--broadcast` and `--verify` flags. This way, you can also make sure your address will have enough tokens to cover the transaction fee estimated in the simulation.
94+
95+
Note: if you are deploying on a local network, don't use the `--verify` flag.
9896

99-
4. Include the relevant logs from the `broadcast` folder in your commit.
97+
4. Include the relevant logs from the `broadcast` folder in your commit.
10098

101-
Tip: if you did multiple runs, search the appropriate block explorer for the tx hash corresponding the desired contract's deployment, and then search the logs for the transaction hash.
99+
Tip: if you did multiple runs, search the appropriate block explorer for the tx hash corresponding the desired contract's deployment, and then search the logs for the transaction hash.
102100

103-
Tip: logs are organized by chain ID in the lower levels in the `broadcast` folder. Use <https://chainlist.org/> to lookup IDs of common chains.
101+
Tip: logs are organized by chain ID in the lower levels in the `broadcast` folder. Use <https://chainlist.org/> to lookup IDs of common chains.
104102

105-
5. Create or update the corresponding file in the `script/cmd` folder using the creation bytecode of the contract from the logs. See the below "Chain Expansion" section for details on how to format of the files in the `script/cmd` folder.
106-
6. Verify in block explorer like etherscan using standard input json
107-
* forge verify-contract `contract_address` `relative_path_to_source:classname` --show-standard-json-input > `script/verify/<filename>`
108-
* eg. `forge verify-contract 0x03431fb00fb2e26b5bc502dfef8da30e1c8643b8 src/msca/6900/v0.7/plugins/v1_0_0/utility/DefaultTokenCallbackPlugin.sol:DefaultTokenCallbackPlugin --show-standard-json-input > script/verify/80002_run-1725650624_DefaultTokenCallbackPlugin.json`
103+
5. Create or update the corresponding file in the `script/cmd` folder using the creation bytecode of the contract from the logs. See the below "Chain Expansion" section for details on how to format of the files in the `script/cmd` folder.
104+
6. Verify in block explorer like etherscan using standard input json
105+
* Create the standard input json: run the beoow command
106+
107+
```shell
108+
forge verify-contract <contract_address> <relative_path_to_source:classname> --show-standard-json-input > <script/verify/<filename>
109+
110+
# Example
111+
forge verify-contract 0x03431fb00fb2e26b5bc502dfef8da30e1c8643b8 src/msca/6900/v0.7/plugins/v1_0_0/utility/DefaultTokenCallbackPlugin.sol:DefaultTokenCallbackPlugin --show-standard-json-input > script/verify/DefaultTokenCallbackPlugin.json
112+
```
109113
* Verify and publish in block explorer (etherscan example)
110114
* Compiler type: `Solidity (Standard-Json-Input)`
111115
* Compiler version: `v0.8.24`
112-
* License: MIT
116+
* License: Option 5 in https://etherscan.io/contract-license-types
113117
* Upload the JSON file
118+
* If the contract you are verifying took constructor arguments, input the output of the below command with the `0x` prefix removed into the "Constructor Arguments ABI-encoded" section:
119+
120+
```shell
121+
cast abi-encode "constructor(<arg type 1>, <arg type 2>, ...)" "arg1Val" "arg2Val"
122+
123+
# Example
124+
cast abi-encode "constructor(address,address,uint256)" "0x0166EA90E565476f13c6a0D25ED2C35599E58785" "0x0000000071727De22E5E9d8BAf0edAc6f37da032" 18
125+
```
114126
* Click verify and publish
115127

128+
### Deployment Metadata
129+
130+
The below contract deployment are based on abi and bytecode to ensure the same address across all EVM-compatible chains. The abi and bytecode for each of the contracts is available at the below locations. These files were generated from first deployments, will all fields except `abi` and `bytecode` removed.
131+
132+
| Contract Name | Location |
133+
|:------------------------:|:------------------------:|
134+
| ECDSAAcountFactory | `deploy/metadata/ECDSAAccountFactory.json` |
135+
| SponsorPaymaster_Implementation | `deploy/metadata/SponsorPaymaster_Implementation.json` |
136+
| SponsorPaymaster_Proxy | `deploy/metadata/SponsorPaymaster_Proxy.json` |
137+
116138
### Chain Expansion
117-
#### SingleOwnerMSCAFactory deployment
118-
Run the command in script/cmd/SingleOwnerMSCAFactory
119-
#### UpgradeableMSCAFactory deployment
120-
Run the command in script/cmd/UpgradeableMSCAFactory
121-
#### Any contracts already deployed by scripts in script/*
139+
140+
To ensure consistent deployment of contracts across chains, we store the `cast send` deployment commands for contracts in the `script/cmd` folder. To deploy these contracts, simply run the command inside the file corresponding to that contract on the command line.
141+
142+
To build the `cast send` deployment command for a contract:
143+
1. Run the Solidity deployment script for the contract in the `script/*` folder:
122144
1. Find the deployment result in broadcast/*
123145
2. Looking for “transactions” -> ”transaction” → “data” in run-*.json
124146
3. Copy the "data" in step 2 without "0x" prefix.
125147
4. Add `cast send --rpc-url $RPC_URL --private-key $DEPLOYER_PRIVATE_KEY 0x4e59b44847b379578588920cA78FbF26c0B4956C 0x0000000000000000000000000000000000000000000000000000000000000000` in front of the bytecode from previous step (no space)
148+
149+
Refer to the note after these steps, you may not need the `0x0...` prefix. The `0x4e59b44847b379578588920cA78FbF26c0B4956C` is foundry's default create2 address deployer. See <https://book.getfoundry.sh/reference/cast/cast-create2>.
126150
5. Run the command in step5 in Terminal.
127-
6. Save this command to script/cmd folder with `<chain_id>_<run-timestamp>_<script_name>`
151+
6. Save this command to script/cmd folder with `<script_name>`
128152
7. Create the README under `broadcast` folder for the chain id. For example, see `broadcast/011_DeployTokenCallbackPlugin.s.sol/11155111/README.md`
129153

130154
Note: The "data" field may be called "input". Additionally, if the input/data field already contains the leading `0000000000000000000000000000000000000000000000000000000000000000` prefix, simply copy this value over directly (no need to re-add the zeros prefix).
131155

132-
## Continuous Integration using Github Actions
133-
We use Github actions to run linter and all the tests. The workflow configuration can be found in [.github/workflows/ci.yml](.github/workflows/ci.yml)
134-
135-
## Trouble-shooting
156+
## Troubleshooting
136157
#### 1. `make: *** [test] Error 137`
137158

138159
If you encountered this error after executing `make test`, try increasing memory resource for docker engine.
@@ -149,6 +170,3 @@ When deploying contract deployment scripts from the `/script` folder on a local
149170
#### 5. failed to read artifact source file for ...
150171

151172
Run `forge clean && forge build`.
152-
153-
## Release
154-
We are using [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) structure to automatically generate releases.

broadcast/001_DeployPluginManager.s.sol/11155111/run-1727353464.json

Lines changed: 47 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/001_DeployPluginManager.s.sol/11155111/run-latest.json

Lines changed: 21 additions & 23 deletions
Large diffs are not rendered by default.

broadcast/001_DeployPluginManager.s.sol/421614/run-1727373504.json

Lines changed: 49 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/001_DeployPluginManager.s.sol/421614/run-latest.json

Lines changed: 49 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/001_DeployPluginManager.s.sol/80002/run-1727290658.json

Lines changed: 64 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/001_DeployPluginManager.s.sol/80002/run-latest.json

Lines changed: 28 additions & 30 deletions
Large diffs are not rendered by default.

broadcast/002_DeployUpgradableMSCAFactory.s.sol/11155111/run-1727353929.json

Lines changed: 90 additions & 0 deletions
Large diffs are not rendered by default.

broadcast/002_DeployUpgradableMSCAFactory.s.sol/11155111/run-latest.json

Lines changed: 43 additions & 68 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)