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

[Vaults] Immutably fix the node operator in the basic StakingVault #897

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

Conversation

mymphe
Copy link
Contributor

@mymphe mymphe commented Dec 13, 2024

This PR fixes the operator address in the basic vault. This means that the vault owner cannot change the node operator address in Delegation and, thus, we don't need the LIDO_DAO role in Delegation to approve the change.

@mymphe mymphe requested a review from a team as a code owner December 13, 2024 10:06
contracts/0.8.25/vaults/Delegation.sol Outdated Show resolved Hide resolved
contracts/0.8.25/vaults/StakingVault.sol Outdated Show resolved Hide resolved
contracts/0.8.25/vaults/StakingVault.sol Outdated Show resolved Hide resolved

$.locked = SafeCast.toUint128(_locked);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe, it's not worth to trust oracle here so much?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we will definitely need a sanity checker here but for now we can leave the safecast.

contracts/0.8.25/vaults/StakingVault.sol Outdated Show resolved Hide resolved
contracts/0.8.25/vaults/StakingVault.sol Outdated Show resolved Hide resolved
contracts/0.8.25/vaults/VaultFactory.sol Outdated Show resolved Hide resolved
* Key master can:
* - deposit validators to the beacon chain
*/
bytes32 public constant KEY_MASTER_ROLE = keccak256("Vault.Delegation.KeyMasterRole");
Copy link
Member

Choose a reason for hiding this comment

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

It may be preliminary to get rid of this role.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? Keymaster does not have any duties in the delegation contract, since they use the base vault for depositing validator keys.

Copy link
Member

Choose a reason for hiding this comment

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

It still can be a useful to have a role that can only deposit, but have no access to fees or role setup.

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 we have 3 different role hierarchy: independent operator in vault, operatir in delegation and default_admin in delegation.

But looks like it should be only two of them:
default_admin and operator(that is the same address that is in the basic vault)

* - Total value = report.valuation + (current inOutDelta - report.inOutDelta)
* - Vault is "healthy" if total value >= locked amount
* - Unlocked ETH = max(0, total value - locked amount)
* 2. Valuation & Balance
Copy link
Member

Choose a reason for hiding this comment

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

Balance here is read as eth balance. Maybe, "Valuation and Lock

Copy link
Member

@tamtamchik tamtamchik left a comment

Choose a reason for hiding this comment

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

🚜 🚜 🚜

@@ -4,7 +4,7 @@
// See contracts/COMPILERS.md
pragma solidity 0.8.25;

import {MemUtils} from "../../common/lib/MemUtils.sol";
import {MemUtils} from "contracts/common/lib/MemUtils.sol";
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure what the process is here, do we need to import our contracts always under "contracts/" namespace or use a relative path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think imports relative to root are much more readable. You can clearly see where the file is imported from

