Skip to content

Commit 4f72cdd

Browse files
committed
Merge 'feat/next-vote' into 'feat/next-vote-with-core'
2 parents 734e7da + 7b9bd60 commit 4f72cdd

File tree

16 files changed

+1314
-477
lines changed

16 files changed

+1314
-477
lines changed

.github/workflows/large_vote_ci.yml.disabled

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ on:
1212
schedule:
1313
- cron: "0 0 * * TUE"
1414
jobs:
15-
run-tests-large:
16-
name: Brownie fork LARGE tests
15+
run-tests-large-1:
16+
name: Brownie fork LARGE tests 1
1717
runs-on: [protocol-heavy-runners]
1818
timeout-minutes: 150
1919

@@ -36,4 +36,56 @@ jobs:
3636
vote: "large"
3737
infura: ${{ secrets.WEB3_INFURA_PROJECT_ID }}
3838
etherscan: ${{ secrets.ETHERSCAN_TOKEN }}
39-
command: "poetry run brownie test --network mfh-1"
39+
command: "make test-1/3"
40+
41+
run-tests-large-2:
42+
name: Brownie fork LARGE tests 2
43+
runs-on: [protocol-heavy-runners]
44+
timeout-minutes: 150
45+
46+
steps:
47+
- name: Enabling swap
48+
run: |
49+
sudo df -h
50+
sudo swapon --show
51+
sudo swapoff -a
52+
sudo touch /swapfile
53+
sudo fallocate -l 32G /swapfile
54+
sudo chmod 600 /swapfile
55+
sudo mkswap /swapfile
56+
sudo swapon /swapfile
57+
sudo swapon --show
58+
- uses: actions/checkout@v3
59+
- name: Main action
60+
uses: ./.github/actions/brownie_fork_tests
61+
with:
62+
vote: "large"
63+
infura: ${{ secrets.WEB3_INFURA_PROJECT_ID }}
64+
etherscan: ${{ secrets.ETHERSCAN_TOKEN }}
65+
command: "make test-2/3"
66+
67+
run-tests-large-3:
68+
name: Brownie fork LARGE tests 3
69+
runs-on: [protocol-heavy-runners]
70+
timeout-minutes: 150
71+
72+
steps:
73+
- name: Enabling swap
74+
run: |
75+
sudo df -h
76+
sudo swapon --show
77+
sudo swapoff -a
78+
sudo touch /swapfile
79+
sudo fallocate -l 32G /swapfile
80+
sudo chmod 600 /swapfile
81+
sudo mkswap /swapfile
82+
sudo swapon /swapfile
83+
sudo swapon --show
84+
- uses: actions/checkout@v3
85+
- name: Main action
86+
uses: ./.github/actions/brownie_fork_tests
87+
with:
88+
vote: "large"
89+
infura: ${{ secrets.WEB3_INFURA_PROJECT_ID }}
90+
etherscan: ${{ secrets.ETHERSCAN_TOKEN }}
91+
command: "make test-3/3"
Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Scripts tests
1+
name: Normal vote CI
22

33
on:
44
push:
@@ -9,40 +9,48 @@ on:
99
- "feat/rc2"
1010
- "feat/rc1"
1111
- "feat/next-vote"
12-
schedule:
13-
- cron: "0 0 * * TUE"
1412
jobs:
15-
run-tests:
16-
name: Run all tests on NORMAL runner
13+
run-tests-normal-1:
14+
name: Brownie fork NORMAL tests 1
1715
runs-on: "ubuntu-latest"
1816
timeout-minutes: 100
19-
20-
services:
21-
hardhat-node:
22-
image: ghcr.io/lidofinance/hardhat-node:2.22.19.2-shanghai
23-
ports:
24-
- 8555:8545
25-
env:
26-
ETH_RPC_URL: "https://mainnet.infura.io/v3/${{ secrets.WEB3_INFURA_PROJECT_ID }}"
27-
17+
2818
steps:
29-
- uses: actions/checkout@v4
30-
31-
- name: Check that the fork is ready
32-
shell: bash
33-
run: timeout 30 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' 127.0.0.1 8555
19+
- uses: actions/checkout@v3
20+
- name: Main action
21+
uses: ./.github/actions/brownie_fork_tests
22+
with:
23+
vote: "normal"
24+
infura: ${{ secrets.WEB3_INFURA_PROJECT_ID }}
25+
etherscan: ${{ secrets.ETHERSCAN_TOKEN }}
26+
command: "make test-1/3"
3427

