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

Deploy multisigs and make scripts compatible with Gnosis Safe #40

Open
wants to merge 10 commits into
base: master
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
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ MAINNET_RPC_URL="..."
BASE_SEPOLIA_RPC_URL="..."
BASE_RPC_URL="..."

# === Comment out the vars for the environments you are not deploying to! ===
# --- Local ---
# (from anvil)
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

# --- Devnet / Testnet ---
PRIVATE_KEY=0x1234...

# --- Mainnet ---
DEPLOYER_ADDR=0x0000...0000
# (Use a local keystore with `cast wallet import lpn_owner --interactive`)
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/forge-safe"]
path = lib/forge-safe
url = https://github.com/lagrange-labs/forge-safe
[submodule "lib/safe-smart-account"]
path = lib/safe-smart-account
url = https://github.com/safe-global/safe-smart-account
152 changes: 54 additions & 98 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,110 +3,66 @@
-include .env

VERBOSITY=-vvvv
# VERBOSITY=
LOCAL_DEPLOY_FLAGS=--broadcast ${VERBOSITY} --ffi --slow
DEPLOY_FLAGS=--verify ${LOCAL_DEPLOY_FLAGS}
MAINNET_DEPLOYER=--account v0_owner --sender ${DEPLOYER_ADDR}
DEPLOY_PROXY_FACTORY_CMD=forge script DeployERC1967ProxyFactory --rpc-url
DEPLOY_REGISTRY_CMD=forge script DeployLPNRegistryV1 --rpc-url
DEPLOY_REGISTRY_V0_CMD=forge script DeployLPNRegistryV0 --rpc-url
DEPLOY_CLIENTS_CMD=forge script DeployClients --rpc-url
DEPLOY_QUERY_CLIENT_CMD=forge script DeployLPNQueryV1 --rpc-url
DEPLOY_TEST_ERC20_CMD=forge script DeployTestERC20 --rpc-url
DEPLOY_ERC20_DISTRIBUTOR_CMD=forge script DeployERC20Distributor --rpc-url
DEPLOY_PENG_CMD=forge script DeployLayeredPenguins --rpc-url
QUERY_CMD=forge script Query --rpc-url
WITHDRAW_FEES_CMD=forge script WithdrawFees --rpc-url
BRIDGE_CMD=forge script Bridge --rpc-url
STAKE_CMD=forge script Stake --rpc-url
BASE_DEPLOY_FLAGS=--broadcast ${VERBOSITY} --ffi --slow
DEPLOY_FLAGS=--verify ${BASE_DEPLOY_FLAGS}
MAINNET_DEPLOYER=--account lpn_owner

# deps
install :; forge install
update :; forge update

# Build & test
build :; forge build
test :; forge test --fork-url sepolia
trace :; forge test -vvv
clean :; forge clean
snapshot :; forge snapshot
fmt :; forge fmt

# -- Integration Test ---
setup_integration_test : local_deploy_erc1967_proxy_factory local_deploy_registry local_deploy_clients

local_deploy_erc1967_proxy_factory :; ${DEPLOY_PROXY_FACTORY_CMD} local ${LOCAL_DEPLOY_FLAGS} --json
holesky_testnet_deploy_erc1967_proxy_factory :; ${DEPLOY_PROXY_FACTORY_CMD} holesky ${DEPLOY_FLAGS}
base_testnet_deploy_erc1967_proxy_factory :; ${DEPLOY_PROXY_FACTORY_CMD} base_sepolia ${DEPLOY_FLAGS}
fraxtal_testnet_deploy_erc1967_proxy_factory :; ${DEPLOY_PROXY_FACTORY_CMD} fraxtal_testnet ${DEPLOY_FLAGS}
fraxtal_mainnet_deploy_erc1967_proxy_factory :; ${DEPLOY_PROXY_FACTORY_CMD} fraxtal ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
mantle_mainnet_deploy_erc1967_proxy_factory :; ${DEPLOY_PROXY_FACTORY_CMD} mantle ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER} --with-gas-price 20000000 -g 4000000
# Define chains
CHAINS=local sepolia holesky mainnet base_sepolia base fraxtal_testnet fraxtal mantle_sepolia mantle polygon_zkevm

# -- Testnet Base Integration Test --
testnet_integration_test : testnet_deploy_registry base_testnet_deploy_registry testnet_deploy_clients base_testnet_deploy_clients base_testnet_query
fraxtal_testnet_integration_test : fraxtal_testnet_deploy_registry fraxtal_testnet_deploy_clients fraxtal_testnet_query
# Find all .s.sol files in the scripts directory and its subdirectories
SCRIPT_FILES := $(shell find ./script -name '*.s.sol' -type f)

