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

feat: local devnet integration #376

Open
wants to merge 6 commits into
base: main
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
16 changes: 15 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ deploy_script_name := if chain == "mainnet" {
"DeployMainnet"
} else if chain == "holesky" {
"DeployHolesky"
} else if chain == "local-devnet" {
"DeployLocalDevNet"
} else {
error("Unsupported chain " + chain)
}
Expand All @@ -14,6 +16,8 @@ deploy_implementations_script_name := if chain == "mainnet" {
"undefined"
} else if chain == "holesky" {
"DeployHoleskyImplementations"
} else if chain == "local-devnet" {
"undefined"
} else {
error("Unsupported chain " + chain)
}
Expand Down Expand Up @@ -133,9 +137,19 @@ deploy-prod *args:
cp ./broadcast/{{deploy_script_name}}.s.sol/`cast chain-id --rpc-url=$RPC_URL`/run-latest.json \
./artifacts/latest/transactions.json

deploy-local-devnet *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-devnet {{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}}
just _deploy-prod --broadcast {{args}}

_deploy-prod-devnet *args:
just _deploy-prod --broadcast {{args}}

deploy-prod-dry *args:
just _deploy-prod {{args}}
Expand Down
14 changes: 10 additions & 4 deletions script/DeployBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct DeployParams {
address sealingCommittee;
uint256 sealDuration;
uint256 sealExpiryTimestamp;
bool gateSealEnabled;
// Testnet stuff
address secondAdminAddress;
}
Expand Down Expand Up @@ -256,11 +257,16 @@ abstract contract DeployBase is Script {
_avgPerfLeewayBP: config.avgPerfLeewayBP
});

address gateSeal = _deployGateSeal();
address gateSeal = address(0);

if (config.gateSealEnabled) {
gateSeal = _deployGateSeal();

csm.grantRole(csm.PAUSE_ROLE(), gateSeal);
oracle.grantRole(oracle.PAUSE_ROLE(), gateSeal);
accounting.grantRole(accounting.PAUSE_ROLE(), gateSeal);
}

csm.grantRole(csm.PAUSE_ROLE(), gateSeal);
oracle.grantRole(oracle.PAUSE_ROLE(), gateSeal);
accounting.grantRole(accounting.PAUSE_ROLE(), gateSeal);
accounting.grantRole(
accounting.SET_BOND_CURVE_ROLE(),
config.setResetBondCurveAddress
Expand Down
50 changes: 47 additions & 3 deletions script/DeployCSVerifierElectra.s.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2024 Lido <info@lido.fi>
// SPDX-License-Identifier: GPL-3.0

// Usage: forge script ./script/DeployCSVerifierElectra.s.sol:DeployCSVerifier[Holesky|Mainnet]
// Usage: forge script ./script/DeployCSVerifierElectra.s.sol:DeployCSVerifier[Holesky|Mainnet|DevNet]

pragma solidity 0.8.24;

Expand All @@ -11,6 +11,7 @@ import { console2 as console } from "forge-std/console2.sol";
import { CSVerifier } from "../src/CSVerifier.sol";
import { GIndex } from "../src/lib/GIndex.sol";
import { Slot } from "../src/lib/Types.sol";
import { JsonObj, Json } from "./utils/Json.sol";

struct Config {
address withdrawalVault;
Expand All @@ -24,6 +25,7 @@ struct Config {
Slot firstSupportedSlot;
Slot pivotSlot;
uint64 slotsPerEpoch;
string chainName;
}

// Check the constants below via `yarn run gindex`.
Expand All @@ -50,8 +52,18 @@ GIndex constant FIRST_VALIDATOR_ELECTRA = GIndex.wrap(

abstract contract DeployCSVerifier is Script {
Config internal config;
string internal artifactDir;
address internal deployer;
uint256 internal pk;

function run() public {
artifactDir = string("./artifacts/latest/");
pk = vm.envUint("DEPLOYER_PRIVATE_KEY");
deployer = vm.addr(pk);
vm.label(deployer, "DEPLOYER");

vm.startBroadcast(pk);

CSVerifier verifier = new CSVerifier({
withdrawalAddress: config.withdrawalVault,
module: config.module,
Expand All @@ -65,8 +77,19 @@ abstract contract DeployCSVerifier is Script {
firstSupportedSlot: config.firstSupportedSlot,
pivotSlot: config.pivotSlot
});
JsonObj memory deployJson = Json.newObj();
deployJson.set("CSVerifier", address(verifier));
vm.writeJson(deployJson.str, _deployJsonFilename());
vm.stopBroadcast();
console.log("CSVerifier deployed at:", address(verifier));
}

function _deployJsonFilename() internal view returns (string memory) {
return
string(
abi.encodePacked(artifactDir, "deploy-verifier-", config.chainName, ".json")
);
}
}

contract DeployCSVerifierHolesky is DeployCSVerifier {
Expand All @@ -82,7 +105,8 @@ contract DeployCSVerifierHolesky is DeployCSVerifier {
gIHistoricalSummariesPrev: HISTORICAL_SUMMARIES_DENEB,
gIHistoricalSummariesCurr: HISTORICAL_SUMMARIES_ELECTRA,
firstSupportedSlot: Slot.wrap(950272), // 269_568 * 32, @see https://github.com/eth-clients/mainnet/blob/main/metadata/config.yaml#L52
pivotSlot: Slot.wrap(0) // TODO: Update with Electra slot.
pivotSlot: Slot.wrap(0), // TODO: Update with Electra slot.
chainName: "holesky"
});
}
}
Expand All @@ -100,7 +124,27 @@ contract DeployCSVerifierMainnet is DeployCSVerifier {
gIHistoricalSummariesPrev: HISTORICAL_SUMMARIES_DENEB,
gIHistoricalSummariesCurr: HISTORICAL_SUMMARIES_ELECTRA,
firstSupportedSlot: Slot.wrap(8626176), // 29_696 * 32, @see https://github.com/eth-clients/holesky/blob/main/metadata/config.yaml#L38
pivotSlot: Slot.wrap(0) // TODO: Update with Electra slot.
pivotSlot: Slot.wrap(0), // TODO: Update with Electra slot.
chainName: "mainnet"
});
}
}

