Skip to content

Commit

Permalink
Merge commit '34a7a8808d54d9056d595d3080af48a8151d4c5f' into chore/re…
Browse files Browse the repository at this point in the history
…naming
  • Loading branch information
vgorkavenko committed Nov 26, 2024
2 parents 429c51c + 34a7a88 commit 99eef49
Show file tree
Hide file tree
Showing 24 changed files with 369 additions and 131 deletions.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ RPC_URL=
DEPLOYER_PRIVATE_KEY=
# Testing purposes
DEPLOY_CONFIG=./artifacts/holesky/deploy-holesky.json
# Optional. Integration tests get new addresses from the upgrade config if present
UPGRADE_CONFIG=./artifacts/local/deploy-local.json
# Specify the chain to deploy or test on
CHAIN=mainnet | holesky
# Where to store the deployment artifacts. Default is ./artifacts/local
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regular-mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
EMBEDS=$(cat <<EOF
[
{
"title": "Regular tests are failed! :scream:",
"title": "Failed mainnet tests! :scream:",
"url": "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID",
"description": "Check the logs for more information."
}
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ jobs:
CHAIN: holesky
RPC_URL: ${{ secrets.RPC_URL_HOLESKY }}

- name: Run post-vote tests after upgrade
run: just test-upgrade
env:
CHAIN: mainnet
DEPLOY_CONFIG: ./artifacts/mainnet/deploy-mainnet.json
RPC_URL: ${{ secrets.RPC_URL_MAINNET }}

# TODO: Enable later
# - name: Check gas report
# run: just gas-report && git diff --exit-code GAS.md
Expand Down
46 changes: 38 additions & 8 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ deploy_script_name := if chain == "mainnet" {
}

deploy_implementations_script_name := if chain == "mainnet" {
"undefined"
"DeployImplementationsMainnet"
} else if chain == "holesky" {
"DeployHoleskyImplementations"
"DeployImplementationsHolesky"
} else {
error("Unsupported chain " + chain)
}

deploy_config_path := if chain == "mainnet" {
"artifacts/mainnet/deploy-mainnet.json"
} else if chain == "holesky" {
"artifacts/holesky/deploy-holesky.json"
} else {
error("Unsupported chain " + chain)
}
Expand Down Expand Up @@ -124,7 +132,7 @@ kill-fork:
@-pkill anvil && just _warn "anvil process is killed"

deploy *args:
forge script {{deploy_script_path}} --rpc-url {{anvil_rpc_url}} --broadcast --slow {{args}}
forge script {{deploy_script_path}} --sig="run(string)" --rpc-url {{anvil_rpc_url}} --broadcast --slow {{args}} -- `git rev-parse HEAD`

deploy-prod *args:
just _warn "The current `tput bold`chain={{chain}}`tput sgr0` with the following rpc url: $RPC_URL"
Expand All @@ -142,24 +150,46 @@ deploy-prod-dry *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
forge script {{deploy_script_path}} --sig="run(string)" --rpc-url ${RPC_URL} --verify {{args}} --unlocked -- `git rev-parse HEAD`

_deploy-prod *args:
forge script {{deploy_script_path}} --force --rpc-url ${RPC_URL} {{args}}
forge script {{deploy_script_path}} --sig="run(string)" --force --rpc-url ${RPC_URL} {{args}} -- `git rev-parse HEAD`

_deploy-impl *args:
forge script {{deploy_impls_script_path}} --sig="deploy(string,string)" \
--rpc-url {{anvil_rpc_url}} --slow {{args}} \
-- {{deploy_config_path}} `git rev-parse HEAD`

[confirm("You are about to broadcast deployment transactions to the network. Are you sure?")]
deploy-impl *args:
ARTIFACTS_DIR=./artifacts/latest/ just deploy-impl-dry --broadcast --verify {{args}}
deploy-impl-prod *args:
ARTIFACTS_DIR=./artifacts/latest/ just _deploy-impl --broadcast --verify {{args}}

deploy-impl-dry *args:
forge script {{deploy_impls_script_path}} --force --rpc-url ${RPC_URL} {{args}}
just _deploy-impl {{args}}

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

test-upgrade *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]"` \
just _deploy-impl --broadcast

DEPLOY_CONFIG=./artifacts/{{chain}}/deploy-{{chain}}.json \
UPGRADE_CONFIG=./artifacts/local/upgrade-{{chain}}.json \
RPC_URL={{anvil_rpc_url}} \
just vote-upgrade

DEPLOY_CONFIG=./artifacts/{{chain}}/deploy-{{chain}}.json \
UPGRADE_CONFIG=./artifacts/local/upgrade-{{chain}}.json \
RPC_URL={{anvil_rpc_url}} \
just test-post-voting {{args}}
just kill-fork

test-local *args:
just make-fork --silent &
@while ! echo exit | nc {{anvil_host}} {{anvil_port}} > /dev/null; do sleep 1; done
Expand Down
11 changes: 7 additions & 4 deletions fork.just
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
# Fork helper scripts
####

vote:
just _impersonate-script SimulateVote
vote-add-module:
just _impersonate-script SimulateVote --sig="addModule"

vote-upgrade:
just _impersonate-script SimulateVote --sig="upgrade"

public-release:
just _impersonate-script PauseResume --sig="publicRelease"
Expand Down Expand Up @@ -82,7 +85,7 @@ exit-request noId validatorIndex validatorPubKey:
just _impersonate-script NodeOperators --sig="exitRequest\(uint256,uint256,bytes\)" -vvv -- {{noId}} {{validatorIndex}} {{validatorPubKey}}

_impersonate-script *args:
cast rpc --rpc-url={{anvil_rpc_url}} anvil_autoImpersonateAccount true
curl -sS {{anvil_rpc_url}} --header 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"anvil_autoImpersonateAccount","params":[true],"id":1}' > /dev/null
forge script --rpc-url={{anvil_rpc_url}} -vvv --broadcast --unlocked \
--sender=`cat localhost.json | jq -r ".available_accounts[0]"` {{args}}
cast rpc --rpc-url={{anvil_rpc_url}} anvil_autoImpersonateAccount false
curl -sS {{anvil_rpc_url}} --header 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"anvil_autoImpersonateAccount","params":[false],"id":1}' > /dev/null
5 changes: 4 additions & 1 deletion script/DeployBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct DeployParams {
}

