Skip to content

Commit

Permalink
Merge pull request #61 from aragon/deploy/mode-upgrade-v2
Browse files Browse the repository at this point in the history
Deploy/mode upgrade v2
  • Loading branch information
jordaniza authored Feb 25, 2025
2 parents 3135c36 + f555d10 commit 653ee26
Show file tree
Hide file tree
Showing 74 changed files with 9,411 additions and 459 deletions.
39 changes: 15 additions & 24 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,45 +1,36 @@
# Fork Test mode:
# "fork-deploy" will run against the live network fork, deploying new contracts via a new instance of the factory
# "fork-existing" will run against the live network fork, using the existing factory & therefore the existing contracts
FORK_TEST_MODE="fork-deploy"
# NETWORK AND ACCOUNT(s)
DEPLOYMENT_PRIVATE_KEY="0x..."
REFUND_ADDRESS="0x..."

# With false, the script will deploy mock tokens with open mint functions
DEPLOY_AS_PRODUCTION=false
# The name of the networks to use for test/production
TESTNET_NETWORK="holesky"
PRODNET_NETWORK="mainnet"

# If deploying against a fork, pass the address of a large token holder who will be
# impersonated to distribute tokens to addresses inside test cases
# the whale should have >= 3000 tokens
TOKEN_TEST_WHALE="0x"

# If the factory singleton is deployed, pass the address. "Fork existing" mode will use this previously
# deployed factory, and "fork deploy" will deploy a new factory instance
FACTORY="0x0000000000000000000000000000000000000000"

# NETWORK AND DEPLOYMENT WALLET
DEPLOYMENT_PRIVATE_KEY="..."
NETWORK="sepolia"
# The RPC of the networks to use for test/production
TESTNET_RPC_URL="https://holesky.drpc.org"
PRODNET_RPC_URL="https://eth.drpc.org"

# API Keys (optional)
# Note that having these active will slow down unit tests even when not needed
# So recommended to only activate when needed
# ETHERSCAN_API_KEY="..."
# ALCHEMY_API_KEY="..."


# MULTISIG PARAMETERS
# define a list of multisig members - said multisig will be assigned administrator roles of the ve contracts
MULTISIG_MEMBERS_JSON_FILE_NAME="/script/multisig-members.json"
MIN_APPROVALS="1" # How many multisig approvals are required
MIN_APPROVALS="1" # How many multisig approvals are required
MULTISIG_PROPOSAL_EXPIRATION_PERIOD="864000" # How long until a pending proposal expires (10 days)

# GAUGE VOTER PARAMETERS
# The token to be used for the escrow
# The main token for the escrow and the escrow details
TOKEN1_ADDRESS="0x0000000000000000000000000000000000000000"
VE_TOKEN1_NAME="Voting Escrow Token 1"
VE_TOKEN1_SYMBOL="veTK1"

# Additional tokens these will have secondary escrow contracts
TOKEN2_ADDRESS="0x0000000000000000000000000000000000000000" # Ignored if 0x0
# Additional tokens (optional)
# Each token gets its own escrow
TOKEN2_ADDRESS="0x0000000000000000000000000000000000000000" # Ignored when zero
VE_TOKEN2_NAME="Voting Escrow Token 2"
VE_TOKEN2_SYMBOL="veTK2"

Expand All @@ -59,7 +50,7 @@ MIN_LOCK_DURATION="3600" # 1 hour
VOTING_PAUSED=true

# Initial minimum amount needed (in wei) to create a lock
MIN_DEPOSIT="1000000000000000000" # 1 ether
MIN_DEPOSIT="1000000000000000000" # 1 ether (in token terms)

# PLUGIN REPO PARAMETERS (per-network)
# SEPOLIA
Expand Down
14 changes: 14 additions & 0 deletions .env.test.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# If deploying against a fork, pass the address of a large token holder.
# This address will be impersonated to distribute tokens to addresses inside test cases.
# The whale needs to hold at least 3000 tokens
TEST_TOKEN_WHALE="0x0000000000000000000000000000000000000000"

# If you are testing with `make test-fork-factory-*`, you need to define the address of the
# existing factory to use. Otherwise, you should use `make test-fork-*`
FACTORY_ADDRESS="0x0000000000000000000000000000000000000000"

# The block number to run fork tests on
# If left empty, the live onchain state will be used, which may
# consume API calls or cause rate limits
FORK_TESTNET_BLOCK_NUMBER=2643743
FORK_PRODNET_BLOCK_NUMBER=
102 changes: 91 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,59 @@
name: CI
name: Tests

on:
push:
branches:
- "main"
- "develop"
- "deploy/**"
pull_request:
workflow_dispatch:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
test-unit:
strategy:
fail-fast: true

name: Foundry project
name: Test Unit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
submodules: true

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: foundry-toolchain
uses: foundry-rs/[email protected]

- name: Show Forge version
run: forge --version

