From c75c894db8a2de1b83c4c8c63745888dc738b9c4 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Wed, 26 Feb 2025 03:37:30 -0300 Subject: [PATCH 1/4] feat: add extra parameters to QueryFeesCollected event --- .../contracts/SubgraphService.sol | 9 ++++++++- .../contracts/interfaces/ISubgraphService.sol | 11 ++++++++++- .../test/subgraphService/SubgraphService.t.sol | 16 ++++++++++++---- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index 3f6b71d0f..4ecfa0c61 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -587,7 +587,14 @@ contract SubgraphService is } } - emit QueryFeesCollected(indexer, _signedRav.rav.payer, tokensCollected, tokensCurators); + emit QueryFeesCollected( + indexer, + _signedRav.rav.payer, + allocationId, + subgraphDeploymentId, + tokensCollected, + tokensCurators + ); return tokensCollected; } diff --git a/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol b/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol index 68639bf8a..049aa6656 100644 --- a/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol +++ b/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol @@ -30,10 +30,19 @@ 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 allocationId The id of the allocation + * @param subgraphDeploymentId The id of the subgraph deployment * @param tokensCollected The amount of tokens collected * @param tokensCurators The amount of tokens curators receive */ - event QueryFeesCollected(address indexed serviceProvider, address indexed payer, uint256 tokensCollected, uint256 tokensCurators); + event QueryFeesCollected( + address indexed serviceProvider, + address indexed payer, + address indexed allocationId, + bytes32 indexed subgraphDeploymentId, + uint256 tokensCollected, + uint256 tokensCurator + ); /** * @notice Emitted when the stake to fees ratio is set. diff --git a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol index 2053083c8..5401e16e1 100644 --- a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol +++ b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol @@ -278,9 +278,10 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { bytes memory _data ) private returns (uint256 paymentCollected) { IGraphTallyCollector.SignedRAV memory signedRav = abi.decode(_data, (IGraphTallyCollector.SignedRAV)); - Allocation.State memory allocation = subgraphService.getAllocation( - address(uint160(uint256(signedRav.rav.collectionId))) - ); + address allocationId = address(uint160(uint256(_signedRav.rav.collectionId))); + Allocation.State memory allocation = subgraphService.getAllocation(allocationId); + bytes32 subgraphDeploymentId = allocation.subgraphDeploymentId; + address payer = graphTallyCollector.isAuthorized(signedRav.rav.payer, _recoverRAVSigner(signedRav)) ? signedRav.rav.payer : address(0); @@ -298,7 +299,14 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { uint256 tokensCurators = (paymentCollected - tokensProtocol).mulPPMRoundUp(queryFeeData.curationCut); vm.expectEmit(address(subgraphService)); - emit ISubgraphService.QueryFeesCollected(_indexer, payer, paymentCollected, tokensCurators); + emit ISubgraphService.QueryFeesCollected( + _indexer, + payer, + allocationId, + subgraphDeploymentId, + paymentCollected, + tokensCurators + ); return paymentCollected; } From c2b526adcfa97772ce60c2dc2b4290bf76f24183 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Wed, 26 Feb 2025 03:48:04 -0300 Subject: [PATCH 2/4] fix: build errors and typo --- .../contracts/interfaces/ISubgraphService.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol b/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol index 049aa6656..5449ca1d3 100644 --- a/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol +++ b/packages/subgraph-service/contracts/interfaces/ISubgraphService.sol @@ -39,9 +39,9 @@ interface ISubgraphService is IDataServiceFees { address indexed serviceProvider, address indexed payer, address indexed allocationId, - bytes32 indexed subgraphDeploymentId, + bytes32 subgraphDeploymentId, uint256 tokensCollected, - uint256 tokensCurator + uint256 tokensCurators ); /** From d3a13cb724574de0ad23855374d8dfcacb49de45 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Wed, 26 Feb 2025 03:56:34 -0300 Subject: [PATCH 3/4] fix: typo --- .../subgraph-service/test/subgraphService/SubgraphService.t.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol index 5401e16e1..3d8fd1b7d 100644 --- a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol +++ b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol @@ -278,7 +278,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { bytes memory _data ) private returns (uint256 paymentCollected) { IGraphTallyCollector.SignedRAV memory signedRav = abi.decode(_data, (IGraphTallyCollector.SignedRAV)); - address allocationId = address(uint160(uint256(_signedRav.rav.collectionId))); + address allocationId = address(uint160(uint256(signedRav.rav.collectionId))); Allocation.State memory allocation = subgraphService.getAllocation(allocationId); bytes32 subgraphDeploymentId = allocation.subgraphDeploymentId; From 9f37b06944e2dc491c9d191c8d553c590b987aa4 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Mon, 3 Mar 2025 12:04:08 -0300 Subject: [PATCH 4/4] feat: add shares to TokensUndelegated --- .../contracts/interfaces/internal/IHorizonStakingMain.sol | 4 +++- packages/horizon/contracts/staking/HorizonStaking.sol | 2 +- .../test/shared/horizon-staking/HorizonStakingShared.t.sol | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/horizon/contracts/interfaces/internal/IHorizonStakingMain.sol b/packages/horizon/contracts/interfaces/internal/IHorizonStakingMain.sol index a934ac667..1a90f69a1 100644 --- a/packages/horizon/contracts/interfaces/internal/IHorizonStakingMain.sol +++ b/packages/horizon/contracts/interfaces/internal/IHorizonStakingMain.sol @@ -186,12 +186,14 @@ interface IHorizonStakingMain { * @param verifier The address of the verifier * @param delegator The address of the delegator * @param tokens The amount of tokens undelegated + * @param tokens The amount of shares undelegated */ event TokensUndelegated( address indexed serviceProvider, address indexed verifier, address indexed delegator, - uint256 tokens + uint256 tokens, + uint256 shares ); /** diff --git a/packages/horizon/contracts/staking/HorizonStaking.sol b/packages/horizon/contracts/staking/HorizonStaking.sol index 9002bce8c..bd3f0841d 100644 --- a/packages/horizon/contracts/staking/HorizonStaking.sol +++ b/packages/horizon/contracts/staking/HorizonStaking.sol @@ -939,7 +939,7 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { pool.thawingNonce ); - emit TokensUndelegated(_serviceProvider, _verifier, msg.sender, tokens); + emit TokensUndelegated(_serviceProvider, _verifier, msg.sender, tokens, _shares); return thawRequestId; } diff --git a/packages/horizon/test/shared/horizon-staking/HorizonStakingShared.t.sol b/packages/horizon/test/shared/horizon-staking/HorizonStakingShared.t.sol index 86817c144..0d84ba708 100644 --- a/packages/horizon/test/shared/horizon-staking/HorizonStakingShared.t.sol +++ b/packages/horizon/test/shared/horizon-staking/HorizonStakingShared.t.sol @@ -1010,7 +1010,7 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { calcValues.thawRequestId ); vm.expectEmit(); - emit IHorizonStakingMain.TokensUndelegated(serviceProvider, verifier, delegator, calcValues.tokens); + emit IHorizonStakingMain.TokensUndelegated(serviceProvider, verifier, delegator, calcValues.tokens, shares); if (legacy) { staking.undelegate(serviceProvider, shares); } else if (thawRequestType == IHorizonStakingTypes.ThawRequestType.Delegation) {