Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix accounting tests for vaults #912

Merged
merged 27 commits into from
Jan 21, 2025

Conversation

vp4242
Copy link
Member

@vp4242 vp4242 commented Dec 30, 2024

Fix accounting tests for vaults

Copy link

github-actions bot commented Dec 30, 2024

badge

Hardhat Unit Tests Coverage Summary

Filename                                                       Stmts    Miss  Cover    Missing
-----------------------------------------------------------  -------  ------  -------  ------------------------------------------------------------------------------
contracts/0.4.24/Lido.sol                                        201       6  97.01%   741, 746, 787-789, 946-947
contracts/0.4.24/StETH.sol                                        79       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                   512       0  100.00%
contracts/0.4.24/oracle/LegacyOracle.sol                          72       0  100.00%
contracts/0.4.24/utils/Pausable.sol                                9       0  100.00%
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/Accounting.sol                                   90       5  94.44%   114-117, 343, 369
contracts/0.8.25/interfaces/ILido.sol                              0       0  100.00%
contracts/0.8.25/interfaces/IOracleReportSanityChecker.sol         0       0  100.00%
contracts/0.8.25/interfaces/IPostTokenRebaseReceiver.sol           0       0  100.00%
contracts/0.8.25/interfaces/IStakingRouter.sol                     0       0  100.00%
contracts/0.8.25/interfaces/IWithdrawalQueue.sol                   0       0  100.00%
contracts/0.8.25/utils/PausableUntilWithRoles.sol                  3       0  100.00%
contracts/0.8.25/vaults/BeaconChainDepositLogistics.sol           21       2  90.48%   57, 60
contracts/0.8.25/vaults/Dashboard.sol                             85       3  96.47%   170, 438, 479
contracts/0.8.25/vaults/Delegation.sol                            73       1  98.63%   340
contracts/0.8.25/vaults/StakingVault.sol                          68       0  100.00%
contracts/0.8.25/vaults/VaultFactory.sol                          22       0  100.00%
contracts/0.8.25/vaults/VaultHub.sol                             151     102  32.45%   125-138, 197-286, 301-367, 399-448, 460-468, 474-504, 518
contracts/0.8.25/vaults/interfaces/IBeaconProxy.sol                0       0  100.00%
contracts/0.8.25/vaults/interfaces/IStakingVault.sol               0       0  100.00%
contracts/0.8.4/WithdrawalsManagerProxy.sol                       61       0  100.00%
contracts/0.8.9/BeaconChainDepositor.sol                          21       2  90.48%   48, 51
contracts/0.8.9/Burner.sol                                        72       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                                   20       0  100.00%
contracts/0.8.9/OracleDaemonConfig.sol                            28       0  100.00%
contracts/0.8.9/StakingRouter.sol                                316       0  100.00%
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                               21       0  100.00%
contracts/0.8.9/lib/Math.sol                                       4       0  100.00%
contracts/0.8.9/lib/PositiveTokenRebaseLimiter.sol                22      22  0.00%    88-172
contracts/0.8.9/lib/UnstructuredRefStorage.sol                     2       0  100.00%
contracts/0.8.9/oracle/AccountingOracle.sol                      190       2  98.95%   154-155
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/ValidatorsExitBusOracle.sol                91      91  0.00%    96-461
contracts/0.8.9/proxy/OssifiableProxy.sol                         17       0  100.00%
contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol      218      56  74.31%   195, 232, 273-324, 413-441, 495-507, 558-561, 569, 578, 586, 697, 702-747, 802
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       1  96.55%   33
contracts/testnets/sepolia/SepoliaDepositAdapter.sol              21      21  0.00%    49-100
TOTAL                                                           3543     316  91.08%

Diff against master

Filename                                                       Stmts    Miss  Cover
-----------------------------------------------------------  -------  ------  --------
contracts/0.4.24/Lido.sol                                        -11      +6  -2.99%
contracts/0.4.24/StETH.sol                                        +7       0  +100.00%
contracts/0.8.25/Accounting.sol                                  +90      +5  +94.44%
contracts/0.8.25/interfaces/ILido.sol                              0       0  +100.00%
contracts/0.8.25/interfaces/IOracleReportSanityChecker.sol         0       0  +100.00%
contracts/0.8.25/interfaces/IPostTokenRebaseReceiver.sol           0       0  +100.00%
contracts/0.8.25/interfaces/IStakingRouter.sol                     0       0  +100.00%
contracts/0.8.25/interfaces/IWithdrawalQueue.sol                   0       0  +100.00%
contracts/0.8.25/utils/PausableUntilWithRoles.sol                 +3       0  +100.00%
contracts/0.8.25/vaults/BeaconChainDepositLogistics.sol          +21      +2  +90.48%
contracts/0.8.25/vaults/Dashboard.sol                            +85      +3  +96.47%
contracts/0.8.25/vaults/Delegation.sol                           +73      +1  +98.63%
contracts/0.8.25/vaults/StakingVault.sol                         +68       0  +100.00%
contracts/0.8.25/vaults/VaultFactory.sol                         +22       0  +100.00%
contracts/0.8.25/vaults/VaultHub.sol                            +151    +102  +32.45%
contracts/0.8.25/vaults/interfaces/IBeaconProxy.sol                0       0  +100.00%
contracts/0.8.25/vaults/interfaces/IStakingVault.sol               0       0  +100.00%
contracts/0.8.9/Burner.sol                                        +1       0  +100.00%
contracts/0.8.9/LidoLocator.sol                                   +2       0  +100.00%
contracts/0.8.9/lib/PositiveTokenRebaseLimiter.sol                 0     +22  -100.00%
contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol      -14     +56  -25.69%
contracts/common/utils/PausableUntil.sol                         +29      +1  +96.55%
TOTAL                                                           +527    +198  -5.01%