abstract contract DeployBase is Script {
string internal gitRef;
DeployParams internal config;
string internal artifactDir;
string internal chainName;
Expand Down Expand Up @@ -105,7 +106,8 @@ abstract contract DeployBase is Script {
locator = ILidoLocator(config.lidoLocatorAddress);
}

function run() external virtual {
function run(string memory _gitRef) external virtual {
gitRef = _gitRef;
if (chainId != block.chainid) {
revert ChainIdMismatch({
actual: block.chainid,
Expand Down Expand Up @@ -328,6 +330,7 @@ abstract contract DeployBase is Script {
deployJson.set("LidoLocator", config.lidoLocatorAddress);
deployJson.set("GateSeal", gateSeal);
deployJson.set("DeployParams", abi.encode(config));
deployJson.set("git-ref", gitRef);
vm.writeJson(deployJson.str, _deployJsonFilename());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pragma solidity 0.8.24;

import { DeployBase } from "./DeployBase.s.sol";
import { GIndex } from "../src/lib/GIndex.sol";
import { DeployHolesky } from "./DeployHolesky.s.sol";

import { HashConsensus } from "../src/lib/base-oracle/HashConsensus.sol";
import { CSModule } from "../src/CSModule.sol";
Expand All @@ -18,11 +17,12 @@ import { CSEarlyAdoption } from "../src/CSEarlyAdoption.sol";
import { JsonObj, Json } from "./utils/Json.sol";
import { GIndex } from "../src/lib/GIndex.sol";
import { Slot } from "../src/lib/Types.sol";
import { DeployBase } from "./DeployBase.s.sol";

contract DeployHoleskyImplementations is DeployHolesky {
abstract contract DeployImplementationsBase is DeployBase {
address gateSeal;

function run() external virtual override {
function _deploy() internal {
if (chainId != block.chainid) {
revert ChainIdMismatch({
actual: block.chainid,
Expand All @@ -33,7 +33,6 @@ contract DeployHoleskyImplementations is DeployHolesky {
pk = vm.envUint("DEPLOYER_PRIVATE_KEY");
deployer = vm.addr(pk);
vm.label(deployer, "DEPLOYER");
parseDeploymentConfig();

vm.startBroadcast(pk);
{
Expand All @@ -55,17 +54,16 @@ contract DeployHoleskyImplementations is DeployHolesky {
maxBondLockPeriod: config.maxBondLockPeriod
});

// No changes in these contracts. Uncomment if any
// CSFeeOracle oracleImpl = new CSFeeOracle({
// secondsPerSlot: config.secondsPerSlot,
// genesisTime: config.clGenesisTime
// });
CSFeeOracle oracleImpl = new CSFeeOracle({
secondsPerSlot: config.secondsPerSlot,
genesisTime: config.clGenesisTime
});

// CSFeeDistributor feeDistributorImpl = new CSFeeDistributor({
// stETH: locator.lido(),
// accounting: address(accounting),
// oracle: address(oracle)
// });
CSFeeDistributor feeDistributorImpl = new CSFeeDistributor({
stETH: locator.lido(),
accounting: address(accounting),
oracle: address(oracle)
});

verifier = new CSVerifier({
withdrawalAddress: locator.withdrawalVault(),
Expand All @@ -88,38 +86,25 @@ contract DeployHoleskyImplementations is DeployHolesky {
JsonObj memory deployJson = Json.newObj();
deployJson.set("CSModuleImpl", address(csmImpl));
deployJson.set("CSAccountingImpl", address(accountingImpl));
// deployJson.set("CSFeeOracleImpl", address(oracle));
// deployJson.set("CSFeeDistributor", address(feeDistributor));
deployJson.set("CSFeeOracleImpl", address(oracleImpl));
deployJson.set("CSFeeDistributorImpl", address(feeDistributorImpl));
deployJson.set("CSVerifier", address(verifier));
deployJson.set("CSEarlyAdoption", address(earlyAdoption));
deployJson.set("HashConsensus", address(hashConsensus));
deployJson.set("git-ref", gitRef);
vm.writeJson(
deployJson.str,
string(
abi.encodePacked(artifactDir, "update-", chainName, ".json")
abi.encodePacked(
artifactDir,
"upgrade-",
chainName,
".json"
)
)
);
}

vm.stopBroadcast();
}

function parseDeploymentConfig() internal {
string memory deployConfig = vm.readFile(
vm.envOr("DEPLOY_CONFIG", string(""))
);
csm = CSModule(vm.parseJsonAddress(deployConfig, ".CSModule"));
earlyAdoption = CSEarlyAdoption(
vm.parseJsonAddress(deployConfig, ".CSEarlyAdoption")
);
accounting = CSAccounting(
vm.parseJsonAddress(deployConfig, ".CSAccounting")
);
oracle = CSFeeOracle(vm.parseJsonAddress(deployConfig, ".CSFeeOracle"));
feeDistributor = CSFeeDistributor(
vm.parseJsonAddress(deployConfig, ".CSFeeDistributor")
);
hashConsensus = HashConsensus(
vm.parseJsonAddress(deployConfig, ".HashConsensus")
);
gateSeal = vm.parseJsonAddress(deployConfig, ".GateSeal");
}
}
46 changes: 46 additions & 0 deletions script/DeployImplementationsHolesky.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

import { DeployBase } from "./DeployBase.s.sol";
import { GIndex } from "../src/lib/GIndex.sol";
import { DeployImplementationsBase } from "./DeployImplementationsBase.s.sol";
import { DeployHolesky } from "./DeployHolesky.s.sol";
import { HashConsensus } from "../src/lib/base-oracle/HashConsensus.sol";
import { CSModule } from "../src/CSModule.sol";
import { CSAccounting } from "../src/CSAccounting.sol";
import { CSFeeDistributor } from "../src/CSFeeDistributor.sol";
import { CSFeeOracle } from "../src/CSFeeOracle.sol";
import { CSVerifier } from "../src/CSVerifier.sol";
import { CSEarlyAdoption } from "../src/CSEarlyAdoption.sol";
import { DeploymentHelpers } from "../test/helpers/Fixtures.sol";

contract DeployImplementationsHolesky is
DeployImplementationsBase,
DeployHolesky,
DeploymentHelpers
{
function deploy(
string memory deploymentConfigPath,
string memory _gitRef
) external {
gitRef = _gitRef;
string memory deploymentConfigContent = vm.readFile(
deploymentConfigPath
);
DeploymentConfig memory deploymentConfig = parseDeploymentConfig(
deploymentConfigContent
);

csm = CSModule(deploymentConfig.csm);
earlyAdoption = CSEarlyAdoption(deploymentConfig.earlyAdoption);
accounting = CSAccounting(deploymentConfig.accounting);
oracle = CSFeeOracle(deploymentConfig.oracle);
feeDistributor = CSFeeDistributor(deploymentConfig.feeDistributor);
hashConsensus = HashConsensus(deploymentConfig.hashConsensus);
gateSeal = deploymentConfig.gateSeal;

_deploy();
}
}
46 changes: 46 additions & 0 deletions script/DeployImplementationsMainnet.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

import { DeployBase } from "./DeployBase.s.sol";
import { GIndex } from "../src/lib/GIndex.sol";
import { DeployImplementationsBase } from "./DeployImplementationsBase.s.sol";
import { DeployMainnet } from "./DeployMainnet.s.sol";
import { HashConsensus } from "../src/lib/base-oracle/HashConsensus.sol";
import { CSModule } from "../src/CSModule.sol";
import { CSAccounting } from "../src/CSAccounting.sol";
import { CSFeeDistributor } from "../src/CSFeeDistributor.sol";
import { CSFeeOracle } from "../src/CSFeeOracle.sol";
import { CSVerifier } from "../src/CSVerifier.sol";
import { CSEarlyAdoption } from "../src/CSEarlyAdoption.sol";
import { DeploymentHelpers } from "../test/helpers/Fixtures.sol";

contract DeployImplementationsMainnet is
DeployImplementationsBase,
DeployMainnet,
DeploymentHelpers
{
function deploy(
string memory deploymentConfigPath,
string memory _gitRef
) external {
gitRef = _gitRef;
string memory deploymentConfigContent = vm.readFile(
deploymentConfigPath
);
DeploymentConfig memory deploymentConfig = parseDeploymentConfig(
deploymentConfigContent
);

csm = CSModule(deploymentConfig.csm);
earlyAdoption = CSEarlyAdoption(deploymentConfig.earlyAdoption);
accounting = CSAccounting(deploymentConfig.accounting);
oracle = CSFeeOracle(deploymentConfig.oracle);
feeDistributor = CSFeeDistributor(deploymentConfig.feeDistributor);
hashConsensus = HashConsensus(deploymentConfig.hashConsensus);
gateSeal = deploymentConfig.gateSeal;

_deploy();
}
}
Loading

0 comments on commit 99eef49

Please sign in to comment.