Skip to content

Commit 58c518c

Browse files
authored
Merge branch 'horizon' into horizon-gre
2 parents 8f3e0f1 + 170572f commit 58c518c

File tree

147 files changed

+3304
-283093
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+3304
-283093
lines changed

packages/horizon/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ Graph Horizon is the next evolution of the Graph Protocol.
44

55
## Deployment
66

7-
We use Hardhat Ignition to deploy the contracts. To build and deploy the contracts run the following commands:
7+
We use Hardhat Ignition to deploy the contracts. To build and deploy Graph Horizon run the following commands:
88

99
```bash
1010
yarn install
1111
yarn build
1212
npx hardhat ignition deploy ./ignition/modules/horizon.ts \
13-
--parameters ./ignition/configs/horizon.hardhat.json \
13+
--parameters ./ignition/configs/horizon.hardhat.json5 \
1414
--network hardhat
1515
```
1616

17-
You can use any network defined in `hardhat.config.ts` by replacing `hardhat` with the network name.
17+
You can use any network defined in `hardhat.config.ts` by replacing `hardhat` with the network name.
18+
19+
Note that this will deploy a standalone version of Graph Horizon contracts, meaning the Subgraph Service or any other data service will not be deployed. If you want to deploy the Subgraph Service please refer to the [Subgraph Service README](../subgraph-service/README.md) for deploy instructions.