Results for commit: ade6c03

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@vp4242 vp4242 force-pushed the feat/fix-accounting-tests-vaults branch from 58f9dc9 to d456680 Compare January 10, 2025 09:59
@vp4242 vp4242 marked this pull request as ready for review January 10, 2025 11:32
@vp4242 vp4242 requested a review from folkyatina January 10, 2025 11:32
Copy link
Member

@folkyatina folkyatina left a comment

Choose a reason for hiding this comment

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

I suggest to reframe it as a unit tests, without testing the lido+accounting duo together

@@ -79,7 +79,14 @@ export async function deployLidoDao({ rootAccount, initialized, locatorConfig =
await lido.initialize(locator, eip712steth, { value: ether("1.0") });
}

return { lido, dao, acl };
const locator = await lido.getLidoLocator();
Copy link
Member

Choose a reason for hiding this comment

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

Looks like these lines add accounting deployment to the dozen of different test suites. Do we really need it this way? It will slow down all the test pipeline. Maybe, we need a separate function for it?

@@ -125,14 +125,6 @@ contract OracleReportSanityCheckerStub {
uint256 _reportTimestamp
) external view {}

function checkSimulatedShareRate(
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this contract is not used at all and may be deleted safely. Probably, even the whole file.

@folkyatina folkyatina marked this pull request as draft January 15, 2025 08:19
@vp4242 vp4242 marked this pull request as ready for review January 16, 2025 10:57
@vp4242 vp4242 requested a review from folkyatina January 16, 2025 10:57
Copy link
Member

@folkyatina folkyatina left a comment

Choose a reason for hiding this comment

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

Almost ready to merge


let elRewardsVault: LidoExecutionLayerRewardsVault__MockForLidoAccounting;
let withdrawalVault: WithdrawalVault__MockForLidoAccounting;
let stakingRouter: StakingRouter__MockForLidoAccounting;
let oracleReportSanityChecker: OracleReportSanityChecker__MockForAccounting;
Copy link
Member

Choose a reason for hiding this comment

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

Lido don't use sanity checker anymore, so we can skip this part of initialization.


let lido: Lido;
let acl: ACL;
// let locator: LidoLocator;
let postTokenRebaseReceiver: IPostTokenRebaseReceiver;
Copy link
Member

Choose a reason for hiding this comment

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

Lido don't use postTokenRebaseReceiver too, so we can skip it.

let locator: LidoLocator;

let lido: Lido__MockForAccounting;
let elRewardsVault: LidoExecutionLayerRewardsVault__MockForLidoAccounting;
Copy link
Member

Choose a reason for hiding this comment

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

We can remove excess dependencies if testing only Accounting: elRewardsVault and withdrawalVault

it("Reverts if the `checkAccountingOracleReport` sanity check fails", async () => {
await oracleReportSanityChecker.mock__checkAccountingOracleReportReverts(true);

await expect(accounting.handleOracleReport(report())).to.be.reverted;
Copy link
Member

Choose a reason for hiding this comment

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

Need to check the exact reason

withdrawalFinalizationBatches: [1n],
}),
),
).to.be.reverted;
Copy link
Member

Choose a reason for hiding this comment

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

Need to check the reason


/// NOTE: This test is not applicable to the current implementation (Accounting's _checkAccountingOracleReport() checks for checkWithdrawalQueueOracleReport()
/// explicitly in case _report.withdrawalFinalizationBatches.length > 0
// it("Does not revert if the `checkWithdrawalQueueOracleReport` sanity check fails but `withdrawalQueue` is paused", async () => {
Copy link
Member

Choose a reason for hiding this comment

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

It maybe a bug in a new Accounting, BTW. Need to check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could be. Previous implementation have explicit check for pause state

if (!withdrawalQueue.isPaused()) {

@vp4242 vp4242 requested a review from folkyatina January 16, 2025 15:50
Copy link
Member

@folkyatina folkyatina left a comment

Choose a reason for hiding this comment

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

:shipit:

}),
),
)
.and.to.emit(lido, "TransferShares")
Copy link
Member

Choose a reason for hiding this comment

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

Looks like formatter troubles

@folkyatina folkyatina merged commit cf4ad78 into feat/vaults Jan 21, 2025
9 checks passed
@folkyatina folkyatina deleted the feat/fix-accounting-tests-vaults branch January 21, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants