Skip to content

deploy refactor and tooling #4

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

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f9ccd12
fix: add events
krogla Jan 21, 2025
f1f7941
fix: undef mainnet constants
krogla Jan 21, 2025
250bb61
fix: init on proxy deploy
krogla Jan 21, 2025
b85fa05
fix: add version, check on manager update
krogla Jan 21, 2025
039c914
fix: initialize during proxy deploy
krogla Jan 21, 2025
98e6586
chore: linter tune
krogla Jan 21, 2025
d6038de
fix: pause/resume roles
krogla Jan 21, 2025
ac812a4
test: deploy state, upgrades
krogla Jan 21, 2025
50d419f
test: add proxy test
krogla Jan 21, 2025
38cbce2
chore: linter+tools
krogla Jan 21, 2025
10048bc
build: env sample
krogla Jan 21, 2025
d9ad35d
fix: deploy script, optim.
krogla Jan 21, 2025
f429bc9
build: justfile + helpers script
krogla Jan 21, 2025
bc3d5bf
deployed holesky artifacts
krogla Jan 21, 2025
c35d4cc
feat: refactor storage contracts
krogla Jan 23, 2025
67e6e75
test: fix tests
krogla Jan 23, 2025
4dc5cd2
chore: code metrics tools
krogla Jan 23, 2025
9942a44
chore: upd holesky deployed
krogla Jan 23, 2025
2a31d99
Merge pull request #5 from lidofinance/storage
krogla Jan 23, 2025
ebacce0
fix: minor cleanup
krogla Jan 23, 2025
bbb994c
style: fix formatting
krogla Jan 23, 2025
47ffa9d
chore: fix comments
krogla Jan 27, 2025
191aa23
fix: deploy scripts refactor+upgrade script
krogla Jan 28, 2025
b99604d
fix: add just commands
krogla Jan 28, 2025
7a90f27
fix: missing operatorId in getOperator
krogla Jan 28, 2025
ac629cf
chore: upd deployed holesky artifacts
krogla Jan 28, 2025
31bcc1d
fix: module config refactor
krogla Jan 29, 2025
7eb3da9
feat: refactor module config, add view methods
krogla Jan 29, 2025
aaa0e97
test: new tests, refactor
krogla Jan 29, 2025
1365a5f
fix: deployed holesky artifacts
krogla Jan 29, 2025
df5cb1f
fix: preconfEnabled logic refactor,fixes, tests
krogla Jan 29, 2025
0527fc9
chore: upd deployed artifacts
krogla Jan 29, 2025
79d5e45
feat: delegates+multi ranges
krogla Feb 11, 2025
aa264e4
fix: holesky deployed artifacts
krogla Feb 11, 2025
cdb2110
Merge pull request #6 from lidofinance:feat/multi-ranges
krogla Feb 11, 2025
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
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ DEPLOYER_PRIVATE_KEY=
# Testing purposes
DEPLOY_CONFIG=./artifacts/holesky/deploy-holesky.json
# Specify the chain to deploy or test on
CHAIN=mainnet | holesky
CHAIN=mainnet | holesky
# Where to store the deployment artifacts. Default is ./artifacts/local
ARTIFACTS_DIR=./artifacts/local
ETHERSCAN_API_KEY=key
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ lcov.info
!.yarn/versions