35-
- name: Execute vote
36-
uses: ./.github/actions/execute_vote
28+
run-tests-normal-2:
29+
name: Brownie fork NORMAL tests 2
30+
runs-on: "ubuntu-latest"
31+
timeout-minutes: 100
32+
33+
steps:
34+
- uses: actions/checkout@v3
35+
- name: Main action
36+
uses: ./.github/actions/brownie_fork_tests
3737
with:
3838
vote: "normal"
3939
infura: ${{ secrets.WEB3_INFURA_PROJECT_ID }}
4040
etherscan: ${{ secrets.ETHERSCAN_TOKEN }}
41+
command: "make test-2/3"
4142

42-
- name: Scripts tests
43-
uses: ./.github/actions/scripts_tests
43+
run-tests-normal-3:
44+
name: Brownie fork NORMAL tests 3
45+
runs-on: "ubuntu-latest"
46+
timeout-minutes: 100
47+
48+
steps:
49+
- uses: actions/checkout@v3
50+
- name: Main action
51+
uses: ./.github/actions/brownie_fork_tests
4452
with:
4553
vote: "normal"
4654
infura: ${{ secrets.WEB3_INFURA_PROJECT_ID }}
4755
etherscan: ${{ secrets.ETHERSCAN_TOKEN }}
48-
command: "poetry run brownie test --network mfh-1"
56+
command: "make test-3/3"

