Skip to content

Commit

Permalink
Merge pull request #165 from lidofinance/fix/WithdrawalBatchesQueue-n…
Browse files Browse the repository at this point in the history
…aming

Audit fix: WithdrawalBatchesQueue naming
  • Loading branch information
bulbozaur authored Nov 11, 2024
2 parents a428d7c + ab3ee59 commit 08e622a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions contracts/Escrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {IWithdrawalQueue, WithdrawalRequestStatus} from "./interfaces/IWithdrawa
import {IDualGovernance} from "./interfaces/IDualGovernance.sol";

import {EscrowState} from "./libraries/EscrowState.sol";
import {WithdrawalsBatchesQueue} from "./libraries/WithdrawalBatchesQueue.sol";
import {WithdrawalsBatchesQueue} from "./libraries/WithdrawalsBatchesQueue.sol";
import {HolderAssets, StETHAccounting, UnstETHAccounting, AssetsAccounting} from "./libraries/AssetsAccounting.sol";

/// @notice Summary of the total locked assets in the Escrow.
Expand Down Expand Up @@ -423,9 +423,9 @@ contract Escrow is IEscrow {
}

/// @dev This check is primarily required when only unstETH NFTs are locked in the Escrow
/// and there are no WithdrawalBatches. In this scenario, the RageQuitExtensionPeriod can only begin
/// and there are no WithdrawalsBatches. In this scenario, the RageQuitExtensionPeriod can only begin
/// when the last locked unstETH id is finalized in the WithdrawalQueue.
/// When the WithdrawalBatchesQueue is not empty, this invariant is maintained by the following:
/// When the WithdrawalsBatchesQueue is not empty, this invariant is maintained by the following:
/// - Any locked unstETH during the VetoSignalling phase has an id less than any unstETH NFT created
/// during the request for withdrawal batches.
/// - Claiming the withdrawal batches requires the finalization of the unstETH with the given id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ library WithdrawalsBatchesQueue {

error EmptyBatch();
error InvalidUnstETHIdsSequence();
error WithdrawalBatchesQueueIsInAbsentState();
error WithdrawalBatchesQueueIsNotInOpenedState();
error WithdrawalBatchesQueueIsNotInAbsentState();
error WithdrawalsBatchesQueueIsInAbsentState();
error WithdrawalsBatchesQueueIsNotInOpenedState();
error WithdrawalsBatchesQueueIsNotInAbsentState();

// ---
// Events
// ---

event WithdrawalBatchesQueueClosed();
event WithdrawalsBatchesQueueClosed();
event UnstETHIdsAdded(uint256[] unstETHIds);
event UnstETHIdsClaimed(uint256[] unstETHIds);
event WithdrawalBatchesQueueOpened(uint256 boundaryUnstETHId);
event WithdrawalsBatchesQueueOpened(uint256 boundaryUnstETHId);

