Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ import { ILegacyAllocation } from "./internal/ILegacyAllocation.sol";
interface ISubgraphService is IDataServiceFees {
/**
* @notice Indexer details
* @param registeredAt The timestamp when the indexer registered
* @param url The URL where the indexer can be reached at for queries
* @param geoHash The indexer's geo location, expressed as a geo hash
*/
struct Indexer {
uint256 registeredAt;
string url;
string geoHash;
}
Expand Down Expand Up @@ -83,11 +81,6 @@ interface ISubgraphService is IDataServiceFees {
*/
error SubgraphServiceEmptyGeohash();

/**
* @notice Thrown when an indexer tries to register but they are already registered
*/
error SubgraphServiceIndexerAlreadyRegistered();

/**
* @notice Thrown when an indexer tries to perform an operation but they are not registered
* @param indexer The address of the indexer that is not registered
Expand Down
14 changes: 4 additions & 10 deletions packages/subgraph-service/contracts/SubgraphService.sol
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.27;

import { IGraphPayments } from "@graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol";

Check warning on line 4 in packages/subgraph-service/contracts/SubgraphService.sol

View workflow job for this annotation

GitHub Actions / Lint Files

Import in packages/subgraph-service/contracts/SubgraphService.sol doesn't exist in: @graphprotocol/interfaces/contracts/horizon/IGraphPayments.sol
import { IGraphToken } from "@graphprotocol/contracts/contracts/token/IGraphToken.sol";

Check warning on line 5 in packages/subgraph-service/contracts/SubgraphService.sol

View workflow job for this annotation

GitHub Actions / Lint Files

Import in packages/subgraph-service/contracts/SubgraphService.sol doesn't exist in: @graphprotocol/contracts/contracts/token/IGraphToken.sol
import { IGraphTallyCollector } from "@graphprotocol/interfaces/contracts/horizon/IGraphTallyCollector.sol";

Check warning on line 6 in packages/subgraph-service/contracts/SubgraphService.sol

View workflow job for this annotation

GitHub Actions / Lint Files

Import in packages/subgraph-service/contracts/SubgraphService.sol doesn't exist in: @graphprotocol/interfaces/contracts/horizon/IGraphTallyCollector.sol
import { IRewardsIssuer } from "@graphprotocol/interfaces/contracts/contracts/rewards/IRewardsIssuer.sol";

Check warning on line 7 in packages/subgraph-service/contracts/SubgraphService.sol

View workflow job for this annotation

GitHub Actions / Lint Files

Import in packages/subgraph-service/contracts/SubgraphService.sol doesn't exist in: @graphprotocol/interfaces/contracts/contracts/rewards/IRewardsIssuer.sol
import { IDataService } from "@graphprotocol/interfaces/contracts/data-service/IDataService.sol";

Check warning on line 8 in packages/subgraph-service/contracts/SubgraphService.sol

View workflow job for this annotation

GitHub Actions / Lint Files

Import in packages/subgraph-service/contracts/SubgraphService.sol doesn't exist in: @graphprotocol/interfaces/contracts/data-service/IDataService.sol
import { ISubgraphService } from "@graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol";

Check warning on line 9 in packages/subgraph-service/contracts/SubgraphService.sol

View workflow job for this annotation

GitHub Actions / Lint Files

Import in packages/subgraph-service/contracts/SubgraphService.sol doesn't exist in: @graphprotocol/interfaces/contracts/subgraph-service/ISubgraphService.sol
import { IAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocation.sol";

Check warning on line 10 in packages/subgraph-service/contracts/SubgraphService.sol

View workflow job for this annotation

GitHub Actions / Lint Files

Import in packages/subgraph-service/contracts/SubgraphService.sol doesn't exist in: @graphprotocol/interfaces/contracts/subgraph-service/internal/IAllocation.sol
import { ILegacyAllocation } from "@graphprotocol/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol";

Check warning on line 11 in packages/subgraph-service/contracts/SubgraphService.sol

View workflow job for this annotation

GitHub Actions / Lint Files

Import in packages/subgraph-service/contracts/SubgraphService.sol doesn't exist in: @graphprotocol/interfaces/contracts/subgraph-service/internal/ILegacyAllocation.sol

import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { MulticallUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/MulticallUpgradeable.sol";
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {
DataServicePausableUpgradeable
} from "@graphprotocol/horizon/contracts/data-service/extensions/DataServicePausableUpgradeable.sol";
import { DataServicePausableUpgradeable } from "@graphprotocol/horizon/contracts/data-service/extensions/DataServicePausableUpgradeable.sol";

Check warning on line 16 in packages/subgraph-service/contracts/SubgraphService.sol

View workflow job for this annotation

GitHub Actions / Lint Files

Import in packages/subgraph-service/contracts/SubgraphService.sol doesn't exist in: @graphprotocol/horizon/contracts/data-service/extensions/DataServicePausableUpgradeable.sol
import { DataService } from "@graphprotocol/horizon/contracts/data-service/DataService.sol";

Check warning on line 17 in packages/subgraph-service/contracts/SubgraphService.sol

View workflow job for this annotation

GitHub Actions / Lint Files

Import in packages/subgraph-service/contracts/SubgraphService.sol doesn't exist in: @graphprotocol/horizon/contracts/data-service/DataService.sol
import { DataServiceFees } from "@graphprotocol/horizon/contracts/data-service/extensions/DataServiceFees.sol";
import { Directory } from "./utilities/Directory.sol";
import { AllocationManager } from "./utilities/AllocationManager.sol";
Expand Down Expand Up @@ -54,7 +52,7 @@
* @param indexer The address of the indexer
*/
modifier onlyRegisteredIndexer(address indexer) {
require(indexers[indexer].registeredAt != 0, SubgraphServiceIndexerNotRegistered(indexer));
require(bytes(indexers[indexer].url).length > 0, SubgraphServiceIndexerNotRegistered(indexer));
_;
}

Expand Down Expand Up @@ -98,7 +96,6 @@
* @dev Implements {IDataService.register}
*
* Requirements:
* - The indexer must not be already registered
* - The URL must not be empty
* - The provision must be valid according to the subgraph service rules
*
Expand All @@ -123,13 +120,10 @@

require(bytes(url).length > 0, SubgraphServiceEmptyUrl());
require(bytes(geohash).length > 0, SubgraphServiceEmptyGeohash());
require(indexers[indexer].registeredAt == 0, SubgraphServiceIndexerAlreadyRegistered());

// Register the indexer
indexers[indexer] = Indexer({ registeredAt: block.timestamp, url: url, geoHash: geohash });
if (paymentsDestination_ != address(0)) {
_setPaymentsDestination(indexer, paymentsDestination_);
}
indexers[indexer] = Indexer({ url: url, geoHash: geohash });
_setPaymentsDestination(indexer, paymentsDestination_);

emit ServiceProviderRegistered(indexer, data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ abstract contract SubgraphServiceSharedTest is HorizonStakingSharedTest {

// Check registered indexer data
ISubgraphService.Indexer memory indexer = _getIndexer(_indexer);
assertEq(indexer.registeredAt, block.timestamp);
assertEq(indexer.url, url);
assertEq(indexer.geoHash, geohash);

Expand Down Expand Up @@ -197,7 +196,7 @@ abstract contract SubgraphServiceSharedTest is HorizonStakingSharedTest {
*/

function _getIndexer(address _indexer) private view returns (ISubgraphService.Indexer memory) {
(uint256 registeredAt, string memory url, string memory geoHash) = subgraphService.indexers(_indexer);
return ISubgraphService.Indexer({ registeredAt: registeredAt, url: url, geoHash: geoHash });
(string memory url, string memory geoHash) = subgraphService.indexers(_indexer);
return ISubgraphService.Indexer({ url: url, geoHash: geoHash });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ contract SubgraphServiceProviderRegisterTest is SubgraphServiceTest {
_register(users.indexer, data);
}

function test_SubgraphService_Provider_Register_RevertIf_AlreadyRegistered(
function test_SubgraphService_Provider_Register_MultipleTimes(
uint256 tokens
) public useIndexer useAllocation(tokens) {
vm.expectRevert(abi.encodeWithSelector(ISubgraphService.SubgraphServiceIndexerAlreadyRegistered.selector));
bytes memory data = abi.encode("url", "geoHash", users.rewardsDestination);
subgraphService.register(users.indexer, data);
_register(users.indexer, data);

bytes memory data2 = abi.encode("url2", "geoHash2", users.rewardsDestination);
_register(users.indexer, data2);

(string memory url, string memory geoHash) = subgraphService.indexers(users.indexer);
assertEq(url, "url2");
assertEq(geoHash, "geoHash2");
}

function test_SubgraphService_Provider_Register_RevertWhen_InvalidProvision() public useIndexer {
Expand Down
Loading