From ccd904391ef3d1424c7a984c68d9fecdb3471ae3 Mon Sep 17 00:00:00 2001 From: Yuri Tkachenko Date: Wed, 12 Feb 2025 17:01:42 +0000 Subject: [PATCH] chore: cleanup --- contracts/0.8.25/vaults/StakingVault.sol | 2 +- contracts/0.8.25/vaults/VaultHub.sol | 2 +- .../StakingVault__HarnessForTestUpgrade.sol | 2 -- .../vaulthub/vaulthub.withdrawals.test.ts | 22 +++++++++---------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/contracts/0.8.25/vaults/StakingVault.sol b/contracts/0.8.25/vaults/StakingVault.sol index b519ae7ef..592c9c8e5 100644 --- a/contracts/0.8.25/vaults/StakingVault.sol +++ b/contracts/0.8.25/vaults/StakingVault.sol @@ -45,7 +45,7 @@ import {IStakingVault} from "./interfaces/IStakingVault.sol"; * - `lock()` * - `report()` * - `rebalance()` - * - `forceValidatorWithdrawals()` + * - `triggerValidatorWithdrawal()` (only full validator exit when the vault is unbalanced) * - Anyone: * - Can send ETH directly to the vault (treated as rewards) * diff --git a/contracts/0.8.25/vaults/VaultHub.sol b/contracts/0.8.25/vaults/VaultHub.sol index 304f49e93..205214f26 100644 --- a/contracts/0.8.25/vaults/VaultHub.sol +++ b/contracts/0.8.25/vaults/VaultHub.sol @@ -347,7 +347,7 @@ abstract contract VaultHub is PausableUntilWithRoles { /// @param _vault vault address /// @param _pubkeys pubkeys of the validators to withdraw /// @param _refundRecepient address of the recipient of the refund - function forceValidatorWithdrawals( + function forceValidatorWithdrawal( address _vault, bytes calldata _pubkeys, address _refundRecepient diff --git a/test/0.8.25/vaults/contracts/StakingVault__HarnessForTestUpgrade.sol b/test/0.8.25/vaults/contracts/StakingVault__HarnessForTestUpgrade.sol index 46eda7ad9..e79f7bb27 100644 --- a/test/0.8.25/vaults/contracts/StakingVault__HarnessForTestUpgrade.sol +++ b/test/0.8.25/vaults/contracts/StakingVault__HarnessForTestUpgrade.sol @@ -133,8 +133,6 @@ contract StakingVault__HarnessForTestUpgrade is IStakingVault, OwnableUpgradeabl address _recipient ) external payable {} - function forceValidatorWithdrawals(bytes calldata _pubkeys) external payable {} - error ZeroArgument(string name); error VaultAlreadyInitialized(); } diff --git a/test/0.8.25/vaults/vaulthub/vaulthub.withdrawals.test.ts b/test/0.8.25/vaults/vaulthub/vaulthub.withdrawals.test.ts index 73c05dd26..2a2d821e8 100644 --- a/test/0.8.25/vaults/vaulthub/vaulthub.withdrawals.test.ts +++ b/test/0.8.25/vaults/vaulthub/vaulthub.withdrawals.test.ts @@ -109,33 +109,33 @@ describe("VaultHub.sol:withdrawals", () => { }); }); - context("forceValidatorWithdrawals", () => { + context("forceValidatorWithdrawal", () => { it("reverts if msg.value is 0", async () => { - await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 0n })) + await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 0n })) .to.be.revertedWithCustomError(vaultHub, "ZeroArgument") .withArgs("msg.value"); }); it("reverts if the vault is zero address", async () => { - await expect(vaultHub.forceValidatorWithdrawals(ZeroAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n })) + await expect(vaultHub.forceValidatorWithdrawal(ZeroAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n })) .to.be.revertedWithCustomError(vaultHub, "ZeroArgument") .withArgs("_vault"); }); it("reverts if zero pubkeys", async () => { - await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, "0x", feeRecipient, { value: 1n })) + await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, "0x", feeRecipient, { value: 1n })) .to.be.revertedWithCustomError(vaultHub, "ZeroArgument") .withArgs("_pubkeys"); }); it("reverts if zero refund recipient", async () => { - await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, SAMPLE_PUBKEY, ZeroAddress, { value: 1n })) + await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, SAMPLE_PUBKEY, ZeroAddress, { value: 1n })) .to.be.revertedWithCustomError(vaultHub, "ZeroArgument") .withArgs("_refundRecepient"); }); it("reverts if vault is not connected to the hub", async () => { - await expect(vaultHub.forceValidatorWithdrawals(stranger, SAMPLE_PUBKEY, feeRecipient, { value: 1n })) + await expect(vaultHub.forceValidatorWithdrawal(stranger, SAMPLE_PUBKEY, feeRecipient, { value: 1n })) .to.be.revertedWithCustomError(vaultHub, "NotConnectedToHub") .withArgs(stranger.address); }); @@ -143,13 +143,13 @@ describe("VaultHub.sol:withdrawals", () => { it("reverts if called for a disconnected vault", async () => { await vaultHub.connect(user).disconnect(vaultAddress); - await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n })) + await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n })) .to.be.revertedWithCustomError(vaultHub, "NotConnectedToHub") .withArgs(vaultAddress); }); it("reverts if called for a healthy vault", async () => { - await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n })) + await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n })) .to.be.revertedWithCustomError(vaultHub, "AlreadyBalanced") .withArgs(vaultAddress, 0n, 0n); }); @@ -158,13 +158,13 @@ describe("VaultHub.sol:withdrawals", () => { beforeEach(async () => await makeVaultUnhealthy()); it("reverts if fees are insufficient", async () => { - await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n })) + await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: 1n })) .to.be.revertedWithCustomError(vault, "InsufficientValidatorWithdrawalFee") .withArgs(1n, FEE); }); it("initiates force validator withdrawal", async () => { - await expect(vaultHub.forceValidatorWithdrawals(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: FEE })) + await expect(vaultHub.forceValidatorWithdrawal(vaultAddress, SAMPLE_PUBKEY, feeRecipient, { value: FEE })) .to.emit(vaultHub, "VaultForceWithdrawalTriggered") .withArgs(vaultAddress, SAMPLE_PUBKEY, feeRecipient); }); @@ -174,7 +174,7 @@ describe("VaultHub.sol:withdrawals", () => { const pubkeys = "0x" + "ab".repeat(numPubkeys * 48); await expect( - vaultHub.forceValidatorWithdrawals(vaultAddress, pubkeys, feeRecipient, { value: FEE * BigInt(numPubkeys) }), + vaultHub.forceValidatorWithdrawal(vaultAddress, pubkeys, feeRecipient, { value: FEE * BigInt(numPubkeys) }), ) .to.emit(vaultHub, "VaultForceWithdrawalTriggered") .withArgs(vaultAddress, pubkeys, feeRecipient);