Skip to content

Commit 7bac074

Browse files
authored
Merge pull request #1119 from graphprotocol/tmigone/more-subgraph-changes
2 parents 26d5caa + 830f7e8 commit 7bac074

File tree

13 files changed

+32
-18
lines changed

13 files changed

+32
-18
lines changed

packages/contracts/contracts/rewards/RewardsManager.sol

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa
3838

3939
/**
4040
* @dev Emitted when rewards are assigned to an indexer.
41+
* @dev We use the Horizon prefix to change the event signature which makes network subgraph development much easier
4142
*/
42-
event RewardsAssigned(address indexed indexer, address indexed allocationID, uint256 amount);
43+
event HorizonRewardsAssigned(address indexed indexer, address indexed allocationID, uint256 amount);
4344

4445
/**
4546
* @dev Emitted when rewards are denied to an indexer.
@@ -412,7 +413,7 @@ contract RewardsManager is RewardsManagerV5Storage, GraphUpgradeable, IRewardsMa
412413
graphToken().mint(rewardsIssuer, rewards);
413414
}
414415

415-
emit RewardsAssigned(indexer, _allocationID, rewards);
416+
emit HorizonRewardsAssigned(indexer, _allocationID, rewards);
416417

417418
return rewards;
418419
}

packages/contracts/test/unit/rewards/rewards.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ describe('Rewards', () => {
675675
// Close allocation. At this point rewards should be collected for that indexer
676676
const tx = staking.connect(indexer1).closeAllocation(allocationID1, randomHexBytes())
677677
await expect(tx)
678-
.emit(rewardsManager, 'RewardsAssigned')
678+
.emit(rewardsManager, 'HorizonRewardsAssigned')
679679
.withArgs(indexer1.address, allocationID1, toBN(0))
680680
})
681681

@@ -693,7 +693,7 @@ describe('Rewards', () => {
693693
// Close allocation. At this point rewards should be collected for that indexer
694694
const tx = staking.connect(indexer1).closeAllocation(allocationID1, randomHexBytes())
695695
await expect(tx)
696-
.emit(rewardsManager, 'RewardsAssigned')
696+
.emit(rewardsManager, 'HorizonRewardsAssigned')
697697
.withArgs(indexer1.address, allocationID1, toBN(0))
698698
})
699699

@@ -710,7 +710,7 @@ describe('Rewards', () => {
710710
const tx = staking.connect(indexer1).closeAllocation(allocationID1, randomHexBytes())
711711

712712
await expect(tx)
713-
.emit(rewardsManager, 'RewardsAssigned')
713+
.emit(rewardsManager, 'HorizonRewardsAssigned')
714714
.withArgs(indexer1.address, allocationID1, toBN(0))
715715
})
716716

packages/contracts/test/unit/staking/allocation.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ describe('Staking:Allocation', () => {
895895
poi,
896896
false,
897897
)
898-
await expect(tx).not.to.emit(rewardsManager, 'RewardsAssigned')
898+
await expect(tx).not.to.emit(rewardsManager, 'HorizonRewardsAssigned')
899899
})
900900

901901
it('reject close if not the owner of allocation', async function () {

packages/subgraph-service/contracts/DisputeManager.sol

+3-1
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,22 @@ contract DisputeManager is
103103

104104
/**
105105
* @notice Initialize this contract.
106+
* @param owner The owner of the contract
106107
* @param arbitrator Arbitrator role
107108
* @param disputePeriod Dispute period in seconds
108109
* @param disputeDeposit Deposit required to create a Dispute
109110
* @param fishermanRewardCut_ Percent of slashed funds for fisherman (ppm)
110111
* @param maxSlashingCut_ Maximum percentage of indexer stake that can be slashed (ppm)
111112
*/
112113
function initialize(
114+
address owner,
113115
address arbitrator,
114116
uint64 disputePeriod,
115117
uint256 disputeDeposit,
116118
uint32 fishermanRewardCut_,
117119
uint32 maxSlashingCut_
118120
) external initializer {
119-
__Ownable_init(msg.sender);
121+
__Ownable_init(owner);
120122
__AttestationManager_init();
121123

122124
_setArbitrator(arbitrator);

packages/subgraph-service/contracts/SubgraphService.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ contract SubgraphService is
587587
}
588588
}
589589

