Skip to content

Commit

Permalink
fix: add whenNotPaused to closeStaleAllocation (#1081)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maikol authored Jan 15, 2025
1 parent 1d097de commit 51d0f7f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/subgraph-service/contracts/SubgraphService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ contract SubgraphService is
/**
* @notice See {ISubgraphService.closeStaleAllocation}
*/
function closeStaleAllocation(address allocationId) external override {
function closeStaleAllocation(address allocationId) external override whenNotPaused {
Allocation.State memory allocation = allocations.get(allocationId);
require(allocation.isStale(maxPOIStaleness), SubgraphServiceCannotForceCloseAllocation(allocationId));
require(!allocation.isAltruistic(), SubgraphServiceAllocationIsAltruistic(allocationId));
Expand Down
4 changes: 3 additions & 1 deletion packages/subgraph-service/test/SubgraphBaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ abstract contract SubgraphBaseTest is Utils, Constants {
delegator: createUser("delegator"),
arbitrator: createUser("arbitrator"),
fisherman: createUser("fisherman"),
rewardsDestination: createUser("rewardsDestination")
rewardsDestination: createUser("rewardsDestination"),
pauseGuardian: createUser("pauseGuardian")
});

deployProtocolContracts();
Expand Down Expand Up @@ -191,6 +192,7 @@ abstract contract SubgraphBaseTest is Utils, Constants {
epochManager.setEpochLength(EPOCH_LENGTH);
subgraphService.setMaxPOIStaleness(maxPOIStaleness);
subgraphService.setCurationCut(curationCut);
subgraphService.setPauseGuardian(users.pauseGuardian, true);
}

function unpauseProtocol() private {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract contract SubgraphServiceSharedTest is HorizonStakingSharedTest {
}

modifier useAllocation(uint256 tokens) {
vm.assume(tokens > minimumProvisionTokens);
vm.assume(tokens >= minimumProvisionTokens);
vm.assume(tokens < 10_000_000_000 ether);
_createProvision(users.indexer, tokens, maxSlashingPercentage, disputePeriod);
_register(users.indexer, abi.encode("url", "geoHash", address(0)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity 0.8.27;

import "forge-std/Test.sol";

import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol";

import { Allocation } from "../../../contracts/libraries/Allocation.sol";
Expand Down Expand Up @@ -91,4 +92,13 @@ contract SubgraphServiceAllocationForceCloseTest is SubgraphServiceTest {
);
subgraphService.closeStaleAllocation(allocationID);
}

function test_SubgraphService_Allocation_ForceClose_RevertIf_Paused() public useIndexer useAllocation(1000 ether) {
resetPrank(users.pauseGuardian);
subgraphService.pause();

resetPrank(permissionlessBob);
vm.expectRevert(abi.encodeWithSelector(PausableUpgradeable.EnforcedPause.selector));
subgraphService.closeStaleAllocation(allocationID);
}
}
1 change: 1 addition & 0 deletions packages/subgraph-service/test/utils/Users.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ struct Users {
address arbitrator;
address fisherman;
address rewardsDestination;
address pauseGuardian;
}

0 comments on commit 51d0f7f

Please sign in to comment.