Skip to content

Fix vault freshness check and repeating reports #1215

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

Open
wants to merge 11 commits into
base: feat/vaults
Choose a base branch
from

Conversation

folkyatina
Copy link
Member

@folkyatina folkyatina commented Jul 2, 2025

Fix #1190
Fix #1200

@folkyatina folkyatina marked this pull request as ready for review July 2, 2025 15:36
@folkyatina folkyatina requested a review from a team as a code owner July 2, 2025 15:36
@folkyatina folkyatina added solidity Smart contract code changes tests When it comes to testing the code vaults Lido stVaults related changes labels Jul 2, 2025
Copy link

github-actions bot commented Jul 2, 2025

badge

Hardhat Unit Tests Coverage Summary

Filename                                                                Stmts    Miss  Cover    Missing
--------------------------------------------------------------------  -------  ------  -------  -------------------------------------------------------------------------------------------------------------------------------------------------------------------
contracts/0.4.24/Lido.sol                                                 240      12  95.00%   769-787, 867-879, 1007-1008
contracts/0.4.24/StETH.sol                                                 82       0  100.00%
contracts/0.4.24/StETHPermit.sol                                           15       0  100.00%
contracts/0.4.24/lib/Packed64x4.sol                                         5       0  100.00%
contracts/0.4.24/lib/SigningKeys.sol                                       36       0  100.00%
contracts/0.4.24/lib/StakeLimitUtils.sol                                   37       0  100.00%
contracts/0.4.24/nos/NodeOperatorsRegistry.sol                            435       0  100.00%
contracts/0.4.24/utils/Pausable.sol                                         9       0  100.00%
contracts/0.4.24/utils/UnstructuredStorageUint128.sol                      14       1  92.86%   49
contracts/0.4.24/utils/Versioned.sol                                        5       0  100.00%
contracts/0.6.12/WstETH.sol                                                17       0  100.00%
contracts/0.8.25/ValidatorExitDelayVerifier.sol                            64       0  100.00%
contracts/0.8.25/utils/AccessControlConfirmable.sol                         2       0  100.00%
contracts/0.8.25/utils/Confirmable2Addresses.sol                            5       0  100.00%
contracts/0.8.25/utils/Confirmations.sol                                   37       0  100.00%
contracts/0.8.25/utils/PausableUntilWithRoles.sol                           3       0  100.00%
contracts/0.8.25/vaults/LazyOracle.sol                                     89       4  95.51%   194, 315, 327, 338
contracts/0.8.25/vaults/OperatorGrid.sol                                  149       0  100.00%
contracts/0.8.25/vaults/PinnedBeaconProxy.sol                               5       0  100.00%
contracts/0.8.25/vaults/StakingVault.sol                                   98       0  100.00%
contracts/0.8.25/vaults/ValidatorConsolidationRequests.sol                 56       2  96.43%   100, 187
contracts/0.8.25/vaults/VaultFactory.sol                                   30       0  100.00%
contracts/0.8.25/vaults/VaultHub.sol                                      396     140  64.65%   261, 279-304, 326-334, 464-484, 540-541, 578-659, 673-675, 698-717, 780-875, 898-949, 1094, 1123-1131, 1205-1207, 1291, 1418, 1426-1440, 1454-1458, 1489-1492, 1541
contracts/0.8.25/vaults/dashboard/Dashboard.sol                           120       0  100.00%
contracts/0.8.25/vaults/dashboard/NodeOperatorFee.sol                      70       0  100.00%
contracts/0.8.25/vaults/dashboard/Permissions.sol                          50       0  100.00%
contracts/0.8.25/vaults/interfaces/IPredepositGuarantee.sol                 0       0  100.00%
contracts/0.8.25/vaults/interfaces/IStakingVault.sol                        0       0  100.00%
contracts/0.8.25/vaults/lib/PinnedBeaconUtils.sol                           6       0  100.00%
contracts/0.8.25/vaults/lib/RefSlotCache.sol                               22      17  22.73%   31-42, 60-61, 77-97
contracts/0.8.25/vaults/predeposit_guarantee/CLProofVerifier.sol           16       1  93.75%   214
contracts/0.8.25/vaults/predeposit_guarantee/MeIfNobodyElse.sol             3       0  100.00%
contracts/0.8.25/vaults/predeposit_guarantee/PredepositGuarantee.sol      159       0  100.00%
contracts/0.8.9/Accounting.sol                                             85       2  97.65%   304-305
contracts/0.8.9/BeaconChainDepositor.sol                                   21       2  90.48%   48, 51
contracts/0.8.9/Burner.sol                                                 92       0  100.00%
contracts/0.8.9/DepositSecurityModule.sol                                 128       0  100.00%
contracts/0.8.9/EIP712StETH.sol                                            16       0  100.00%
contracts/0.8.9/LidoExecutionLayerRewardsVault.sol                         16       0  100.00%
contracts/0.8.9/LidoLocator.sol                                            26       0  100.00%
contracts/0.8.9/OracleDaemonConfig.sol                                     28       0  100.00%
contracts/0.8.9/StakingRouter.sol                                         305       0  100.00%
contracts/0.8.9/TriggerableWithdrawalsGateway.sol                          54       1  98.15%   275
contracts/0.8.9/WithdrawalQueue.sol                                        88       0  100.00%
contracts/0.8.9/WithdrawalQueueBase.sol                                   146       0  100.00%
contracts/0.8.9/WithdrawalQueueERC721.sol                                  89       0  100.00%
contracts/0.8.9/WithdrawalVault.sol                                        32       0  100.00%
contracts/0.8.9/WithdrawalVaultEIP7002.sol                                 21       0  100.00%
contracts/0.8.9/lib/ExitLimitUtils.sol                                     31       0  100.00%
contracts/0.8.9/lib/Math.sol                                                4       0  100.00%
contracts/0.8.9/lib/PositiveTokenRebaseLimiter.sol                         22       0  100.00%
contracts/0.8.9/lib/UnstructuredRefStorage.sol                              2       0  100.00%
contracts/0.8.9/oracle/AccountingOracle.sol                               173       2  98.84%   123-124
contracts/0.8.9/oracle/BaseOracle.sol                                      89       1  98.88%   397
contracts/0.8.9/oracle/HashConsensus.sol                                  263       1  99.62%   1005
contracts/0.8.9/oracle/ValidatorsExitBus.sol                              136      10  92.65%   440-453, 516
contracts/0.8.9/oracle/ValidatorsExitBusOracle.sol                         53       1  98.11%   232
contracts/0.8.9/proxy/OssifiableProxy.sol                                  17       0  100.00%
contracts/0.8.9/proxy/WithdrawalsManagerProxy.sol                          60       0  100.00%
contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol               216       1  99.54%   860
contracts/0.8.9/utils/DummyEmptyContract.sol                                0       0  100.00%
contracts/0.8.9/utils/PausableUntil.sol                                    31       0  100.00%
contracts/0.8.9/utils/Versioned.sol                                        11       0  100.00%
contracts/0.8.9/utils/access/AccessControl.sol                             23       0  100.00%
contracts/0.8.9/utils/access/AccessControlEnumerable.sol                    9       0  100.00%
contracts/common/utils/PausableUntil.sol                                   29       0  100.00%
TOTAL                                                                    4591     198  95.69%