- name: Run Forge build
run: |
forge build --sizes
id: build

- name: Run Forge tests
run: |
forge --version
forge test --match-path "test/**/unit/**/*.sol"
id: test

test-upgrade:
strategy:
fail-fast: true
name: Test Upgrade
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: foundry-toolchain
uses: foundry-rs/[email protected]

- name: Show Forge version
run: forge --version

- name: Run Forge build
run: |
Expand All @@ -36,5 +62,59 @@ jobs:

- name: Run Forge tests
run: |
forge test --no-match-path "test/fork/**/*.sol" -vvv
forge test --match-path "test/**/upgrade/**/*.sol" --force
id: test

test-fork:
strategy:
fail-fast: true
name: Test Fork
runs-on: ubuntu-latest
env:
NETWORK: "sepolia"
FORK_TEST_MODE: "new-factory"
DEPLOY_AS_PRODUCTION: false
TOKEN_TEST_WHALE: "0x"
FACTORY_ADDRESS: "0x"
MULTISIG_MEMBERS_JSON_FILE_NAME: "/script/multisig-members.json"
MIN_APPROVALS: 1
MULTISIG_PROPOSAL_EXPIRATION_PERIOD: "864000"
MINT_TEST_TOKENS: true
TOKEN1_ADDRESS: "0x0000000000000000000000000000000000000000"
VE_TOKEN1_NAME: "Voting Escrow Token 1"
VE_TOKEN1_SYMBOL: "veTK1"
TOKEN2_ADDRESS: "0x0000000000000000000000000000000000000000"
VE_TOKEN2_NAME: "Voting Escrow Token 2"
VE_TOKEN2_SYMBOL: "veTK2"
FEE_PERCENT: "0" # 10_000 = 100%
WARMUP_PERIOD: "259200" # 3 days
COOLDOWN_PERIOD: "259200" # 3 days
MIN_LOCK_DURATION: "1"
VOTING_PAUSED: true
MIN_DEPOSIT: "10000000000000000" # 0.01 ETH
MULTISIG_PLUGIN_REPO_ADDRESS: "0x9e7956C8758470dE159481e5DD0d08F8B59217A2"
MULTISIG_PLUGIN_RELEASE: "1"
MULTISIG_PLUGIN_BUILD: "2"
SIMPLE_GAUGE_VOTER_REPO_ENS_SUBDOMAIN: "gauge-voter-${{ vars.GITHUB_RUN_ID }}"
DAO_FACTORY: "0x7a62da7B56fB3bfCdF70E900787010Bc4c9Ca42e"
PLUGIN_SETUP_PROCESSOR: "0xC24188a73dc09aA7C721f96Ad8857B469C01dC9f"
PLUGIN_REPO_FACTORY: "0x07f49c49Ce2A99CF7C28F66673d406386BDD8Ff4"
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: foundry-toolchain
uses: foundry-rs/[email protected]

- name: Show Forge version
run: forge --version

- name: Run Forge build
run: |
forge build --sizes
id: build

- name: Run Forge tests
run: |
forge test --match-path "test/**/fork/**/*.sol" --rpc-url https://sepolia.drpc.org -vvv
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
^.env.example
.env*
!.env.example
!.env.test.example

# Logs
*.log

# Foundry
cache/
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ branch = v4.9.2
[submodule "lib/ens-contracts"]
path = lib/ens-contracts
url = https://github.com/ensdomains/ens-contracts
[submodule "lib/openzeppelin-foundry-upgrades"]
path = lib/openzeppelin-foundry-upgrades
url = https://github.com/Openzeppelin/openzeppelin-foundry-upgrades
107 changes: 72 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# include .env file and export its env vars
# (-include to ignore error if it does not exist)
-include .env
Expand All @@ -11,54 +10,94 @@ install :; make allow-scripts && forge build

# create an HTML coverage report in ./report (requires lcov & genhtml)
coverage:; ./coverage.sh
#

# run unit tests
test-unit :; forge test --no-match-path "test/fork/**/*.sol"
test-unit :; forge test --match-path "test/**/unit/**/*.sol"

# run unit tests for specific version
test-unit-100 :; forge test --match-path "test/v1_0_0/unit/**/*.sol"
test-unit-110 :; forge test --match-path "test/v1_1_0/unit/**/*.sol"

# regression and upgrade tests
test-upgrade-110 :; forge test --match-path "test/v1_1_0/upgrade/**/*.sol" --force

#### Fork testing ####

# Fork testing - mode sepolia
ft-mode-sepolia-fork :; forge test --match-contract TestE2EV2 \
--fork-block-number 19879000 \

ft-mode-sepolia-fork-100 :; forge test --match-contract TestE2E \
--rpc-url https://sepolia.mode.network \
-vv

ft-mode-sepolia-fork-110 :; forge test --match-contract TestE2EV1_1_0 \
--rpc-url https://sepolia.mode.network \
-vvvvv