contract DeployCSVerifierDevNet is DeployCSVerifier {
constructor() {
config = Config({
withdrawalVault: vm.envAddress("CSM_WITHDRAWAL_VAULT"),
module: vm.envAddress("CSM_MODULE"),
slotsPerEpoch: uint64(vm.envUint("DEVNET_SLOTS_PER_EPOCH")),
gIFirstWithdrawalPrev: FIRST_WITHDRAWAL_DENEB,
gIFirstWithdrawalCurr: FIRST_WITHDRAWAL_ELECTRA,
gIFirstValidatorPrev: FIRST_VALIDATOR_DENEB,
gIFirstValidatorCurr: FIRST_VALIDATOR_ELECTRA,
gIHistoricalSummariesPrev: HISTORICAL_SUMMARIES_DENEB,
gIHistoricalSummariesCurr: HISTORICAL_SUMMARIES_ELECTRA,
firstSupportedSlot: Slot.wrap(0),
pivotSlot: Slot.wrap(uint64(vm.envUint("DEVNET_ELECTRA_EPOCH")) * 32),
chainName: "devnet"
});
}
}
2 changes: 2 additions & 0 deletions script/DeployHolesky.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ contract DeployHolesky is DeployBase {
config.earlyAdoptionBondCurve[4] = 8.5 ether;
config.earlyAdoptionBondCurve[5] = 10 ether;
// GateSeal
config.gateSealEnabled = true;

config.gateSealFactory = 0x1134F7077055b0B3559BE52AfeF9aA22A0E1eEC2;
config.sealingCommittee = 0xc4DAB3a3ef68C6DFd8614a870D64D475bA44F164; // Dev team EOA
config.sealDuration = 6 days;
Expand Down
89 changes: 89 additions & 0 deletions script/DeployLocalDevNet.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// SPDX-FileCopyrightText: 2024 Lido <info@lido.fi>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.24;

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

contract DeployLocalDevNet is DeployBase {
constructor() DeployBase("local-devnet", 32382) {
// Lido addresses
config.lidoLocatorAddress = vm.envAddress("CSM_LOCATOR_ADDRESS");
config.aragonAgent = vm.envAddress("CSM_ARAGON_AGENT_ADDRESS");
config
.easyTrackEVMScriptExecutor = vm.envAddress("EVM_SCRIPT_EXECUTOR_ADDRESS");
config.proxyAdmin = vm.envAddress("CSM_FIRST_ADMIN_ADDRESS"); // Dev team EOA

// Oracle
config.secondsPerSlot = 12;
config.slotsPerEpoch = vm.envUint("DEVNET_SLOTS_PER_EPOCH");
config.clGenesisTime = vm.envUint("DEVNET_GENESIS_TIME");
config.oracleReportEpochsPerFrame = 50;
config.fastLaneLengthSlots = 0;
config.consensusVersion = 1;
config.avgPerfLeewayBP = 500;
config.oracleMembers = new address[](3);
config.oracleMembers[0] = vm.envAddress("CSM_ORACLE_1_ADDRESS");
config.oracleMembers[1] = vm.envAddress("CSM_ORACLE_2_ADDRESS");
config.oracleMembers[2] = vm.envAddress("CSM_ORACLE_3_ADDRESS");
config.hashConsensusQuorum = 3;
// Verifier
// NOTE: Deneb fork gIndexes. Should be updated according to `config.verifierSupportedEpoch` fork epoch if needed
config.gIFirstWithdrawal = GIndex.wrap(
0x0000000000000000000000000000000000000000000000000000000000e1c004
);
config.gIFirstValidator = GIndex.wrap(
0x0000000000000000000000000000000000000000000000000056000000000028
);
config.gIHistoricalSummaries = GIndex.wrap(
0x0000000000000000000000000000000000000000000000000000000000003b00
);

config.verifierSupportedEpoch = vm.envUint("DEVNET_ELECTRA_EPOCH");
// Accounting
config.maxCurveLength = 10;
config.bondCurve = new uint256[](6);
// 2 -> 1.9 -> 1.8 -> 1.7 -> 1.6 -> 1.5
config.bondCurve[0] = 2 ether;
config.bondCurve[1] = 3.9 ether;
config.bondCurve[2] = 5.7 ether;
config.bondCurve[3] = 7.4 ether;
config.bondCurve[4] = 9 ether;
config.bondCurve[5] = 10.5 ether;

config
.setResetBondCurveAddress = vm.envAddress("CSM_FIRST_ADMIN_ADDRESS"); // Dev team EOA
// Module
config.moduleType = "community-onchain-v1";
config.minSlashingPenaltyQuotient = 32;
config.maxKeysPerOperatorEA = 10;
config.maxKeyRemovalCharge = 0.1 ether;
config.keyRemovalCharge = 0.05 ether;
config
.elRewardsStealingReporter = vm.envAddress("CSM_FIRST_ADMIN_ADDRESS"); // Dev team EOA
config
.chargePenaltyRecipient = vm.envAddress("CSM_LOCATOR_TREASURY_ADDRESS"); // locator.treasury()
// EarlyAdoption
config
.earlyAdoptionTreeRoot = 0xc9a9c1576cf4f3213ad9075b72a1f1b147914a252ad927fa4ca3460ff0723ca9;
config.earlyAdoptionBondCurve = new uint256[](6);
// 1.5 -> 1.9 -> 1.8 -> 1.7 -> 1.6 -> 1.5
config.earlyAdoptionBondCurve[0] = 1.5 ether;
config.earlyAdoptionBondCurve[1] = 3.4 ether;
config.earlyAdoptionBondCurve[2] = 5.2 ether;
config.earlyAdoptionBondCurve[3] = 6.9 ether;
config.earlyAdoptionBondCurve[4] = 8.5 ether;
config.earlyAdoptionBondCurve[5] = 10 ether;
// GateSeal
config.gateSealEnabled = false;

config.gateSealFactory = 0x1134F7077055b0B3559BE52AfeF9aA22A0E1eEC2;
config.sealingCommittee = vm.envAddress("CSM_FIRST_ADMIN_ADDRESS"); // Dev team EOA
config.sealDuration = 6 days;
config.sealExpiryTimestamp = block.timestamp + 365 days;

config.secondAdminAddress = vm.envAddress("CSM_FIRST_ADMIN_ADDRESS"); // Dev team EOA
_setUp();
}
}
2 changes: 2 additions & 0 deletions script/DeployMainnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ contract DeployMainnet is DeployBase {
config.earlyAdoptionBondCurve[1] = 2.8 ether;

// GateSeal
config.gateSealEnabled = true;

config.gateSealFactory = 0x6C82877cAC5a7A739f16Ca0A89c0A328B8764A24;
config.sealingCommittee = 0xC52fC3081123073078698F1EAc2f1Dc7Bd71880f; // CSM Committee MS
config.sealDuration = 6 days;
Expand Down
Loading