Skip to content

Commit 26d5caa

Browse files
authored
Merge pull request #1118 from graphprotocol/tmigone/horizon-last-minute-fixes
2 parents 7df009f + 0b7730a commit 26d5caa

File tree

13 files changed

+89
-12
lines changed

13 files changed

+89
-12
lines changed

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ pragma solidity 0.8.27;
66
*/
77
abstract contract ProvisionManagerV1Storage {
88
/// @notice The minimum amount of tokens required to register a provision in the data service
9-
uint256 public minimumProvisionTokens;
9+
uint256 internal minimumProvisionTokens;
1010

1111
/// @notice The maximum amount of tokens allowed to register a provision in the data service
12-
uint256 public maximumProvisionTokens;
12+
uint256 internal maximumProvisionTokens;
1313

1414
/// @notice The minimum thawing period required to register a provision in the data service
15-
uint64 public minimumThawingPeriod;
15+
uint64 internal minimumThawingPeriod;
1616

1717
/// @notice The maximum thawing period allowed to register a provision in the data service
18-
uint64 public maximumThawingPeriod;
18+
uint64 internal maximumThawingPeriod;
1919

2020
/// @notice The minimum verifier cut required to register a provision in the data service (in PPM)
21-
uint32 public minimumVerifierCut;
21+
uint32 internal minimumVerifierCut;
2222

2323
/// @notice The maximum verifier cut allowed to register a provision in the data service (in PPM)
24-
uint32 public maximumVerifierCut;
24+
uint32 internal maximumVerifierCut;
2525

2626
/// @notice How much delegation the service provider can effectively use
2727
/// @dev Max calculated as service provider's stake * delegationRatio
28-
uint32 public delegationRatio;
28+
uint32 internal delegationRatio;
2929

3030
/// @dev Gap to allow adding variables in future upgrades
3131
/// Note that this contract is not upgradeable but might be inherited by an upgradeable contract

packages/horizon/contracts/interfaces/internal/IHorizonStakingExtension.sol

+6
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,10 @@ interface IHorizonStakingExtension is IRewardsIssuer {
164164
*/
165165
// solhint-disable-next-line func-name-mixedcase
166166
function __DEPRECATED_getThawingPeriod() external view returns (uint64);
167+
168+
/**
169+
* @notice Return the address of the subgraph data service.
170+
* @return Address of the subgraph data service
171+
*/
172+
function getSubgraphService() external view returns (address);
167173
}

packages/horizon/contracts/payments/PaymentsEscrow.sol

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ contract PaymentsEscrow is Initializable, MulticallUpgradeable, GraphDirectory,
5555
);
5656

5757
WITHDRAW_ESCROW_THAWING_PERIOD = withdrawEscrowThawingPeriod;
58+
_disableInitializers();
5859
}
5960

6061
/**

packages/horizon/contracts/staking/HorizonStakingExtension.sol

+9
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,15 @@ contract HorizonStakingExtension is HorizonStakingBase, IHorizonStakingExtension
283283
return _serviceProviders[indexer].tokensStaked;
284284
}
285285

286+
/**
287+
* @notice Return the address of the subgraph data service.
288+
* @dev TODO: After transition period move to main HorizonStaking contract
289+
* @return Address of the subgraph data service
290+
*/
291+
function getSubgraphService() external view override returns (address) {
292+
return SUBGRAPH_DATA_SERVICE_ADDRESS;
293+
}
294+
286295
/**
287296
* @notice Getter that returns if an indexer has any stake.
288297
* @param indexer Address of the indexer

packages/subgraph-service/contracts/SubgraphService.sol

+24-1
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,18 @@ contract SubgraphService is
7575
* @notice Initialize the contract
7676
* @dev The thawingPeriod and verifierCut ranges are not set here because they are variables
7777
* on the DisputeManager. We use the {ProvisionManager} overrideable getters to get the ranges.
78+
* @param owner The owner of the contract
7879
* @param minimumProvisionTokens The minimum amount of provisioned tokens required to create an allocation
7980
* @param maximumDelegationRatio The maximum delegation ratio allowed for an allocation
8081
* @param stakeToFeesRatio The ratio of stake to fees to lock when collecting query fees
8182
*/
8283
function initialize(
84+
address owner,
8385
uint256 minimumProvisionTokens,
8486
uint32 maximumDelegationRatio,
8587
uint256 stakeToFeesRatio
8688
) external initializer {
87-
__Ownable_init(msg.sender);
89+
__Ownable_init(owner);
8890
__Multicall_init();
8991
__DataService_init();
9092
__DataServicePausable_init();
@@ -456,6 +458,27 @@ contract SubgraphService is
456458
return _legacyAllocations[allocationId];
457459
}
458460

