diff --git a/contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol b/contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol index e9a7ac191..c18e04b8f 100644 --- a/contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol +++ b/contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol @@ -37,16 +37,10 @@ interface IWithdrawalQueue { /// @notice The set of restrictions used in the sanity checks of the oracle report /// @dev struct is loaded from the storage and stored in memory during the tx running struct LimitsList { - /// @notice The max possible number of validators that might be reported as `exited` - /// per single day, depends on the Consensus Layer churn limit + /// @notice The max possible number of validators that might appear or exit on the Consensus + /// Layer during one day /// @dev Must fit into uint16 (<= 65_535) - uint256 exitedValidatorsPerDayLimit; - - /// @notice The max possible number of validators that might be reported as `appeared` - /// per single day, limited by the max daily deposits via DepositSecurityModule in practice - /// isn't limited by a consensus layer (because `appeared` includes `pending`, i.e., not `activated` yet) - /// @dev Must fit into uint16 (<= 65_535) - uint256 appearedValidatorsPerDayLimit; + uint256 churnValidatorsPerDayLimit; /// @notice The max decrease of the total validators' balances on the Consensus Layer since /// the previous oracle report @@ -85,8 +79,7 @@ struct LimitsList { /// @dev The packed version of the LimitsList struct to be effectively persisted in storage struct LimitsListPacked { - uint16 exitedValidatorsPerDayLimit; - uint16 appearedValidatorsPerDayLimit; + uint16 churnValidatorsPerDayLimit; uint16 oneOffCLBalanceDecreaseBPLimit; uint16 annualBalanceIncreaseBPLimit; uint16 simulatedShareRateDeviationBPLimit; @@ -109,10 +102,8 @@ contract OracleReportSanityChecker is AccessControlEnumerable { using PositiveTokenRebaseLimiter for TokenRebaseLimiterData; bytes32 public constant ALL_LIMITS_MANAGER_ROLE = keccak256("ALL_LIMITS_MANAGER_ROLE"); - bytes32 public constant EXITED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE = - keccak256("EXITED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE"); - bytes32 public constant APPEARED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE = - keccak256("APPEARED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE"); + bytes32 public constant CHURN_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE = + keccak256("CHURN_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE"); bytes32 public constant ONE_OFF_CL_BALANCE_DECREASE_LIMIT_MANAGER_ROLE = keccak256("ONE_OFF_CL_BALANCE_DECREASE_LIMIT_MANAGER_ROLE"); bytes32 public constant ANNUAL_BALANCE_INCREASE_LIMIT_MANAGER_ROLE = @@ -139,8 +130,7 @@ contract OracleReportSanityChecker is AccessControlEnumerable { struct ManagersRoster { address[] allLimitsManagers; - address[] exitedValidatorsPerDayLimitManagers; - address[] appearedValidatorsPerDayLimitManagers; + address[] churnValidatorsPerDayLimitManagers; address[] oneOffCLBalanceDecreaseLimitManagers; address[] annualBalanceIncreaseLimitManagers; address[] shareRateDeviationLimitManagers; @@ -168,9 +158,7 @@ contract OracleReportSanityChecker is AccessControlEnumerable { _grantRole(DEFAULT_ADMIN_ROLE, _admin); _grantRole(ALL_LIMITS_MANAGER_ROLE, _managersRoster.allLimitsManagers); - _grantRole(EXITED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE, _managersRoster.exitedValidatorsPerDayLimitManagers); - _grantRole(APPEARED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE, - _managersRoster.appearedValidatorsPerDayLimitManagers); + _grantRole(CHURN_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE, _managersRoster.churnValidatorsPerDayLimitManagers); _grantRole(ONE_OFF_CL_BALANCE_DECREASE_LIMIT_MANAGER_ROLE, _managersRoster.oneOffCLBalanceDecreaseLimitManagers); _grantRole(ANNUAL_BALANCE_INCREASE_LIMIT_MANAGER_ROLE, _managersRoster.annualBalanceIncreaseLimitManagers); @@ -228,35 +216,14 @@ contract OracleReportSanityChecker is AccessControlEnumerable { _updateLimits(_limitsList); } - /// @notice Sets the new value for the exitedValidatorsPerDayLimit - /// - /// NB: AccountingOracle reports validators as exited once they passed the `EXIT_EPOCH` on Consensus Layer - /// therefore, the value should be set in accordance to the consensus layer churn limit - /// - /// @param _exitedValidatorsPerDayLimit new exitedValidatorsPerDayLimit value - function setExitedValidatorsPerDayLimit(uint256 _exitedValidatorsPerDayLimit) + /// @notice Sets the new value for the churnValidatorsPerDayLimit + /// @param _churnValidatorsPerDayLimit new churnValidatorsPerDayLimit value + function setChurnValidatorsPerDayLimit(uint256 _churnValidatorsPerDayLimit) external - onlyRole(EXITED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE) + onlyRole(CHURN_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE) { LimitsList memory limitsList = _limits.unpack(); - limitsList.exitedValidatorsPerDayLimit = _exitedValidatorsPerDayLimit; - _updateLimits(limitsList); - } - - /// @notice Sets the new value for the appearedValidatorsPerDayLimit - /// - /// NB: AccountingOracle reports validators as appeared once they become `pending` - /// (might be not `activated` yet). Thus, this limit should be high enough because consensus layer - /// has no intrinsic churn limit for the amount of `pending` validators (only for `activated` instead). - /// For Lido it depends on the amount of deposits that can be made via DepositSecurityModule daily. - /// - /// @param _appearedValidatorsPerDayLimit new appearedValidatorsPerDayLimit value - function setAppearedValidatorsPerDayLimit(uint256 _appearedValidatorsPerDayLimit) - external - onlyRole(APPEARED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE) - { - LimitsList memory limitsList = _limits.unpack(); - limitsList.appearedValidatorsPerDayLimit = _appearedValidatorsPerDayLimit; + limitsList.churnValidatorsPerDayLimit = _churnValidatorsPerDayLimit; _updateLimits(limitsList); } @@ -459,7 +426,7 @@ contract OracleReportSanityChecker is AccessControlEnumerable { // 6. Appeared validators increase if (_postCLValidators > _preCLValidators) { - _checkAppearedValidators(limitsList, (_postCLValidators - _preCLValidators), _timeElapsed); + _checkValidatorsChurnLimit(limitsList, (_postCLValidators - _preCLValidators), _timeElapsed); } } @@ -481,9 +448,9 @@ contract OracleReportSanityChecker is AccessControlEnumerable { external view { - uint256 exitedValidatorsLimit = _limits.unpack().exitedValidatorsPerDayLimit; - if (_exitedValidatorsCount > exitedValidatorsLimit) { - revert ExitedValidatorsLimitExceeded(exitedValidatorsLimit, _exitedValidatorsCount); + uint256 limit = _limits.unpack().churnValidatorsPerDayLimit; + if (_exitedValidatorsCount > limit) { + revert ExitedValidatorsLimitExceeded(limit, _exitedValidatorsCount); } } @@ -622,7 +589,7 @@ contract OracleReportSanityChecker is AccessControlEnumerable { } } - function _checkAppearedValidators( + function _checkValidatorsChurnLimit( LimitsList memory _limitsList, uint256 _appearedValidators, uint256 _timeElapsed @@ -631,9 +598,9 @@ contract OracleReportSanityChecker is AccessControlEnumerable { _timeElapsed = DEFAULT_TIME_ELAPSED; } - uint256 appearedLimit = (_limitsList.appearedValidatorsPerDayLimit * _timeElapsed) / SECONDS_PER_DAY; + uint256 churnLimit = (_limitsList.churnValidatorsPerDayLimit * _timeElapsed) / SECONDS_PER_DAY; - if (_appearedValidators > appearedLimit) revert IncorrectAppearedValidators(_appearedValidators); + if (_appearedValidators > churnLimit) revert IncorrectAppearedValidators(_appearedValidators); } function _checkLastFinalizableId( @@ -708,13 +675,9 @@ contract OracleReportSanityChecker is AccessControlEnumerable { function _updateLimits(LimitsList memory _newLimitsList) internal { LimitsList memory _oldLimitsList = _limits.unpack(); - if (_oldLimitsList.exitedValidatorsPerDayLimit != _newLimitsList.exitedValidatorsPerDayLimit) { - _checkLimitValue(_newLimitsList.exitedValidatorsPerDayLimit, 0, type(uint16).max); - emit ExitedValidatorsPerDayLimitSet(_newLimitsList.exitedValidatorsPerDayLimit); - } - if (_oldLimitsList.appearedValidatorsPerDayLimit != _newLimitsList.appearedValidatorsPerDayLimit) { - _checkLimitValue(_newLimitsList.appearedValidatorsPerDayLimit, 0, type(uint16).max); - emit AppearedValidatorsPerDayLimitSet(_newLimitsList.appearedValidatorsPerDayLimit); + if (_oldLimitsList.churnValidatorsPerDayLimit != _newLimitsList.churnValidatorsPerDayLimit) { + _checkLimitValue(_newLimitsList.churnValidatorsPerDayLimit, 0, type(uint16).max); + emit ChurnValidatorsPerDayLimitSet(_newLimitsList.churnValidatorsPerDayLimit); } if (_oldLimitsList.oneOffCLBalanceDecreaseBPLimit != _newLimitsList.oneOffCLBalanceDecreaseBPLimit) { _checkLimitValue(_newLimitsList.oneOffCLBalanceDecreaseBPLimit, 0, MAX_BASIS_POINTS); @@ -757,8 +720,7 @@ contract OracleReportSanityChecker is AccessControlEnumerable { } } - event ExitedValidatorsPerDayLimitSet(uint256 exitedValidatorsPerDayLimit); - event AppearedValidatorsPerDayLimitSet(uint256 appearedValidatorsPerDayLimit); + event ChurnValidatorsPerDayLimitSet(uint256 churnValidatorsPerDayLimit); event OneOffCLBalanceDecreaseBPLimitSet(uint256 oneOffCLBalanceDecreaseBPLimit); event AnnualBalanceIncreaseBPLimitSet(uint256 annualBalanceIncreaseBPLimit); event SimulatedShareRateDeviationBPLimitSet(uint256 simulatedShareRateDeviationBPLimit); @@ -774,9 +736,9 @@ contract OracleReportSanityChecker is AccessControlEnumerable { error IncorrectSharesRequestedToBurn(uint256 actualSharesToBurn); error IncorrectCLBalanceDecrease(uint256 oneOffCLBalanceDecreaseBP); error IncorrectCLBalanceIncrease(uint256 annualBalanceDiff); - error IncorrectAppearedValidators(uint256 appearedValidatorsLimit); + error IncorrectAppearedValidators(uint256 churnLimit); error IncorrectNumberOfExitRequestsPerReport(uint256 maxRequestsCount); - error IncorrectExitedValidators(uint256 exitedValudatorsLimit); + error IncorrectExitedValidators(uint256 churnLimit); error IncorrectRequestFinalization(uint256 requestCreationBlock); error ActualShareRateIsZero(); error IncorrectSimulatedShareRate(uint256 simulatedShareRate, uint256 actualShareRate); @@ -788,8 +750,7 @@ contract OracleReportSanityChecker is AccessControlEnumerable { library LimitsListPacker { function pack(LimitsList memory _limitsList) internal pure returns (LimitsListPacked memory res) { - res.exitedValidatorsPerDayLimit = SafeCast.toUint16(_limitsList.exitedValidatorsPerDayLimit); - res.appearedValidatorsPerDayLimit = SafeCast.toUint16(_limitsList.appearedValidatorsPerDayLimit); + res.churnValidatorsPerDayLimit = SafeCast.toUint16(_limitsList.churnValidatorsPerDayLimit); res.oneOffCLBalanceDecreaseBPLimit = _toBasisPoints(_limitsList.oneOffCLBalanceDecreaseBPLimit); res.annualBalanceIncreaseBPLimit = _toBasisPoints(_limitsList.annualBalanceIncreaseBPLimit); res.simulatedShareRateDeviationBPLimit = _toBasisPoints(_limitsList.simulatedShareRateDeviationBPLimit); @@ -808,8 +769,7 @@ library LimitsListPacker { library LimitsListUnpacker { function unpack(LimitsListPacked memory _limitsList) internal pure returns (LimitsList memory res) { - res.exitedValidatorsPerDayLimit = _limitsList.exitedValidatorsPerDayLimit; - res.appearedValidatorsPerDayLimit = _limitsList.appearedValidatorsPerDayLimit; + res.churnValidatorsPerDayLimit = _limitsList.churnValidatorsPerDayLimit; res.oneOffCLBalanceDecreaseBPLimit = _limitsList.oneOffCLBalanceDecreaseBPLimit; res.annualBalanceIncreaseBPLimit = _limitsList.annualBalanceIncreaseBPLimit; res.simulatedShareRateDeviationBPLimit = _limitsList.simulatedShareRateDeviationBPLimit; diff --git a/test/0.4.24/lido-handle-oracle-report.test.js b/test/0.4.24/lido-handle-oracle-report.test.js index 3e39b8465..f5cdfdffe 100644 --- a/test/0.4.24/lido-handle-oracle-report.test.js +++ b/test/0.4.24/lido-handle-oracle-report.test.js @@ -29,8 +29,7 @@ const Lido = artifacts.require('Lido') const ONE_YEAR = 3600 * 24 * 365 const ONE_DAY = 3600 * 24 const ORACLE_REPORT_LIMITS_BOILERPLATE = { - exitedValidatorsPerDayLimit: 255, - appearedValidatorsPerDayLimit: 500, + churnValidatorsPerDayLimit: 255, oneOffCLBalanceDecreaseBPLimit: 100, annualBalanceIncreaseBPLimit: 10000, simulatedShareRateDeviationBPLimit: 15, @@ -685,7 +684,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, annualBalanceIncreaseBPLimit: 100, }, { from: voting, gasPrice: 1 } @@ -709,7 +708,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - appearedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, annualBalanceIncreaseBPLimit: 100, }, { from: voting, gasPrice: 1 } @@ -747,7 +746,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, }, { from: voting, gasPrice: 1 } ) @@ -767,7 +766,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, }, { from: voting, gasPrice: 1 } ) @@ -797,7 +796,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, annualBalanceIncreaseBPLimit: 100, }, { from: voting, gasPrice: 1 } @@ -830,7 +829,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, maxPositiveTokenRebase: 10000000, }, { from: voting, gasPrice: 1 } @@ -864,7 +863,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, maxPositiveTokenRebase: 10000000, }, { from: voting, gasPrice: 1 } @@ -899,7 +898,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, maxPositiveTokenRebase: 10000000, }, { from: voting, gasPrice: 1 } @@ -933,7 +932,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, maxPositiveTokenRebase: 10000000, }, { from: voting, gasPrice: 1 } @@ -967,7 +966,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, }, { from: voting, gasPrice: 1 } ) @@ -1001,7 +1000,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, maxPositiveTokenRebase: 10000000, }, { from: voting, gasPrice: 1 } @@ -1346,7 +1345,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, maxPositiveTokenRebase: 10000000, }, { from: voting, gasPrice: 1 } @@ -1377,7 +1376,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, }, { from: voting, gasPrice: 1 } ) @@ -1398,7 +1397,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, }, { from: voting, gasPrice: 1 } ) @@ -1432,7 +1431,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, annualBalanceIncreaseBPLimit: 100, }, { from: voting, gasPrice: 1 } @@ -1465,7 +1464,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, maxPositiveTokenRebase: 10000000, }, { from: voting, gasPrice: 1 } @@ -1499,7 +1498,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, maxPositiveTokenRebase: 10000000, }, { from: voting, gasPrice: 1 } @@ -1534,7 +1533,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, maxPositiveTokenRebase: 10000000, }, { from: voting, gasPrice: 1 } @@ -1568,7 +1567,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, maxPositiveTokenRebase: 10000000, }, { from: voting, gasPrice: 1 } @@ -1602,7 +1601,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, }, { from: voting, gasPrice: 1 } ) @@ -1933,7 +1932,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, maxPositiveTokenRebase: 10000000, }, { from: voting, gasPrice: 1 } @@ -1987,7 +1986,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, maxPositiveTokenRebase: 10000000, }, { from: voting, gasPrice: 1 } @@ -2096,7 +2095,7 @@ contract('Lido: handleOracleReport', ([appManager, , , , , , bob, stranger, anot await oracleReportSanityChecker.setOracleReportLimits( { ...ORACLE_REPORT_LIMITS_BOILERPLATE, - exitedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 100, maxPositiveTokenRebase: 10000000, }, { from: voting, gasPrice: 1 } diff --git a/test/0.8.9/oracle-report-sanity-checker.test.js b/test/0.8.9/oracle-report-sanity-checker.test.js index aa5e0ebba..27ac1e304 100644 --- a/test/0.8.9/oracle-report-sanity-checker.test.js +++ b/test/0.8.9/oracle-report-sanity-checker.test.js @@ -25,20 +25,18 @@ contract('OracleReportSanityChecker', ([deployer, admin, withdrawalVault, elRewa let oracleReportSanityChecker, lidoLocatorMock, lidoMock, withdrawalQueueMock, burnerMock, snapshot const managersRoster = { allLimitsManagers: accounts.slice(0, 2), - exitedValidatorsPerDayLimitManagers: accounts.slice(2, 4), - appearedValidatorsPerDayLimitManagers: accounts.slice(4, 6), - oneOffCLBalanceDecreaseLimitManagers: accounts.slice(6, 8), - annualBalanceIncreaseLimitManagers: accounts.slice(8, 10), - shareRateDeviationLimitManagers: accounts.slice(10, 12), - maxValidatorExitRequestsPerReportManagers: accounts.slice(12, 14), - maxAccountingExtraDataListItemsCountManagers: accounts.slice(14, 16), - maxNodeOperatorsPerExtraDataItemCountManagers: accounts.slice(16, 18), - requestTimestampMarginManagers: accounts.slice(18, 20), - maxPositiveTokenRebaseManagers: accounts.slice(20, 22), + churnValidatorsPerDayLimitManagers: accounts.slice(2, 4), + oneOffCLBalanceDecreaseLimitManagers: accounts.slice(4, 6), + annualBalanceIncreaseLimitManagers: accounts.slice(6, 8), + shareRateDeviationLimitManagers: accounts.slice(8, 10), + maxValidatorExitRequestsPerReportManagers: accounts.slice(10, 12), + maxAccountingExtraDataListItemsCountManagers: accounts.slice(12, 14), + maxNodeOperatorsPerExtraDataItemCountManagers: accounts.slice(14, 16), + requestTimestampMarginManagers: accounts.slice(16, 18), + maxPositiveTokenRebaseManagers: accounts.slice(18, 20), } const defaultLimitsList = { - exitedValidatorsPerDayLimit: 55, - appearedValidatorsPerDayLimit: 100, + churnValidatorsPerDayLimit: 55, oneOffCLBalanceDecreaseBPLimit: 5_00, // 5% annualBalanceIncreaseBPLimit: 10_00, // 10% simulatedShareRateDeviationBPLimit: 2_50, // 2.5% @@ -116,8 +114,7 @@ contract('OracleReportSanityChecker', ([deployer, admin, withdrawalVault, elRewa describe('setOracleReportLimits()', () => { it('sets limits correctly', async () => { const newLimitsList = { - exitedValidatorsPerDayLimit: 50, - appearedValidatorsPerDayLimit: 75, + churnValidatorsPerDayLimit: 50, oneOffCLBalanceDecreaseBPLimit: 10_00, annualBalanceIncreaseBPLimit: 15_00, simulatedShareRateDeviationBPLimit: 1_50, // 1.5% @@ -128,8 +125,7 @@ contract('OracleReportSanityChecker', ([deployer, admin, withdrawalVault, elRewa maxPositiveTokenRebase: 10_000_000, } const limitsBefore = await oracleReportSanityChecker.getOracleReportLimits() - assert.notEquals(limitsBefore.exitedValidatorsPerDayLimit, newLimitsList.exitedValidatorsPerDayLimit) - assert.notEquals(limitsBefore.appearedValidatorsPerDayLimit, newLimitsList.appearedValidatorsPerDayLimit) + assert.notEquals(limitsBefore.churnValidatorsPerDayLimit, newLimitsList.churnValidatorsPerDayLimit) assert.notEquals(limitsBefore.oneOffCLBalanceDecreaseBPLimit, newLimitsList.oneOffCLBalanceDecreaseBPLimit) assert.notEquals(limitsBefore.annualBalanceIncreaseBPLimit, newLimitsList.annualBalanceIncreaseBPLimit) assert.notEquals( @@ -160,8 +156,7 @@ contract('OracleReportSanityChecker', ([deployer, admin, withdrawalVault, elRewa }) const limitsAfter = await oracleReportSanityChecker.getOracleReportLimits() - assert.equals(limitsAfter.exitedValidatorsPerDayLimit, newLimitsList.exitedValidatorsPerDayLimit) - assert.equals(limitsAfter.appearedValidatorsPerDayLimit, newLimitsList.appearedValidatorsPerDayLimit) + assert.equals(limitsAfter.churnValidatorsPerDayLimit, newLimitsList.churnValidatorsPerDayLimit) assert.equals(limitsAfter.oneOffCLBalanceDecreaseBPLimit, newLimitsList.oneOffCLBalanceDecreaseBPLimit) assert.equals(limitsAfter.annualBalanceIncreaseBPLimit, newLimitsList.annualBalanceIncreaseBPLimit) assert.equals(limitsAfter.simulatedShareRateDeviationBPLimit, newLimitsList.simulatedShareRateDeviationBPLimit) @@ -978,90 +973,54 @@ contract('OracleReportSanityChecker', ([deployer, admin, withdrawalVault, elRewa }) }) - describe('validators limits', () => { - it('setExitedValidatorsPerDayLimit works', async () => { - const oldExitedLimit = defaultLimitsList.exitedValidatorsPerDayLimit - await oracleReportSanityChecker.checkExitedValidatorsRatePerDay(oldExitedLimit) + describe('churn limit', () => { + it('setChurnValidatorsPerDayLimit works', async () => { + const oldChurnLimit = defaultLimitsList.churnValidatorsPerDayLimit + await oracleReportSanityChecker.checkExitedValidatorsRatePerDay(oldChurnLimit) await assert.reverts( - oracleReportSanityChecker.checkExitedValidatorsRatePerDay(oldExitedLimit + 1), - `ExitedValidatorsLimitExceeded(${oldExitedLimit}, ${oldExitedLimit + 1})` - ) - assert.equals( - (await oracleReportSanityChecker.getOracleReportLimits()).exitedValidatorsPerDayLimit, - oldExitedLimit + oracleReportSanityChecker.checkExitedValidatorsRatePerDay(oldChurnLimit + 1), + `ExitedValidatorsLimitExceeded(${oldChurnLimit}, ${oldChurnLimit + 1})` ) + assert.equals((await oracleReportSanityChecker.getOracleReportLimits()).churnValidatorsPerDayLimit, oldChurnLimit) - const newExitedLimit = 30 - assert.notEquals(newExitedLimit, oldExitedLimit) + const newChurnLimit = 30 + assert.notEquals(newChurnLimit, oldChurnLimit) await assert.revertsOZAccessControl( - oracleReportSanityChecker.setExitedValidatorsPerDayLimit(newExitedLimit, { from: deployer }), + oracleReportSanityChecker.setChurnValidatorsPerDayLimit(newChurnLimit, { from: deployer }), deployer, - 'EXITED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE' + 'CHURN_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE' ) - const tx = await oracleReportSanityChecker.setExitedValidatorsPerDayLimit(newExitedLimit, { - from: managersRoster.exitedValidatorsPerDayLimitManagers[0], + const tx = await oracleReportSanityChecker.setChurnValidatorsPerDayLimit(newChurnLimit, { + from: managersRoster.churnValidatorsPerDayLimitManagers[0], }) - assert.emits(tx, 'ExitedValidatorsPerDayLimitSet', { exitedValidatorsPerDayLimit: newExitedLimit }) - assert.equals( - (await oracleReportSanityChecker.getOracleReportLimits()).exitedValidatorsPerDayLimit, - newExitedLimit - ) + assert.emits(tx, 'ChurnValidatorsPerDayLimitSet', { churnValidatorsPerDayLimit: newChurnLimit }) + assert.equals((await oracleReportSanityChecker.getOracleReportLimits()).churnValidatorsPerDayLimit, newChurnLimit) - await oracleReportSanityChecker.checkExitedValidatorsRatePerDay(newExitedLimit) + await oracleReportSanityChecker.checkExitedValidatorsRatePerDay(newChurnLimit) await assert.reverts( - oracleReportSanityChecker.checkExitedValidatorsRatePerDay(newExitedLimit + 1), - `ExitedValidatorsLimitExceeded(${newExitedLimit}, ${newExitedLimit + 1})` + oracleReportSanityChecker.checkExitedValidatorsRatePerDay(newChurnLimit + 1), + `ExitedValidatorsLimitExceeded(${newChurnLimit}, ${newChurnLimit + 1})` ) }) - it('setAppearedValidatorsPerDayLimit works', async () => { - const oldAppearedLimit = defaultLimitsList.appearedValidatorsPerDayLimit - await oracleReportSanityChecker.checkAccountingOracleReport( - ...Object.values({ ...correctLidoOracleReport, postCLValidators: oldAppearedLimit }) - ) - await assert.reverts( - oracleReportSanityChecker.checkAccountingOracleReport( - ...Object.values({ - ...correctLidoOracleReport, - postCLValidators: oldAppearedLimit + 1, - }) - ), - `IncorrectAppearedValidators(${oldAppearedLimit + 1})` - ) - - const newAppearedLimit = 30 - assert.notEquals(newAppearedLimit, oldAppearedLimit) - - await assert.revertsOZAccessControl( - oracleReportSanityChecker.setAppearedValidatorsPerDayLimit(newAppearedLimit, { from: deployer }), - deployer, - 'APPEARED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE' - ) - - const tx = await oracleReportSanityChecker.setAppearedValidatorsPerDayLimit(newAppearedLimit, { - from: managersRoster.appearedValidatorsPerDayLimitManagers[0], - }) - - assert.emits(tx, 'AppearedValidatorsPerDayLimitSet', { appearedValidatorsPerDayLimit: newAppearedLimit }) - assert.equals( - (await oracleReportSanityChecker.getOracleReportLimits()).appearedValidatorsPerDayLimit, - newAppearedLimit - ) + it('checkAccountingOracleReport: churnLimit works', async () => { + const churnLimit = defaultLimitsList.churnValidatorsPerDayLimit + assert.equals((await oracleReportSanityChecker.getOracleReportLimits()).churnValidatorsPerDayLimit, churnLimit) await oracleReportSanityChecker.checkAccountingOracleReport( - ...Object.values({ ...correctLidoOracleReport, postCLValidators: newAppearedLimit }) + ...Object.values({ ...correctLidoOracleReport, postCLValidators: churnLimit }) ) await assert.reverts( oracleReportSanityChecker.checkAccountingOracleReport( ...Object.values({ ...correctLidoOracleReport, - postCLValidators: newAppearedLimit + 1, + postCLValidators: churnLimit + 1, }) ), - `IncorrectAppearedValidators(${newAppearedLimit + 1})` + `IncorrectAppearedValidators(${churnLimit + 1})` ) }) }) @@ -1245,18 +1204,7 @@ contract('OracleReportSanityChecker', ([deployer, admin, withdrawalVault, elRewa await assert.reverts( oracleReportSanityChecker.setOracleReportLimits( - Object.values({ ...defaultLimitsList, exitedValidatorsPerDayLimit: INVALID_VALUE }), - { - from: managersRoster.allLimitsManagers[0], - } - ), - 'IncorrectLimitValue', - [INVALID_VALUE, 0, MAX_UINT_16] - ) - - await assert.reverts( - oracleReportSanityChecker.setOracleReportLimits( - Object.values({ ...defaultLimitsList, appearedValidatorsPerDayLimit: INVALID_VALUE }), + Object.values({ ...defaultLimitsList, churnValidatorsPerDayLimit: INVALID_VALUE }), { from: managersRoster.allLimitsManagers[0], } diff --git a/test/0.8.9/oracle/accounting-oracle-deploy.test.js b/test/0.8.9/oracle/accounting-oracle-deploy.test.js index efcd29ee6..4e603cf3b 100644 --- a/test/0.8.9/oracle/accounting-oracle-deploy.test.js +++ b/test/0.8.9/oracle/accounting-oracle-deploy.test.js @@ -194,22 +194,9 @@ async function initAccountingOracle({ } async function deployOracleReportSanityCheckerForAccounting(lidoLocator, admin) { - const exitedValidatorsPerDayLimit = 100 - const appearedValidatorsPerDayLimit = 200 - const limitsList = [exitedValidatorsPerDayLimit, appearedValidatorsPerDayLimit, 0, 0, 0, 32 * 12, 15, 16, 0, 0] - const managersRoster = [ - [admin], - [admin], - [admin], - [admin], - [admin], - [admin], - [admin], - [admin], - [admin], - [admin], - [admin], - ] + const churnValidatorsPerDayLimit = 100 + const limitsList = [churnValidatorsPerDayLimit, 0, 0, 0, 32 * 12, 15, 16, 0, 0] + const managersRoster = [[admin], [admin], [admin], [admin], [admin], [admin], [admin], [admin], [admin], [admin]] const OracleReportSanityChecker = artifacts.require('OracleReportSanityChecker') diff --git a/test/0.8.9/oracle/accounting-oracle-submit-report-data.test.js b/test/0.8.9/oracle/accounting-oracle-submit-report-data.test.js index 00f7568cb..49581646e 100644 --- a/test/0.8.9/oracle/accounting-oracle-submit-report-data.test.js +++ b/test/0.8.9/oracle/accounting-oracle-submit-report-data.test.js @@ -425,9 +425,9 @@ contract('AccountingOracle', ([admin, member1, member2]) => { 0 ) const exitingRateLimit = totalExitedValidators - 1 - await oracleReportSanityChecker.setExitedValidatorsPerDayLimit(exitingRateLimit) + await oracleReportSanityChecker.setChurnValidatorsPerDayLimit(exitingRateLimit) assert.equals( - (await oracleReportSanityChecker.getOracleReportLimits()).exitedValidatorsPerDayLimit, + (await oracleReportSanityChecker.getOracleReportLimits()).churnValidatorsPerDayLimit, exitingRateLimit ) await assert.reverts( diff --git a/test/0.8.9/oracle/validators-exit-bus-oracle-deploy.test.js b/test/0.8.9/oracle/validators-exit-bus-oracle-deploy.test.js index d1c5a142d..b69b28e8f 100644 --- a/test/0.8.9/oracle/validators-exit-bus-oracle-deploy.test.js +++ b/test/0.8.9/oracle/validators-exit-bus-oracle-deploy.test.js @@ -75,20 +75,8 @@ module.exports = { } async function deployOracleReportSanityCheckerForExitBus(lidoLocator, admin) { const maxValidatorExitRequestsPerReport = 2000 - const limitsList = [0, 0, 0, 0, 0, maxValidatorExitRequestsPerReport, 0, 0, 0, 0] - const managersRoster = [ - [admin], - [admin], - [admin], - [admin], - [admin], - [admin], - [admin], - [admin], - [admin], - [admin], - [admin], - ] + const limitsList = [0, 0, 0, 0, maxValidatorExitRequestsPerReport, 0, 0, 0, 0] + const managersRoster = [[admin], [admin], [admin], [admin], [admin], [admin], [admin], [admin], [admin], [admin]] const OracleReportSanityChecker = artifacts.require('OracleReportSanityChecker') diff --git a/test/helpers/config.js b/test/helpers/config.js index ac2c97d50..451c89a02 100644 --- a/test/helpers/config.js +++ b/test/helpers/config.js @@ -20,8 +20,7 @@ const DEFAULT_DEPLOY_PARAMS = { }, oracleReportSanityChecker: { limitsList: { - exitedValidatorsPerDayLimit: 255, - appearedValidatorsPerDayLimit: 500, + churnValidatorsPerDayLimit: 255, oneOffCLBalanceDecreaseBPLimit: 10000, annualBalanceIncreaseBPLimit: 10000, simulatedShareRateDeviationBPLimit: 10000, @@ -33,8 +32,7 @@ const DEFAULT_DEPLOY_PARAMS = { }, managersRoster: { allLimitsManagers: [], - exitedValidatorsPerDayLimitManagers: [], - appearedValidatorsPerDayLimitManagers: [], + churnValidatorsPerDayLimitManagers: [], oneOffCLBalanceDecreaseLimitManagers: [], annualBalanceIncreaseLimitManagers: [], shareRateDeviationLimitManagers: [], diff --git a/test/helpers/factories.js b/test/helpers/factories.js index 5dbd5b9e9..374073f43 100644 --- a/test/helpers/factories.js +++ b/test/helpers/factories.js @@ -328,8 +328,7 @@ async function oracleReportSanityCheckerFactory({ lidoLocator, voting, appManage to: voting.address, roles: [ 'ALL_LIMITS_MANAGER_ROLE', - 'EXITED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE', - 'APPEARED_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE', + 'CHURN_VALIDATORS_PER_DAY_LIMIT_MANAGER_ROLE', 'ONE_OFF_CL_BALANCE_DECREASE_LIMIT_MANAGER_ROLE', 'ANNUAL_BALANCE_INCREASE_LIMIT_MANAGER_ROLE', 'SHARE_RATE_DEVIATION_LIMIT_MANAGER_ROLE', diff --git a/test/scenario/execution_layer_rewards_after_the_merge.test.js b/test/scenario/execution_layer_rewards_after_the_merge.test.js index 51495eaa0..77dd30b8d 100644 --- a/test/scenario/execution_layer_rewards_after_the_merge.test.js +++ b/test/scenario/execution_layer_rewards_after_the_merge.test.js @@ -18,8 +18,7 @@ const LIDO_INIT_BALANCE_ETH = 1 const ONE_DAY_WITH_MARGIN = 1 * 24 * 60 * 60 + 60 * 10 // one day and 10 minutes const ORACLE_REPORT_LIMITS_BOILERPLATE = { - exitedValidatorsPerDayLimit: 255, - appearedValidatorsPerDayLimit: 500, + churnValidatorsPerDayLimit: 255, oneOffCLBalanceDecreaseBPLimit: 100, annualBalanceIncreaseBPLimit: 10000, simulatedShareRateDeviationBPLimit: 10000,