Makefile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
define run_2nd_test
2+
ETH_RPC_URL="$${ETH_RPC_URL2:-$$ETH_RPC_URL}" \
3+
ETHERSCAN_TOKEN="$${ETHERSCAN_TOKEN2:-$$ETHERSCAN_TOKEN}" \
4+
poetry run $(1)
5+
endef
6+
7+
define run_3rd_test
8+
ETH_RPC_URL="$${ETH_RPC_URL3:-$$ETH_RPC_URL}" \
9+
ETHERSCAN_TOKEN="$${ETHERSCAN_TOKEN3:-$$ETHERSCAN_TOKEN}" \
10+
poetry run $(1)
11+
endef
12+
13+
test:
14+
ifdef vote
15+
OMNIBUS_VOTE_IDS=$(vote) poetry run brownie test --network mfh-1
16+
else
17+
ifdef dg
18+
DG_PROPOSAL_IDS=$(dg) poetry run brownie test --network mfh-1
19+
else
20+
poetry run brownie test --network mfh-1
21+
endif
22+
endif
23+
24+
test-1/2:
25+
poetry run brownie test tests/*.py tests/regression/test_staking_router_stake_distribution.py --network mfh-1
26+
27+
test-2/2:
28+
$(call run_2nd_test,brownie test -k 'not test_staking_router_stake_distribution.py' --network mfh-2)
29+
30+
test-1/3:
31+
poetry run brownie test tests/*.py tests/regression/test_accounting_oracle_extra_data_full_items.py --network mfh-1
32+
33+
test-2/3:
34+
$(call run_2nd_test,brownie test tests/*.py tests/regression/test_staking_router_stake_distribution.py tests/regression/test_sanity_checks.py --network mfh-2)
35+
36+
test-3/3:
37+
$(call run_3rd_test,brownie test -k 'not test_sanity_checks.py and not test_accounting_oracle_extra_data_full_items.py and not test_staking_router_stake_distribution.py' --network mfh-3)
38+
39+
docker:
40+
docker exec -it scripts /bin/bash
41+
42+
node:
43+
npx hardhat node --fork ${ETH_RPC_URL}
44+
45+
slots:
46+
@echo "Input https://github.com/lidofinance/protocol-onchain-mon-bots/blob/main/bots/ethereum-steth-v2/src/utils/constants.ts file content (end with Enter and Ctrl+D):"
47+
@cat | grep -v "import { StorageSlot } from '../entity/storage_slot'" | sed 's/StorageSlot/any/g' > slots.ts
48+
@cat check_storage_slots.ts >> slots.ts
49+
@echo "Checking storage slots against 127.0.0.1:8545..."
50+
@npx tsx slots.ts
51+
@rm -f slots.ts
52+
53+
enact-fork:
54+
poetry run brownie run $(vote) start_and_execute_vote_on_fork_manual --network=mfh-1

README.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,27 @@ git clone git@github.com:lidofinance/scripts.git
3131
cd scripts
3232
```
3333

34-
#### Step 2. Set up the ENV VARs, for example:
34+
#### Step 2. Set up the ENV VARs for Mainnet:
3535

36-
- `WEB3_INFURA_PROJECT_ID` - **mandatory** for the execution of tests
36+
| ENV VAR | RUN TESTS | RUN VOTES |
37+
| ------------- | ------------- | ------------- |
38+
| `ETH_RPC_URL` | **mandatory** | **mandatory** |
39+
| `ETH_RPC_URL2` | optional* | - |
40+
| `ETH_RPC_URL3` | optional* | - |
41+
| `PINATA_CLOUD_TOKEN` | - | **mandatory** |
42+
| `DEPLOYER` | - | **mandatory** |
43+
| `ETHERSCAN_TOKEN` | **mandatory** | **mandatory** |
44+
| `ETHERSCAN_TOKEN2` | optional* | - |
45+
| `ETHERSCAN_TOKEN3` | optional* | - |
46+
47+
_*may be optionally set when running tests asynchronously to reduce the risk of getting 529 error_
3748

3849
#### Step 3. Run the container
3950

4051
Run the container in the `scripts` directory and specify the ENV VARs:
4152

4253
```shell
43-
docker run --name scripts -v "$(pwd)":/root/scripts -e WEB3_INFURA_PROJECT_ID -d ghcr.io/lidofinance/scripts:v18 && docker logs scripts -f
44-
54+
docker run --name scripts -v "$(pwd)":/root/scripts -e ETH_RPC_URL -e ETH_RPC_URL2 -e ETH_RPC_URL3 -e PINATA_CLOUD_TOKEN -e DEPLOYER -e ETHERSCAN_TOKEN -e ETHERSCAN_TOKEN2 -e ETHERSCAN_TOKEN3 -d ghcr.io/lidofinance/scripts:v18 && docker logs scripts -f
4555
```
4656

4757
Note: _It may take up to 5 minutes for the container to initialize properly the first time: wait till container output stops and press CTRL/CMD+C to exit._
@@ -58,11 +68,26 @@ To run a Hardhat node inside a deployed Docker container:
5868
npx hardhat node --fork $ETH_RPC_URL
5969
```
6070

71+
Do not forget to add a DEPLOYER account:
72+
73+
```shell
74+
poetry run brownie accounts new <id>
75+
```
76+
6177
You now have a fully functional environment to run scripts & tests in, which is linked to your local scripts repo, for example:
6278

6379
```shell
6480
poetry run brownie test tests/acceptance/test_accounting_oracle.py -s
6581
```
82+
You can use the following shortcuts:
83+
- `make test` run all tests on Hardhat node
84+
- `make test vote=XXX` run all tests on Hardhat node with applied Vote #XXX
85+
- `make test dg=XX` run all tests with executed DG proposal #XX
86+
- `make test-1/2`, `make test-2/2` run tests divided into 2 parts (can be run asynchronously)
87+
- `make test-1/3`, `make test-2/3`, `make test-3/3` run tests divided into 3 parts (can be run asynchronously)
88+
- `make enact-fork vote=scripts/vote_01_01_0001.py` deploy vote and enact it on mainnet fork
89+
- `make docker` connect to the `scripts` docker container
90+
- `make node` start local mainnet node
6691

6792
or, to run core repository integrations tests on the Hardhat node run on default port 8545 (in a step above):
6893

scripts/upgrade_2025_06_25_mainnet_dg_launch.py renamed to archive/scripts/upgrade_2025_06_25_mainnet_dg_launch.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@
6363
5. Validate roles were updated correctly
6464
56. Verify Dual Governance launch state
6565
57. Set an "expiration deadline" after which the omnibus can no longer be enacted
66+
67+
68+
Vote passed & executed on June 30, 2025 at 14:04, block 22817714
6669
"""
6770

71+
import time
72+
6873
from typing import Dict
6974
from brownie import interface
7075
from utils.voting import bake_vote_items, confirm_vote_script, create_vote
@@ -74,6 +79,7 @@
7479
get_is_live,
7580
get_priority_fee,
7681
)
82+
from utils.mainnet_fork import pass_and_exec_dao_vote
7783

7884
dual_governance_launch_omnibus_provider = "0x1DB8a9313785b78f7d0a201C5E0BE007f1eb63b4"
7985
description = """
@@ -127,3 +133,16 @@ def main():
127133
assert dual_governance_launch_omnibus_provider_contract.isValidVoteScript(vote_id)
128134

129135
vote_id >= 0 and print(f"Vote created: {vote_id}.")
136+
137+
138+
def start_and_execute_vote_on_fork_manual():
139+
if get_is_live():
140+
raise Exception("This script is for local testing only.")
141+
142+
tx_params = {"from": get_deployer_account()}
143+
vote_id, _ = start_vote(tx_params=tx_params, silent=True)
144+
145+
time.sleep(5) # hack for waiting thread #2.
146+
147+
print(f"Vote created: {vote_id}.")
148+
pass_and_exec_dao_vote(int(vote_id), step_by_step=True)

0 commit comments

Comments
 (0)