Diff against master

Filename                                                                Stmts    Miss  Cover
--------------------------------------------------------------------  -------  ------  --------
contracts/0.4.24/Lido.sol                                                 +28     +12  -5.00%
contracts/0.4.24/StETH.sol                                                +10       0  +100.00%
contracts/0.4.24/nos/NodeOperatorsRegistry.sol                            -77       0  +100.00%
contracts/0.4.24/utils/UnstructuredStorageUint128.sol                     +14      +1  +92.86%
contracts/0.8.25/ValidatorExitDelayVerifier.sol                           +64       0  +100.00%
contracts/0.8.25/utils/AccessControlConfirmable.sol                        +2       0  +100.00%
contracts/0.8.25/utils/Confirmable2Addresses.sol                           +5       0  +100.00%
contracts/0.8.25/utils/Confirmations.sol                                  +37       0  +100.00%
contracts/0.8.25/utils/PausableUntilWithRoles.sol                          +3       0  +100.00%
contracts/0.8.25/vaults/LazyOracle.sol                                    +89      +4  +95.51%
contracts/0.8.25/vaults/OperatorGrid.sol                                 +149       0  +100.00%
contracts/0.8.25/vaults/PinnedBeaconProxy.sol                              +5       0  +100.00%
contracts/0.8.25/vaults/StakingVault.sol                                  +98       0  +100.00%
contracts/0.8.25/vaults/ValidatorConsolidationRequests.sol                +56      +2  +96.43%
contracts/0.8.25/vaults/VaultFactory.sol                                  +30       0  +100.00%
contracts/0.8.25/vaults/VaultHub.sol                                     +396    +140  +64.65%
contracts/0.8.25/vaults/dashboard/Dashboard.sol                          +120       0  +100.00%
contracts/0.8.25/vaults/dashboard/NodeOperatorFee.sol                     +70       0  +100.00%
contracts/0.8.25/vaults/dashboard/Permissions.sol                         +50       0  +100.00%
contracts/0.8.25/vaults/interfaces/IPredepositGuarantee.sol                 0       0  +100.00%
contracts/0.8.25/vaults/interfaces/IStakingVault.sol                        0       0  +100.00%
contracts/0.8.25/vaults/lib/PinnedBeaconUtils.sol                          +6       0  +100.00%
contracts/0.8.25/vaults/lib/RefSlotCache.sol                              +22     +17  +22.73%
contracts/0.8.25/vaults/predeposit_guarantee/CLProofVerifier.sol          +16      +1  +93.75%
contracts/0.8.25/vaults/predeposit_guarantee/MeIfNobodyElse.sol            +3       0  +100.00%
contracts/0.8.25/vaults/predeposit_guarantee/PredepositGuarantee.sol     +159       0  +100.00%
contracts/0.8.9/Accounting.sol                                            +85      +2  +97.65%
contracts/0.8.9/Burner.sol                                                +21       0  +100.00%
contracts/0.8.9/LidoLocator.sol                                            +8       0  +100.00%
contracts/0.8.9/StakingRouter.sol                                         -11       0  +100.00%
contracts/0.8.9/TriggerableWithdrawalsGateway.sol                         +54      +1  +98.15%
contracts/0.8.9/WithdrawalVault.sol                                       +11       0  +100.00%
contracts/0.8.9/WithdrawalVaultEIP7002.sol                                +21       0  +100.00%
contracts/0.8.9/lib/ExitLimitUtils.sol                                    +31       0  +100.00%
contracts/0.8.9/oracle/AccountingOracle.sol                               -17       0  -0.11%
contracts/0.8.9/oracle/ValidatorsExitBus.sol                             +136     +10  +92.65%
contracts/0.8.9/oracle/ValidatorsExitBusOracle.sol                        -38      -1  +0.31%
contracts/0.8.9/proxy/WithdrawalsManagerProxy.sol                         +60       0  +100.00%
contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol               -16      +1  -0.46%
contracts/common/utils/PausableUntil.sol                                  +29       0  +100.00%
TOTAL                                                                   +1729    +190  -3.35%

