Skip to content

Commit 2b03618

Browse files
authored
Merge branch 'horizon' into mde/horizon-and-subgrah-service-deploy-fix
2 parents a256d74 + a228e0e commit 2b03618

File tree

81 files changed

+3211
-1342
lines changed

Some content is hidden

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

81 files changed

+3211
-1342
lines changed

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
/**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ abstract contract ProvisionManagerV1Storage {
2828
uint32 public delegationRatio;
2929

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

0 commit comments

Comments
 (0)