Skip to content

Commit cf2109f

Browse files
MoonBoi9001tmigone
andauthored
fix: remove unused errors, use LegacyAllocationAlreadyMigrated to prevent migrating a legacy allocation twice (OZ N-02) (#1029)
* fix: remove AllocationManagerZeroTokensAllocation. (OZ N-02) * fix: remove DataServiceFeatureNotImplemented. (OZ N-02) * fix: Use LegacyAllocationAlreadyMigrated. (OZ N-02) Use LegacyAllocationAlreadyMigrated to prevent migrating a legacy allocation twice. * fix: restore migrate function to require from if revert. Co-authored-by: Tomás Migone <[email protected]> * fix: missing closing braket. --------- Co-authored-by: Tomás Migone <[email protected]>
1 parent 3e57ba3 commit cf2109f

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

packages/horizon/contracts/data-service/interfaces/IDataService.sol

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ interface IDataService {
6060
*/
6161
event ServiceProviderSlashed(address indexed serviceProvider, uint256 tokens);
6262

63-
/**
64-
* @notice Thrown to signal that a feature is not implemented by a data service.
65-
*/
66-
error DataServiceFeatureNotImplemented();
67-
6863
/**
6964
* @notice Registers a service provider with the data service. The service provider can now
7065
* start providing the service.

packages/subgraph-service/contracts/libraries/LegacyAllocation.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,20 @@ library LegacyAllocation {
3939
/**
4040
* @notice Migrate a legacy allocation
4141
* @dev Requirements:
42-
* - The allocation must not exist
42+
* - The allocation must not have been previously migrated
4343
* @param self The legacy allocation list mapping
4444
* @param indexer The indexer that owns the allocation
4545
* @param allocationId The allocation id
4646
* @param subgraphDeploymentId The subgraph deployment id the allocation is for
47+
* @custom:error LegacyAllocationAlreadyMigrated if the allocation has already been migrated
4748
*/
4849
function migrate(
4950
mapping(address => State) storage self,
5051
address indexer,
5152
address allocationId,
5253
bytes32 subgraphDeploymentId
5354
) internal {
54-
require(!self[allocationId].exists(), LegacyAllocationExists(allocationId));
55+
require(!self[allocationId].exists(), LegacyAllocationAlreadyMigrated(allocationId));
5556

5657
State memory allocation = State({ indexer: indexer, subgraphDeploymentId: subgraphDeploymentId });
5758
self[allocationId] = allocation;

packages/subgraph-service/contracts/utilities/AllocationManager.sol

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,7 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca
139139
error AllocationManagerInvalidZeroAllocationId();
140140

141141
/**
142-
* @notice Thrown when attempting to create an allocation with zero tokens
143-
* @param allocationId The id of the allocation
144-
*/
145-
error AllocationManagerZeroTokensAllocation(address allocationId);
146-
147-
/**
148-
* @notice Thrown when attempting to collect indexing rewards on a closed allocation
142+
* @notice Thrown when attempting to collect indexing rewards on a closed allocationl
149143
* @param allocationId The id of the allocation
150144
*/
151145
error AllocationManagerAllocationClosed(address allocationId);
@@ -178,7 +172,7 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca
178172
/**
179173
* @notice Imports a legacy allocation id into the subgraph service
180174
* This is a governor only action that is required to prevent indexers from re-using allocation ids from the
181-
* legacy staking contract.
175+
* legacy staking contract. It will revert with LegacyAllocationAlreadyMigrated if the allocation has already been migrated.
182176
* @param _indexer The address of the indexer
183177
* @param _allocationId The id of the allocation
184178
* @param _subgraphDeploymentId The id of the subgraph deployment

0 commit comments

Comments
 (0)