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

feat: [draft] vaults validators triggerable exits #933

Draft
wants to merge 41 commits into
base: feat/vaults
Choose a base branch
from

Conversation

tamtamchik
Copy link
Member

@tamtamchik tamtamchik commented Jan 29, 2025

Add options for node operator, vault owner, and dao to exit validators from the beacon chain.

  • requestValidatorExit – just an event from REQUEST_VALIDATOR_EXIT_ROLE to NO to exit validators.
  • initiateValidatorWithdrawal - EIP-7002-based trigger for validators exit by VO of NO. Will trigger complete validators exit.
  • initiatePartialValidatorWithdrawal - EIP-7002-based trigger for validators exit by VO of NO. This will trigger partial validator withdrawals from the beacon chain.

Extras:

  • Vault withdrawal credentials are set to 0x02 type.

mkurayan and others added 30 commits December 19, 2024 19:45
Add role ADD_FULL_WITHDRAWAL_REQUEST_ROLE for full withdrawal requests.
Access pubkeys and amounts directly instead of copying them to memory.
pass pubkeys as array of bytes
…o feat/waults-triggerable-exits

# Conflicts:
#	scripts/scratch/steps/0120-initialize-non-aragon-contracts.ts
# Conflicts:
#	contracts/0.8.25/vaults/Dashboard.sol
#	test/integration/vaults-happy-path.integration.ts
…le-exits

# Conflicts:
#	contracts/0.8.9/WithdrawalVault.sol
#	contracts/common/lib/TriggerableWithdrawals.sol
…le-exits

# Conflicts:
#	contracts/common/lib/TriggerableWithdrawals.sol
#	test/common/lib/triggerableWithdrawals/triggerableWithdrawals.test.ts
Comment on lines +160 to +188
function addFullWithdrawalRequests(
bytes calldata pubkeys
) external payable onlyRole(ADD_FULL_WITHDRAWAL_REQUEST_ROLE) {
uint256 prevBalance = address(this).balance - msg.value;

uint256 minFeePerRequest = TriggerableWithdrawals.getWithdrawalRequestFee();
uint256 totalFee = (pubkeys.length / TriggerableWithdrawals.PUBLIC_KEY_LENGTH) * minFeePerRequest;

if (totalFee > msg.value) {
revert InsufficientTriggerableWithdrawalFee(
msg.value,
totalFee,
pubkeys.length / TriggerableWithdrawals.PUBLIC_KEY_LENGTH
);
}

TriggerableWithdrawals.addFullWithdrawalRequests(pubkeys, minFeePerRequest);

uint256 refund = msg.value - totalFee;
if (refund > 0) {
(bool success, ) = msg.sender.call{value: refund}("");

if (!success) {
revert TriggerableWithdrawalRefundFailed();
}
}

assert(address(this).balance == prevBalance);
}

Check warning

Code scanning / Slither

Divide before multiply Medium

Comment on lines +160 to +188
function addFullWithdrawalRequests(
bytes calldata pubkeys
) external payable onlyRole(ADD_FULL_WITHDRAWAL_REQUEST_ROLE) {
uint256 prevBalance = address(this).balance - msg.value;

uint256 minFeePerRequest = TriggerableWithdrawals.getWithdrawalRequestFee();
uint256 totalFee = (pubkeys.length / TriggerableWithdrawals.PUBLIC_KEY_LENGTH) * minFeePerRequest;

if (totalFee > msg.value) {
revert InsufficientTriggerableWithdrawalFee(
msg.value,
totalFee,
pubkeys.length / TriggerableWithdrawals.PUBLIC_KEY_LENGTH
);
}

TriggerableWithdrawals.addFullWithdrawalRequests(pubkeys, minFeePerRequest);

uint256 refund = msg.value - totalFee;
if (refund > 0) {
(bool success, ) = msg.sender.call{value: refund}("");

if (!success) {
revert TriggerableWithdrawalRefundFailed();
}
}

assert(address(this).balance == prevBalance);
}

Check warning

Code scanning / Slither

Dangerous strict equalities Medium

@tamtamchik tamtamchik force-pushed the feat/vaults-triggerable-exits branch from 41728a7 to a30cd67 Compare January 29, 2025 08:20
Copy link

github-actions bot commented Jan 29, 2025

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%   117-120, 346, 372
contracts/0.8.25/interfaces/IDepositContract.sol                   0       0  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/utils/AccessControlVoteable.sol                  29       0  100.00%
contracts/0.8.25/utils/PausableUntilWithRoles.sol                  3       0  100.00%
contracts/0.8.25/vaults/BeaconValidatorController.sol             48       0  100.00%
contracts/0.8.25/vaults/Dashboard.sol                             90       6  93.33%   474-490
contracts/0.8.25/vaults/Delegation.sol                            39       0  100.00%
contracts/0.8.25/vaults/Permissions.sol                           29       2  93.10%   154-158
contracts/0.8.25/vaults/StakingVault.sol                          85       9  89.41%   414-416, 434-466, 480-481
contracts/0.8.25/vaults/VaultFactory.sol                          32       0  100.00%
contracts/0.8.25/vaults/VaultHub.sol                             144     102  29.17%   111-124, 180-269, 284-350, 382-431, 443-451, 457-487, 501
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                               40       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                                                           3638     327  91.01%

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/IDepositContract.sol                   0       0  +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/utils/AccessControlVoteable.sol                 +29       0  +100.00%
contracts/0.8.25/utils/PausableUntilWithRoles.sol                 +3       0  +100.00%
contracts/0.8.25/vaults/BeaconValidatorController.sol            +48       0  +100.00%
contracts/0.8.25/vaults/Dashboard.sol                            +90      +6  +93.33%
contracts/0.8.25/vaults/Delegation.sol                           +39       0  +100.00%
contracts/0.8.25/vaults/Permissions.sol                          +29      +2  +93.10%
contracts/0.8.25/vaults/StakingVault.sol                         +85      +9  +89.41%
contracts/0.8.25/vaults/VaultFactory.sol                         +32       0  +100.00%
contracts/0.8.25/vaults/VaultHub.sol                            +144    +102  +29.17%
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/WithdrawalVault.sol                              +19       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                                                           +622    +209  -5.08%

Results for commit: 7f18488

Minimum allowed coverage is 90%

♻️ This comment has been updated with latest results

@tamtamchik tamtamchik changed the title feat: vaults triggerable exits feat: [draft] vaults validators triggerable exits Jan 30, 2025
contracts/0.8.25/vaults/StakingVault.sol Dismissed Show dismissed Hide dismissed
contracts/0.8.25/vaults/StakingVault.sol Dismissed Show dismissed Hide dismissed
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