// ---
// Data types
Expand Down Expand Up @@ -92,7 +92,7 @@ library WithdrawalsBatchesQueue {
/// `boundaryUnstETHId` value is used as a lower bound for the adding unstETH ids.
function open(Context storage self, uint256 boundaryUnstETHId) internal {
if (self.info.state != State.Absent) {
revert WithdrawalBatchesQueueIsNotInAbsentState();
revert WithdrawalsBatchesQueueIsNotInAbsentState();
}

self.info.state = State.Opened;
Expand All @@ -101,7 +101,7 @@ library WithdrawalsBatchesQueue {
/// when the queue is empty. This element doesn't used during the claiming of the batches created
/// via `addUnstETHIds()` method and always allocates single batch.
self.batches.push(SequentialBatch({firstUnstETHId: boundaryUnstETHId, lastUnstETHId: boundaryUnstETHId}));
emit WithdrawalBatchesQueueOpened(boundaryUnstETHId);
emit WithdrawalsBatchesQueueOpened(boundaryUnstETHId);
}

/// @notice Adds a new batch of unstETH ids to the withdrawal queue.
Expand Down Expand Up @@ -165,7 +165,7 @@ library WithdrawalsBatchesQueue {
function close(Context storage self) internal {
_checkInOpenedState(self);
self.info.state = State.Closed;
emit WithdrawalBatchesQueueClosed();
emit WithdrawalsBatchesQueueClosed();
}

// ---
Expand Down Expand Up @@ -293,13 +293,13 @@ library WithdrawalsBatchesQueue {

function _checkNotInAbsentState(Context storage self) private view {
if (self.info.state == State.Absent) {
revert WithdrawalBatchesQueueIsInAbsentState();
revert WithdrawalsBatchesQueueIsInAbsentState();
}
}

function _checkInOpenedState(Context storage self) private view {
if (self.info.state != State.Opened) {
revert WithdrawalBatchesQueueIsNotInOpenedState();
revert WithdrawalsBatchesQueueIsNotInOpenedState();
}
}
}
8 changes: 4 additions & 4 deletions test/scenario/escrow.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ contract EscrowHappyPath is ScenarioTestBlueprint {
escrow.startRageQuit(_RAGE_QUIT_EXTRA_TIMELOCK, _RAGE_QUIT_WITHDRAWALS_TIMELOCK);

uint256 escrowStETHBalance = _lido.stETH.balanceOf(address(escrow));
uint256 expectedWithdrawalBatchesCount = escrowStETHBalance / requestAmount + 1;
uint256 expectedWithdrawalsBatchesCount = escrowStETHBalance / requestAmount + 1;
assertEq(_lido.withdrawalQueue.balanceOf(address(escrow)), 10);

escrow.requestNextWithdrawalsBatch(10);
Expand All @@ -314,13 +314,13 @@ contract EscrowHappyPath is ScenarioTestBlueprint {
escrow.requestNextWithdrawalsBatch(96);
}

assertEq(_lido.withdrawalQueue.balanceOf(address(escrow)), 10 + expectedWithdrawalBatchesCount);
assertEq(_lido.withdrawalQueue.balanceOf(address(escrow)), 10 + expectedWithdrawalsBatchesCount);
assertEq(escrow.isRageQuitFinalized(), false);

_finalizeWithdrawalQueue();

uint256[] memory unstETHIdsToClaim = escrow.getNextWithdrawalBatch(expectedWithdrawalBatchesCount);
// assertEq(total, expectedWithdrawalBatchesCount);
uint256[] memory unstETHIdsToClaim = escrow.getNextWithdrawalBatch(expectedWithdrawalsBatchesCount);
// assertEq(total, expectedWithdrawalsBatchesCount);

WithdrawalRequestStatus[] memory statuses = _lido.withdrawalQueue.getWithdrawalStatus(unstETHIdsToClaim);

Expand Down
22 changes: 11 additions & 11 deletions test/unit/libraries/WithdrawalBatchesQueue.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity 0.8.26;

import {UnitTest} from "test/utils/unit-test.sol";
import {WithdrawalsBatchesQueue, State} from "contracts/libraries/WithdrawalBatchesQueue.sol";
import {WithdrawalsBatchesQueue, State} from "contracts/libraries/WithdrawalsBatchesQueue.sol";

contract WithdrawalsBatchesQueueTest is UnitTest {
using WithdrawalsBatchesQueue for WithdrawalsBatchesQueue.Context;
Expand Down Expand Up @@ -30,15 +30,15 @@ contract WithdrawalsBatchesQueueTest is UnitTest {
_batchesQueue.info.state = State.Opened;
assertEq(_batchesQueue.info.state, State.Opened);

vm.expectRevert(WithdrawalsBatchesQueue.WithdrawalBatchesQueueIsNotInAbsentState.selector);
vm.expectRevert(WithdrawalsBatchesQueue.WithdrawalsBatchesQueueIsNotInAbsentState.selector);
_batchesQueue.open(_DEFAULT_BOUNDARY_UNST_ETH_ID);
}

function test_open_Emit_WithdrawalBatchesQueueOpened() external {
function test_open_Emit_WithdrawalsBatchesQueueOpened() external {
assertEq(_batchesQueue.info.state, State.Absent);

vm.expectEmit(true, false, false, false);
emit WithdrawalsBatchesQueue.WithdrawalBatchesQueueOpened(_DEFAULT_BOUNDARY_UNST_ETH_ID);
emit WithdrawalsBatchesQueue.WithdrawalsBatchesQueueOpened(_DEFAULT_BOUNDARY_UNST_ETH_ID);

_batchesQueue.open(_DEFAULT_BOUNDARY_UNST_ETH_ID);
}
Expand Down Expand Up @@ -126,7 +126,7 @@ contract WithdrawalsBatchesQueueTest is UnitTest {
}

function test_addUnstETHIds_RevertOn_QueueNotInOpenedState() external {
vm.expectRevert(WithdrawalsBatchesQueue.WithdrawalBatchesQueueIsNotInOpenedState.selector);
vm.expectRevert(WithdrawalsBatchesQueue.WithdrawalsBatchesQueueIsNotInOpenedState.selector);
_batchesQueue.addUnstETHIds(new uint256[](0));
}

Expand Down Expand Up @@ -305,22 +305,22 @@ contract WithdrawalsBatchesQueueTest is UnitTest {
}

function test_close_RevertOn_QueueNotInOpenedState() external {
vm.expectRevert(WithdrawalsBatchesQueue.WithdrawalBatchesQueueIsNotInOpenedState.selector);
vm.expectRevert(WithdrawalsBatchesQueue.WithdrawalsBatchesQueueIsNotInOpenedState.selector);
_batchesQueue.close();

_batchesQueue.open({boundaryUnstETHId: 1});
_batchesQueue.close();

vm.expectRevert(WithdrawalsBatchesQueue.WithdrawalBatchesQueueIsNotInOpenedState.selector);
vm.expectRevert(WithdrawalsBatchesQueue.WithdrawalsBatchesQueueIsNotInOpenedState.selector);
_batchesQueue.close();
}

function test_close_Emit_WithdrawalBatchesQueueClosed() external {
function test_close_Emit_WithdrawalsBatchesQueueClosed() external {
_openBatchesQueue();
assertEq(_batchesQueue.info.state, State.Opened);

vm.expectEmit(true, false, false, false);
emit WithdrawalsBatchesQueue.WithdrawalBatchesQueueClosed();
emit WithdrawalsBatchesQueue.WithdrawalsBatchesQueueClosed();

_batchesQueue.close();
}
Expand Down Expand Up @@ -502,7 +502,7 @@ contract WithdrawalsBatchesQueueTest is UnitTest {
}

function test_getBoundaryUnstETHId_RevertOn_QueueInAbsentState() external {
vm.expectRevert(WithdrawalsBatchesQueue.WithdrawalBatchesQueueIsInAbsentState.selector);
vm.expectRevert(WithdrawalsBatchesQueue.WithdrawalsBatchesQueueIsInAbsentState.selector);
_batchesQueue.getBoundaryUnstETHId();
}

Expand Down Expand Up @@ -554,7 +554,7 @@ contract WithdrawalsBatchesQueueTest is UnitTest {
}

function test_getLastClaimedOrBoundaryUnstETHId_RevertOn_AbsentQueueState() external {
vm.expectRevert(WithdrawalsBatchesQueue.WithdrawalBatchesQueueIsInAbsentState.selector);
vm.expectRevert(WithdrawalsBatchesQueue.WithdrawalsBatchesQueueIsInAbsentState.selector);
_batchesQueue.getLastClaimedOrBoundaryUnstETHId();
}

Expand Down

0 comments on commit 08e622a

Please sign in to comment.