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

refactor: renaming for lock and fine #363

Merged
merged 7 commits into from
Dec 2, 2024
Merged
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
17 changes: 9 additions & 8 deletions script/DeployBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ struct DeployParams {
// Accounting
uint256 maxCurveLength;
uint256[] bondCurve;
uint256 minBondLockRetentionPeriod;
uint256 maxBondLockRetentionPeriod;
uint256 bondLockRetentionPeriod;
uint256 minBondLockPeriod;
uint256 maxBondLockPeriod;
uint256 bondLockPeriod;
address setResetBondCurveAddress;
address chargePenaltyRecipient;
// Module
bytes32 moduleType;
uint256 minSlashingPenaltyQuotient;
uint256 elRewardsStealingFine;
uint256 elRewardsStealingAdditionalFine;
uint256 maxKeysPerOperatorEA;
uint256 maxKeyRemovalCharge;
uint256 keyRemovalCharge;
Expand Down Expand Up @@ -138,7 +138,8 @@ abstract contract DeployBase is Script {
CSModule csmImpl = new CSModule({
moduleType: config.moduleType,
minSlashingPenaltyQuotient: config.minSlashingPenaltyQuotient,
elRewardsStealingFine: config.elRewardsStealingFine,
elRewardsStealingAdditionalFine: config
.elRewardsStealingAdditionalFine,
maxKeysPerOperatorEA: config.maxKeysPerOperatorEA,
maxKeyRemovalCharge: config.maxKeyRemovalCharge,
lidoLocator: config.lidoLocatorAddress
Expand All @@ -149,8 +150,8 @@ abstract contract DeployBase is Script {
lidoLocator: config.lidoLocatorAddress,
communityStakingModule: address(csm),
maxCurveLength: config.maxCurveLength,
minBondLockRetentionPeriod: config.minBondLockRetentionPeriod,
maxBondLockRetentionPeriod: config.maxBondLockRetentionPeriod
minBondLockPeriod: config.minBondLockPeriod,
maxBondLockPeriod: config.maxBondLockPeriod
});
accounting = CSAccounting(
_deployProxy(config.proxyAdmin, address(accountingImpl))
Expand Down Expand Up @@ -195,7 +196,7 @@ abstract contract DeployBase is Script {
bondCurve: config.bondCurve,
admin: deployer,
_feeDistributor: address(feeDistributor),
bondLockRetentionPeriod: config.bondLockRetentionPeriod,
bondLockPeriod: config.bondLockPeriod,
_chargePenaltyRecipient: config.chargePenaltyRecipient
});

Expand Down
8 changes: 4 additions & 4 deletions script/DeployHolesky.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ contract DeployHolesky is DeployBase {
config.bondCurve[4] = 9 ether;
config.bondCurve[5] = 10.5 ether;

config.minBondLockRetentionPeriod = 0;
config.maxBondLockRetentionPeriod = 365 days;
config.bondLockRetentionPeriod = 8 weeks;
config.minBondLockPeriod = 0;
config.maxBondLockPeriod = 365 days;
config.bondLockPeriod = 8 weeks;
config
.setResetBondCurveAddress = 0xc4DAB3a3ef68C6DFd8614a870D64D475bA44F164; // Dev team EOA
// Module
config.moduleType = "community-onchain-v1";
config.minSlashingPenaltyQuotient = 32;
config.elRewardsStealingFine = 0.1 ether;
config.elRewardsStealingAdditionalFine = 0.1 ether;
config.maxKeysPerOperatorEA = 10;
config.maxKeyRemovalCharge = 0.1 ether;
config.keyRemovalCharge = 0.05 ether;
Expand Down
7 changes: 4 additions & 3 deletions script/DeployImplementationsBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ abstract contract DeployImplementationsBase is DeployBase {
CSModule csmImpl = new CSModule({
moduleType: config.moduleType,
minSlashingPenaltyQuotient: config.minSlashingPenaltyQuotient,
elRewardsStealingFine: config.elRewardsStealingFine,
elRewardsStealingAdditionalFine: config
.elRewardsStealingAdditionalFine,
maxKeysPerOperatorEA: config.maxKeysPerOperatorEA,
maxKeyRemovalCharge: config.maxKeyRemovalCharge,
lidoLocator: config.lidoLocatorAddress
Expand All @@ -49,8 +50,8 @@ abstract contract DeployImplementationsBase is DeployBase {
lidoLocator: config.lidoLocatorAddress,
communityStakingModule: address(csm),
maxCurveLength: config.maxCurveLength,
minBondLockRetentionPeriod: config.minBondLockRetentionPeriod,
maxBondLockRetentionPeriod: config.maxBondLockRetentionPeriod
minBondLockPeriod: config.minBondLockPeriod,
maxBondLockPeriod: config.maxBondLockPeriod
});

CSFeeOracle oracleImpl = new CSFeeOracle({
Expand Down
8 changes: 4 additions & 4 deletions script/DeployMainnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ contract DeployMainnet is DeployBase {
config.bondCurve[0] = 2.4 ether;
config.bondCurve[1] = 3.7 ether;

config.minBondLockRetentionPeriod = 4 weeks;
config.maxBondLockRetentionPeriod = 365 days;
config.bondLockRetentionPeriod = 8 weeks;
config.minBondLockPeriod = 4 weeks;
config.maxBondLockPeriod = 365 days;
config.bondLockPeriod = 8 weeks;
config
.setResetBondCurveAddress = 0xC52fC3081123073078698F1EAc2f1Dc7Bd71880f; // CSM Committee MS
config
.chargePenaltyRecipient = 0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c; // locator.treasury()
// Module
config.moduleType = "community-onchain-v1"; // Just a unique type name to be used by the off-chain tooling
config.minSlashingPenaltyQuotient = 32;
config.elRewardsStealingFine = 0.1 ether;
config.elRewardsStealingAdditionalFine = 0.1 ether;
config.maxKeysPerOperatorEA = 12; // 12 EA vals will result in approx 16 ETH worth of bond
config.maxKeyRemovalCharge = 0.1 ether;
config.keyRemovalCharge = 0.05 ether;
Expand Down
2 changes: 1 addition & 1 deletion script/fork-helpers/NodeOperators.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ contract NodeOperators is
uint256 lockedAfter = accounting.getActualLockedBond(noId);
assertEq(
lockedAfter,
lockedBefore + amount + csm.EL_REWARDS_STEALING_FINE()
lockedBefore + amount + csm.EL_REWARDS_STEALING_ADDITIONAL_FINE()
);
}

Expand Down
27 changes: 18 additions & 9 deletions src/CSAccounting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ contract CSAccounting is
/// @param lidoLocator Lido locator contract address
/// @param communityStakingModule Community Staking Module contract address
/// @param maxCurveLength Max number of the points in the bond curves
/// @param minBondLockRetentionPeriod Min time in seconds for the bondLock retention period
/// @param maxBondLockRetentionPeriod Max time in seconds for the bondLock retention period
/// @param minBondLockPeriod Min time in seconds for the bondLock period
/// @param maxBondLockPeriod Max time in seconds for the bondLock period
constructor(
address lidoLocator,
address communityStakingModule,
uint256 maxCurveLength,
uint256 minBondLockRetentionPeriod,
uint256 maxBondLockRetentionPeriod
uint256 minBondLockPeriod,
uint256 maxBondLockPeriod
)
CSBondCore(lidoLocator)
CSBondCurve(maxCurveLength)
CSBondLock(minBondLockRetentionPeriod, maxBondLockRetentionPeriod)
CSBondLock(minBondLockPeriod, maxBondLockPeriod)
{
if (communityStakingModule == address(0)) {
revert ZeroModuleAddress();
Expand All @@ -87,18 +87,18 @@ contract CSAccounting is
/// @param bondCurve Initial bond curve
/// @param admin Admin role member address
/// @param _feeDistributor Fee Distributor contract address
/// @param bondLockRetentionPeriod Retention period for locked bond in seconds
/// @param bondLockPeriod Bond lock period in seconds
/// @param _chargePenaltyRecipient Recipient of the charge penalty type
function initialize(
uint256[] calldata bondCurve,
address admin,
address _feeDistributor,
uint256 bondLockRetentionPeriod,
uint256 bondLockPeriod,
address _chargePenaltyRecipient
) external initializer {
__AccessControlEnumerable_init();
__CSBondCurve_init(bondCurve);
__CSBondLock_init(bondLockRetentionPeriod);
__CSBondLock_init(bondLockPeriod);

if (admin == address(0)) {
revert ZeroAdminAddress();
Expand Down Expand Up @@ -141,12 +141,21 @@ contract CSAccounting is
_setChargePenaltyRecipient(_chargePenaltyRecipient);
}

/// @dev DEPRECATED. Use `setLockedBondPeriod` instead
/// @notice Set bond lock retention period
/// @param retention Period in seconds to retain bond lock
function setLockedBondRetentionPeriod(
uint256 retention
) external onlyRole(ACCOUNTING_MANAGER_ROLE) {
CSBondLock._setBondLockRetentionPeriod(retention);
CSBondLock._setBondLockPeriod(retention);
}

/// @notice Set bond lock period
/// @param period Period in seconds to retain bond lock
function setLockedBondPeriod(
uint256 period
) external onlyRole(ACCOUNTING_MANAGER_ROLE) {
CSBondLock._setBondLockPeriod(period);
}

/// @notice Add a new bond curve
Expand Down
16 changes: 11 additions & 5 deletions src/CSModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract CSModule is
uint8 private constant FORCED_TARGET_LIMIT_MODE_ID = 2;

uint256 public immutable INITIAL_SLASHING_PENALTY;
uint256 public immutable EL_REWARDS_STEALING_FINE;
uint256 public immutable EL_REWARDS_STEALING_ADDITIONAL_FINE;
uint256
public immutable MAX_SIGNING_KEYS_PER_OPERATOR_BEFORE_PUBLIC_RELEASE;
uint256 public immutable MAX_KEY_REMOVAL_CHARGE;
Expand Down Expand Up @@ -172,7 +172,7 @@ contract CSModule is
constructor(
bytes32 moduleType,
uint256 minSlashingPenaltyQuotient,
uint256 elRewardsStealingFine,
uint256 elRewardsStealingAdditionalFine,
uint256 maxKeysPerOperatorEA,
uint256 maxKeyRemovalCharge,
address lidoLocator
Expand All @@ -181,7 +181,7 @@ contract CSModule is

MODULE_TYPE = moduleType;
INITIAL_SLASHING_PENALTY = DEPOSIT_SIZE / minSlashingPenaltyQuotient;
EL_REWARDS_STEALING_FINE = elRewardsStealingFine;
EL_REWARDS_STEALING_ADDITIONAL_FINE = elRewardsStealingAdditionalFine;
MAX_SIGNING_KEYS_PER_OPERATOR_BEFORE_PUBLIC_RELEASE = maxKeysPerOperatorEA;
MAX_KEY_REMOVAL_CHARGE = maxKeyRemovalCharge;
LIDO_LOCATOR = ILidoLocator(lidoLocator);
Expand Down Expand Up @@ -1003,7 +1003,7 @@ contract CSModule is
}

/// @notice Report EL rewards stealing for the given Node Operator
/// @notice The amount equal to the stolen funds plus EL stealing fine will be locked
/// @notice The final locked amount will be equal to the stolen funds plus EL stealing additional fine
/// @param nodeOperatorId ID of the Node Operator
/// @param blockHash Execution layer block hash of the proposed block with EL rewards stealing
/// @param amount Amount of stolen EL rewards in ETH
Expand All @@ -1016,7 +1016,7 @@ contract CSModule is
if (amount == 0) revert InvalidAmount();
accounting.lockBondETH(
nodeOperatorId,
amount + EL_REWARDS_STEALING_FINE
amount + EL_REWARDS_STEALING_ADDITIONAL_FINE
);
emit ELRewardsStealingPenaltyReported(
nodeOperatorId,
Expand Down Expand Up @@ -1359,6 +1359,12 @@ contract CSModule is
return MODULE_TYPE;
}

/// @dev DEPRECATED. Use `EL_REWARDS_STEALING_ADDITIONAL_FINE` instead
// solhint-disable func-name-mixedcase
function EL_REWARDS_STEALING_FINE() external view returns (uint256) {
return EL_REWARDS_STEALING_ADDITIONAL_FINE;
}

/// @notice Get staking module summary
function getStakingModuleSummary()
external
Expand Down
Loading
Loading