lib/*

scc-report.*
scm-report.*
10 changes: 6 additions & 4 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"extends": "solhint:recommended",
"plugins": [""],
"plugins": ["lido-csm"],
"rules": {
"constructor-syntax": "error",
"compiler-version": ["error", "0.8.28"],
"no-inline-assembly": "off",
"no-unused-import": "error",
"func-named-parameters": "error",
"func-named-parameters": ["warn", 5],
"func-visibility": ["error", { "ignoreConstructors": true }],
"reason-string": ["warn", { "maxLength": 64 }],
"immutable-vars-naming": ["error", { "immutablesAsConstants": true }],
"var-name-mixedcase": "error",
"func-name-mixedcase": "error",
"var-name-mixedcase": "warn",
"func-name-mixedcase": "warn",
"foundry-test-functions": ["off", ["setUp"]],
"no-global-import": "error",
"ordering": "warn",
"gas-calldata-parameters": "error",
Expand Down
Binary file modified .yarn/install-state.gz
Binary file not shown.
186 changes: 186 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
set dotenv-load

chain := env_var_or_default("CHAIN", "mainnet")
deploy_script_name := if chain == "mainnet" {
"DeployMainnet"
} else if chain == "holesky" {
"DeployHolesky"
} else {
error("Unsupported chain " + chain)
}

upgrade_script_name := if chain == "mainnet" {
"UpgradeMainnet"
} else if chain == "holesky" {
"UpgradeHolesky"
} else {
error("Unsupported chain " + chain)
}

deploy_script_path := "script" / deploy_script_name + ".s.sol:" + deploy_script_name
upgrade_script_path := "script" / upgrade_script_name + ".s.sol:" + upgrade_script_name

anvil_host := env_var_or_default("ANVIL_IP_ADDR", "127.0.0.1")
anvil_port := "8545"
anvil_rpc_url := "http://" + anvil_host + ":" + anvil_port

default: clean deps build test-all

build *args:
forge build --force {{args}}

clean:
forge clean
rm -rf cache broadcast out node_modules

deps:
yarn workspaces focus --all --production

deps-dev:
yarn workspaces focus --all && npx husky install

lint-solhint:
yarn lint:solhint

lint-fix:
yarn lint:fix

lint:
yarn lint:check

test-all:
just test-unit &
just test-local

test-unit *args:
forge test --no-match-path 'test/fork/*' -vvv {{args}}

test-deployment *args:
forge test --match-path 'test/fork/*' -vvv {{args}}

gas-report:
#!/usr/bin/env python

import subprocess
import re

command = "just test-unit --nmt 'testFuzz.+' --gas-report"
output = subprocess.check_output(command, shell=True, text=True)

lines = output.split('\n')

filename = 'GAS.md'
to_print = False
skip_next = False

with open(filename, 'w') as fh:
for line in lines:
if skip_next:
skip_next = False
continue

if line.startswith('|'):
to_print = True

if line.startswith('| Deployment Cost'):
to_print = False
skip_next = True

if re.match(r"Ran \d+ test suites", line):
break

if to_print:
fh.write(line + '\n')

print(f"Done. Gas report saved to {filename}")

coverage *args:
FOUNDRY_PROFILE=coverage forge coverage --no-match-path 'test/fork/*' {{args}}

# Run coverage and save the report in LCOV file.
coverage-lcov *args:
FOUNDRY_PROFILE=coverage forge coverage --no-match-path 'test/fork/*' --report lcov {{args}}

diffyscan-contracts *args:
yarn generate:diffyscan {{args}}

make-fork *args:
@if pgrep -x "anvil" > /dev/null; \
then just _warn "anvil process is already running in the background. Make sure it's connected to the right network and in the right state."; \
else anvil -f ${RPC_URL} --host {{anvil_host}} --port {{anvil_port}} --config-out localhost.json {{args}}; \
fi

kill-fork:
@-pkill anvil && just _warn "anvil process is killed"

# deploy production
deploy *args:
forge script {{deploy_script_path}} --rpc-url {{anvil_rpc_url}} --broadcast --slow {{args}}

deploy-prod *args:
just _warn "The current `tput bold`chain={{chain}}`tput sgr0` with the following rpc url: $RPC_URL"
ARTIFACTS_DIR=./artifacts/latest/ just _deploy-prod-confirm {{args}}

cp ./broadcast/{{deploy_script_name}}.s.sol/`cast chain-id --rpc-url=$RPC_URL`/run-latest.json \
./artifacts/latest/transactions.json

[confirm("You are about to broadcast deployment transactions to the network. Are you sure?")]
_deploy-prod-confirm *args:
just _deploy-prod --broadcast --verify {{args}}

deploy-prod-dry *args:
just _deploy-prod {{args}}

verify-prod *args:
just _warn "Pass --chain=your_chain manually. e.g. --chain=holesky for testnet deployment"
forge script {{deploy_script_path}} --rpc-url ${RPC_URL} --verify {{args}} --unlocked

_deploy-prod *args:
forge script {{deploy_script_path}} --force --rpc-url ${RPC_URL} {{args}}

# upgrade production
upgrade *args:
forge script {{upgrade_script_path}} --rpc-url {{anvil_rpc_url}} --broadcast --slow {{args}}

upgrade-prod *args:
just _warn "The current `tput bold`chain={{chain}}`tput sgr0` with the following rpc url: $RPC_URL"
ARTIFACTS_DIR=./artifacts/latest/ just _upgrade-prod-confirm {{args}}

cp ./broadcast/{{upgrade_script_name}}.s.sol/`cast chain-id --rpc-url=$RPC_URL`/run-latest.json \
./artifacts/latest/transactions.json

[confirm("You are about to broadcast upgrade transactions to the network. Are you sure?")]
_upgrade-prod-confirm *args:
just _upgrade-prod --broadcast --verify {{args}}

upgrade-prod-dry *args:
just _upgrade-prod {{args}}

_upgrade-prod *args:
forge script {{upgrade_script_path}} --force --rpc-url ${RPC_URL} {{args}}

# local deployment
deploy-local:
just make-fork &
@while ! echo exit | nc {{anvil_host}} {{anvil_port}} > /dev/null; do sleep 1; done
ARTIFACTS_DIR=./artifacts/local/ just deploy
just _warn "anvil is kept running in the background: {{anvil_rpc_url}}"

upgrade-local:
just make-fork &
@while ! echo exit | nc {{anvil_host}} {{anvil_port}} > /dev/null; do sleep 1; done
ARTIFACTS_DIR=./artifacts/local/ just upgrade
just _warn "anvil is kept running in the background: {{anvil_rpc_url}}"

test-local *args:
just make-fork --silent &
@while ! echo exit | nc {{anvil_host}} {{anvil_port}} > /dev/null; do sleep 1; done
DEPLOYER_PRIVATE_KEY=`cat localhost.json | jq -r ".private_keys[0]"` \
ARTIFACTS_DIR=./artifacts/local/ just deploy --silent
DEPLOY_CONFIG=./artifacts/local/deploy-{{chain}}.json \
RPC_URL={{anvil_rpc_url}} \
just test-deployment {{args}}
just kill-fork

_warn message:
@tput setaf 3 && printf "[WARNING]" && tput sgr0 && echo " {{message}}"
Empty file added artifacts/holesky/.gikeep
Empty file.
7 changes: 7 additions & 0 deletions artifacts/holesky/deploy-holesky.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"CCR": "0x5e30e8958a4361ac7a7C4FcE978FF18f70E915a2",
"CCRImpl": "0x76773E5A432113238be489F9A7Bf716e8dC4a015",
"ChainId": 17000,
"DeployParams": "0x00000000000000000000000028fab2059c713a7f9d8c86db49f9bb0e96af1ef8636f6d6d756e6974792d6f6e636861696e2d7631000000000000000000000000000000000000000000000000401fd888b5e41113b7c0c47725a742bbc3a083ef000000000000000000000000401fd888b5e41113b7c0c47725a742bbc3a083ef00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000f4240",
"LidoLocator": "0x28FAB2059C713A7F9D8c86Db49f9bb0e96Af1ef8"
}
648 changes: 648 additions & 0 deletions artifacts/holesky/transactions.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions artifacts/latest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# latest deployment configs after broadcasting on the network
*.json
2 changes: 2 additions & 0 deletions artifacts/local/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# latest deployment configs after broadcasting on the network
*.json
Empty file added artifacts/mainnet/.gikeep
Empty file.
10 changes: 8 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ cache_path = "cache"
block_gas_limit = 30_000_000
fuzz = { runs = 256 }

# gas_reports = [
# ]
gas_reports = [
"CCR",
"CCRDataStorage",
"OssifiableProxy"
]


fs_permissions = [
{ access = "read-write", path = "./out" },
{ access = "read-write", path = "./artifacts" },
# { access = "read", path = "./test/fixtures" },
]

ignored_warnings_from = ["test/OssifiableProxy.t.sol"]

[profile.ci]
verbosity = 3
fuzz = { runs = 10_000, max_test_rejects = 2_000_000 }
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@
"private": true,
"scripts": {
"lint:solhint": "solhint './src/**/*.sol'",
"lint:check": "prettier --check **.sol && yarn lint:solhint",
"lint:fix": "prettier --write **.sol"
"lint:check": "forge fmt --check && yarn lint:solhint",
"lint:fix": "forge fmt",
"generate:diffyscan": "node script/generateDiffyscanContracts.js",
"scc:report": "scc src --sort names --no-cocomo --exclude-dir interfaces --by-file --format wide > scc-report.txt",
"scm:report": "solidity-code-metrics $(tree -f -i -I '*interfaces*' | grep '^./src.*sol' | xargs ls -d 2>/dev/null) > scm-report.md"
},
"devDependencies": {
"husky": "^9.1.7",
"lint-staged": "^15.3.0",
"lint-staged": "^15.4.2",
"prettier": "^3.4.2",
"prettier-plugin-solidity": "^1.4.2",
"solhint": "5.0.4"
"solhint": "5.0.5",
"solhint-plugin-lido-csm": "https://github.com/lidofinance/solhint-plugin-lido-csm.git#0.3.3",
"solidity-code-metrics": "^0.0.28"
},
"lint-staged": {
"*": "prettier --ignore-unknown --write",
Expand Down
91 changes: 0 additions & 91 deletions script/DeployBase.s.sol

This file was deleted.

Loading
Loading