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

Gates contracts #377

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
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
44 changes: 24 additions & 20 deletions script/DeployBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ 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 { PermissionlessGate } from "../src/PermissionlessGate.sol";
import { VettedGate } from "../src/VettedGate.sol";

import { ILidoLocator } from "../src/interfaces/ILidoLocator.sol";
import { IGateSealFactory } from "../src/interfaces/IGateSealFactory.sol";
Expand Down Expand Up @@ -59,9 +60,9 @@ struct DeployParams {
uint256 maxKeyRemovalCharge;
uint256 keyRemovalCharge;
address elRewardsStealingReporter;
// EarlyAdoption
bytes32 earlyAdoptionTreeRoot;
uint256[] earlyAdoptionBondCurve;
// VettedGate
bytes32 vettedGateTreeRoot;
uint256[] vettedGateBondCurve;
// GateSeal
address gateSealFactory;
address sealingCommittee;
Expand All @@ -86,7 +87,8 @@ abstract contract DeployBase is Script {
CSFeeOracle public oracle;
CSFeeDistributor public feeDistributor;
CSVerifier public verifier;
CSEarlyAdoption public earlyAdoption;
PermissionlessGate public permissionlessGate;
VettedGate public vettedGate;
HashConsensus public hashConsensus;

error ChainIdMismatch(uint256 actual, uint256 expected);
Expand Down Expand Up @@ -205,26 +207,26 @@ abstract contract DeployBase is Script {
accounting.MANAGE_BOND_CURVES_ROLE(),
address(deployer)
);
uint256 eaCurveId = accounting.addBondCurve(
config.earlyAdoptionBondCurve
uint256 identifiedSolosCurve = accounting.addBondCurve(
config.vettedGateBondCurve
);
accounting.revokeRole(
accounting.MANAGE_BOND_CURVES_ROLE(),
address(deployer)
);

earlyAdoption = new CSEarlyAdoption({
treeRoot: config.earlyAdoptionTreeRoot,
curveId: eaCurveId,
module: address(csm)
});

csm.initialize({
_accounting: address(accounting),
_earlyAdoption: address(earlyAdoption),
_keyRemovalCharge: config.keyRemovalCharge,
admin: deployer
});
permissionlessGate = new PermissionlessGate(address(csm));
vettedGate = new VettedGate({
_treeRoot: config.vettedGateTreeRoot,
curveId: identifiedSolosCurve,
csm: address(csm),
admin: config.aragonAgent
});

feeDistributor.initialize({ admin: address(deployer) });

Expand Down Expand Up @@ -271,16 +273,17 @@ abstract contract DeployBase is Script {
oracle.grantRole(oracle.PAUSE_ROLE(), gateSeal);
accounting.grantRole(accounting.PAUSE_ROLE(), gateSeal);
verifier.grantRole(verifier.PAUSE_ROLE(), gateSeal);

accounting.grantRole(
accounting.SET_BOND_CURVE_ROLE(),
config.setResetBondCurveAddress
);
accounting.grantRole(
accounting.RESET_BOND_CURVE_ROLE(),
config.setResetBondCurveAddress
);

csm.grantRole(
csm.CREATE_NODE_OPERATOR_ROLE(),
address(permissionlessGate)
);
csm.grantRole(csm.CREATE_NODE_OPERATOR_ROLE(), address(vettedGate));
csm.grantRole(csm.SET_BOND_CURVE_ROLE(), address(vettedGate));
csm.grantRole(
csm.REPORT_EL_REWARDS_STEALING_PENALTY_ROLE(),
config.elRewardsStealingReporter
Expand Down Expand Up @@ -334,8 +337,9 @@ abstract contract DeployBase is Script {

JsonObj memory deployJson = Json.newObj();
deployJson.set("ChainId", chainId);
deployJson.set("PermissionlessGate", address(permissionlessGate));
deployJson.set("VettedGate", address(vettedGate));
deployJson.set("CSModule", address(csm));
deployJson.set("CSEarlyAdoption", address(earlyAdoption));
deployJson.set("CSAccounting", address(accounting));
deployJson.set("CSFeeOracle", address(oracle));
deployJson.set("CSFeeDistributor", address(feeDistributor));
Expand Down
18 changes: 9 additions & 9 deletions script/DeployHolesky.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ contract DeployHolesky is DeployBase {
.elRewardsStealingReporter = 0xc4DAB3a3ef68C6DFd8614a870D64D475bA44F164; // Dev team EOA
config
.chargePenaltyRecipient = 0xE92329EC7ddB11D25e25b3c21eeBf11f15eB325d; // locator.treasury()
// EarlyAdoption
// VettedGate
config
.earlyAdoptionTreeRoot = 0xc9a9c1576cf4f3213ad9075b72a1f1b147914a252ad927fa4ca3460ff0723ca9;
config.earlyAdoptionBondCurve = new uint256[](6);
.vettedGateTreeRoot = 0xc9a9c1576cf4f3213ad9075b72a1f1b147914a252ad927fa4ca3460ff0723ca9;
config.vettedGateBondCurve = 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;
config.vettedGateBondCurve[0] = 1.5 ether;
config.vettedGateBondCurve[1] = 3.4 ether;
config.vettedGateBondCurve[2] = 5.2 ether;
config.vettedGateBondCurve[3] = 6.9 ether;
config.vettedGateBondCurve[4] = 8.5 ether;
config.vettedGateBondCurve[5] = 10 ether;
// GateSeal
config.gateSealFactory = 0x1134F7077055b0B3559BE52AfeF9aA22A0E1eEC2;
config.sealingCommittee = 0xc4DAB3a3ef68C6DFd8614a870D64D475bA44F164; // Dev team EOA
Expand Down
16 changes: 14 additions & 2 deletions script/DeployImplementationsBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ 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 { PermissionlessGate } from "../src/PermissionlessGate.sol";
import { VettedGate } from "../src/VettedGate.sol";
import { ICSEarlyAdoption } from "../src/interfaces/ICSEarlyAdoption.sol";

import { JsonObj, Json } from "./utils/Json.sol";
import { GIndex } from "../src/lib/GIndex.sol";
Expand All @@ -21,6 +23,7 @@ import { DeployBase } from "./DeployBase.s.sol";

abstract contract DeployImplementationsBase is DeployBase {
address gateSeal;
address earlyAdoption;
dgusakov marked this conversation as resolved.
Show resolved Hide resolved

function _deploy() internal {
if (chainId != block.chainid) {
Expand Down Expand Up @@ -54,6 +57,14 @@ abstract contract DeployImplementationsBase is DeployBase {
maxBondLockPeriod: config.maxBondLockPeriod
});

permissionlessGate = new PermissionlessGate(address(csm));
vettedGate = new VettedGate({
_treeRoot: config.vettedGateTreeRoot,
curveId: ICSEarlyAdoption(earlyAdoption).CURVE_ID(),
csm: address(csm),
admin: config.aragonAgent
});

CSFeeOracle oracleImpl = new CSFeeOracle({
secondsPerSlot: config.secondsPerSlot,
genesisTime: config.clGenesisTime
Expand Down Expand Up @@ -99,12 +110,13 @@ abstract contract DeployImplementationsBase is DeployBase {
verifier.revokeRole(verifier.DEFAULT_ADMIN_ROLE(), deployer);

JsonObj memory deployJson = Json.newObj();
deployJson.set("PermissionlessGate", address(permissionlessGate));
deployJson.set("VettedGate", address(vettedGate));
dgusakov marked this conversation as resolved.
Show resolved Hide resolved
deployJson.set("CSModuleImpl", address(csmImpl));
deployJson.set("CSAccountingImpl", address(accountingImpl));
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("GateSeal", address(gateSeal));
deployJson.set("git-ref", gitRef);
Expand Down
4 changes: 1 addition & 3 deletions script/DeployImplementationsHolesky.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ 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
Expand All @@ -34,12 +33,11 @@ contract DeployImplementationsHolesky is
);

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

_deploy();
}
Expand Down
4 changes: 1 addition & 3 deletions script/DeployImplementationsMainnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ 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
Expand All @@ -34,12 +33,11 @@ contract DeployImplementationsMainnet is
);

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

_deploy();
}
Expand Down
10 changes: 5 additions & 5 deletions script/DeployMainnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ contract DeployMainnet is DeployBase {
config.keyRemovalCharge = 0.05 ether;
config
.elRewardsStealingReporter = 0xC52fC3081123073078698F1EAc2f1Dc7Bd71880f; // CSM Committee MS
// EarlyAdoption
// VettedGate
config
.earlyAdoptionTreeRoot = 0x359e02c5c065c682839661c9bdfaf38db472629bf5f7a7e8f0261b31dc9332c2; // See the first value in artifacts/mainnet/early-adoption/merkle-tree.json
config.earlyAdoptionBondCurve = new uint256[](2);
.vettedGateTreeRoot = 0x359e02c5c065c682839661c9bdfaf38db472629bf5f7a7e8f0261b31dc9332c2; // See the first value in artifacts/mainnet/early-adoption/merkle-tree.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to update the root before deployment to avoid double claming

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing to do right now in the code here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment pls

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is room for frontrunning anyway. if somebody decides to claim EA before CSM plug-in the gate for v2

config.vettedGateBondCurve = new uint256[](2);
// 1.5 -> 1.3
config.earlyAdoptionBondCurve[0] = 1.5 ether;
config.earlyAdoptionBondCurve[1] = 2.8 ether;
config.vettedGateBondCurve[0] = 1.5 ether;
config.vettedGateBondCurve[1] = 2.8 ether;

// GateSeal
config.gateSealFactory = 0x6C82877cAC5a7A739f16Ca0A89c0A328B8764A24;
Expand Down
1 change: 1 addition & 0 deletions script/fork-helpers/NodeOperators.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ contract NodeOperators is
bytes memory keys = randomBytes(48 * keysCount);
bytes memory signatures = randomBytes(96 * keysCount);
csm.addValidatorKeysETH{ value: amount }(
msg.sender,
noId,
keysCount,
keys,
Expand Down
16 changes: 16 additions & 0 deletions script/fork-helpers/SimulateVote.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ contract SimulateVote is Script, DeploymentFixtures, ForkHelpersCommon {
oracle = CSFeeOracle(deploymentConfig.oracle);

vm.startBroadcast(admin);

accounting.revokeRole(accounting.SET_BOND_CURVE_ROLE(), address(csm));
accounting.revokeRole(
accounting.SET_BOND_CURVE_ROLE(),
accounting.getRoleMember(accounting.SET_BOND_CURVE_ROLE(), 0)
);
csm.grantRole(
csm.CREATE_NODE_OPERATOR_ROLE(),
upgradeConfig.permissionlessGate
);
csm.grantRole(
csm.CREATE_NODE_OPERATOR_ROLE(),
upgradeConfig.vettedGate
);
csm.grantRole(csm.SET_BOND_CURVE_ROLE(), upgradeConfig.vettedGate);

csm.revokeRole(csm.VERIFIER_ROLE(), address(deploymentConfig.verifier));
csm.grantRole(csm.VERIFIER_ROLE(), address(upgradeConfig.verifier));

Expand Down
5 changes: 3 additions & 2 deletions src/CSAccounting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ contract CSAccounting is
bytes32 public constant RESUME_ROLE = keccak256("RESUME_ROLE");
bytes32 public constant MANAGE_BOND_CURVES_ROLE =
keccak256("MANAGE_BOND_CURVES_ROLE");

/// @dev Deprecated. Use setBondCurve with the corresponding role on the CSM contract instead
bytes32 public constant SET_BOND_CURVE_ROLE =
keccak256("SET_BOND_CURVE_ROLE");
bytes32 public constant RESET_BOND_CURVE_ROLE =
Expand Down Expand Up @@ -96,7 +98,6 @@ contract CSAccounting is
}

_grantRole(DEFAULT_ADMIN_ROLE, admin);
_grantRole(SET_BOND_CURVE_ROLE, address(CSM));
_grantRole(RESET_BOND_CURVE_ROLE, address(CSM));

feeDistributor = ICSFeeDistributor(_feeDistributor);
Expand Down Expand Up @@ -158,7 +159,7 @@ contract CSAccounting is
function setBondCurve(
uint256 nodeOperatorId,
uint256 curveId
) external onlyRole(SET_BOND_CURVE_ROLE) {
) external onlyCSM {
_onlyExistingNodeOperator(nodeOperatorId);
CSBondCurve._setBondCurve(nodeOperatorId, curveId);
}
Expand Down
55 changes: 0 additions & 55 deletions src/CSEarlyAdoption.sol

This file was deleted.

Loading
Loading