Skip to content

Commit

Permalink
Merge pull request #1118 from graphprotocol/tmigone/horizon-last-minu…
Browse files Browse the repository at this point in the history
…te-fixes
  • Loading branch information
tmigone authored Feb 25, 2025
2 parents 7df009f + 0b7730a commit 26d5caa
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ pragma solidity 0.8.27;
*/
abstract contract ProvisionManagerV1Storage {
/// @notice The minimum amount of tokens required to register a provision in the data service
uint256 public minimumProvisionTokens;
uint256 internal minimumProvisionTokens;

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

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

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

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

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

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

/// @dev Gap to allow adding variables in future upgrades
/// Note that this contract is not upgradeable but might be inherited by an upgradeable contract
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,10 @@ interface IHorizonStakingExtension is IRewardsIssuer {
*/
// solhint-disable-next-line func-name-mixedcase
function __DEPRECATED_getThawingPeriod() external view returns (uint64);

/**
* @notice Return the address of the subgraph data service.
* @return Address of the subgraph data service
*/
function getSubgraphService() external view returns (address);
}
1 change: 1 addition & 0 deletions packages/horizon/contracts/payments/PaymentsEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ contract PaymentsEscrow is Initializable, MulticallUpgradeable, GraphDirectory,
);

WITHDRAW_ESCROW_THAWING_PERIOD = withdrawEscrowThawingPeriod;
_disableInitializers();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ contract HorizonStakingExtension is HorizonStakingBase, IHorizonStakingExtension
return _serviceProviders[indexer].tokensStaked;
}

/**
* @notice Return the address of the subgraph data service.
* @dev TODO: After transition period move to main HorizonStaking contract
* @return Address of the subgraph data service
*/
function getSubgraphService() external view override returns (address) {
return SUBGRAPH_DATA_SERVICE_ADDRESS;
}

/**
* @notice Getter that returns if an indexer has any stake.
* @param indexer Address of the indexer
Expand Down
25 changes: 24 additions & 1 deletion packages/subgraph-service/contracts/SubgraphService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,18 @@ contract SubgraphService is
* @notice Initialize the contract
* @dev The thawingPeriod and verifierCut ranges are not set here because they are variables
* on the DisputeManager. We use the {ProvisionManager} overrideable getters to get the ranges.
* @param owner The owner of the contract
* @param minimumProvisionTokens The minimum amount of provisioned tokens required to create an allocation
* @param maximumDelegationRatio The maximum delegation ratio allowed for an allocation
* @param stakeToFeesRatio The ratio of stake to fees to lock when collecting query fees
*/
function initialize(
address owner,
uint256 minimumProvisionTokens,
uint32 maximumDelegationRatio,
uint256 stakeToFeesRatio
) external initializer {
__Ownable_init(msg.sender);
__Ownable_init(owner);
__Multicall_init();
__DataService_init();
__DataServicePausable_init();
Expand Down Expand Up @@ -456,6 +458,27 @@ contract SubgraphService is
return _legacyAllocations[allocationId];
}

/**
* @notice See {ISubgraphService.getDisputeManager}
*/
function getDisputeManager() external view override returns (address) {
return address(_disputeManager());
}

/**
* @notice See {ISubgraphService.getGraphTallyCollector}
*/
function getGraphTallyCollector() external view override returns (address) {
return address(_graphTallyCollector());
}

/**
* @notice See {ISubgraphService.getCuration}
*/
function getCuration() external view override returns (address) {
return address(_curation());
}

/**
* @notice See {ISubgraphService.encodeAllocationProof}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ abstract contract SubgraphServiceV1Storage {
///@notice Multiplier for how many tokens back collected query fees
uint256 public stakeToFeesRatio;

/// @notice The cut curators take from query fee payments
/// @notice The cut curators take from query fee payments. In PPM.
uint256 public curationFeesCut;
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,22 @@ interface ISubgraphService is IDataServiceFees {
* @return True if the indexer is over-allocated, false otherwise
*/
function isOverAllocated(address allocationId) external view returns (bool);

/**
* @notice Gets the address of the dispute manager
* @return The address of the dispute manager
*/
function getDisputeManager() external view returns (address);

/**
* @notice Gets the address of the graph tally collector
* @return The address of the graph tally collector
*/
function getGraphTallyCollector() external view returns (address);

/**
* @notice Gets the address of the curation contract
* @return The address of the curation contract
*/
function getCuration() external view returns (address);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$global": {
"governor": "0x72ee30d43Fb5A90B3FE983156C5d2fBE6F6d07B3",
"arbitrator": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
"pauseGuardian": "0xB0aD33a21b98bCA1761729A105e2E34e27153aAE",

// Addresses for contracts deployed in the original Graph Protocol
"controllerAddress": "0x9DB3ee191681f092607035d9BDA6e59FbEaCa695",
Expand All @@ -22,6 +23,8 @@
"minimumProvisionTokens": "100000000000000000000000n",
"maximumDelegationRatio": 16,
"stakeToFeesRatio": 2,
"maxPOIStaleness": 2419200, // 28 days = 2419200 seconds
"curationCut": 100000,