461+
/**
462+
* @notice See {ISubgraphService.getDisputeManager}
463+
*/
464+
function getDisputeManager() external view override returns (address) {
465+
return address(_disputeManager());
466+
}
467+
468+
/**
469+
* @notice See {ISubgraphService.getGraphTallyCollector}
470+
*/
471+
function getGraphTallyCollector() external view override returns (address) {
472+
return address(_graphTallyCollector());
473+
}
474+
475+
/**
476+
* @notice See {ISubgraphService.getCuration}
477+
*/
478+
function getCuration() external view override returns (address) {
479+
return address(_curation());
480+
}
481+
459482
/**
460483
* @notice See {ISubgraphService.encodeAllocationProof}
461484
*/

packages/subgraph-service/contracts/SubgraphServiceStorage.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ abstract contract SubgraphServiceV1Storage {
1010
///@notice Multiplier for how many tokens back collected query fees
1111
uint256 public stakeToFeesRatio;
1212

13-
/// @notice The cut curators take from query fee payments
13+
/// @notice The cut curators take from query fee payments. In PPM.
1414
uint256 public curationFeesCut;
1515
}

packages/subgraph-service/contracts/interfaces/ISubgraphService.sol

+18
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,22 @@ interface ISubgraphService is IDataServiceFees {
247247
* @return True if the indexer is over-allocated, false otherwise
248248
*/
249249
function isOverAllocated(address allocationId) external view returns (bool);
250+
251+
/**
252+
* @notice Gets the address of the dispute manager
253+
* @return The address of the dispute manager
254+
*/
255+
function getDisputeManager() external view returns (address);
256+
257+
/**
258+
* @notice Gets the address of the graph tally collector
259+
* @return The address of the graph tally collector
260+
*/
261+
function getGraphTallyCollector() external view returns (address);
262+
263+
/**
264+
* @notice Gets the address of the curation contract
265+
* @return The address of the curation contract
266+
*/
267+
function getCuration() external view returns (address);
250268
}

packages/subgraph-service/ignition/configs/migrate.default.json5

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$global": {
33
"governor": "0x72ee30d43Fb5A90B3FE983156C5d2fBE6F6d07B3",
44
"arbitrator": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
5+
"pauseGuardian": "0xB0aD33a21b98bCA1761729A105e2E34e27153aAE",
56

67
// Addresses for contracts deployed in the original Graph Protocol
78
"controllerAddress": "0x9DB3ee191681f092607035d9BDA6e59FbEaCa695",
@@ -22,6 +23,8 @@
2223
"minimumProvisionTokens": "100000000000000000000000n",
2324
"maximumDelegationRatio": 16,
2425
"stakeToFeesRatio": 2,
26+
"maxPOIStaleness": 2419200, // 28 days = 2419200 seconds
27+
"curationCut": 100000,
2528

2629
// Addresses for contracts deployed in the original Graph Protocol
2730
"curationAddress": "0xDe761f075200E75485F4358978FB4d1dC8644FD5",

packages/subgraph-service/ignition/configs/protocol.default.json5

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$global": {
33
"governor": "0x72ee30d43Fb5A90B3FE983156C5d2fBE6F6d07B3",
44
"arbitrator": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
5+
"pauseGuardian": "0xB0aD33a21b98bCA1761729A105e2E34e27153aAE",
56

67
// Must be set for step 2 of the deployment
78
"controllerAddress": "",
@@ -22,6 +23,8 @@
2223
"minimumProvisionTokens": "100000000000000000000000n",
2324
"maximumDelegationRatio": 16,
2425
"stakeToFeesRatio": 2,
26+
"maxPOIStaleness": 2419200, // 28 days = 2419200 seconds
27+
"curationCut": 100000,
2528

2629
// Must be set for step 2 of the deployment
2730
"subgraphServiceProxyAddress": "",

