You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## 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.
Copy file name to clipboardExpand all lines: README.md
+86-68Lines changed: 86 additions & 68 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,27 +5,38 @@ This repository includes support for both the Hardhat and Foundry frameworks. Go
5
5
-`src/account/v1`
6
6
-`src/paymaster/v1/permissioned`
7
7
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.
12
14
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
16
16
17
-
## Test
17
+
### Lint
18
+
Run `yarn lint` to lint all `.sol` files in the `src` and `test` directories.
19
+
20
+
### Test
18
21
To run tests using Foundry, follow the steps below:
(Note: some contracts like WeightedMultisigPlugin require using --ir-minimum because of stack depth. To build coverage
27
30
faster locally, comment out this and dependent contracts and omit --ir-minimum flag.)
28
31
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
+
29
40
## Export Interface
30
41
To export contract bytecode & ABI for programmable wallet:
31
42
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:
36
47
37
48
For running integration tests in Anvil node, run `make anvil-tests`. This runs the python tests in [test/anvil](test/anvil/)
38
49
39
-
### Linting
40
-
Run `yarn lint` to lint all `.sol` files in the `src` and `test` directories.
41
-
42
-
### Gas report
50
+
## Gas Report
43
51
### Function report
44
52
* Run `yarn build`
45
53
* Run `yarn gasreport`
@@ -54,85 +62,98 @@ Run `yarn lint` to lint all `.sol` files in the `src` and `test` directories.
54
62
55
63
*`cast code $address`
56
64
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
+
73
69
`npx hardhat node` (if using hardhat stack)
74
70
75
71
`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>.
* 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`
* 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.
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.
98
96
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.
100
98
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.
102
100
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.
104
102
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
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
* Verify and publish in block explorer (etherscan example)
110
114
* Compiler type: `Solidity (Standard-Json-Input)`
111
115
* Compiler version: `v0.8.24`
112
-
* License: MIT
116
+
* License: Option 5 in https://etherscan.io/contract-license-types
113
117
* 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"
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.
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:
122
144
1. Find the deployment result in broadcast/*
123
145
2. Looking for “transactions” -> ”transaction” → “data” in run-*.json
124
146
3. Copy the "data" in step 2 without "0x" prefix.
125
147
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>.
126
150
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>`
128
152
7. Create the README under `broadcast` folder for the chain id. For example, see `broadcast/011_DeployTokenCallbackPlugin.s.sol/11155111/README.md`
129
153
130
154
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).
131
155
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
136
157
#### 1. `make: *** [test] Error 137`
137
158
138
159
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
149
170
#### 5. failed to read artifact source file for ...
150
171
151
172
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.
0 commit comments