Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: change some events for easier indexing #1119

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/contracts/contracts/rewards/RewardsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/contracts/test/unit/rewards/rewards.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})

Expand All @@ -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))
})

Expand All @@ -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))
})

Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/test/unit/staking/allocation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
4 changes: 3 additions & 1 deletion packages/subgraph-service/contracts/DisputeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,22 @@ 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
* @param fishermanRewardCut_ Percent of slashed funds for fisherman (ppm)
* @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);
Expand Down
2 changes: 1 addition & 1 deletion packages/subgraph-service/contracts/SubgraphService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ contract SubgraphService is
}
}

emit QueryFeesCollected(indexer, tokensCollected, tokensCurators);
emit QueryFeesCollected(indexer, _signedRav.rav.payer, tokensCollected, tokensCurators);
return tokensCollected;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"controllerAddress": "",
"disputeManagerProxyAddress": "",
"curationAddress": "",
"curationImplementationAddress": ""
"curationImplementationAddress": "",
"subgraphServiceProxyAddress": ""
},
"DisputeManager": {
"disputePeriod": 2419200,
Expand All @@ -27,7 +28,6 @@
"curationCut": 100000,

// Must be set for step 2 of the deployment
"subgraphServiceProxyAddress": "",
"subgraphServiceProxyAdminAddress": "",
"graphTallyCollectorAddress": ""
}
Expand Down
8 changes: 7 additions & 1 deletion packages/subgraph-service/ignition/modules/DisputeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -34,6 +36,7 @@ export default buildModule('DisputeManager', (m) => {
name: 'DisputeManager',
artifact: DisputeManagerArtifact,
initArgs: [
deployer,
arbitrator,
disputePeriod,
disputeDeposit,
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions packages/subgraph-service/ignition/modules/SubgraphService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 5 additions & 3 deletions packages/subgraph-service/tasks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}),
Expand All @@ -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,
},
Expand Down Expand Up @@ -170,8 +170,10 @@ function _patchStepConfig<ChainId extends number, ContractName extends string, H
const GraphTallyCollector = horizonAddressBook.getEntry('GraphTallyCollector')

patchedConfig = IgnitionHelper.patchConfig(config, {
SubgraphService: {
$global: {
subgraphServiceProxyAddress: SubgraphService.address,
},
SubgraphService: {
subgraphServiceProxyAdminAddress: SubgraphService.proxyAdmin,
graphTallyCollectorAddress: GraphTallyCollector.address,
disputeManagerProxyAddress: DisputeManager.address,
Expand Down
2 changes: 1 addition & 1 deletion packages/subgraph-service/test/SubgraphBaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ abstract contract SubgraphBaseTest is Utils, Constants {
users.governor,
abi.encodeCall(
DisputeManager.initialize,
(users.arbitrator, disputePeriod, disputeDeposit, fishermanRewardPercentage, maxSlashingPercentage)
(users.deployer, users.arbitrator, disputePeriod, disputeDeposit, fishermanRewardPercentage, maxSlashingPercentage)
)
);
disputeManager = DisputeManager(disputeManagerProxy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract DisputeManagerConstructorTest is DisputeManagerTest {
users.governor,
abi.encodeCall(
DisputeManager.initialize,
(arbitrator, disputePeriod, disputeDeposit, fishermanRewardPercentage, maxSlashingPercentage)
(users.deployer, arbitrator, disputePeriod, disputeDeposit, fishermanRewardPercentage, maxSlashingPercentage)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest {
uint256 tokensCurators = (paymentCollected - tokensProtocol).mulPPMRoundUp(queryFeeData.curationCut);

vm.expectEmit(address(subgraphService));
emit ISubgraphService.QueryFeesCollected(_indexer, paymentCollected, tokensCurators);
emit ISubgraphService.QueryFeesCollected(_indexer, payer, paymentCollected, tokensCurators);

return paymentCollected;
}
Expand Down
Loading