packages/subgraph-service/ignition/configs/protocol.local-network.json5

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"$global": {
44
"governor": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
55
"arbitrator": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
6+
"pauseGuardian": "0xB0aD33a21b98bCA1761729A105e2E34e27153aAE",
67

78
// Must be set for step 2 of the deployment
89
"controllerAddress": "",
@@ -23,6 +24,8 @@
2324
"minimumProvisionTokens": "100000000000000000000000n",
2425
"maximumDelegationRatio": 16,
2526
"stakeToFeesRatio": 2,
27+
"maxPOIStaleness": 2419200, // 28 days = 2419200 seconds
28+
"curationCut": 100000,
2629

2730
// Must be set for step 2 of the deployment
2831
"subgraphServiceProxyAddress": "",

packages/subgraph-service/ignition/modules/SubgraphService.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import SubgraphServiceArtifact from '../../build/contracts/contracts/SubgraphSer
77
import TransparentUpgradeableProxyArtifact from '@openzeppelin/contracts/build/contracts/TransparentUpgradeableProxy.json'
88

99
export default buildModule('SubgraphService', (m) => {
10+
const deployer = m.getAccount(0)
1011
const governor = m.getParameter('governor')
12+
const pauseGuardian = m.getParameter('pauseGuardian')
1113
const controllerAddress = m.getParameter('controllerAddress')
1214
const subgraphServiceProxyAddress = m.getParameter('subgraphServiceProxyAddress')
1315
const subgraphServiceProxyAdminAddress = m.getParameter('subgraphServiceProxyAdminAddress')
@@ -17,6 +19,8 @@ export default buildModule('SubgraphService', (m) => {
1719
const minimumProvisionTokens = m.getParameter('minimumProvisionTokens')
1820
const maximumDelegationRatio = m.getParameter('maximumDelegationRatio')
1921
const stakeToFeesRatio = m.getParameter('stakeToFeesRatio')
22+
const maxPOIStaleness = m.getParameter('maxPOIStaleness')
23+
const curationCut = m.getParameter('curationCut')
2024

2125
const SubgraphServiceProxyAdmin = m.contractAt('ProxyAdmin', ProxyAdminArtifact, subgraphServiceProxyAdminAddress)
2226
const SubgraphServiceProxy = m.contractAt('SubgraphServiceProxy', TransparentUpgradeableProxyArtifact, subgraphServiceProxyAddress)
@@ -35,13 +39,17 @@ export default buildModule('SubgraphService', (m) => {
3539
name: 'SubgraphService',
3640
artifact: SubgraphServiceArtifact,
3741
initArgs: [
42+
deployer,
3843
minimumProvisionTokens,
3944
maximumDelegationRatio,
4045
stakeToFeesRatio,
4146
],
4247
})
4348

44-
m.call(SubgraphServiceProxyAdmin, 'transferOwnership', [governor], { after: [SubgraphService] })
49+
const callSetPauseGuardian = m.call(SubgraphService, 'setPauseGuardian', [pauseGuardian, true])
50+
const callSetMaxPOIStaleness = m.call(SubgraphService, 'setMaxPOIStaleness', [maxPOIStaleness])
51+
const callSetCurationCut = m.call(SubgraphService, 'setCurationCut', [curationCut])
52+
m.call(SubgraphServiceProxyAdmin, 'transferOwnership', [governor], { after: [callSetPauseGuardian, callSetMaxPOIStaleness, callSetCurationCut] })
4553

4654
return {
4755
SubgraphService,

packages/subgraph-service/test/SubgraphBaseTest.t.sol

+4-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ abstract contract SubgraphBaseTest is Utils, Constants {
160160
address subgraphServiceProxy = UnsafeUpgrades.deployTransparentProxy(
161161
subgraphServiceImplementation,
162162
users.governor,
163-
abi.encodeCall(SubgraphService.initialize, (minimumProvisionTokens, delegationRatio, stakeToFeesRatio))
163+
abi.encodeCall(
164+
SubgraphService.initialize,
165+
(users.deployer, minimumProvisionTokens, delegationRatio, stakeToFeesRatio)
166+
)
164167
);
165168
subgraphService = SubgraphService(subgraphServiceProxy);
166169

packages/subgraph-service/test/subgraphService/SubgraphService.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest {
434434
uint256 tokensAvailable = staking.getTokensAvailable(
435435
_indexer,
436436
address(subgraphService),
437-
subgraphService.delegationRatio()
437+
subgraphService.getDelegationRatio()
438438
);
439439
if (allocation.tokens <= tokensAvailable) {
440440
// Indexer isn't over allocated so allocation should still be open

0 commit comments

Comments
 (0)