packages/horizon/contracts/data-service/DataService.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import { ProvisionManager } from "./utilities/ProvisionManager.sol";
2525
* - If the data service implementation is NOT upgradeable, it must initialize the contract by calling
2626
* {__DataService_init} or {__DataService_init_unchained} in the constructor. Note that the `initializer`
2727
* will be required in the constructor.
28+
* - Note that in both cases if using {__DataService_init_unchained} variant the corresponding parent
29+
* initializers must be called in the implementation.
2830
*/
2931
abstract contract DataService is GraphDirectory, ProvisionManager, DataServiceV1Storage, IDataService {
3032
/**

packages/horizon/contracts/data-service/DataServiceStorage.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ pragma solidity 0.8.27;
33

44
abstract contract DataServiceV1Storage {
55
/// @dev Gap to allow adding variables in future upgrades
6+
/// Note that this contract is not upgradeable but might be inherited by an upgradeable contract
67
uint256[50] private __gap;
78
}

packages/horizon/contracts/data-service/extensions/DataServiceFees.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { DataServiceFeesV1Storage } from "./DataServiceFeesStorage.sol";
1414
* @dev Implementation of the {IDataServiceFees} interface.
1515
* @notice Extension for the {IDataService} contract to handle payment collateralization
1616
* using a Horizon provision. See {IDataServiceFees} for more details.
17+
* @dev This contract inherits from {DataService} which needs to be initialized, please see
18+
* {DataService} for detailed instructions.
1719
*/
1820
abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDataServiceFees {
1921
using ProvisionTracker for mapping(address => uint256);
@@ -127,9 +129,7 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat
127129
* @param _claimId The ID of the stake claim
128130
*/
129131
function _getNextStakeClaim(bytes32 _claimId) private view returns (bytes32) {
130-
StakeClaim memory claim = claims[_claimId];
131-
require(claim.createdAt != 0, DataServiceFeesClaimNotFound(_claimId));
132-
return claim.nextClaim;
132+
return claims[_claimId].nextClaim;
133133
}
134134

135135
/**

packages/horizon/contracts/data-service/extensions/DataServiceFeesStorage.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ abstract contract DataServiceFeesV1Storage {
1818
mapping(address serviceProvider => LinkedList.List list) public claimsLists;
1919

2020
/// @dev Gap to allow adding variables in future upgrades
21+
/// Note that this contract is not upgradeable but might be inherited by an upgradeable contract
2122
uint256[50] private __gap;
2223
}

packages/horizon/contracts/data-service/extensions/DataServicePausable.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { DataService } from "../DataService.sol";
1414
* pause guardians.
1515
* @dev Note that this extension does not provide an external function to set pause
1616
* guardians. This should be implemented in the derived contract.
17+
* @dev This contract inherits from {DataService} which needs to be initialized, please see
18+
* {DataService} for detailed instructions.
1719
*/
1820
abstract contract DataServicePausable is Pausable, DataService, IDataServicePausable {
1921
/// @notice List of pause guardians and their allowed status
@@ -51,6 +53,10 @@ abstract contract DataServicePausable is Pausable, DataService, IDataServicePaus
5153
* @param _allowed The allowed status of the pause guardian
5254
*/
5355
function _setPauseGuardian(address _pauseGuardian, bool _allowed) internal {
56+
require(
57+
pauseGuardians[_pauseGuardian] == !_allowed,
58+
DataServicePausablePauseGuardianNoChange(_pauseGuardian, _allowed)
59+
);
5460
pauseGuardians[_pauseGuardian] = _allowed;
5561
emit PauseGuardianSet(_pauseGuardian, _allowed);
5662
}

packages/horizon/contracts/data-service/extensions/DataServicePausableUpgradeable.sol

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ import { DataService } from "../DataService.sol";
1010
* @title DataServicePausableUpgradeable contract
1111
* @dev Implementation of the {IDataServicePausable} interface.
1212
* @dev Upgradeable version of the {DataServicePausable} contract.
13+
* @dev This contract inherits from {DataService} which needs to be initialized, please see
14+
* {DataService} for detailed instructions.
1315
*/
1416
abstract contract DataServicePausableUpgradeable is PausableUpgradeable, DataService, IDataServicePausable {
1517
/// @notice List of pause guardians and their allowed status
1618
mapping(address pauseGuardian => bool allowed) public pauseGuardians;
1719

20+
/// @dev Gap to allow adding variables in future upgrades
21+
uint256[50] private __gap;
22+
1823
/**
1924
* @notice Checks if the caller is a pause guardian.
2025
*/
@@ -61,7 +66,11 @@ abstract contract DataServicePausableUpgradeable is PausableUpgradeable, DataSer
6166
* @param _pauseGuardian The address of the pause guardian
6267
* @param _allowed The allowed status of the pause guardian
6368
*/
64-
function _setPauseGuardian(address _pauseGuardian, bool _allowed) internal whenNotPaused {
69+
function _setPauseGuardian(address _pauseGuardian, bool _allowed) internal {
70+
require(
71+
pauseGuardians[_pauseGuardian] == !_allowed,
72+
DataServicePausablePauseGuardianNoChange(_pauseGuardian, _allowed)
73+
);
6574
pauseGuardians[_pauseGuardian] = _allowed;
6675
emit PauseGuardianSet(_pauseGuardian, _allowed);
6776
}

packages/horizon/contracts/data-service/extensions/DataServiceRescuable.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.s
1717
* that calls this contract's _rescueTokens.
1818
* @dev Note that this extension does not provide an external function to set
1919
* rescuers. This should be implemented in the derived contract.
20+
* @dev This contract inherits from {DataService} which needs to be initialized, please see
21+
* {DataService} for detailed instructions.
2022
*/
2123
abstract contract DataServiceRescuable is DataService, IDataServiceRescuable {
2224
/// @notice List of rescuers and their allowed status
2325
mapping(address rescuer => bool allowed) public rescuers;
2426

27+
/// @dev Gap to allow adding variables in future upgrades
28+
/// Note that this contract is not upgradeable but might be inherited by an upgradeable contract
29+
uint256[50] private __gap;
30+
2531
/**
2632
* @notice Checks if the caller is a rescuer.
2733
*/

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ interface IDataServicePausable is IDataService {
2323
*/
2424
error DataServicePausableNotPauseGuardian(address account);
2525

26+
/**
27+
* @notice Emitted when a pause guardian is set to the same allowed status
28+
* @param account The address of the pause guardian
29+
* @param allowed The allowed status of the pause guardian
30+
*/
31+
error DataServicePausablePauseGuardianNoChange(address account, bool allowed);
32+
2633
/**
2734
* @notice Pauses the data service.
2835
* @dev Note that only functions using the modifiers `whenNotPaused`

packages/horizon/contracts/data-service/utilities/ProvisionManager.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,16 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa
202202

203203
/**
204204
* @notice Checks if the provision tokens of a service provider are within the valid range.
205+
* Note that thawing tokens are not considered in this check.
205206
* @param _provision The provision to check.
206207
*/
207208
function _checkProvisionTokens(IHorizonStaking.Provision memory _provision) internal view virtual {
208-
_checkValueInRange(_provision.tokens, minimumProvisionTokens, maximumProvisionTokens, "tokens");
209+
_checkValueInRange(
210+
_provision.tokens - _provision.tokensThawing,
211+
minimumProvisionTokens,
212+
maximumProvisionTokens,
213+
"tokens"
214+
);
209215
}
210216

211217
/**

0 commit comments

Comments
 (0)