Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add whenNotPaused to closeStaleAllocation #1081

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Loading