# Fork testing - mode mainnet
ft-mode-fork :; forge test --match-contract TestE2EV2 \
ft-mode-fork-100 :; forge test --match-contract TestE2E \
--rpc-url https://mainnet.mode.network/ \
-vvvvv

# Fork testing - holesky
ft-holesky-fork :; forge test --match-contract TestE2EV2 \
--rpc-url https://holesky.drpc.org \
ft-mode-fork-110 :; forge test --match-contract TestE2EV1_1_0 \
--rpc-url https://mainnet.mode.network/ \
-vvvvv


## Upgrade testing
ft-mode-upgrade-fork :; forge test --match-contract UpgradeModeTo110 \
--rpc-url https://mainnet.mode.network/ \
--fork-block-number 18697900 \
-vvvv

# Fork testing - sepolia
ft-sepolia-fork :; forge test --match-contract TestE2EV2 \
--rpc-url https://sepolia.drpc.org \
ft-mode-sepolia-upgrade-fork :; forge test --match-contract UpgradeModeTo110 \
--rpc-url https://sepolia.mode.network/ \
--fork-block-number 26050695 \
--force \
-vvvv

upgrade-preview-mode-sepolia :; forge script UpgradeModeTo110 \
--rpc-url https://sepolia.mode.network \
--private-key $(DEPLOYMENT_PRIVATE_KEY) \
-vvvvv

#### Deployments ####
upgrade-mode-sepolia :; forge script UpgradeModeTo110 \
--rpc-url https://sepolia.mode.network \
--private-key $(DEPLOYMENT_PRIVATE_KEY) \
--broadcast \
--verify \
--verifier blockscout \
--verifier-url https://sepolia.explorer.mode.network/api\? \
-vvvvv

# on an anvil fork will run the upgrade script
anvil-fork-mode :; anvil -f https://mainnet.mode.network --fork-block-number 18697900 # --auto-impersonate
upgrade-fork-mode :; forge script UpgradeModeTo110 \
--rpc-url http://localhost:8545 \
--private-key $(DEPLOYMENT_PRIVATE_KEY) \
--broadcast \
-vvvvv

stakeinspector-preview-mode :; forge script DeployStakeInspector \
--rpc-url https://mainnet.mode.network \
upgrade-preview-mode :; forge script UpgradeModeTo110 \
--rpc-url https://mainnet.mode.network \
--private-key $(DEPLOYMENT_PRIVATE_KEY) \
-vvvvv

stakeinspector-mode :; forge script DeployStakeInspector \
--rpc-url https://mainnet.mode.network \
--private-key $(DEPLOYMENT_PRIVATE_KEY) \
--broadcast \
--verify \
--verifier blockscout \
--verifier-url https://explorer.mode.network/api\? \
-vvvvv
upgrade-mode :; forge script UpgradeModeTo110 \
--rpc-url https://mainnet.mode.network \
--private-key $(DEPLOYMENT_PRIVATE_KEY) \
--broadcast \
--verify \
--verifier blockscout \
--verifier-url https://explorer.mode.network/api\? \
-vvvvv

deploy-preview-mode-sepolia :; forge script script/Deploy.s.sol:Deploy \
#### Deployments ####
deploy-preview-mode-sepolia-110 :; forge script DeployGaugesV1_1_0 \
--rpc-url https://sepolia.mode.network \
--private-key $(DEPLOYMENT_PRIVATE_KEY) \
-vvvvv

deploy-mode-sepolia :; forge script script/Deploy.s.sol:Deploy \
deploy-mode-sepolia :; forge script DeployGauges \
--rpc-url https://sepolia.mode.network \
--private-key $(DEPLOYMENT_PRIVATE_KEY) \
--broadcast \
Expand All @@ -67,18 +106,16 @@ deploy-mode-sepolia :; forge script script/Deploy.s.sol:Deploy \
--verifier-url https://sepolia.explorer.mode.network/api\? \
-vvvvv

deploy-preview-mode :; forge script script/Deploy.s.sol:Deploy \
--rpc-url https://mainnet.mode.network \
### Other scripts ###
seed-preview-mode-sepolia :; forge script SeedState \
--rpc-url https://sepolia.mode.network \
--private-key $(DEPLOYMENT_PRIVATE_KEY) \
-vvvvv

seed-mode-sepolia :; forge script SeedState \
--rpc-url https://sepolia.mode.network \
--private-key $(DEPLOYMENT_PRIVATE_KEY) \
--broadcast \
-vvvvv

deploy-mode :; forge script script/Deploy.s.sol:Deploy \
--rpc-url https://mainnet.mode.network \
--private-key $(DEPLOYMENT_PRIVATE_KEY) \
--broadcast \
--verify \
--verifier blockscout \
--verifier-url https://explorer.mode.network/api\? \
-vvv

Loading

0 comments on commit 653ee26

Please sign in to comment.