Skip to content

Commit

Permalink
feat: remove sanity check for max submitted keys
Browse files Browse the repository at this point in the history
  • Loading branch information
tamtamchik committed Feb 25, 2025
1 parent 984e948 commit 868690c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
11 changes: 0 additions & 11 deletions contracts/0.8.25/vaults/StakingVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ contract StakingVault is IStakingVault, OwnableUpgradeable {
*/
uint256 public constant PUBLIC_KEY_LENGTH = 48;

/**
* @notice The maximum number of pubkeys per request (to avoid burning too much gas)
*/
uint256 public constant MAX_PUBLIC_KEYS_PER_REQUEST = 5000;

/**
* @notice Storage offset slot for ERC-7201 namespace
* The storage namespace is used to prevent upgrade collisions
Expand Down Expand Up @@ -451,7 +446,6 @@ contract StakingVault is IStakingVault, OwnableUpgradeable {
}

uint256 keysCount = _pubkeys.length / PUBLIC_KEY_LENGTH;
if (keysCount > MAX_PUBLIC_KEYS_PER_REQUEST) revert TooManyPubkeys();
for (uint256 i = 0; i < keysCount; i++) {
bytes memory pubkey = _pubkeys[i * PUBLIC_KEY_LENGTH : (i + 1) * PUBLIC_KEY_LENGTH];
emit ValidatorExitRequested(msg.sender, pubkey, pubkey);
Expand Down Expand Up @@ -738,11 +732,6 @@ contract StakingVault is IStakingVault, OwnableUpgradeable {
*/
error InvalidAmountsLength();

/**
* @notice Thrown when the number of pubkeys is too large
*/
error TooManyPubkeys();

/**
* @notice Thrown when the validator withdrawal fee is insufficient
* @param _passed Amount of ether passed to the function
Expand Down
18 changes: 0 additions & 18 deletions test/0.8.25/vaults/staking-vault/stakingVault.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ const MAX_INT128 = 2n ** 127n - 1n;
const MAX_UINT128 = 2n ** 128n - 1n;

const PUBLIC_KEY_LENGTH = 48;
const MAX_PUBLIC_KEYS_PER_REQUEST = 5000;

const SAMPLE_PUBKEY = "0x" + "ab".repeat(48);

const getPubkeys = (num: number): { pubkeys: string[]; stringified: string } => {
Expand Down Expand Up @@ -134,7 +132,6 @@ describe("StakingVault.sol", () => {
it("returns the correct initial state and constants", async () => {
expect(await stakingVault.DEPOSIT_CONTRACT()).to.equal(depositContractAddress);
expect(await stakingVault.PUBLIC_KEY_LENGTH()).to.equal(PUBLIC_KEY_LENGTH);
expect(await stakingVault.MAX_PUBLIC_KEYS_PER_REQUEST()).to.equal(MAX_PUBLIC_KEYS_PER_REQUEST);

expect(await stakingVault.owner()).to.equal(await vaultOwner.getAddress());
expect(await stakingVault.getInitializedVersion()).to.equal(1n);
Expand Down Expand Up @@ -665,14 +662,6 @@ describe("StakingVault.sol", () => {
).to.be.revertedWithCustomError(stakingVault, "InvalidPubkeysLength");
});

it("reverts if the number of validator keys is too large", async () => {
const numberOfKeys = Number(await stakingVault.MAX_PUBLIC_KEYS_PER_REQUEST()) + 1;
const keys = getPubkeys(numberOfKeys);
await expect(
stakingVault.connect(vaultOwner).requestValidatorExit(keys.stringified),
).to.be.revertedWithCustomError(stakingVault, "TooManyPubkeys");
});

it("emits the `ValidatorExitRequested` event for a single validator key", async () => {
await expect(stakingVault.connect(vaultOwner).requestValidatorExit(SAMPLE_PUBKEY))
.to.emit(stakingVault, "ValidatorExitRequested")
Expand All @@ -693,13 +682,6 @@ describe("StakingVault.sol", () => {
const receipt = (await tx.wait()) as ContractTransactionReceipt;
expect(receipt.logs.length).to.equal(numberOfKeys);
});

it("handles up to MAX_PUBLIC_KEYS_PER_REQUEST validator keys", async () => {
const numberOfKeys = 5000; // uses ~16300771 gas (>54% from the 30000000 gas limit)
const keys = getPubkeys(numberOfKeys);

await stakingVault.connect(vaultOwner).requestValidatorExit(keys.stringified);
});
});

context("triggerValidatorWithdrawal", () => {
Expand Down

0 comments on commit 868690c

Please sign in to comment.