590-
emit QueryFeesCollected(indexer, tokensCollected, tokensCurators);
590+
emit QueryFeesCollected(indexer, _signedRav.rav.payer, tokensCollected, tokensCurators);
591591
return tokensCollected;
592592
}
593593

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ interface ISubgraphService is IDataServiceFees {
2929
/**
3030
* @notice Emitted when a subgraph service collects query fees from Graph Payments
3131
* @param serviceProvider The address of the service provider
32+
* @param payer The address paying for the query fees
3233
* @param tokensCollected The amount of tokens collected
3334
* @param tokensCurators The amount of tokens curators receive
3435
*/
35-
event QueryFeesCollected(address indexed serviceProvider, uint256 tokensCollected, uint256 tokensCurators);
36+
event QueryFeesCollected(address indexed serviceProvider, address indexed payer, uint256 tokensCollected, uint256 tokensCurators);
3637

3738
/**
3839
* @notice Emitted when the stake to fees ratio is set.

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"controllerAddress": "",
99
"disputeManagerProxyAddress": "",
1010
"curationAddress": "",
11-
"curationImplementationAddress": ""
11+
"curationImplementationAddress": "",
12+
"subgraphServiceProxyAddress": ""
1213
},
1314
"DisputeManager": {
1415
"disputePeriod": 2419200,
@@ -27,7 +28,6 @@
2728
"curationCut": 100000,
2829

2930
// Must be set for step 2 of the deployment
30-
"subgraphServiceProxyAddress": "",
3131
"subgraphServiceProxyAdminAddress": "",
3232
"graphTallyCollectorAddress": ""
3333
}

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import ProxyAdminArtifact from '@openzeppelin/contracts/build/contracts/ProxyAdm
77
import TransparentUpgradeableProxyArtifact from '@openzeppelin/contracts/build/contracts/TransparentUpgradeableProxy.json'
88

99
export default buildModule('DisputeManager', (m) => {
10+
const deployer = m.getAccount(0)
1011
const governor = m.getParameter('governor')
1112
const controllerAddress = m.getParameter('controllerAddress')
13+
const subgraphServiceProxyAddress = m.getParameter('subgraphServiceProxyAddress')
1214
const disputeManagerProxyAddress = m.getParameter('disputeManagerProxyAddress')
1315
const disputeManagerProxyAdminAddress = m.getParameter('disputeManagerProxyAdminAddress')
1416
const arbitrator = m.getParameter('arbitrator')
@@ -34,6 +36,7 @@ export default buildModule('DisputeManager', (m) => {
3436
name: 'DisputeManager',
3537
artifact: DisputeManagerArtifact,
3638
initArgs: [
39+
deployer,
3740
arbitrator,
3841
disputePeriod,
3942
disputeDeposit,
@@ -42,7 +45,10 @@ export default buildModule('DisputeManager', (m) => {
4245
],
4346
})
4447

45-
m.call(DisputeManagerProxyAdmin, 'transferOwnership', [governor], { after: [DisputeManager] })
48+
const callSetSubgraphService = m.call(DisputeManager, 'setSubgraphService', [subgraphServiceProxyAddress])
49+
50+
m.call(DisputeManager, 'transferOwnership', [governor], { after: [callSetSubgraphService] })
51+
m.call(DisputeManagerProxyAdmin, 'transferOwnership', [governor], { after: [callSetSubgraphService] })
4652

4753
return {
4854
DisputeManager,

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

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export default buildModule('SubgraphService', (m) => {
4949
const callSetPauseGuardian = m.call(SubgraphService, 'setPauseGuardian', [pauseGuardian, true])
5050
const callSetMaxPOIStaleness = m.call(SubgraphService, 'setMaxPOIStaleness', [maxPOIStaleness])
5151
const callSetCurationCut = m.call(SubgraphService, 'setCurationCut', [curationCut])
52+
53+
m.call(SubgraphService, 'transferOwnership', [governor], { after: [callSetPauseGuardian, callSetMaxPOIStaleness, callSetCurationCut] })
5254
m.call(SubgraphServiceProxyAdmin, 'transferOwnership', [governor], { after: [callSetPauseGuardian, callSetMaxPOIStaleness, callSetCurationCut] })
5355

5456
return {

packages/subgraph-service/tasks/deploy.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ task('deploy:protocol', 'Deploy a new version of the Graph Protocol Horizon cont
5252
const horizonDeployment = await hre.ignition.deploy(HorizonModule, {
5353
displayUi: true,
5454
parameters: IgnitionHelper.patchConfig(HorizonConfig, {
55-
SubgraphService: {
55+
$global: {
5656
subgraphServiceProxyAddress: proxiesDeployment.Transparent_Proxy_SubgraphService.target as string,
5757
},
5858
}),
@@ -68,12 +68,12 @@ task('deploy:protocol', 'Deploy a new version of the Graph Protocol Horizon cont
6868
disputeManagerProxyAddress: proxiesDeployment.Transparent_Proxy_DisputeManager.target as string,
6969
curationAddress: horizonDeployment.Graph_Proxy_L2Curation.target as string,
7070
curationImplementationAddress: horizonDeployment.Implementation_L2Curation.target as string,
71+
subgraphServiceProxyAddress: proxiesDeployment.Transparent_Proxy_SubgraphService.target as string,
7172
},
7273
DisputeManager: {
7374
disputeManagerProxyAdminAddress: proxiesDeployment.Transparent_ProxyAdmin_DisputeManager.target as string,
7475
},
7576
SubgraphService: {
76-
subgraphServiceProxyAddress: proxiesDeployment.Transparent_Proxy_SubgraphService.target as string,
7777
subgraphServiceProxyAdminAddress: proxiesDeployment.Transparent_ProxyAdmin_SubgraphService.target as string,
7878
graphTallyCollectorAddress: horizonDeployment.GraphTallyCollector.target as string,
7979
},
@@ -170,8 +170,10 @@ function _patchStepConfig<ChainId extends number, ContractName extends string, H
170170
const GraphTallyCollector = horizonAddressBook.getEntry('GraphTallyCollector')
171171

172172
patchedConfig = IgnitionHelper.patchConfig(config, {
173-
SubgraphService: {
173+
$global: {
174174
subgraphServiceProxyAddress: SubgraphService.address,
175+
},
176+
SubgraphService: {
175177
subgraphServiceProxyAdminAddress: SubgraphService.proxyAdmin,
176178
graphTallyCollectorAddress: GraphTallyCollector.address,
177179
disputeManagerProxyAddress: DisputeManager.address,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ abstract contract SubgraphBaseTest is Utils, Constants {
137137
users.governor,
138138
abi.encodeCall(
139139
DisputeManager.initialize,
140-
(users.arbitrator, disputePeriod, disputeDeposit, fishermanRewardPercentage, maxSlashingPercentage)
140+
(users.deployer, users.arbitrator, disputePeriod, disputeDeposit, fishermanRewardPercentage, maxSlashingPercentage)
141141
)
142142
);
143143
disputeManager = DisputeManager(disputeManagerProxy);

packages/subgraph-service/test/disputeManager/constructor/constructor.t.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ contract DisputeManagerConstructorTest is DisputeManagerTest {
4141
users.governor,
4242
abi.encodeCall(
4343
DisputeManager.initialize,
44-
(arbitrator, disputePeriod, disputeDeposit, fishermanRewardPercentage, maxSlashingPercentage)
44+
(users.deployer, arbitrator, disputePeriod, disputeDeposit, fishermanRewardPercentage, maxSlashingPercentage)
4545
)
4646
);
4747
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest {
298298
uint256 tokensCurators = (paymentCollected - tokensProtocol).mulPPMRoundUp(queryFeeData.curationCut);
299299

300300
vm.expectEmit(address(subgraphService));
301-
emit ISubgraphService.QueryFeesCollected(_indexer, paymentCollected, tokensCurators);
301+
emit ISubgraphService.QueryFeesCollected(_indexer, payer, paymentCollected, tokensCurators);
302302

303303
return paymentCollected;
304304
}

0 commit comments

Comments
 (0)