@@ -26,7 +26,7 @@ interface IDepositContract {
*
* This contract will be refactored to support custom deposit amounts for MAX_EB.
*/
contract VaultBeaconChainDepositor {
contract BeaconChainDepositLogistics {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this makes the naming better, tbh

contracts/0.8.25/vaults/Delegation.sol Show resolved Hide resolved
contracts/0.8.25/vaults/Delegation.sol Show resolved Hide resolved
Comment on lines 125 to 128
/**
* @notice Returns the current version of the contract
* @return uint64 contract version number
*/
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/**
* @notice Returns the current version of the contract
* @return uint64 contract version number
*/
/// @return uint64 contract version number

test/0.8.25/vaults/dashboard/dashboard.test.ts Outdated Show resolved Hide resolved
test/0.8.25/vaults/dashboard/dashboard.test.ts Outdated Show resolved Hide resolved
.connect(vaultOwner)
.createVault({ managementFee: 0n, performanceFee: 0n, manager, operator }, "0x");
const vaultCreationReceipt = await vaultCreationTx.wait();
if (!vaultCreationReceipt) throw new Error("Vault creation receipt not found");
Copy link
Member

Choose a reason for hiding this comment

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

Is this a possible scenario in the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it depends on the network. It is always defined in Hardhat but maybe null in some other network

address _owner = owner();
uint256 codeSize;

assembly {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assembly {
// Checking if owner is a contract by getting its code size
assembly {


try IReportReceiver(owner()).onReport(_valuation, _inOutDelta, _locked) {} catch (bytes memory reason) {
emit OnReportFailed(address(this), reason);
if (codeSize > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (codeSize > 0) {
// If owner is a contract (has code), try to notify it about the report
if (codeSize > 0) {

# Conflicts:
#	package.json
#	test/0.8.25/vaults/delegation-voting.test.ts
#	test/0.8.25/vaults/delegation.test.ts
#	yarn.lock
Copy link

github-actions bot commented Dec 17, 2024

badge

Hardhat Unit Tests Coverage Summary

Filename                                                       Stmts    Miss  Cover    Missing
-----------------------------------------------------------  -------  ------  -------  ---------
contracts/0.4.24/Lido.sol                                        197     197  0.00%    199-1047
contracts/0.4.24/StETH.sol                                        77      77  0.00%    123-558
contracts/0.4.24/StETHPermit.sol                                  15      15  0.00%    102-176
contracts/0.4.24/lib/Packed64x4.sol                                5       5  0.00%    26-47
contracts/0.4.24/lib/SigningKeys.sol                              36      36  0.00%    25-177
contracts/0.4.24/lib/StakeLimitUtils.sol                          37      37  0.00%    67-229
contracts/0.4.24/nos/NodeOperatorsRegistry.sol                   512     512  0.00%    220-1566
contracts/0.4.24/oracle/LegacyOracle.sol                          72      72  0.00%    114-399
contracts/0.4.24/utils/Pausable.sol                                9       9  0.00%    19-41
contracts/0.4.24/utils/Versioned.sol                               5       5  0.00%    31-45
contracts/0.6.12/WstETH.sol                                       17      17  0.00%    39-116
contracts/0.8.25/Accounting.sol                                   90      90  0.00%    95-487
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/vaults/BeaconChainDepositLogistics.sol           21       2  90.48%   57, 60
contracts/0.8.25/vaults/Dashboard.sol                             42      42  0.00%    44-287
contracts/0.8.25/vaults/Delegation.sol                            80      80  0.00%    110-399
contracts/0.8.25/vaults/StakingVault.sol                          68       0  100.00%
contracts/0.8.25/vaults/VaultFactory.sol                          19      19  0.00%    48-90
contracts/0.8.25/vaults/VaultHub.sol                             151     151  0.00%    83-519
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      61  0.00%    26-518
contracts/0.8.9/BeaconChainDepositor.sol                          21      21  0.00%    32-88
contracts/0.8.9/Burner.sol                                        72      72  0.00%    129-378
contracts/0.8.9/DepositSecurityModule.sol                        128     128  0.00%    115-622
contracts/0.8.9/EIP712StETH.sol                                   16      16  0.00%    52-117
contracts/0.8.9/LidoExecutionLayerRewardsVault.sol                16      16  0.00%    64-121
contracts/0.8.9/LidoLocator.sol                                   20      20  0.00%    60-116
contracts/0.8.9/OracleDaemonConfig.sol                            28      28  0.00%    16-73
contracts/0.8.9/StakingRouter.sol                                316     316  0.00%    168-1504
contracts/0.8.9/WithdrawalQueue.sol                               88      88  0.00%    79-413
contracts/0.8.9/WithdrawalQueueBase.sol                          146     146  0.00%    117-594
contracts/0.8.9/WithdrawalQueueERC721.sol                         89      89  0.00%    78-392
contracts/0.8.9/WithdrawalVault.sol                               21      21  0.00%    56-123
contracts/0.8.9/lib/Math.sol                                       4       4  0.00%    9-29
contracts/0.8.9/lib/PositiveTokenRebaseLimiter.sol                22      22  0.00%    88-172
contracts/0.8.9/lib/UnstructuredRefStorage.sol                     2       2  0.00%    10-16
contracts/0.8.9/oracle/AccountingOracle.sol                      190     190  0.00%    125-893
contracts/0.8.9/oracle/BaseOracle.sol                             89      89  0.00%    104-410
contracts/0.8.9/oracle/HashConsensus.sol                         263     263  0.00%    249-1094
contracts/0.8.9/oracle/ValidatorsExitBusOracle.sol                91      91  0.00%    96-461
contracts/0.8.9/proxy/OssifiableProxy.sol                         17      17  0.00%    24-87
contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol      218     218  0.00%    180-876
contracts/0.8.9/utils/DummyEmptyContract.sol                       0       0  100.00%
contracts/0.8.9/utils/PausableUntil.sol                           31      31  0.00%    28-100
contracts/0.8.9/utils/Versioned.sol                               11      11  0.00%    30-59
contracts/0.8.9/utils/access/AccessControl.sol                    23      23  0.00%    63-230
contracts/0.8.9/utils/access/AccessControlEnumerable.sol           9       9  0.00%    27-75
contracts/testnets/sepolia/SepoliaDepositAdapter.sol              21      21  0.00%    49-100
TOTAL                                                           3466    3379  2.51%

Diff against master

Filename                                                       Stmts    Miss  Cover
-----------------------------------------------------------  -------  ------  --------
contracts/0.4.24/Lido.sol                                        -15    +197  -100.00%
contracts/0.4.24/StETH.sol                                        +5     +77  -100.00%
contracts/0.4.24/StETHPermit.sol                                   0     +15  -100.00%
contracts/0.4.24/lib/Packed64x4.sol                                0      +5  -100.00%
contracts/0.4.24/lib/SigningKeys.sol                               0     +36  -100.00%
contracts/0.4.24/lib/StakeLimitUtils.sol                           0     +37  -100.00%
contracts/0.4.24/nos/NodeOperatorsRegistry.sol                     0    +512  -100.00%
contracts/0.4.24/oracle/LegacyOracle.sol                           0     +72  -100.00%
contracts/0.4.24/utils/Pausable.sol                                0      +9  -100.00%
contracts/0.4.24/utils/Versioned.sol                               0      +5  -100.00%
contracts/0.6.12/WstETH.sol                                        0     +17  -100.00%
contracts/0.8.25/Accounting.sol                                  +90     +90  +100.00%
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/vaults/BeaconChainDepositLogistics.sol          +21      +2  +90.48%
contracts/0.8.25/vaults/Dashboard.sol                            +42     +42  +100.00%
contracts/0.8.25/vaults/Delegation.sol                           +80     +80  +100.00%
contracts/0.8.25/vaults/StakingVault.sol                         +68       0  +100.00%
contracts/0.8.25/vaults/VaultFactory.sol                         +19     +19  +100.00%
contracts/0.8.25/vaults/VaultHub.sol                            +151    +151  +100.00%
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                        0     +61  -100.00%
contracts/0.8.9/BeaconChainDepositor.sol                           0     +19  -90.48%
contracts/0.8.9/Burner.sol                                        +1     +72  -100.00%
contracts/0.8.9/DepositSecurityModule.sol                          0    +128  -100.00%
contracts/0.8.9/EIP712StETH.sol                                    0     +16  -100.00%
contracts/0.8.9/LidoExecutionLayerRewardsVault.sol                 0     +16  -100.00%
contracts/0.8.9/LidoLocator.sol                                   +2     +20  -100.00%
contracts/0.8.9/OracleDaemonConfig.sol                             0     +28  -100.00%
contracts/0.8.9/StakingRouter.sol                                  0    +316  -100.00%
contracts/0.8.9/WithdrawalQueue.sol                                0     +88  -100.00%
contracts/0.8.9/WithdrawalQueueBase.sol                            0    +146  -100.00%
contracts/0.8.9/WithdrawalQueueERC721.sol                          0     +89  -100.00%
contracts/0.8.9/WithdrawalVault.sol                                0     +21  -100.00%
contracts/0.8.9/lib/Math.sol                                       0      +4  -100.00%
contracts/0.8.9/lib/PositiveTokenRebaseLimiter.sol                 0     +22  -100.00%
contracts/0.8.9/lib/UnstructuredRefStorage.sol                     0      +2  -100.00%
contracts/0.8.9/oracle/AccountingOracle.sol                        0    +188  -98.95%
contracts/0.8.9/oracle/BaseOracle.sol                              0     +88  -98.88%
contracts/0.8.9/oracle/HashConsensus.sol                           0    +262  -99.62%
contracts/0.8.9/proxy/OssifiableProxy.sol                          0     +17  -100.00%
contracts/0.8.9/sanity_checks/OracleReportSanityChecker.sol      -14    +218  -100.00%
contracts/0.8.9/utils/PausableUntil.sol                            0     +31  -100.00%
contracts/0.8.9/utils/Versioned.sol                                0     +11  -100.00%
contracts/0.8.9/utils/access/AccessControl.sol                     0     +23  -100.00%
contracts/0.8.9/utils/access/AccessControlEnumerable.sol           0      +9  -100.00%
TOTAL                                                           +450   +3261  -93.58%

Results for commit: f7086b5

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@tamtamchik tamtamchik requested a review from a team as a code owner December 17, 2024 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants