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: vaults validators triggerable exits #933

Merged
merged 104 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from 101 commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
9b454a8
feat: add withdrawal credentials lib
mkurayan Dec 19, 2024
3bfe5ac
feat: split full and partial withdrawals
mkurayan Dec 19, 2024
4420a7c
feat: decouple fee allocation strategy from withdrawal request library
mkurayan Dec 21, 2024
1a394bf
feat: rename triggerable withdrawals lib
mkurayan Dec 23, 2024
5183e89
feat: add unit tests for triggerable withdrawals lib
mkurayan Dec 26, 2024
2fc90ec
feat: add unit tests for triggerable withdrawals in the withdrawal va…
mkurayan Dec 26, 2024
5888fac
feat: use lido locator instead of direct VEB address
mkurayan Jan 10, 2025
c251b90
feat: add access control to WithdrawalVault contract
mkurayan Jan 14, 2025
9cf5ea4
Merge commit '49c97519e932f5084d4faa698f14b261befa055d' into feat/wit…
mkurayan Jan 14, 2025
1b2dd97
refactor: remove unnecessary memory allocation
mkurayan Jan 15, 2025
d26dddc
feat: specify fee per request instead of total fee in TW library
mkurayan Jan 17, 2025
66ccbcf
feat: tightly pack pubkeys
mkurayan Jan 20, 2025
96968fe
Merge remote-tracking branch 'origin/feat/withdrawal-credentials' int…
tamtamchik Jan 23, 2025
0f37e51
refactor: format code
mkurayan Jan 27, 2025
93c56a4
Merge branch 'feat/vaults' into feat/waults-triggerable-exits
tamtamchik Jan 27, 2025
6f303e5
refactor: move TriggerableWithdrawals lib from 0.8.9 to common
mkurayan Jan 27, 2025
60ba435
chore: basic refactoring of staking vault validator management
tamtamchik Jan 27, 2025
ade67a7
refactor: improve naming for address validation utility
mkurayan Jan 28, 2025
57cad87
chore: simplify code
tamtamchik Jan 28, 2025
89d583a
test: add unit tests for Withdrawal Vault excess fee refund behavior
mkurayan Jan 28, 2025
a8a9762
feat: add base layer for triggerable exits
tamtamchik Jan 28, 2025
6d31a25
Merge branch 'feat/vaults' into feat/waults-triggerable-exits
tamtamchik Jan 28, 2025
2ce0a1c
chore: cleanup
tamtamchik Jan 28, 2025
d928cf9
Merge branch 'feat/withdrawal-credentials' into feat/waults-triggerab…
tamtamchik Jan 28, 2025
cfadfb4
refactor: improve TriggerableWithdrawals lib methods description
mkurayan Jan 28, 2025
9f268cf
refactor: triggerable withdrawals lib rename errors for clarity
mkurayan Jan 28, 2025
811fdf8
refactor: describe full withdrawal method in withdrawal vault
mkurayan Jan 28, 2025
da8fad2
chore: add fees calculation base
tamtamchik Jan 28, 2025
7743888
Merge branch 'feat/withdrawal-credentials' into feat/waults-triggerab…
tamtamchik Jan 28, 2025
a7447df
chore: tests
tamtamchik Jan 28, 2025
a30cd67
chore: renaming
tamtamchik Jan 29, 2025
8bedfe6
chore: restore request validator exit
tamtamchik Jan 29, 2025
6cdc711
Merge commit '2d11786ebc1f06165c501fa8e9fecef053e12ab9' into feat/wit…
mkurayan Jan 30, 2025
6da1d6f
feat: grant withdrawal request role to ValidatorsExitBusOracle contra…
mkurayan Feb 1, 2025
cd8ec7e
Merge branch 'feat/withdrawal-credentials' into feat/vaults-triggerab…
tamtamchik Feb 3, 2025
9a1a8d8
feat: move to 0x02 wc for vaults
tamtamchik Feb 3, 2025
ab1a048
feat: beacon chain foundation contract
tamtamchik Feb 3, 2025
daf96c4
chore: cleanup staking vault interface
tamtamchik Feb 3, 2025
fde279b
test: update staking vault tests
tamtamchik Feb 3, 2025
8763f26
Merge branch 'feat/vaults' into feat/vaults-triggerable-exits
tamtamchik Feb 3, 2025
7f18488
fix: tests
tamtamchik Feb 3, 2025
1af1d3a
feat: validate withdrawal fee response
mkurayan Feb 4, 2025
c27de34
feat: update eip-7002 contract address
mkurayan Feb 4, 2025
1b11c66
feat: add initiate withdrawal functions
tamtamchik Feb 4, 2025
c9d3226
Merge branch 'feat/withdrawal-credentials' into feat/vaults-triggerab…
tamtamchik Feb 4, 2025
9b52efa
feat: forceValidatorWithdrawals poc
tamtamchik Feb 4, 2025
f27d244
chore: update permissions and dashboard
tamtamchik Feb 4, 2025
939cbb4
chore: update dashboard test coverage
tamtamchik Feb 4, 2025
6722576
chore: cleanup
tamtamchik Feb 4, 2025
748f8c9
chore: fix tests and linter
tamtamchik Feb 5, 2025
33f1d5c
chore: remove controller
tamtamchik Feb 5, 2025
dd67b36
chore: add timelock for force withdrawals
tamtamchik Feb 5, 2025
ebd830d
feat: update timelock logic
tamtamchik Feb 6, 2025
1c7abcb
ci: disable Hardhat / Mainnet tests
tamtamchik Feb 6, 2025
5d3dd3c
chore: refactor the threshold calculation
tamtamchik Feb 6, 2025
c2facaf
chore: fix assessment
tamtamchik Feb 7, 2025
0b91931
chore: update dashboarad
tamtamchik Feb 7, 2025
34bceac
feat: update staking valult
tamtamchik Feb 8, 2025
4895d35
test: fix
tamtamchik Feb 8, 2025
a8b41ab
chore: add tests
tamtamchik Feb 8, 2025
f0d865e
feat: isVaultHealthy function
tamtamchik Feb 8, 2025
60f3e68
feat: revert if partial withdrawals are requested on the unhealthy vault
tamtamchik Feb 10, 2025
5260fcd
Merge branch 'feat/vaults' into feat/vaults-triggerable-exits
tamtamchik Feb 11, 2025
fb94485
chore: some documentation
tamtamchik Feb 12, 2025
7bc6c00
chore: massive renaming
tamtamchik Feb 12, 2025
dd28196
chore: polishing
tamtamchik Feb 12, 2025
b19caf9
test: partially restore negative rebase
tamtamchik Feb 12, 2025
ccd9043
chore: cleanup
tamtamchik Feb 12, 2025
32bacb4
fix: event indexing
tamtamchik Feb 13, 2025
07655e8
test: update vault hub tests
tamtamchik Feb 13, 2025
46b08ec
test: add tests for hub functions for vaulthub
tamtamchik Feb 13, 2025
3e3c185
chore: add separate role for hub limits manipulations
tamtamchik Feb 13, 2025
c483544
chore: comments and naming fixes
tamtamchik Feb 13, 2025
8082977
chore: use msg.sender as refund address in case of zero address
tamtamchik Feb 14, 2025
83181a3
docs: cleanup
tamtamchik Feb 14, 2025
533c91c
Merge branch 'develop' into feat/vaults-triggerable-exits
tamtamchik Feb 14, 2025
633d83a
Merge branch 'develop' into feat/vaults-triggerable-exits
tamtamchik Feb 14, 2025
48141ca
feat: add typecheck to pre-commit
tamtamchik Feb 14, 2025
12beecf
fix(test): fix vaults happy path
tamtamchik Feb 14, 2025
f99a141
Merge commit '1ef6b88a7241ab6d54fb5f7f224ab88568a0d4b9' into feat/wit…
mkurayan Feb 17, 2025
bdda728
Merge branch 'feat/vaults' into feat/vaults-triggerable-exits
tamtamchik Feb 18, 2025
1f76bae
test: add review scenario test
tamtamchik Feb 18, 2025
85a2888
Merge branch 'feat/vaults' into feat/vaults-triggerable-exits
tamtamchik Feb 19, 2025
a3c2c83
Merge branch 'feat/vaults' into feat/vaults-triggerable-exits
tamtamchik Feb 19, 2025
bb5faf2
chore: apply suggestions from code review
tamtamchik Feb 19, 2025
c6640ba
chore: apply suggestions from code review
tamtamchik Feb 19, 2025
d1ed20e
Merge branch 'feat/withdrawal-credentials' into feat/vaults-triggerab…
tamtamchik Feb 20, 2025
1b9132e
chore: move vault limits to immutable
tamtamchik Feb 20, 2025
cc21f4f
feat: vaultHealthRatio
tamtamchik Feb 20, 2025
ca59995
feat: rename to healthy
tamtamchik Feb 20, 2025
f146a28
fix: event name
tamtamchik Feb 20, 2025
da3a831
chore: cleanup
tamtamchik Feb 21, 2025
c7e4a5e
chore: refactoring
tamtamchik Feb 21, 2025
145d4ef
test: vaulthub healthy
tamtamchik Feb 21, 2025
91eb54c
feat: small refactoring
tamtamchik Feb 24, 2025
9c22cdf
Merge pull request #955 from lidofinance/feat/healthy
tamtamchik Feb 24, 2025
b4c79b6
chore: better naming
tamtamchik Feb 24, 2025
586b0e2
fix: events
tamtamchik Feb 25, 2025
f76c8c2
Merge branch 'feat/vaults' into feat/vaults-triggerable-exits
tamtamchik Feb 25, 2025
984e948
chore: hardhat 2.22.19
tamtamchik Feb 25, 2025
868690c
feat: remove sanity check for max submitted keys
tamtamchik Feb 25, 2025
d4f3a62
chore: apply suggestions from code review
tamtamchik Feb 26, 2025
081444b
chore: fix comments
tamtamchik Feb 26, 2025
aa92ca3
refactor: reserveRatioThresholdBP ⇒ rebalanceThresholdBP
tamtamchik Feb 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests-integration-mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

services:
hardhat-node:
image: ghcr.io/lidofinance/hardhat-node:2.22.18
image: ghcr.io/lidofinance/hardhat-node:2.22.19
ports:
- 8545:8545
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-integration-scratch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

services:
hardhat-node:
image: ghcr.io/lidofinance/hardhat-node:2.22.18-scratch
image: ghcr.io/lidofinance/hardhat-node:2.22.19-scratch
ports:
- 8555:8545

Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
yarn lint-staged
yarn typecheck
10 changes: 8 additions & 2 deletions contracts/0.8.25/Accounting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,16 @@ contract Accounting is VaultHub {
/// @notice Lido contract
ILido public immutable LIDO;

/// @param _lidoLocator Lido Locator contract
/// @param _lido Lido contract
/// @param _connectedVaultsLimit Maximum number of active vaults that can be connected to the hub
/// @param _relativeShareLimitBP Maximum share limit for a single vault relative to Lido TVL in basis points
constructor(
ILidoLocator _lidoLocator,
ILido _lido
) VaultHub(_lido) {
ILido _lido,
uint256 _connectedVaultsLimit,
uint256 _relativeShareLimitBP
) VaultHub(_lido, _connectedVaultsLimit, _relativeShareLimitBP) {
LIDO_LOCATOR = _lidoLocator;
LIDO = _lido;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/0.8.25/interfaces/IStakingRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ interface IStakingRouter {
uint256 precisionPoints
);

function reportRewardsMinted(uint256[] memory _stakingModuleIds, uint256[] memory _totalShares) external;
function reportRewardsMinted(uint256[] calldata _stakingModuleIds, uint256[] calldata _totalShares) external;
}
34 changes: 26 additions & 8 deletions contracts/0.8.25/vaults/Dashboard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,6 @@ contract Dashboard is Permissions {
SafeERC20.safeTransfer(WETH, _recipient, _amountOfWETH);
}

/**
* @notice Requests the exit of a validator from the staking vault
* @param _validatorPublicKey Public key of the validator to exit
*/
function requestValidatorExit(bytes calldata _validatorPublicKey) external {
_requestValidatorExit(_validatorPublicKey);
}

/**
* @notice Mints stETH shares backed by the vault to the recipient.
* @param _recipient Address of the recipient
Expand Down Expand Up @@ -427,6 +419,32 @@ contract Dashboard is Permissions {
_resumeBeaconChainDeposits();
}

/**
* @notice Signals to node operators that specific validators should exit from the beacon chain. It DOES NOT
* directly trigger the exit - node operators must monitor for request events and handle the exits.
* @param _pubkeys Concatenated validator public keys (48 bytes each).
* @dev Emits `ValidatorExitRequested` event for each validator public key through the `StakingVault`.
* This is a voluntary exit request - node operators can choose whether to act on it or not.
*/
function requestValidatorExit(bytes calldata _pubkeys) external {
_requestValidatorExit(_pubkeys);
}

/**
* @notice Initiates a withdrawal from validator(s) on the beacon chain using EIP-7002 triggerable withdrawals
* Both partial withdrawals (disabled for unbalanced `StakingVault`) and full validator exits are supported.
* @param _pubkeys Concatenated validator public keys (48 bytes each).
* @param _amounts Withdrawal amounts in wei for each validator key and must match _pubkeys length.
* Set amount to 0 for a full validator exit.
* For partial withdrawals, amounts will be capped to maintain the minimum stake of 32 ETH on the validator.
* @param _refundRecipient Address to receive any fee refunds, if zero, refunds go to msg.sender.
* @dev A withdrawal fee (calculated on block-by-block basis) must be paid via msg.value.
* Use `StakingVault.calculateValidatorWithdrawalFee()` to determine the required fee.
*/
function triggerValidatorWithdrawal(bytes calldata _pubkeys, uint64[] calldata _amounts, address _refundRecipient) external payable {
_triggerValidatorWithdrawal(_pubkeys, _amounts, _refundRecipient);
}

// ==================== Internal Functions ====================

/**
Expand Down
21 changes: 18 additions & 3 deletions contracts/0.8.25/vaults/Permissions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ abstract contract Permissions is AccessControlConfirmable {
*/
bytes32 public constant REQUEST_VALIDATOR_EXIT_ROLE = keccak256("vaults.Permissions.RequestValidatorExit");

/**
* @notice Permission for triggering validator withdrawal from the StakingVault using EIP-7002 triggerable exit.
*/
bytes32 public constant TRIGGER_VALIDATOR_WITHDRAWAL_ROLE = keccak256("vaults.Permissions.TriggerValidatorWithdrawal");

/**
* @notice Permission for voluntary disconnecting the StakingVault.
*/
Expand Down Expand Up @@ -218,10 +223,20 @@ abstract contract Permissions is AccessControlConfirmable {

/**
* @dev Checks the REQUEST_VALIDATOR_EXIT_ROLE and requests validator exit on the StakingVault.
* @param _pubkey The public key of the validator to request exit for.
* @param _pubkeys The public keys of the validators to request exit for.
*/
function _requestValidatorExit(bytes calldata _pubkeys) internal onlyRole(REQUEST_VALIDATOR_EXIT_ROLE) {
stakingVault().requestValidatorExit(_pubkeys);
}

/**
* @dev Checks the TRIGGER_VALIDATOR_WITHDRAWAL_ROLE and triggers validator withdrawal on the StakingVault using EIP-7002 triggerable exit.
* @param _pubkeys The public keys of the validators to trigger withdrawal for.
* @param _amounts The amounts of ether to trigger withdrawal for.
* @param _refundRecipient The address to refund the excess ether to.
*/
function _requestValidatorExit(bytes calldata _pubkey) internal onlyRole(REQUEST_VALIDATOR_EXIT_ROLE) {
stakingVault().requestValidatorExit(_pubkey);
function _triggerValidatorWithdrawal(bytes calldata _pubkeys, uint64[] calldata _amounts, address _refundRecipient) internal onlyRole(TRIGGER_VALIDATOR_WITHDRAWAL_ROLE) {
stakingVault().triggerValidatorWithdrawal{value: msg.value}(_pubkeys, _amounts, _refundRecipient);
}

/**
Expand Down
Loading
Loading