diff --git a/packages/contracts/contracts/rewards/RewardsManager.sol b/packages/contracts/contracts/rewards/RewardsManager.sol index 72afc3e1a..5e4b6f4c6 100644 --- a/packages/contracts/contracts/rewards/RewardsManager.sol +++ b/packages/contracts/contracts/rewards/RewardsManager.sol @@ -38,8 +38,9 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa /** * @dev Emitted when rewards are assigned to an indexer. + * @dev We use the Horizon prefix to change the event signature which makes network subgraph development much easier */ - event RewardsAssigned(address indexed indexer, address indexed allocationID, uint256 amount); + event HorizonRewardsAssigned(address indexed indexer, address indexed allocationID, uint256 amount); /** * @dev Emitted when rewards are denied to an indexer. @@ -412,7 +413,7 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa graphToken().mint(rewardsIssuer, rewards); } - emit RewardsAssigned(indexer, _allocationID, rewards); + emit HorizonRewardsAssigned(indexer, _allocationID, rewards); return rewards; } diff --git a/packages/contracts/test/unit/rewards/rewards.test.ts b/packages/contracts/test/unit/rewards/rewards.test.ts index cff7b0787..fe5ac75fb 100644 --- a/packages/contracts/test/unit/rewards/rewards.test.ts +++ b/packages/contracts/test/unit/rewards/rewards.test.ts @@ -675,7 +675,7 @@ describe('Rewards', () => { // Close allocation. At this point rewards should be collected for that indexer const tx = staking.connect(indexer1).closeAllocation(allocationID1, randomHexBytes()) await expect(tx) - .emit(rewardsManager, 'RewardsAssigned') + .emit(rewardsManager, 'HorizonRewardsAssigned') .withArgs(indexer1.address, allocationID1, toBN(0)) }) @@ -693,7 +693,7 @@ describe('Rewards', () => { // Close allocation. At this point rewards should be collected for that indexer const tx = staking.connect(indexer1).closeAllocation(allocationID1, randomHexBytes()) await expect(tx) - .emit(rewardsManager, 'RewardsAssigned') + .emit(rewardsManager, 'HorizonRewardsAssigned') .withArgs(indexer1.address, allocationID1, toBN(0)) }) @@ -710,7 +710,7 @@ describe('Rewards', () => { const tx = staking.connect(indexer1).closeAllocation(allocationID1, randomHexBytes()) await expect(tx) - .emit(rewardsManager, 'RewardsAssigned') + .emit(rewardsManager, 'HorizonRewardsAssigned') .withArgs(indexer1.address, allocationID1, toBN(0)) }) diff --git a/packages/contracts/test/unit/staking/allocation.test.ts b/packages/contracts/test/unit/staking/allocation.test.ts index bd930eaba..10bdd22be 100644 --- a/packages/contracts/test/unit/staking/allocation.test.ts +++ b/packages/contracts/test/unit/staking/allocation.test.ts @@ -895,7 +895,7 @@ describe('Staking:Allocation', () => { poi, false, ) - await expect(tx).not.to.emit(rewardsManager, 'RewardsAssigned') + await expect(tx).not.to.emit(rewardsManager, 'HorizonRewardsAssigned') }) it('reject close if not the owner of allocation', async function () { diff --git a/packages/subgraph-service/contracts/DisputeManager.sol b/packages/subgraph-service/contracts/DisputeManager.sol index 2854282f4..a59d84474 100644 --- a/packages/subgraph-service/contracts/DisputeManager.sol +++ b/packages/subgraph-service/contracts/DisputeManager.sol @@ -103,6 +103,7 @@ contract DisputeManager is /** * @notice Initialize this contract. + * @param owner The owner of the contract * @param arbitrator Arbitrator role * @param disputePeriod Dispute period in seconds * @param disputeDeposit Deposit required to create a Dispute @@ -110,13 +111,14 @@ contract DisputeManager is * @param maxSlashingCut_ Maximum percentage of indexer stake that can be slashed (ppm) */ function initialize( + address owner, address arbitrator, uint64 disputePeriod, uint256 disputeDeposit, uint32 fishermanRewardCut_, uint32 maxSlashingCut_ ) external initializer { - __Ownable_init(msg.sender); + __Ownable_init(owner); __AttestationManager_init(); _setArbitrator(arbitrator); diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index 0846d819e..3f6b71d0f 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -587,7 +587,7 @@ contract SubgraphService is } } - emit QueryFeesCollected(indexer, tokensCollected, tokensCurators); + emit QueryFeesCollected(indexer, _signedRav.rav.payer, tokensCollected, tokensCurators); return tokensCollected; } diff --git a/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol b/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol index a63b6b072..68639bf8a 100644 --- a/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol +++ b/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol @@ -29,10 +29,11 @@ interface ISubgraphService is IDataServiceFees { /** * @notice Emitted when a subgraph service collects query fees from Graph Payments * @param serviceProvider The address of the service provider + * @param payer The address paying for the query fees * @param tokensCollected The amount of tokens collected * @param tokensCurators The amount of tokens curators receive */ - event QueryFeesCollected(address indexed serviceProvider, uint256 tokensCollected, uint256 tokensCurators); + event QueryFeesCollected(address indexed serviceProvider, address indexed payer, uint256 tokensCollected, uint256 tokensCurators); /** * @notice Emitted when the stake to fees ratio is set. diff --git a/packages/subgraph-service/ignition/configs/protocol.default.json5 b/packages/subgraph-service/ignition/configs/protocol.default.json5 index 9693a77d2..6bb5191bf 100644 --- a/packages/subgraph-service/ignition/configs/protocol.default.json5 +++ b/packages/subgraph-service/ignition/configs/protocol.default.json5 @@ -8,7 +8,8 @@ "controllerAddress": "", "disputeManagerProxyAddress": "", "curationAddress": "", - "curationImplementationAddress": "" + "curationImplementationAddress": "", + "subgraphServiceProxyAddress": "" }, "DisputeManager": { "disputePeriod": 2419200, @@ -27,7 +28,6 @@ "curationCut": 100000, // Must be set for step 2 of the deployment - "subgraphServiceProxyAddress": "", "subgraphServiceProxyAdminAddress": "", "graphTallyCollectorAddress": "" } diff --git a/packages/subgraph-service/ignition/modules/DisputeManager.ts b/packages/subgraph-service/ignition/modules/DisputeManager.ts index e1a456059..00038e480 100644 --- a/packages/subgraph-service/ignition/modules/DisputeManager.ts +++ b/packages/subgraph-service/ignition/modules/DisputeManager.ts @@ -7,8 +7,10 @@ import ProxyAdminArtifact from '@openzeppelin/contracts/build/contracts/ProxyAdm import TransparentUpgradeableProxyArtifact from '@openzeppelin/contracts/build/contracts/TransparentUpgradeableProxy.json' export default buildModule('DisputeManager', (m) => { + const deployer = m.getAccount(0) const governor = m.getParameter('governor') const controllerAddress = m.getParameter('controllerAddress') + const subgraphServiceProxyAddress = m.getParameter('subgraphServiceProxyAddress') const disputeManagerProxyAddress = m.getParameter('disputeManagerProxyAddress') const disputeManagerProxyAdminAddress = m.getParameter('disputeManagerProxyAdminAddress') const arbitrator = m.getParameter('arbitrator') @@ -34,6 +36,7 @@ export default buildModule('DisputeManager', (m) => { name: 'DisputeManager', artifact: DisputeManagerArtifact, initArgs: [ + deployer, arbitrator, disputePeriod, disputeDeposit, @@ -42,7 +45,10 @@ export default buildModule('DisputeManager', (m) => { ], }) - m.call(DisputeManagerProxyAdmin, 'transferOwnership', [governor], { after: [DisputeManager] }) + const callSetSubgraphService = m.call(DisputeManager, 'setSubgraphService', [subgraphServiceProxyAddress]) + + m.call(DisputeManager, 'transferOwnership', [governor], { after: [callSetSubgraphService] }) + m.call(DisputeManagerProxyAdmin, 'transferOwnership', [governor], { after: [callSetSubgraphService] }) return { DisputeManager, diff --git a/packages/subgraph-service/ignition/modules/SubgraphService.ts b/packages/subgraph-service/ignition/modules/SubgraphService.ts index 9e208e826..b8ab37711 100644 --- a/packages/subgraph-service/ignition/modules/SubgraphService.ts +++ b/packages/subgraph-service/ignition/modules/SubgraphService.ts @@ -49,6 +49,8 @@ export default buildModule('SubgraphService', (m) => { const callSetPauseGuardian = m.call(SubgraphService, 'setPauseGuardian', [pauseGuardian, true]) const callSetMaxPOIStaleness = m.call(SubgraphService, 'setMaxPOIStaleness', [maxPOIStaleness]) const callSetCurationCut = m.call(SubgraphService, 'setCurationCut', [curationCut]) + + m.call(SubgraphService, 'transferOwnership', [governor], { after: [callSetPauseGuardian, callSetMaxPOIStaleness, callSetCurationCut] }) m.call(SubgraphServiceProxyAdmin, 'transferOwnership', [governor], { after: [callSetPauseGuardian, callSetMaxPOIStaleness, callSetCurationCut] }) return { diff --git a/packages/subgraph-service/tasks/deploy.ts b/packages/subgraph-service/tasks/deploy.ts index 2edb26b19..1e545c9f4 100644 --- a/packages/subgraph-service/tasks/deploy.ts +++ b/packages/subgraph-service/tasks/deploy.ts @@ -52,7 +52,7 @@ task('deploy:protocol', 'Deploy a new version of the Graph Protocol Horizon cont const horizonDeployment = await hre.ignition.deploy(HorizonModule, { displayUi: true, parameters: IgnitionHelper.patchConfig(HorizonConfig, { - SubgraphService: { + $global: { subgraphServiceProxyAddress: proxiesDeployment.Transparent_Proxy_SubgraphService.target as string, }, }), @@ -68,12 +68,12 @@ task('deploy:protocol', 'Deploy a new version of the Graph Protocol Horizon cont disputeManagerProxyAddress: proxiesDeployment.Transparent_Proxy_DisputeManager.target as string, curationAddress: horizonDeployment.Graph_Proxy_L2Curation.target as string, curationImplementationAddress: horizonDeployment.Implementation_L2Curation.target as string, + subgraphServiceProxyAddress: proxiesDeployment.Transparent_Proxy_SubgraphService.target as string, }, DisputeManager: { disputeManagerProxyAdminAddress: proxiesDeployment.Transparent_ProxyAdmin_DisputeManager.target as string, }, SubgraphService: { - subgraphServiceProxyAddress: proxiesDeployment.Transparent_Proxy_SubgraphService.target as string, subgraphServiceProxyAdminAddress: proxiesDeployment.Transparent_ProxyAdmin_SubgraphService.target as string, graphTallyCollectorAddress: horizonDeployment.GraphTallyCollector.target as string, }, @@ -170,8 +170,10 @@ function _patchStepConfig