Results for commit: b284ef8

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@folkyatina folkyatina added the bug Something isn't working label Jul 4, 2025
folkyatina added a commit that referenced this pull request Jul 4, 2025
@folkyatina folkyatina force-pushed the fix/report-freshness branch from 9627031 to 9e5226d Compare July 4, 2025 10:20
Base automatically changed from feat/testnet-2 to feat/vaults July 16, 2025 13:52
Copy link
Contributor

@TheDZhon TheDZhon left a comment

Choose a reason for hiding this comment

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

LGTM, just a small change needed in comments.

Comment on lines +1194 to +1198
// happy path. vault's report ts is the same as the latest AO report ts
if (latestReportTimestamp32 == vaultReportTimestamp) {
// check if AO has not stopped bringing the report
return block.timestamp - latestReportTimestamp < REPORT_FRESHNESS_DELTA;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// happy path. vault's report ts is the same as the latest AO report ts
if (latestReportTimestamp32 == vaultReportTimestamp) {
// check if AO has not stopped bringing the report
return block.timestamp - latestReportTimestamp < REPORT_FRESHNESS_DELTA;
}

🔪

/// @dev Returns the distance between two 32-bit numbers in counterclockwise direction
/// @param a the first number that's suppose to be larger than b
/// @param b the second number that's suppose to be smaller than a
/// @return the distance between a and b in counterclockwise direction modulo 2**32 + 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// @return the distance between a and b in counterclockwise direction modulo 2**32 + 1
/// @return the distance between a and b in counterclockwise direction modulo 2**32

/// @return the distance between a and b in counterclockwise direction modulo 2**32 + 1
/// @dev this function is used to check if a is larger than b taking into account the overflow of uint32
function ccwDistance32(uint32 a, uint32 b) internal pure returns (uint256) {
uint256 modulo = uint256(~uint32(0)) + 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
uint256 modulo = uint256(~uint32(0)) + 1;
uint256 modulo = 1 << 32;

@folkyatina folkyatina changed the title Fix vault freshness check Fix vault freshness check and repeating reports Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working solidity Smart contract code changes tests When it comes to testing the code vaults Lido stVaults related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Repetitive vault reports allowed at the same reference slot [Bug]: vault creation during the report collection interval makes report not fresh
2 participants