Skip to content

Commit af32f47

Browse files
authored
[CHAIN-1729]: Clean up templates (#405)
* chore: remove unused templates * chore(templates): refactor templates * chore(templates): progress * chore(templates): progress upgrade-fault-proofs * chore(templates): refactor upgrade-fault-proofs commands * chore(templates): minor changes * chore(templates): cleanup * chore(templates): add _postCheck * chore(templates): update root README.md
1 parent 8cd4e71 commit af32f47

35 files changed

+228
-716
lines changed

Makefile

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
PROJECT_DIR = $(network)/$(shell date +'%Y-%m-%d')-$(task)
2-
DEPLOY_DIR = $(network)/$(shell date +'%Y-%m-%d')-deploy
3-
INCIDENT_DIR = $(network)/$(shell date +'%Y-%m-%d')-$(incident)
42
GAS_INCREASE_DIR = $(network)/$(shell date +'%Y-%m-%d')-increase-gas-limit
53
FAULT_PROOF_UPGRADE_DIR = $(network)/$(shell date +'%Y-%m-%d')-upgrade-fault-proofs
64
SAFE_MANAGEMENT_DIR = $(network)/$(shell date +'%Y-%m-%d')-safe-swap-owner
75
FUNDING_DIR = $(network)/$(shell date +'%Y-%m-%d')-funding
86

97
TEMPLATE_GENERIC = setup-templates/template-generic
10-
TEMPLATE_DEPLOY = setup-templates/template-deploy
11-
TEMPLATE_INCIDENT = setup-templates/template-incident
128
TEMPLATE_GAS_INCREASE = setup-templates/template-gas-increase
139
TEMPLATE_UPGRADE_FAULT_PROOFS = setup-templates/template-upgrade-fault-proofs
1410
TEMPLATE_SAFE_MANAGEMENT = setup-templates/template-safe-management
@@ -32,16 +28,6 @@ setup-task:
3228
rm -rf $(TEMPLATE_GENERIC)/cache $(TEMPLATE_GENERIC)/lib $(TEMPLATE_GENERIC)/out
3329
cp -r $(TEMPLATE_GENERIC) $(PROJECT_DIR)
3430

35-
# Run `make setup-deploy network=<network>`
36-
setup-deploy:
37-
rm -rf $(TEMPLATE_DEPLOY)/cache $(TEMPLATE_DEPLOY)/lib $(TEMPLATE_DEPLOY)/out
38-
mkdir -p $(network) && cp -r $(TEMPLATE_DEPLOY) $(DEPLOY_DIR)
39-
40-
# Run `make setup-incident network=<network> incident=<incident-name>`
41-
setup-incident:
42-
rm -rf $(TEMPLATE_INCIDENT)/cache $(TEMPLATE_INCIDENT)/lib $(TEMPLATE_INCIDENT)/out
43-
mkdir -p $(network) && cp -r $(TEMPLATE_INCIDENT) $(INCIDENT_DIR)
44-
4531
# Run `make setup-gas-increase network=<network>`
4632
setup-gas-increase:
4733
rm -rf $(TEMPLATE_GAS_INCREASE)/cache $(TEMPLATE_GAS_INCREASE)/lib $(TEMPLATE_GAS_INCREASE)/out

Multisig.mk

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# ---------- Common fragments ----------
2+
3+
LEDGER_HD_PATH = "m/44'/60'/$(LEDGER_ACCOUNT)'/0/0"
4+
5+
empty :=
6+
space := $(empty) $(empty)
7+
comma := ,
8+
9+
# Join a whitespace-separated list with ", " and normalize whitespace
10+
comma_join = $(subst $(space),$(comma) ,$(strip $(foreach w,$(1),$(w))))
11+
12+
# Validation helper for required variables
13+
require_vars = $(foreach _var,$(2),$(if $(strip $($(_var))),,$(error $(1): required variable $(_var) is not defined)))
14+
15+
# ---------- Procedures ----------
16+
17+
# MULTISIG_SIGN: $(1)=address list (space-separated)
18+
define MULTISIG_SIGN
19+
$(call require_vars,MULTISIG_SIGN,LEDGER_ACCOUNT RPC_URL SCRIPT_NAME)
20+
$(GOPATH)/bin/eip712sign --ledger --hd-paths $(LEDGER_HD_PATH) -- \
21+
forge script --rpc-url $(RPC_URL) $(SCRIPT_NAME) \
22+
--sig "sign(address[])" "[$(call comma_join,$(1))]"
23+
endef
24+
25+
# MULTISIG_APPROVE: $(1)=address list (space-separated), $(2)=signatures (e.g., 0x or $(SIGNATURES))
26+
define MULTISIG_APPROVE
27+
$(call require_vars,MULTISIG_APPROVE,LEDGER_ACCOUNT RPC_URL SCRIPT_NAME)
28+
forge script --rpc-url $(RPC_URL) $(SCRIPT_NAME) \
29+
--sig "approve(address[],bytes)" "[$(call comma_join,$(1))]" $(2) \
30+
--ledger --hd-paths $(LEDGER_HD_PATH) --broadcast -vvvv
31+
endef
32+
33+
# MULTISIG_EXECUTE: $(1)=signatures for run(bytes) (e.g., 0x or $(SIGNATURES))
34+
define MULTISIG_EXECUTE
35+
$(call require_vars,MULTISIG_EXECUTE,LEDGER_ACCOUNT RPC_URL SCRIPT_NAME)
36+
forge script --rpc-url $(RPC_URL) $(SCRIPT_NAME) \
37+
--sig "run(bytes)" $(1) \
38+
--ledger --hd-paths $(LEDGER_HD_PATH) --broadcast -vvvv
39+
endef

README.md

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ First, install forge if you don't have it already:
3535

3636
To execute a new task, run one of the following commands (depending on the type of change you're making):
3737

38-
- For incident response commands: `make setup-incident network=<network> incident=<incident-name>`
39-
- For gas increase commands: `make setup-gas-increase network=<network>`
40-
- For full new deployment (of L1 contracts related to Base): `make setup-deploy network=<network>`
38+
- For a generic task: `make setup-task network=<network> task=<task-name>`
39+
- For gas increase tasks: `make setup-gas-increase network=<network>`
40+
- For funding: `make setup-funding network=<network>`
4141
- For fault proof upgrade: `make setup-upgrade-fault-proofs network=<network>`
42-
- For contract calls, upgrades, or one-off contract deployments: `make setup-task network=<network> task=<task-name>`
42+
- For safe management tasks: `make setup-safe-management network=<network>`
43+
- For funding tasks: `make setup-funding network=<network>`
4344

4445
Next, `cd` into the directory that was created for you and follow the steps listed below for the relevant template.
4546

@@ -75,18 +76,14 @@ To add new incident response scripts:
7576
1. Add the relevant make commands that would need to be run for the script to the template Makefile
7677
1. Add relevant mainnet addresses in comments to increase efficiency responding to an incident.
7778

78-
## Using the deploy template
79+
## Using the generic template
7980

80-
This template is used for deploying the L1 contracts in the OP stack to set up a new network.
81+
This template can be used to do contract calls, upgrades, or one-off deployments.
8182

82-
1. Ensure you have followed the instructions above in `setup`
83-
1. Rename the folder to something more descriptive
8483
1. Specify the commit of [Optimism code](https://github.com/ethereum-optimism/optimism) and [Base contracts code](https://github.com/base-org/contracts) you intend to use in the `.env` file
8584
1. Run `make deps`
86-
1. Fill in the `inputs/deploy-config.json` and `inputs/misc-config.json` files with the input variables for the deployment.
87-
1. See the example `make deploy` command. Modifications may need to be made if you're using a key for deployment that you do not have the private key for (e.g. a hardware wallet)
88-
1. Run `make deploy` command
89-
1. Check in files to GitHub. The files to ignore should already have been specified in the `.gitignore`, so you should be able to check in everything.
85+
1. Put scripts in the `script` directory (see examples that are part of the template, for example, there is a file `BasicScript.s.sol`). See note below if running a task that requires a multisig to sign.
86+
1. Call scripts from the Makefile (see examples in the template Makefile that's copied over).
9087

9188
## Using the gas limit increase template
9289

@@ -108,9 +105,7 @@ This template is used to upgrade the fault proof contracts. This is commonly don
108105
1. Run `make deps`
109106
1. Add the new absolute prestate to the `.env` file. This can be found in the op-program prestates [releases.json](https://github.com/ethereum-optimism/superchain-registry/blob/main/validation/standard/standard-prestates.toml) file.
110107
1. NOTE: If this task is for mainnet, the directory should work as-is. If this task is for testnet, you will need to follow the following steps:
111-
1. Update the `UpgradeDGF` script to inherit `MultisigBuilder` instead of `NestedMultisigBuilder`
112108
1. Comment out the mainnet environment variables and uncomment the testnet vars in `.env`
113-
1. Comment out the nested multisig builder commands in the Makefile and uncomment the multisig builder commands
114109
1. Build the contracts with `forge build`
115110
1. Remove the unneeded validations from `VALIDATION.md` and update the relevant validations accordingly
116111
1. Check in the task when it's ready to sign and collect signatures from signers
@@ -145,13 +140,4 @@ This template is used to fund addresses from a Gnosis Safe.
145140
1. Check in the task when it's ready to sign and request the facilitators to collect signatures from signers.
146141
1. Once executed, check in the records files and mark the task `DONE` in the README.
147142

148-
## Using the generic template
149-
150-
This template can be used to do contract calls, upgrades, or one-off deployments.
151-
152-
1. Specify the commit of [Optimism code](https://github.com/ethereum-optimism/optimism) and [Base contracts code](https://github.com/base-org/contracts) you intend to use in the `.env` file
153-
1. Run `make deps`
154-
1. Put scripts in the `scripts` directory (see examples that are part of the template, for example, there is a file `TransferOwner.s.sol`, which can be used to set up the ownership transfer task). See note below if running a task that requires a multisig to sign.
155-
1. Call scripts from the Makefile (see examples in the template Makefile that's copied over).
156143

157-
Note: If using a multisig as a signer, you can leverage the `MultisigBuilder` for standard multisigs or the `NestedMultisigBuilder` scripts in the [base contracts repo](https://github.com/base-org/contracts/tree/main/script/universal) for multisigs that contain other multisigs as signers. For these scripts, you need to implement the virtual functions that are provided, which will allow you to configure the task you'd like to run, the address of the multisig you're running it from, and any post-execution checks. See the files themselves for more details. It is recommended to add any configured addresses as constants at the top of the file and provide links to Etherscan, etc., as needed for reviewers to more accurately review the PR.

setup-templates/template-deploy/.env

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup-templates/template-deploy/Makefile

Lines changed: 0 additions & 13 deletions
This file was deleted.

setup-templates/template-deploy/deployed/addresses.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup-templates/template-deploy/foundry.toml

Lines changed: 0 additions & 20 deletions
This file was deleted.

setup-templates/template-deploy/inputs/construct-config.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

setup-templates/template-deploy/inputs/deploy-config.json

Whitespace-only changes.

setup-templates/template-deploy/inputs/misc-config.json

Whitespace-only changes.

0 commit comments

Comments
 (0)