From d9435e5892f2d324b4dfe3f7a36e5a16615a7a1c Mon Sep 17 00:00:00 2001 From: Vladimir Gorkavenko <32727352+vgorkavenko@users.noreply.github.com> Date: Mon, 2 Dec 2024 18:02:11 +0800 Subject: [PATCH] refactor: renaming for lock and fine (#363) --- script/DeployBase.s.sol | 17 ++-- script/DeployHolesky.s.sol | 8 +- script/DeployImplementationsBase.s.sol | 7 +- script/DeployMainnet.s.sol | 8 +- script/fork-helpers/NodeOperators.s.sol | 2 +- src/CSAccounting.sol | 27 ++++--- src/CSModule.sol | 16 ++-- src/abstract/CSBondLock.sol | 96 +++++++++++++---------- src/interfaces/ICSBondLock.sol | 9 ++- test/CSAccounting.t.sol | 30 +++---- test/CSBondLock.t.sol | 89 ++++++++++----------- test/CSModule.t.sol | 83 ++++++++++---------- test/fork/deployment/PostDeployment.t.sol | 19 ++--- test/fork/deployment/Upgradability.sol | 18 ++--- test/fork/integration/Penalty.t.sol | 2 +- 15 files changed, 228 insertions(+), 203 deletions(-) diff --git a/script/DeployBase.s.sol b/script/DeployBase.s.sol index c11d95bd..27e47c9b 100644 --- a/script/DeployBase.s.sol +++ b/script/DeployBase.s.sol @@ -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; @@ -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 @@ -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)) @@ -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 }); diff --git a/script/DeployHolesky.s.sol b/script/DeployHolesky.s.sol index 82d16c48..fd6d6ef7 100644 --- a/script/DeployHolesky.s.sol +++ b/script/DeployHolesky.s.sol @@ -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; diff --git a/script/DeployImplementationsBase.s.sol b/script/DeployImplementationsBase.s.sol index a2e6aa79..642a3be2 100644 --- a/script/DeployImplementationsBase.s.sol +++ b/script/DeployImplementationsBase.s.sol @@ -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 @@ -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({ diff --git a/script/DeployMainnet.s.sol b/script/DeployMainnet.s.sol index 0c29e194..49dbe3d6 100644 --- a/script/DeployMainnet.s.sol +++ b/script/DeployMainnet.s.sol @@ -55,9 +55,9 @@ 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 @@ -65,7 +65,7 @@ contract DeployMainnet is DeployBase { // 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; diff --git a/script/fork-helpers/NodeOperators.s.sol b/script/fork-helpers/NodeOperators.s.sol index 39f7e074..a03230af 100644 --- a/script/fork-helpers/NodeOperators.s.sol +++ b/script/fork-helpers/NodeOperators.s.sol @@ -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() ); } diff --git a/src/CSAccounting.sol b/src/CSAccounting.sol index 1ad606e2..ff8ea5d8 100644 --- a/src/CSAccounting.sol +++ b/src/CSAccounting.sol @@ -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(); @@ -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(); @@ -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 diff --git a/src/CSModule.sol b/src/CSModule.sol index b84b89c7..79e1feb9 100644 --- a/src/CSModule.sol +++ b/src/CSModule.sol @@ -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; @@ -172,7 +172,7 @@ contract CSModule is constructor( bytes32 moduleType, uint256 minSlashingPenaltyQuotient, - uint256 elRewardsStealingFine, + uint256 elRewardsStealingAdditionalFine, uint256 maxKeysPerOperatorEA, uint256 maxKeyRemovalCharge, address lidoLocator @@ -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); @@ -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 @@ -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, @@ -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 diff --git a/src/abstract/CSBondLock.sol b/src/abstract/CSBondLock.sol index a04d9086..3ab751f3 100644 --- a/src/abstract/CSBondLock.sol +++ b/src/abstract/CSBondLock.sol @@ -14,8 +14,8 @@ import { ICSBondLock } from "../interfaces/ICSBondLock.sol"; /// After that period, the lock is removed, and the bond amount is considered unlocked. /// /// The contract contains: -/// - set default bond lock retention period -/// - get default bond lock retention period +/// - set default bond lock period +/// - get default bond lock period /// - lock bond /// - get locked bond info /// - get actual locked bond amount @@ -31,9 +31,9 @@ abstract contract CSBondLock is ICSBondLock, Initializable { /// @custom:storage-location erc7201:CSAccounting.CSBondLock struct CSBondLockStorage { - /// @dev Default bond lock retention period for all locks + /// @dev Default bond lock period for all locks /// After this period the bond lock is removed and no longer valid - uint256 bondLockRetentionPeriod; + uint256 bondLockPeriod; /// @dev Mapping of the Node Operator id to the bond lock mapping(uint256 nodeOperatorId => BondLock) bondLock; } @@ -42,40 +42,56 @@ abstract contract CSBondLock is ICSBondLock, Initializable { bytes32 private constant CS_BOND_LOCK_STORAGE_LOCATION = 0x78c5a36767279da056404c09083fca30cf3ea61c442cfaba6669f76a37393f00; - uint256 public immutable MIN_BOND_LOCK_RETENTION_PERIOD; - uint256 public immutable MAX_BOND_LOCK_RETENTION_PERIOD; + uint256 public immutable MIN_BOND_LOCK_PERIOD; + uint256 public immutable MAX_BOND_LOCK_PERIOD; event BondLockChanged( uint256 indexed nodeOperatorId, uint256 newAmount, - uint256 retentionUntil + uint256 lockUntil ); event BondLockRemoved(uint256 indexed nodeOperatorId); - event BondLockRetentionPeriodChanged(uint256 retentionPeriod); + event BondLockPeriodChanged(uint256 lockPeriod); - error InvalidBondLockRetentionPeriod(); + error InvalidBondLockPeriod(); error InvalidBondLockAmount(); - constructor( - uint256 minBondLockRetentionPeriod, - uint256 maxBondLockRetentionPeriod - ) { - if (minBondLockRetentionPeriod > maxBondLockRetentionPeriod) { - revert InvalidBondLockRetentionPeriod(); + constructor(uint256 minBondLockPeriod, uint256 maxBondLockPeriod) { + if (minBondLockPeriod > maxBondLockPeriod) { + revert InvalidBondLockPeriod(); } - // retention period can not be more than type(uint64).max to avoid overflow when setting bond lock - if (maxBondLockRetentionPeriod > type(uint64).max) { - revert InvalidBondLockRetentionPeriod(); + // period can not be more than type(uint64).max to avoid overflow when setting bond lock + if (maxBondLockPeriod > type(uint64).max) { + revert InvalidBondLockPeriod(); } - MIN_BOND_LOCK_RETENTION_PERIOD = minBondLockRetentionPeriod; - MAX_BOND_LOCK_RETENTION_PERIOD = maxBondLockRetentionPeriod; + MIN_BOND_LOCK_PERIOD = minBondLockPeriod; + MAX_BOND_LOCK_PERIOD = maxBondLockPeriod; } + /// @dev DEPRECATED. Use `MIN_BOND_LOCK_PERIOD` instead + // solhint-disable func-name-mixedcase + function MIN_BOND_LOCK_RETENTION_PERIOD() external view returns (uint256) { + return MIN_BOND_LOCK_PERIOD; + } + + /// @dev DEPRECATED. Use `MAX_BOND_LOCK_PERIOD` instead + // solhint-disable func-name-mixedcase + function MAX_BOND_LOCK_RETENTION_PERIOD() external view returns (uint256) { + return MAX_BOND_LOCK_PERIOD; + } + + /// @dev DEPRECATED. Use `getBondLockPeriod` instead /// @notice Get default bond lock retention period /// @return Default bond lock retention period function getBondLockRetentionPeriod() external view returns (uint256) { - return _getCSBondLockStorage().bondLockRetentionPeriod; + return _getCSBondLockStorage().bondLockPeriod; + } + + /// @notice Get default bond lock period + /// @return Default bond lock period + function getBondLockPeriod() external view returns (uint256) { + return _getCSBondLockStorage().bondLockPeriod; } /// @notice Get information about the locked bond for the given Node Operator @@ -96,26 +112,26 @@ abstract contract CSBondLock is ICSBondLock, Initializable { BondLock storage bondLock = _getCSBondLockStorage().bondLock[ nodeOperatorId ]; - return bondLock.retentionUntil > block.timestamp ? bondLock.amount : 0; + return bondLock.lockUntil > block.timestamp ? bondLock.amount : 0; } - /// @dev Lock bond amount for the given Node Operator until the retention period. + /// @dev Lock bond amount for the given Node Operator until the period. function _lock(uint256 nodeOperatorId, uint256 amount) internal { CSBondLockStorage storage $ = _getCSBondLockStorage(); if (amount == 0) { revert InvalidBondLockAmount(); } - if ($.bondLock[nodeOperatorId].retentionUntil > block.timestamp) { + if ($.bondLock[nodeOperatorId].lockUntil > block.timestamp) { amount += $.bondLock[nodeOperatorId].amount; } _changeBondLock({ nodeOperatorId: nodeOperatorId, amount: amount, - retentionUntil: block.timestamp + $.bondLockRetentionPeriod + lockUntil: block.timestamp + $.bondLockPeriod }); } - /// @dev Reduce locked bond amount for the given Node Operator without changing retention period + /// @dev Reduce the locked bond amount for the given Node Operator without changing the lock period function _reduceAmount(uint256 nodeOperatorId, uint256 amount) internal { uint256 blocked = getActualLockedBond(nodeOperatorId); if (amount == 0) { @@ -128,7 +144,7 @@ abstract contract CSBondLock is ICSBondLock, Initializable { _changeBondLock( nodeOperatorId, blocked - amount, - _getCSBondLockStorage().bondLock[nodeOperatorId].retentionUntil + _getCSBondLockStorage().bondLock[nodeOperatorId].lockUntil ); } } @@ -140,28 +156,26 @@ abstract contract CSBondLock is ICSBondLock, Initializable { } // solhint-disable-next-line func-name-mixedcase - function __CSBondLock_init( - uint256 retentionPeriod - ) internal onlyInitializing { - _setBondLockRetentionPeriod(retentionPeriod); + function __CSBondLock_init(uint256 lockPeriod) internal onlyInitializing { + _setBondLockPeriod(lockPeriod); } - /// @dev Set default bond lock retention period. That period will be sum with the current block timestamp of lock tx - function _setBondLockRetentionPeriod(uint256 retentionPeriod) internal { + /// @dev Set default bond lock period. That period will be added to the block timestamp of the lock translation to determine the bond lock duration + function _setBondLockPeriod(uint256 lockPeriod) internal { if ( - retentionPeriod < MIN_BOND_LOCK_RETENTION_PERIOD || - retentionPeriod > MAX_BOND_LOCK_RETENTION_PERIOD + lockPeriod < MIN_BOND_LOCK_PERIOD || + lockPeriod > MAX_BOND_LOCK_PERIOD ) { - revert InvalidBondLockRetentionPeriod(); + revert InvalidBondLockPeriod(); } - _getCSBondLockStorage().bondLockRetentionPeriod = retentionPeriod; - emit BondLockRetentionPeriodChanged(retentionPeriod); + _getCSBondLockStorage().bondLockPeriod = lockPeriod; + emit BondLockPeriodChanged(lockPeriod); } function _changeBondLock( uint256 nodeOperatorId, uint256 amount, - uint256 retentionUntil + uint256 lockUntil ) private { if (amount == 0) { _remove(nodeOperatorId); @@ -169,9 +183,9 @@ abstract contract CSBondLock is ICSBondLock, Initializable { } _getCSBondLockStorage().bondLock[nodeOperatorId] = BondLock({ amount: amount.toUint128(), - retentionUntil: retentionUntil.toUint128() + lockUntil: lockUntil.toUint128() }); - emit BondLockChanged(nodeOperatorId, amount, retentionUntil); + emit BondLockChanged(nodeOperatorId, amount, lockUntil); } function _getCSBondLockStorage() diff --git a/src/interfaces/ICSBondLock.sol b/src/interfaces/ICSBondLock.sol index b00db407..2b99e21f 100644 --- a/src/interfaces/ICSBondLock.sol +++ b/src/interfaces/ICSBondLock.sol @@ -6,18 +6,21 @@ pragma solidity 0.8.24; interface ICSBondLock { /// @dev Bond lock structure. /// It contains: - /// - amount |> amount of locked bond - /// - retentionUntil |> timestamp until locked bond is retained + /// - amount |> amount of locked bond + /// - lockUntil |> timestamp until locked bond is retained struct BondLock { uint128 amount; - uint128 retentionUntil; + uint128 lockUntil; } + /// @dev DEPRECATED: Use `getBondLockPeriod` instead function getBondLockRetentionPeriod() external view returns (uint256 retention); + function getBondLockPeriod() external view returns (uint256 period); + function getLockedBondInfo( uint256 nodeOperatorId ) external view returns (BondLock memory); diff --git a/test/CSAccounting.t.sol b/test/CSAccounting.t.sol index b120dc54..4be77749 100644 --- a/test/CSAccounting.t.sol +++ b/test/CSAccounting.t.sol @@ -167,10 +167,10 @@ contract CSAccountingConstructorTest is CSAccountingBaseConstructorTest { ); } - function test_constructor_RevertWhen_InvalidBondLockRetentionPeriod_MinMoreThanMax() + function test_constructor_RevertWhen_InvalidBondLockPeriod_MinMoreThanMax() public { - vm.expectRevert(CSBondLock.InvalidBondLockRetentionPeriod.selector); + vm.expectRevert(CSBondLock.InvalidBondLockPeriod.selector); accounting = new CSAccounting( address(locator), address(0), @@ -180,10 +180,10 @@ contract CSAccountingConstructorTest is CSAccountingBaseConstructorTest { ); } - function test_constructor_RevertWhen_InvalidBondLockRetentionPeriod_MaxTooBig() + function test_constructor_RevertWhen_InvalidBondLockPeriod_MaxTooBig() public { - vm.expectRevert(CSBondLock.InvalidBondLockRetentionPeriod.selector); + vm.expectRevert(CSBondLock.InvalidBondLockPeriod.selector); accounting = new CSAccounting( address(locator), address(0), @@ -241,7 +241,7 @@ contract CSAccountingInitTest is CSAccountingBaseInitTest { vm.expectEmit(true, false, false, true, address(accounting)); emit CSBondCurve.BondCurveAdded(curve); vm.expectEmit(true, false, false, true, address(accounting)); - emit CSBondLock.BondLockRetentionPeriodChanged(8 weeks); + emit CSBondLock.BondLockPeriodChanged(8 weeks); vm.expectEmit(true, false, false, true, address(accounting)); emit CSAccounting.ChargePenaltyRecipientSet(testChargePenaltyRecipient); accounting.initialize( @@ -3602,16 +3602,16 @@ contract CSAccountingChargeFeeTest is CSAccountingBaseTest { } contract CSAccountingLockBondETHTest is CSAccountingBaseTest { - function setLockedBondRetentionPeriod() public { + function setLockedBondPeriod() public { vm.prank(admin); - accounting.setLockedBondRetentionPeriod(200 days); - assertEq(accounting.getBondLockRetentionPeriod(), 200 days); + accounting.setLockedBondPeriod(200 days); + assertEq(accounting.getBondLockPeriod(), 200 days); } - function setLockedBondRetentionPeriod_RevertWhen_DoesNotHaveRole() public { + function setLockedBondPeriod_RevertWhen_DoesNotHaveRole() public { expectRoleRevert(stranger, accounting.ACCOUNTING_MANAGER_ROLE()); vm.prank(stranger); - accounting.setLockedBondRetentionPeriod(200 days); + accounting.setLockedBondPeriod(200 days); } function test_lockBondETH() public assertInvariants { @@ -3914,12 +3914,12 @@ contract CSAccountingMiscTest is CSAccountingBaseTest { accounting.setChargePenaltyRecipient(address(0)); } - function test_setLockedBondRetentionPeriod() public assertInvariants { - uint256 retention = accounting.MIN_BOND_LOCK_RETENTION_PERIOD() + 1; + function test_setLockedBondPeriod() public assertInvariants { + uint256 period = accounting.MIN_BOND_LOCK_PERIOD() + 1; vm.prank(admin); - accounting.setLockedBondRetentionPeriod(retention); - uint256 actualRetention = accounting.getBondLockRetentionPeriod(); - assertEq(actualRetention, retention); + accounting.setLockedBondPeriod(period); + uint256 actual = accounting.getBondLockPeriod(); + assertEq(actual, period); } function test_renewBurnerAllowance() public assertInvariants { diff --git a/test/CSBondLock.t.sol b/test/CSBondLock.t.sol index 526d2230..8c6914cf 100644 --- a/test/CSBondLock.t.sol +++ b/test/CSBondLock.t.sol @@ -17,12 +17,12 @@ import { Utilities } from "./helpers/Utilities.sol"; import { Fixtures } from "./helpers/Fixtures.sol"; contract CSBondLockTestable is CSBondLock(4 weeks, 365 days) { - function initialize(uint256 retentionPeriod) public initializer { - CSBondLock.__CSBondLock_init(retentionPeriod); + function initialize(uint256 period) public initializer { + CSBondLock.__CSBondLock_init(period); } - function setBondLockRetentionPeriod(uint256 retention) external { - _setBondLockRetentionPeriod(retention); + function setBondLockPeriod(uint256 period) external { + _setBondLockPeriod(period); } function lock(uint256 nodeOperatorId, uint256 amount) external { @@ -46,32 +46,28 @@ contract CSBondLockTest is Test { bondLock.initialize(8 weeks); } - function test_setBondLockRetentionPeriod() public { - uint256 retention = 4 weeks; + function test_setBondLockPeriod() public { + uint256 period = 4 weeks; vm.expectEmit(true, true, true, true, address(bondLock)); - emit CSBondLock.BondLockRetentionPeriodChanged(retention); + emit CSBondLock.BondLockPeriodChanged(period); - bondLock.setBondLockRetentionPeriod(retention); + bondLock.setBondLockPeriod(period); - uint256 _retention = bondLock.getBondLockRetentionPeriod(); - assertEq(_retention, retention); + uint256 _period = bondLock.getBondLockPeriod(); + assertEq(_period, period); } - function test_setBondLockRetentionPeriod_RevertWhen_RetentionLessThanMin() - public - { - uint256 minRetention = bondLock.MIN_BOND_LOCK_RETENTION_PERIOD(); - vm.expectRevert(CSBondLock.InvalidBondLockRetentionPeriod.selector); - bondLock.setBondLockRetentionPeriod(minRetention - 1 seconds); + function test_setBondLockPeriod_RevertWhen_LessThanMin() public { + uint256 min = bondLock.MIN_BOND_LOCK_PERIOD(); + vm.expectRevert(CSBondLock.InvalidBondLockPeriod.selector); + bondLock.setBondLockPeriod(min - 1 seconds); } - function test_setBondLockRetentionPeriod_RevertWhen_RetentionGreaterThanMax() - public - { - uint256 maxRetention = bondLock.MAX_BOND_LOCK_RETENTION_PERIOD(); - vm.expectRevert(CSBondLock.InvalidBondLockRetentionPeriod.selector); - bondLock.setBondLockRetentionPeriod(maxRetention + 1 seconds); + function test_setBondLockPeriod_RevertWhen_GreaterThanMax() public { + uint256 max = bondLock.MAX_BOND_LOCK_PERIOD(); + vm.expectRevert(CSBondLock.InvalidBondLockPeriod.selector); + bondLock.setBondLockPeriod(max + 1 seconds); } function test_getActualLockedBond() public { @@ -83,44 +79,44 @@ contract CSBondLockTest is Test { assertEq(value, amount); } - function test_getActualLockedBond_WhenOnRetentionUntil() public { + function test_getActualLockedBond_WhenOnUntil() public { uint256 noId = 0; uint256 amount = 1 ether; bondLock.lock(noId, amount); CSBondLock.BondLock memory lock = bondLock.getLockedBondInfo(noId); - vm.warp(lock.retentionUntil); + vm.warp(lock.lockUntil); uint256 value = bondLock.getActualLockedBond(noId); assertEq(value, 0); } - function test_getActualLockedBond_WhenRetentionPeriodIsPassed() public { - uint256 retentionPeriod = bondLock.getBondLockRetentionPeriod(); + function test_getActualLockedBond_WhenPeriodIsPassed() public { + uint256 period = bondLock.getBondLockPeriod(); uint256 noId = 0; uint256 amount = 1 ether; bondLock.lock(noId, amount); - vm.warp(block.timestamp + retentionPeriod + 1 seconds); + vm.warp(block.timestamp + period + 1 seconds); uint256 value = bondLock.getActualLockedBond(noId); assertEq(value, 0); } function test_lock() public { - uint256 retentionPeriod = bondLock.getBondLockRetentionPeriod(); + uint256 period = bondLock.getBondLockPeriod(); uint256 noId = 0; uint256 amount = 1 ether; - uint256 retentionUntil = block.timestamp + retentionPeriod; + uint256 until = block.timestamp + period; vm.expectEmit(true, true, true, true, address(bondLock)); - emit CSBondLock.BondLockChanged(noId, amount, retentionUntil); + emit CSBondLock.BondLockChanged(noId, amount, until); bondLock.lock(noId, amount); CSBondLock.BondLock memory lock = bondLock.getLockedBondInfo(noId); assertEq(lock.amount, amount); - assertEq(lock.retentionUntil, retentionUntil); + assertEq(lock.lockUntil, until); } function test_lock_secondLock() public { @@ -135,42 +131,39 @@ contract CSBondLockTest is Test { bondLock.lock(noId, 1 ether); CSBondLock.BondLock memory lock = bondLock.getLockedBondInfo(noId); assertEq(lock.amount, 2 ether); - assertEq(lock.retentionUntil, lockBefore.retentionUntil + 1 hours); + assertEq(lock.lockUntil, lockBefore.lockUntil + 1 hours); } - function test_lock_WhenSecondLockOnRetentionUntil() public { + function test_lock_WhenSecondLockOnUntil() public { uint256 noId = 0; - uint256 retentionPeriod = bondLock.getBondLockRetentionPeriod(); + uint256 period = bondLock.getBondLockPeriod(); bondLock.lock(noId, 1 ether); CSBondLock.BondLock memory lockBefore = bondLock.getLockedBondInfo( noId ); - vm.warp(lockBefore.retentionUntil); + vm.warp(lockBefore.lockUntil); bondLock.lock(noId, 1 ether); CSBondLock.BondLock memory lock = bondLock.getLockedBondInfo(noId); assertEq(lock.amount, 1 ether); - assertEq( - lock.retentionUntil, - lockBefore.retentionUntil + retentionPeriod - ); + assertEq(lock.lockUntil, lockBefore.lockUntil + period); } function test_lock_WhenSecondLockAfterFirstExpired() public { uint256 noId = 0; - uint256 retentionPeriod = bondLock.getBondLockRetentionPeriod(); + uint256 period = bondLock.getBondLockPeriod(); bondLock.lock(noId, 1 ether); CSBondLock.BondLock memory lockBefore = bondLock.getLockedBondInfo( noId ); - vm.warp(lockBefore.retentionUntil + 1 hours); + vm.warp(lockBefore.lockUntil + 1 hours); bondLock.lock(noId, 1 ether); CSBondLock.BondLock memory lock = bondLock.getLockedBondInfo(noId); assertEq(lock.amount, 1 ether); - assertEq(lock.retentionUntil, block.timestamp + retentionPeriod); + assertEq(lock.lockUntil, block.timestamp + period); } function test_lock_RevertWhen_ZeroAmount() public { @@ -203,16 +196,16 @@ contract CSBondLockTest is Test { CSBondLock.BondLock memory lock = bondLock.getLockedBondInfo(0); assertEq(lock.amount, 0); - assertEq(lock.retentionUntil, 0); + assertEq(lock.lockUntil, 0); } function test_reduceAmount_WhenPartial() public { - uint256 retentionPeriod = bondLock.getBondLockRetentionPeriod(); + uint256 period = bondLock.getBondLockPeriod(); uint256 noId = 0; uint256 amount = 100 ether; bondLock.lock(noId, amount); - uint256 retentionPeriodWhenLock = block.timestamp + retentionPeriod; + uint256 periodWhenLock = block.timestamp + period; uint256 toRelease = 10 ether; uint256 rest = amount - toRelease; @@ -220,13 +213,13 @@ contract CSBondLockTest is Test { vm.warp(block.timestamp + 1 seconds); vm.expectEmit(true, true, true, true, address(bondLock)); - emit CSBondLock.BondLockChanged(noId, rest, retentionPeriodWhenLock); + emit CSBondLock.BondLockChanged(noId, rest, periodWhenLock); bondLock.reduceAmount(noId, toRelease); CSBondLock.BondLock memory lock = bondLock.getLockedBondInfo(0); assertEq(lock.amount, rest); - assertEq(lock.retentionUntil, retentionPeriodWhenLock); + assertEq(lock.lockUntil, periodWhenLock); } function test_reduceAmount_RevertWhen_ZeroAmount() public { @@ -257,6 +250,6 @@ contract CSBondLockTest is Test { CSBondLock.BondLock memory lock = bondLock.getLockedBondInfo(0); assertEq(lock.amount, 0); - assertEq(lock.retentionUntil, 0); + assertEq(lock.lockUntil, 0); } } diff --git a/test/CSModule.t.sol b/test/CSModule.t.sol index 5da2914f..4e2f1c6b 100644 --- a/test/CSModule.t.sol +++ b/test/CSModule.t.sol @@ -261,12 +261,12 @@ abstract contract CSMFixtures is Test, Fixtures, Utilities, InvariantAsserts { }); } - // amount can not be lower than EL_REWARDS_STEALING_FINE + // amount can not be lower than EL_REWARDS_STEALING_ADDITIONAL_FINE function penalize(uint256 noId, uint256 amount) public { csm.reportELRewardsStealingPenalty( noId, blockhash(block.number), - amount - csm.EL_REWARDS_STEALING_FINE() + amount - csm.EL_REWARDS_STEALING_ADDITIONAL_FINE() ); csm.settleELRewardsStealingPenalty(UintArr(noId)); } @@ -287,7 +287,7 @@ contract CSMCommonNoPublicRelease is CSMFixtures { csm = new CSModule({ moduleType: "community-staking-module", minSlashingPenaltyQuotient: 32, - elRewardsStealingFine: 0.1 ether, + elRewardsStealingAdditionalFine: 0.1 ether, maxKeysPerOperatorEA: 10, maxKeyRemovalCharge: 0.1 ether, lidoLocator: address(locator) @@ -379,7 +379,7 @@ contract CSMCommonNoPublicReleaseNoEA is CSMFixtures { csm = new CSModule({ moduleType: "community-staking-module", minSlashingPenaltyQuotient: 32, - elRewardsStealingFine: 0.1 ether, + elRewardsStealingAdditionalFine: 0.1 ether, maxKeysPerOperatorEA: 10, maxKeyRemovalCharge: 0.1 ether, lidoLocator: address(locator) @@ -462,7 +462,7 @@ contract CSMCommonNoRoles is CSMFixtures { csm = new CSModule({ moduleType: "community-staking-module", minSlashingPenaltyQuotient: 32, - elRewardsStealingFine: 0.1 ether, + elRewardsStealingAdditionalFine: 0.1 ether, maxKeysPerOperatorEA: 10, maxKeyRemovalCharge: 0.1 ether, lidoLocator: address(locator) @@ -559,13 +559,13 @@ contract CsmInitialize is CSMCommon { CSModule csm = new CSModule({ moduleType: "community-staking-module", minSlashingPenaltyQuotient: 32, - elRewardsStealingFine: 0.1 ether, + elRewardsStealingAdditionalFine: 0.1 ether, maxKeysPerOperatorEA: 10, maxKeyRemovalCharge: 0.1 ether, lidoLocator: address(locator) }); assertEq(csm.getType(), "community-staking-module"); - assertEq(csm.EL_REWARDS_STEALING_FINE(), 0.1 ether); + assertEq(csm.EL_REWARDS_STEALING_ADDITIONAL_FINE(), 0.1 ether); assertEq(csm.MAX_SIGNING_KEYS_PER_OPERATOR_BEFORE_PUBLIC_RELEASE(), 10); assertEq(address(csm.LIDO_LOCATOR()), address(locator)); } @@ -575,7 +575,7 @@ contract CsmInitialize is CSMCommon { new CSModule({ moduleType: "community-staking-module", minSlashingPenaltyQuotient: 32, - elRewardsStealingFine: 0.1 ether, + elRewardsStealingAdditionalFine: 0.1 ether, maxKeysPerOperatorEA: 10, maxKeyRemovalCharge: 0.1 ether, lidoLocator: address(0) @@ -586,7 +586,7 @@ contract CsmInitialize is CSMCommon { CSModule csm = new CSModule({ moduleType: "community-staking-module", minSlashingPenaltyQuotient: 32, - elRewardsStealingFine: 0.1 ether, + elRewardsStealingAdditionalFine: 0.1 ether, maxKeysPerOperatorEA: 10, maxKeyRemovalCharge: 0.1 ether, lidoLocator: address(locator) @@ -605,7 +605,7 @@ contract CsmInitialize is CSMCommon { CSModule csm = new CSModule({ moduleType: "community-staking-module", minSlashingPenaltyQuotient: 32, - elRewardsStealingFine: 0.1 ether, + elRewardsStealingAdditionalFine: 0.1 ether, maxKeysPerOperatorEA: 10, maxKeyRemovalCharge: 0.1 ether, lidoLocator: address(locator) @@ -619,7 +619,7 @@ contract CsmInitialize is CSMCommon { admin: address(this) }); assertEq(csm.getType(), "community-staking-module"); - assertEq(csm.EL_REWARDS_STEALING_FINE(), 0.1 ether); + assertEq(csm.EL_REWARDS_STEALING_ADDITIONAL_FINE(), 0.1 ether); assertEq(csm.MAX_SIGNING_KEYS_PER_OPERATOR_BEFORE_PUBLIC_RELEASE(), 10); assertEq(address(csm.LIDO_LOCATOR()), address(locator)); assertEq(address(csm.accounting()), address(accounting)); @@ -632,7 +632,7 @@ contract CsmInitialize is CSMCommon { CSModule csm = new CSModule({ moduleType: "community-staking-module", minSlashingPenaltyQuotient: 32, - elRewardsStealingFine: 0.1 ether, + elRewardsStealingAdditionalFine: 0.1 ether, maxKeysPerOperatorEA: 10, maxKeyRemovalCharge: 0.1 ether, lidoLocator: address(locator) @@ -652,7 +652,7 @@ contract CsmInitialize is CSMCommon { CSModule csm = new CSModule({ moduleType: "community-staking-module", minSlashingPenaltyQuotient: 32, - elRewardsStealingFine: 0.1 ether, + elRewardsStealingAdditionalFine: 0.1 ether, maxKeysPerOperatorEA: 10, maxKeyRemovalCharge: 0.1 ether, lidoLocator: address(locator) @@ -5457,7 +5457,10 @@ contract CsmReportELRewardsStealingPenalty is CSMCommon { ); uint256 lockedBond = accounting.getActualLockedBond(noId); - assertEq(lockedBond, BOND_SIZE / 2 + csm.EL_REWARDS_STEALING_FINE()); + assertEq( + lockedBond, + BOND_SIZE / 2 + csm.EL_REWARDS_STEALING_ADDITIONAL_FINE() + ); assertEq(csm.getNonce(), nonce + 1); } @@ -5520,11 +5523,11 @@ contract CsmCancelELRewardsStealingPenalty is CSMCommon { vm.expectEmit(true, true, true, true, address(csm)); emit CSModule.ELRewardsStealingPenaltyCancelled( noId, - BOND_SIZE / 2 + csm.EL_REWARDS_STEALING_FINE() + BOND_SIZE / 2 + csm.EL_REWARDS_STEALING_ADDITIONAL_FINE() ); csm.cancelELRewardsStealingPenalty( noId, - BOND_SIZE / 2 + csm.EL_REWARDS_STEALING_FINE() + BOND_SIZE / 2 + csm.EL_REWARDS_STEALING_ADDITIONAL_FINE() ); uint256 lockedBond = accounting.getActualLockedBond(noId); @@ -5551,7 +5554,7 @@ contract CsmCancelELRewardsStealingPenalty is CSMCommon { csm.cancelELRewardsStealingPenalty(noId, BOND_SIZE / 2); uint256 lockedBond = accounting.getActualLockedBond(noId); - assertEq(lockedBond, csm.EL_REWARDS_STEALING_FINE()); + assertEq(lockedBond, csm.EL_REWARDS_STEALING_ADDITIONAL_FINE()); // nonce should not change due to no changes in the depositable validators assertEq(csm.getNonce(), nonce); } @@ -5586,7 +5589,7 @@ contract CsmSettleELRewardsStealingPenaltyBasic is CSMCommon { CSBondLock.BondLock memory lock = accounting.getLockedBondInfo(noId); assertEq(lock.amount, 0 ether); - assertEq(lock.retentionUntil, 0); + assertEq(lock.lockUntil, 0); } function test_settleELRewardsStealingPenalty_multipleNOs() @@ -5635,11 +5638,11 @@ contract CsmSettleELRewardsStealingPenaltyBasic is CSMCommon { firstNoId ); assertEq(lock.amount, 0 ether); - assertEq(lock.retentionUntil, 0); + assertEq(lock.lockUntil, 0); lock = accounting.getLockedBondInfo(secondNoId); assertEq(lock.amount, 0 ether); - assertEq(lock.retentionUntil, 0); + assertEq(lock.lockUntil, 0); } function test_settleELRewardsStealingPenalty_NoLock() @@ -5658,7 +5661,7 @@ contract CsmSettleELRewardsStealingPenaltyBasic is CSMCommon { CSBondLock.BondLock memory lock = accounting.getLockedBondInfo(noId); assertEq(lock.amount, 0 ether); - assertEq(lock.retentionUntil, 0); + assertEq(lock.lockUntil, 0); } function test_settleELRewardsStealingPenalty_multipleNOs_NoLock() @@ -5691,12 +5694,12 @@ contract CsmSettleELRewardsStealingPenaltyBasic is CSMCommon { firstNoId ); assertEq(firstLock.amount, 0 ether); - assertEq(firstLock.retentionUntil, 0); + assertEq(firstLock.lockUntil, 0); CSBondLock.BondLock memory secondLock = accounting.getLockedBondInfo( secondNoId ); assertEq(secondLock.amount, 0 ether); - assertEq(secondLock.retentionUntil, 0); + assertEq(secondLock.lockUntil, 0); } function test_settleELRewardsStealingPenalty_multipleNOs_oneWithNoLock() @@ -5736,12 +5739,12 @@ contract CsmSettleELRewardsStealingPenaltyBasic is CSMCommon { firstNoId ); assertEq(firstLock.amount, 0 ether); - assertEq(firstLock.retentionUntil, 0); + assertEq(firstLock.lockUntil, 0); CSBondLock.BondLock memory secondLock = accounting.getLockedBondInfo( secondNoId ); assertEq(secondLock.amount, 0 ether); - assertEq(secondLock.retentionUntil, 0); + assertEq(secondLock.lockUntil, 0); } function test_settleELRewardsStealingPenalty_withDuplicates() public { @@ -5778,10 +5781,12 @@ contract CsmSettleELRewardsStealingPenaltyBasic is CSMCommon { secondNoId ); assertEq(currentLock.amount, 0 ether); - assertEq(currentLock.retentionUntil, 0); + assertEq(currentLock.lockUntil, 0); assertEq( bondBalanceAfter, - bondBalanceBefore - lockAmount - csm.EL_REWARDS_STEALING_FINE() + bondBalanceBefore - + lockAmount - + csm.EL_REWARDS_STEALING_ADDITIONAL_FINE() ); } @@ -5798,11 +5803,9 @@ contract CsmSettleELRewardsStealingPenaltyBasic is CSMCommon { } contract CsmSettleELRewardsStealingPenaltyAdvanced is CSMCommon { - function test_settleELRewardsStealingPenalty_RetentionPeriodIsExpired() - public - { + function test_settleELRewardsStealingPenalty_PeriodIsExpired() public { uint256 noId = createNodeOperator(); - uint256 retentionPeriod = accounting.getBondLockRetentionPeriod(); + uint256 period = accounting.getBondLockPeriod(); uint256[] memory idsToSettle = new uint256[](1); idsToSettle[0] = noId; uint256 amount = 1 ether; @@ -5813,7 +5816,7 @@ contract CsmSettleELRewardsStealingPenaltyAdvanced is CSMCommon { amount ); - vm.warp(block.timestamp + retentionPeriod + 1 seconds); + vm.warp(block.timestamp + period + 1 seconds); expectNoCall( address(accounting), @@ -5827,7 +5830,7 @@ contract CsmSettleELRewardsStealingPenaltyAdvanced is CSMCommon { function test_settleELRewardsStealingPenalty_multipleNOs_oneExpired() public { - uint256 retentionPeriod = accounting.getBondLockRetentionPeriod(); + uint256 period = accounting.getBondLockPeriod(); uint256 firstNoId = createNodeOperator(2); uint256 secondNoId = createNodeOperator(2); uint256[] memory idsToSettle = new uint256[](2); @@ -5838,7 +5841,7 @@ contract CsmSettleELRewardsStealingPenaltyAdvanced is CSMCommon { blockhash(block.number), 1 ether ); - vm.warp(block.timestamp + retentionPeriod + 1 seconds); + vm.warp(block.timestamp + period + 1 seconds); csm.reportELRewardsStealingPenalty( secondNoId, blockhash(block.number), @@ -5863,7 +5866,7 @@ contract CsmSettleELRewardsStealingPenaltyAdvanced is CSMCommon { secondNoId ); assertEq(lock.amount, 0 ether); - assertEq(lock.retentionUntil, 0); + assertEq(lock.lockUntil, 0); } function test_settleELRewardsStealingPenalty_CurveReset_NoNewUnbonded() @@ -5984,7 +5987,7 @@ contract CSMCompensateELRewardsStealingPenalty is CSMCommon { function test_compensateELRewardsStealingPenalty() public assertInvariants { uint256 noId = createNodeOperator(); uint256 amount = 1 ether; - uint256 fine = csm.EL_REWARDS_STEALING_FINE(); + uint256 fine = csm.EL_REWARDS_STEALING_ADDITIONAL_FINE(); csm.reportELRewardsStealingPenalty( noId, blockhash(block.number), @@ -6018,7 +6021,7 @@ contract CSMCompensateELRewardsStealingPenalty is CSMCommon { { uint256 noId = createNodeOperator(); uint256 amount = 1 ether; - uint256 fine = csm.EL_REWARDS_STEALING_FINE(); + uint256 fine = csm.EL_REWARDS_STEALING_ADDITIONAL_FINE(); csm.reportELRewardsStealingPenalty( noId, blockhash(block.number), @@ -6051,7 +6054,7 @@ contract CSMCompensateELRewardsStealingPenalty is CSMCommon { { uint256 noId = createNodeOperator(2); uint256 amount = 1 ether; - uint256 fine = csm.EL_REWARDS_STEALING_FINE(); + uint256 fine = csm.EL_REWARDS_STEALING_ADDITIONAL_FINE(); csm.reportELRewardsStealingPenalty( noId, blockhash(block.number), @@ -6430,7 +6433,7 @@ contract CSMAccessControl is CSMCommonNoRoles { CSModule csm = new CSModule({ moduleType: "community-staking-module", minSlashingPenaltyQuotient: 32, - elRewardsStealingFine: 0.1 ether, + elRewardsStealingAdditionalFine: 0.1 ether, maxKeysPerOperatorEA: 10, maxKeyRemovalCharge: 0.1 ether, lidoLocator: address(locator) @@ -6452,7 +6455,7 @@ contract CSMAccessControl is CSMCommonNoRoles { CSModule csm = new CSModule({ moduleType: "community-staking-module", minSlashingPenaltyQuotient: 32, - elRewardsStealingFine: 0.1 ether, + elRewardsStealingAdditionalFine: 0.1 ether, maxKeysPerOperatorEA: 10, maxKeyRemovalCharge: 0.1 ether, lidoLocator: address(locator) diff --git a/test/fork/deployment/PostDeployment.t.sol b/test/fork/deployment/PostDeployment.t.sol index 5a053d21..ec127d8a 100644 --- a/test/fork/deployment/PostDeployment.t.sol +++ b/test/fork/deployment/PostDeployment.t.sol @@ -41,8 +41,8 @@ contract CSModuleDeploymentTest is Test, Utilities, DeploymentFixtures { 32 ether / deployParams.minSlashingPenaltyQuotient ); assertEq( - csm.EL_REWARDS_STEALING_FINE(), - deployParams.elRewardsStealingFine + csm.EL_REWARDS_STEALING_ADDITIONAL_FINE(), + deployParams.elRewardsStealingAdditionalFine ); assertEq( csm.MAX_SIGNING_KEYS_PER_OPERATOR_BEFORE_PUBLIC_RELEASE(), @@ -147,12 +147,12 @@ contract CSAccountingDeploymentTest is Test, Utilities, DeploymentFixtures { ); assertEq( - accounting.MIN_BOND_LOCK_RETENTION_PERIOD(), - deployParams.minBondLockRetentionPeriod + accounting.MIN_BOND_LOCK_PERIOD(), + deployParams.minBondLockPeriod ); assertEq( - accounting.MAX_BOND_LOCK_RETENTION_PERIOD(), - deployParams.maxBondLockRetentionPeriod + accounting.MAX_BOND_LOCK_PERIOD(), + deployParams.maxBondLockPeriod ); assertEq(accounting.MAX_CURVE_LENGTH(), deployParams.maxCurveLength); } @@ -163,10 +163,7 @@ contract CSAccountingDeploymentTest is Test, Utilities, DeploymentFixtures { deployParams.bondCurve ); assertEq(address(accounting.feeDistributor()), address(feeDistributor)); - assertEq( - accounting.getBondLockRetentionPeriod(), - deployParams.bondLockRetentionPeriod - ); + assertEq(accounting.getBondLockPeriod(), deployParams.bondLockPeriod); assertEq( accounting.chargePenaltyRecipient(), deployParams.chargePenaltyRecipient @@ -255,7 +252,7 @@ contract CSAccountingDeploymentTest is Test, Utilities, DeploymentFixtures { bondCurve: deployParams.bondCurve, admin: address(deployParams.aragonAgent), _feeDistributor: address(feeDistributor), - bondLockRetentionPeriod: deployParams.bondLockRetentionPeriod, + bondLockPeriod: deployParams.bondLockPeriod, _chargePenaltyRecipient: address(0) }); } diff --git a/test/fork/deployment/Upgradability.sol b/test/fork/deployment/Upgradability.sol index cf140c87..ba3710d2 100644 --- a/test/fork/deployment/Upgradability.sol +++ b/test/fork/deployment/Upgradability.sol @@ -25,7 +25,8 @@ contract UpgradabilityTest is Test, Utilities, DeploymentFixtures { CSModule newModule = new CSModule({ moduleType: "CSMv2", minSlashingPenaltyQuotient: 32, - elRewardsStealingFine: csm.EL_REWARDS_STEALING_FINE(), + elRewardsStealingAdditionalFine: csm + .EL_REWARDS_STEALING_ADDITIONAL_FINE(), maxKeysPerOperatorEA: csm .MAX_SIGNING_KEYS_PER_OPERATOR_BEFORE_PUBLIC_RELEASE(), maxKeyRemovalCharge: csm.MAX_KEY_REMOVAL_CHARGE(), @@ -41,7 +42,8 @@ contract UpgradabilityTest is Test, Utilities, DeploymentFixtures { CSModule newModule = new CSModule({ moduleType: "CSMv2", minSlashingPenaltyQuotient: 32, - elRewardsStealingFine: csm.EL_REWARDS_STEALING_FINE(), + elRewardsStealingAdditionalFine: csm + .EL_REWARDS_STEALING_ADDITIONAL_FINE(), maxKeysPerOperatorEA: csm .MAX_SIGNING_KEYS_PER_OPERATOR_BEFORE_PUBLIC_RELEASE(), maxKeyRemovalCharge: csm.MAX_KEY_REMOVAL_CHARGE(), @@ -73,10 +75,8 @@ contract UpgradabilityTest is Test, Utilities, DeploymentFixtures { lidoLocator: address(accounting.LIDO_LOCATOR()), communityStakingModule: address(csm), maxCurveLength: currentMaxCurveLength + 10, - minBondLockRetentionPeriod: accounting - .MIN_BOND_LOCK_RETENTION_PERIOD(), - maxBondLockRetentionPeriod: accounting - .MAX_BOND_LOCK_RETENTION_PERIOD() + minBondLockPeriod: accounting.MIN_BOND_LOCK_PERIOD(), + maxBondLockPeriod: accounting.MAX_BOND_LOCK_PERIOD() }); vm.prank(proxy.proxy__getAdmin()); proxy.proxy__upgradeTo(address(newAccounting)); @@ -90,10 +90,8 @@ contract UpgradabilityTest is Test, Utilities, DeploymentFixtures { lidoLocator: address(accounting.LIDO_LOCATOR()), communityStakingModule: address(csm), maxCurveLength: currentMaxCurveLength + 10, - minBondLockRetentionPeriod: accounting - .MIN_BOND_LOCK_RETENTION_PERIOD(), - maxBondLockRetentionPeriod: accounting - .MAX_BOND_LOCK_RETENTION_PERIOD() + minBondLockPeriod: accounting.MIN_BOND_LOCK_PERIOD(), + maxBondLockPeriod: accounting.MAX_BOND_LOCK_PERIOD() }); address contractAdmin = accounting.getRoleMember( accounting.DEFAULT_ADMIN_ROLE(), diff --git a/test/fork/integration/Penalty.t.sol b/test/fork/integration/Penalty.t.sol index 5f9edf50..0e6c6ae3 100644 --- a/test/fork/integration/Penalty.t.sol +++ b/test/fork/integration/Penalty.t.sol @@ -124,7 +124,7 @@ contract PenaltyIntegrationTest is csm.reportELRewardsStealingPenalty( defaultNoId, blockhash(block.number), - amount - csm.EL_REWARDS_STEALING_FINE() + amount - csm.EL_REWARDS_STEALING_ADDITIONAL_FINE() ); uint256[] memory idsToSettle = new uint256[](1);