# --- Deploy ---
# Deploy the registry
local_deploy_registry :; ${DEPLOY_REGISTRY_CMD} local ${LOCAL_DEPLOY_FLAGS} --json
testnet_deploy_registry :; ${DEPLOY_REGISTRY_CMD} sepolia ${DEPLOY_FLAGS} --priority-gas-price 0.1gwei
holesky_testnet_deploy_registry :; ${DEPLOY_REGISTRY_CMD} holesky ${DEPLOY_FLAGS} --legacy
mainnet_deploy_registry :; ${DEPLOY_REGISTRY_CMD} mainnet ${DEPLOY_FLAGS} --priority-gas-price 0.5gwei ${MAINNET_DEPLOYER}
mainnet_deploy_registry_v0 :; ${DEPLOY_REGISTRY_V0_CMD} mainnet ${DEPLOY_FLAGS} --priority-gas-price 0.5gwei ${MAINNET_DEPLOYER}
base_testnet_deploy_registry :; ${DEPLOY_REGISTRY_CMD} base_sepolia ${DEPLOY_FLAGS}
base_mainnet_deploy_registry :; ${DEPLOY_REGISTRY_CMD} base ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
fraxtal_testnet_deploy_registry :; ${DEPLOY_REGISTRY_CMD} fraxtal_testnet ${DEPLOY_FLAGS}
fraxtal_mainnet_deploy_registry :; ${DEPLOY_REGISTRY_CMD} fraxtal ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
mantle_testnet_deploy_registry :; ${DEPLOY_REGISTRY_CMD} mantle_sepolia ${DEPLOY_FLAGS} --with-gas-price 20000000 -g 4000000
mantle_mainnet_deploy_registry :; ${DEPLOY_REGISTRY_CMD} mantle ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER} --legacy -g 1000000
polygon_deploy_registry :; ${DEPLOY_REGISTRY_CMD} polygon_zkevm ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
# Extract script names without .s.sol extension to get the ContractName, e.g. DeployLPNRegistryV1
SCRIPT_NAMES := $(patsubst %.s.sol,%,$(notdir $(SCRIPT_FILES)))

# Deploy clients
local_deploy_clients :; ${DEPLOY_CLIENTS_CMD} local ${LOCAL_DEPLOY_FLAGS}
testnet_deploy_clients :; ${DEPLOY_CLIENTS_CMD} sepolia ${DEPLOY_FLAGS} --priority-gas-price 0.1gwei
holesky_deploy_clients :; ${DEPLOY_CLIENTS_CMD} holesky ${DEPLOY_FLAGS} --gas-estimate-multiplier 1000 # multiply estimate by 10
holesky_deploy_test_erc20 :; ${DEPLOY_TEST_ERC20_CMD} holesky ${DEPLOY_FLAGS} --gas-estimate-multiplier 1000 # --sender ${DEPLOYER_ADDR}
mainnet_deploy_clients :; ${DEPLOY_CLIENTS_CMD} mainnet ${DEPLOY_FLAGS} --priority-gas-price 0.5gwei --account v0_owner
base_testnet_deploy_clients :; ${DEPLOY_CLIENTS_CMD} base_sepolia ${DEPLOY_FLAGS}
base_mainnet_deploy_clients :; ${DEPLOY_CLIENTS_CMD} base ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
fraxtal_testnet_deploy_clients :; ${DEPLOY_CLIENTS_CMD} fraxtal_testnet ${DEPLOY_FLAGS}
fraxtal_mainnet_deploy_clients :; ${DEPLOY_CLIENTS_CMD} fraxtal ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
mantle_testnet_deploy_clients :; ${DEPLOY_CLIENTS_CMD} mantle_sepolia ${DEPLOY_FLAGS} --with-gas-price 20000000 -g 4000000
mantle_mainnet_deploy_clients :; ${DEPLOY_CLIENTS_CMD} mantle ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER} --with-gas-price 20000000 -g 4000000
polygon_mainnet_deploy_clients :; ${DEPLOY_CLIENTS_CMD} polygon_zkevm ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
# Function to get chain-specific flags
define get-chain-flags
$(if $(filter mantle% polygon_zkevm%,$(1)),--with-gas-price 20000000,\
$(if $(filter mainnet,$(1)),--priority-gas-price 0.5gwei,))
endef

