Skip to content

Commit

Permalink
Prevent vacant minipool from refunding
Browse files Browse the repository at this point in the history
  • Loading branch information
kanewallmann committed Mar 13, 2023
1 parent 1367c19 commit 503c515
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contracts/contract/minipool/RocketMinipoolDelegate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,8 @@ contract RocketMinipoolDelegate is RocketMinipoolStorageLayout, RocketMinipoolIn

/// @dev Transfer refunded ETH balance to the node operator
function _refund() private {
// Prevent vacant minipools from calling
require(vacant == false, "Vacant minipool cannot refund");
// Update refund balance
uint256 refundAmount = nodeRefundBalance;
nodeRefundBalance = 0;
Expand Down
8 changes: 8 additions & 0 deletions test/minipool/minipool-vacant-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ export default function() {
});


it(printTitle('node operator', 'cannot call refund while vacant'), async () => {
// Create a vacant minipool with current balance of 33
let minipool = await createVacantMinipool('8'.ether, {from: node}, null, '33'.ether);
// Try to refund
await shouldRevert(refund(minipool, { from: node }), 'Was able to refund', 'Vacant minipool cannot refund');
});


it(printTitle('node operator', 'can not create a vacant minipool with an existing pubkey'), async () => {
// Create minipool with a pubkey
const pubkey = getValidatorPubkey();
Expand Down

0 comments on commit 503c515

Please sign in to comment.