// Addresses for contracts deployed in the original Graph Protocol
"curationAddress": "0xDe761f075200E75485F4358978FB4d1dC8644FD5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$global": {
"governor": "0x72ee30d43Fb5A90B3FE983156C5d2fBE6F6d07B3",
"arbitrator": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
"pauseGuardian": "0xB0aD33a21b98bCA1761729A105e2E34e27153aAE",

// Must be set for step 2 of the deployment
"controllerAddress": "",
Expand All @@ -22,6 +23,8 @@
"minimumProvisionTokens": "100000000000000000000000n",
"maximumDelegationRatio": 16,
"stakeToFeesRatio": 2,
"maxPOIStaleness": 2419200, // 28 days = 2419200 seconds
"curationCut": 100000,

// Must be set for step 2 of the deployment
"subgraphServiceProxyAddress": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$global": {
"governor": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"arbitrator": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
"pauseGuardian": "0xB0aD33a21b98bCA1761729A105e2E34e27153aAE",

// Must be set for step 2 of the deployment
"controllerAddress": "",
Expand All @@ -23,6 +24,8 @@
"minimumProvisionTokens": "100000000000000000000000n",
"maximumDelegationRatio": 16,
"stakeToFeesRatio": 2,
"maxPOIStaleness": 2419200, // 28 days = 2419200 seconds
"curationCut": 100000,

// Must be set for step 2 of the deployment
"subgraphServiceProxyAddress": "",
Expand Down
10 changes: 9 additions & 1 deletion packages/subgraph-service/ignition/modules/SubgraphService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import SubgraphServiceArtifact from '../../build/contracts/contracts/SubgraphSer
import TransparentUpgradeableProxyArtifact from '@openzeppelin/contracts/build/contracts/TransparentUpgradeableProxy.json'

export default buildModule('SubgraphService', (m) => {
const deployer = m.getAccount(0)
const governor = m.getParameter('governor')
const pauseGuardian = m.getParameter('pauseGuardian')
const controllerAddress = m.getParameter('controllerAddress')
const subgraphServiceProxyAddress = m.getParameter('subgraphServiceProxyAddress')
const subgraphServiceProxyAdminAddress = m.getParameter('subgraphServiceProxyAdminAddress')
Expand All @@ -17,6 +19,8 @@ export default buildModule('SubgraphService', (m) => {
const minimumProvisionTokens = m.getParameter('minimumProvisionTokens')
const maximumDelegationRatio = m.getParameter('maximumDelegationRatio')
const stakeToFeesRatio = m.getParameter('stakeToFeesRatio')
const maxPOIStaleness = m.getParameter('maxPOIStaleness')
const curationCut = m.getParameter('curationCut')

const SubgraphServiceProxyAdmin = m.contractAt('ProxyAdmin', ProxyAdminArtifact, subgraphServiceProxyAdminAddress)
const SubgraphServiceProxy = m.contractAt('SubgraphServiceProxy', TransparentUpgradeableProxyArtifact, subgraphServiceProxyAddress)
Expand All @@ -35,13 +39,17 @@ export default buildModule('SubgraphService', (m) => {
name: 'SubgraphService',
artifact: SubgraphServiceArtifact,
initArgs: [
deployer,
minimumProvisionTokens,
maximumDelegationRatio,
stakeToFeesRatio,
],
})

m.call(SubgraphServiceProxyAdmin, 'transferOwnership', [governor], { after: [SubgraphService] })
const callSetPauseGuardian = m.call(SubgraphService, 'setPauseGuardian', [pauseGuardian, true])
const callSetMaxPOIStaleness = m.call(SubgraphService, 'setMaxPOIStaleness', [maxPOIStaleness])
const callSetCurationCut = m.call(SubgraphService, 'setCurationCut', [curationCut])
m.call(SubgraphServiceProxyAdmin, 'transferOwnership', [governor], { after: [callSetPauseGuardian, callSetMaxPOIStaleness, callSetCurationCut] })

return {
SubgraphService,
Expand Down
5 changes: 4 additions & 1 deletion packages/subgraph-service/test/SubgraphBaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ abstract contract SubgraphBaseTest is Utils, Constants {
address subgraphServiceProxy = UnsafeUpgrades.deployTransparentProxy(
subgraphServiceImplementation,
users.governor,
abi.encodeCall(SubgraphService.initialize, (minimumProvisionTokens, delegationRatio, stakeToFeesRatio))
abi.encodeCall(
SubgraphService.initialize,
(users.deployer, minimumProvisionTokens, delegationRatio, stakeToFeesRatio)
)
);
subgraphService = SubgraphService(subgraphServiceProxy);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest {
uint256 tokensAvailable = staking.getTokensAvailable(
_indexer,
address(subgraphService),
subgraphService.delegationRatio()
subgraphService.getDelegationRatio()
);
if (allocation.tokens <= tokensAvailable) {
// Indexer isn't over allocated so allocation should still be open
Expand Down

0 comments on commit 26d5caa

Please sign in to comment.