# Deploy Query Clients
holesky_deploy_query_client :; ${DEPLOY_QUERY_CLIENT_CMD} holesky ${DEPLOY_FLAGS} --gas-estimate-multiplier 1000 # multiply estimate by 10
mainnet_deploy_query_client :; ${DEPLOY_QUERY_CLIENT_CMD} mainnet ${DEPLOY_FLAGS} --priority-gas-price 0.5gwei --account v0_owner
# Function to determine if MAINNET_DEPLOYER should be used
define use-mainnet-deployer
$(if $(or $(findstring local,$(1)),$(findstring sepolia,$(1)),$(findstring holesky,$(1)),$(findstring testnet,$(1))),,${MAINNET_DEPLOYER})
endef

# Deploy Examples
holesky_deploy_erc20_distributor :; ${DEPLOY_ERC20_DISTRIBUTOR_CMD} holesky ${DEPLOY_FLAGS} --gas-estimate-multiplier 1000 # multiply estimate by 10
mainnet_deploy_layered_penguins :; ${DEPLOY_PENG_CMD} mainnet ${DEPLOY_FLAGS} --priority-gas-price 0.5gwei --account v0_owner

# Run Queries
testnet_query :; ${QUERY_CMD} sepolia ${DEPLOY_FLAGS}
holesky_query :; ${QUERY_CMD} holesky ${DEPLOY_FLAGS}
base_testnet_query :; ${QUERY_CMD} base_sepolia ${DEPLOY_FLAGS}
fraxtal_testnet_query :; ${QUERY_CMD} fraxtal_testnet ${DEPLOY_FLAGS}
mainnet_query :; ${QUERY_CMD} mainnet ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
base_mainnet_query :; ${QUERY_CMD} base ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
fraxtal_mainnet_query :; ${QUERY_CMD} fraxtal ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
mantle_mainnet_query :; ${QUERY_CMD} mantle ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER} --with-gas-price 20000000 -g 4000000
polygon_mainnet_query :; ${QUERY_CMD} polygon_zkevm ${DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
# Generate rules for all scripts and chains
# e.g. DeployLPNRegistryV1_mainnet
define make-command-rule
$(1)_$(2): CHAIN_FLAGS = $(call get-chain-flags,$(2))
$(1)_$(2): DEPLOYER_FLAGS = $(call use-mainnet-deployer,$(2))
$(1)_$(2):
forge script $(1) --rpc-url $(2) $${DEPLOY_FLAGS} $${CHAIN_FLAGS} $${DEPLOYER_FLAGS} $(ARGS)
endef

# Withdraw fees
mainnet_withdraw_fees :; ${WITHDRAW_FEES_CMD} mainnet ${LOCAL_DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
base_withdraw_fees :; ${WITHDRAW_FEES_CMD} base ${LOCAL_DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
fraxtal_withdraw_fees :; ${WITHDRAW_FEES_CMD} fraxtal ${LOCAL_DEPLOY_FLAGS} ${MAINNET_DEPLOYER}
mantle_withdraw_fees :; ${WITHDRAW_FEES_CMD} mantle ${LOCAL_DEPLOY_FLAGS} ${MAINNET_DEPLOYER} --legacy -g 1000000
$(foreach chain,${CHAINS},$(foreach script,${SCRIPT_NAMES},$(eval $(call make-command-rule,${script},${chain}))))

# Bridge
mainnet_bridge_base :; ${BRIDGE_CMD} mainnet ${LOCAL_DEPLOY_FLAGS} --account v0_relayer --sender 0x373a4796Eb758a416366F561206E0472B508eCd1 --priority-gas-price 0.01gwei
holesky_bridge_fraxtal :; ${BRIDGE_CMD} holesky ${LOCAL_DEPLOY_FLAGS} --priority-gas-price 0.01gwei -vvvv

base_mainnet_deployment : base_mainnet_deploy_registry base_mainnet_deploy_clients

# Stake
holesky_stake :; ${STAKE_CMD} holesky ${LOCAL_DEPLOY_FLAGS} --priority-gas-price 0.01gwei -vvvv --skip-simulation

base_mainnet_deployment : base_mainnet_deploy_registry base_mainnet_deploy_clients
# Other non-generic rules
install :; forge install
update :; forge update
build :; forge build
test :; forge test --fork-url sepolia
trace :; forge test -vvv
clean :; forge clean
snapshot:; forge snapshot
fmt :; forge fmt

# List available scripts
list-scripts:
@echo "Available scripts:"
@for script in $(SCRIPT_NAMES); do echo " $$script"; done

.PHONY: $(CHAINS) $(SCRIPT_NAMES) list-scripts

# Default target to show usage
.DEFAULT_GOAL := usage

usage:
@echo "Usage: make <script_name>_<chain>"
@echo "Example: make DeployERC1967ProxyFactory_local"
@echo ""
@echo "Available chains: $(CHAINS)"
@echo ""
@echo "To see available scripts, run: make list-scripts"
48 changes: 33 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,45 @@ $ forge test -vvv
### Deployment
```bash
# Local development
$ make local_deploy_registry
$ make local_deploy_clients

# Deploy to Testnet
$ make holesky_deploy_registry
$ make holesky_deploy_clients

# Deploy to Mainnet
$ make mainnet_deploy_registry
$ make mainnet_deploy_clients
$ make DeployLPNRegistryV1_local
$ make DeployLPNQueryV1_local

# Deploy / Upgrade Testnet
$ make DeployLPNRegistryV1_holesky

# Deploy / Upgrade Mainnet
$ make DeployLPNRegistryV1_mainnet
$ make DeployLPNRegistryV1_base
$ make DeployLPNRegistryV1_fraxtal
$ make DeployLPNRegistryV1_mantle
$ make DeployLPNRegistryV1_polygon_zkevm
```

### Queries
```bash
# Run queries on different networks
$ make holesky_query
$ make Query_holesky

$ make Query_mainnet
$ make Query_base
$ make Query_fraxtal
$ make Query_mantle
```

### Multisig Admin Scripts
```bash
$ make DeployMultisig_base

$ make UpdateMultisigSigners_polygon_zkevm \
ARGS='--sig "run(address[],uint256)" "[0x1234...5678,0x5678...1234]" 2'

$ make WhitelistZKMR_mainnet
$ make WhitelistLSC_mainnet

$ make mainnet_query
$ make base_mainnet_query
$ make fraxtal_mainnet_query
$ make mantle_mainnet_query
$ make WithdrawFees_mainnet
$ make WithdrawFees_base
$ make WithdrawFees_mantle
$ make WithdrawFees_polygon_zkevm
```

## Key Features
Expand Down
30 changes: 30 additions & 0 deletions config/holesky-operators.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
"0xa337f1f29b0886fc4a5aa9c57abb0f73affa59f1",
"0xc3ba9dd24129fa0688adf866fc3db054ebb78dd7",
"0x479E1BB08aB4dF7632357C6e0f4eDd7ac0059Ea3",
"0xbb7fe0c234cd07e2440b515621ab31d263f76e1e",
"0xEC84951F01910EB716de5F16e4c1ee9A3482dF06",
"0xc511461589B3295F492fA594f55F7dC26Ef4E113",
"0xf98D5De1014110C65c51b85Ea55f73863215CC10",
"0xd216ccb2d95809957a3128824dddb136d90dfde7",
"0x758e016468e5e90cdb42e743881c2e921d8e7bf8",
"0x30b837c791caf71781db9637a276b2e9ec1daf63",
"0x7F9F584bf0BE617FDD0AA3f7400427b60E2C5d27",
"0x73bf91bb1327415ec7b9d436bfced67c3ee843fa",
"0x1392d82c6e22cC6E7d48Be93050F6f3EbEE5986d",
"0x06fb6c463cc68100355624b6006471a960704126",
"0x63A27Fd29a5385561991108e0cEFb288C627cC03",
"0x6c76a22052d5e8bbad9801bf1e413477843af698",
"0x48211415Fc3e48b1aC5389fdDD4c1755783F6199",
"0x5d0eb7efbae980582be4a121750addcfb7f6a186",
"0x08b9C489b6B0bEBf21e350e6067829b881854a24",
"0xBB5614CdA99012c473b0aAa22904a270d50A149a",
"0x4a3D6E0Ff640f2F0C1091878E6eD3bE7ED3F6665",
"0x37d5077434723d0ec21D894a52567cbE6Fb2C3D8",
"0x4Ed6b07Cb57e2898c77F67A8BB31ef1423216568",
"0xD2420290c96D55ee0dae47Ab3BAA590ead5B04E6",
"0xf4A13927d38aC7F2eAc201a3b43DD0418a7c2adb",
"0xC421e1216f99C838B0a426B1CD10C8E40030Ca5C",
"0x5f5B6C071855EB0dD2A2519CA18c1A6Af3025f80",
"0xfbd03AF3eaE1E44D729365670731d88F8a11033C"
]
Loading