diff --git a/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol b/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol index 671826169..9a417fd9b 100644 --- a/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol +++ b/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol @@ -102,7 +102,10 @@ contract GraphTallyCollector is EIP712, GraphDirectory, Authorizable, IGraphTall bytes calldata _data, uint256 _tokensToCollect ) private returns (uint256) { - (SignedRAV memory signedRAV, uint256 dataServiceCut, address receiverDestination) = abi.decode(_data, (SignedRAV, uint256, address)); + (SignedRAV memory signedRAV, uint256 dataServiceCut, address receiverDestination) = abi.decode( + _data, + (SignedRAV, uint256, address) + ); // Ensure caller is the RAV data service require( @@ -153,7 +156,15 @@ contract GraphTallyCollector is EIP712, GraphDirectory, Authorizable, IGraphTall if (tokensToCollect > 0) { tokensCollected[dataService][collectionId][receiver][signedRAV.rav.payer] += tokensToCollect; - _graphPaymentsEscrow().collect(_paymentType, signedRAV.rav.payer, receiver, tokensToCollect, dataService, dataServiceCut, receiverDestination); + _graphPaymentsEscrow().collect( + _paymentType, + signedRAV.rav.payer, + receiver, + tokensToCollect, + dataService, + dataServiceCut, + receiverDestination + ); } emit PaymentCollected(_paymentType, collectionId, signedRAV.rav.payer, receiver, dataService, tokensToCollect); diff --git a/packages/horizon/package.json b/packages/horizon/package.json index e2ba98cc0..c3f960433 100644 --- a/packages/horizon/package.json +++ b/packages/horizon/package.json @@ -18,8 +18,8 @@ "lint": "pnpm lint:ts && pnpm lint:sol", "lint:ts": "eslint '**/*.{js,ts}' --fix --no-warn-ignored", "lint:sol": "pnpm lint:sol:prettier && pnpm lint:sol:solhint", - "lint:sol:prettier": "prettier --write contracts/**/*.sol test/**/*.sol", - "lint:sol:solhint": "solhint --noPrompt --fix contracts/**/*.sol --config node_modules/solhint-graph-config/index.js", + "lint:sol:prettier": "prettier --write \"contracts/**/*.sol\" \"test/**/*.sol\"", + "lint:sol:solhint": "solhint --noPrompt --fix \"contracts/**/*.sol\" --config node_modules/solhint-graph-config/index.js", "lint:sol:natspec": "natspec-smells --config natspec-smells.config.js", "clean": "rm -rf build dist cache cache_forge typechain-types", "build": "hardhat compile", diff --git a/packages/horizon/test/unit/escrow/GraphEscrow.t.sol b/packages/horizon/test/unit/escrow/GraphEscrow.t.sol index 5ce7dcf37..247fd3cf5 100644 --- a/packages/horizon/test/unit/escrow/GraphEscrow.t.sol +++ b/packages/horizon/test/unit/escrow/GraphEscrow.t.sol @@ -199,11 +199,17 @@ contract GraphEscrowTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest { } // Check receiver balance after payment - assertEq(afterBalances.receiverBalance - previousBalances.receiverBalance, collectTokensData.receiverExpectedPayment); + assertEq( + afterBalances.receiverBalance - previousBalances.receiverBalance, + collectTokensData.receiverExpectedPayment + ); assertEq(token.balanceOf(address(payments)), 0); // Check delegation pool balance after payment - assertEq(afterBalances.delegationPoolBalance - previousBalances.delegationPoolBalance, collectTokensData.tokensDelegation); + assertEq( + afterBalances.delegationPoolBalance - previousBalances.delegationPoolBalance, + collectTokensData.tokensDelegation + ); // Check that the escrow account has been updated assertEq(previousBalances.escrowBalance, afterBalances.escrowBalance + _tokens); @@ -212,7 +218,10 @@ contract GraphEscrowTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest { assertEq(previousBalances.paymentsBalance, afterBalances.paymentsBalance); // Check data service balance after payment - assertEq(afterBalances.dataServiceBalance - previousBalances.dataServiceBalance, collectTokensData.tokensDataService); + assertEq( + afterBalances.dataServiceBalance - previousBalances.dataServiceBalance, + collectTokensData.tokensDataService + ); // Check payers escrow balance after payment assertEq(previousBalances.payerEscrowBalance - _tokens, afterBalances.payerEscrowBalance); diff --git a/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol b/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol index 62b531ffb..526894264 100644 --- a/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol +++ b/packages/horizon/test/unit/shared/horizon-staking/HorizonStakingShared.t.sol @@ -54,21 +54,12 @@ abstract contract HorizonStakingSharedTest is GraphBaseTest { _; } - modifier useProvision( - uint256 tokens, - uint32 maxVerifierCut, - uint64 thawingPeriod - ) virtual { + modifier useProvision(uint256 tokens, uint32 maxVerifierCut, uint64 thawingPeriod) virtual { _useProvision(subgraphDataServiceAddress, tokens, maxVerifierCut, thawingPeriod); _; } - modifier useProvisionDataService( - address dataService, - uint256 tokens, - uint32 maxVerifierCut, - uint64 thawingPeriod - ) { + modifier useProvisionDataService(address dataService, uint256 tokens, uint32 maxVerifierCut, uint64 thawingPeriod) { _useProvision(dataService, tokens, maxVerifierCut, thawingPeriod); _; } diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index 4179cf786..140ab9c34 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -425,6 +425,17 @@ contract SubgraphService is return _isOverAllocated(indexer, _delegationRatio); } + /** + * @notice Sets the payments destination for an indexer to receive payments + * @dev Emits a {PaymentsDestinationSet} event + * @param _indexer The address of the indexer + * @param _paymentsDestination The address where payments should be sent + */ + function _setPaymentsDestination(address _indexer, address _paymentsDestination) internal { + paymentsDestination[_indexer] = _paymentsDestination; + emit PaymentsDestinationSet(_indexer, _paymentsDestination); + } + // -- Data service parameter getters -- /** * @notice Getter for the accepted thawing period range for provisions @@ -470,21 +481,21 @@ contract SubgraphService is * Emits a {StakeClaimLocked} event. * Emits a {QueryFeesCollected} event. * - * @param indexer The address of the indexer - * @param data Encoded data: + * @param _indexer The address of the indexer + * @param _data Encoded data: * - IGraphTallyCollector.SignedRAV `signedRav`: The signed RAV * - uint256 `tokensToCollect`: The amount of tokens to collect. Allows partially collecting a RAV. If 0, the entire RAV will * be collected. * @return The amount of fees collected */ - function _collectQueryFees(address indexer, bytes calldata data) private returns (uint256) { + function _collectQueryFees(address _indexer, bytes calldata _data) private returns (uint256) { (IGraphTallyCollector.SignedRAV memory signedRav, uint256 tokensToCollect) = abi.decode( - data, + _data, (IGraphTallyCollector.SignedRAV, uint256) ); require( - signedRav.rav.serviceProvider == indexer, - SubgraphServiceIndexerMismatch(signedRav.rav.serviceProvider, indexer) + signedRav.rav.serviceProvider == _indexer, + SubgraphServiceIndexerMismatch(signedRav.rav.serviceProvider, _indexer) ); // Check that collectionId (256 bits) is a valid address (160 bits) @@ -497,11 +508,11 @@ contract SubgraphService is Allocation.State memory allocation = _allocations.get(allocationId); // Check RAV is consistent - RAV indexer must match the allocation's indexer - require(allocation.indexer == indexer, SubgraphServiceInvalidRAV(indexer, allocation.indexer)); + require(allocation.indexer == _indexer, SubgraphServiceInvalidRAV(_indexer, allocation.indexer)); bytes32 subgraphDeploymentId = allocation.subgraphDeploymentId; // release expired stake claims - _releaseStake(indexer, 0); + _releaseStake(_indexer, 0); // Collect from GraphPayments - only curators cut is sent back to the subgraph service uint256 tokensCollected; @@ -523,7 +534,7 @@ contract SubgraphService is if (tokensCollected > 0) { // lock stake as economic security for fees _lockStake( - indexer, + _indexer, tokensCollected * stakeToFeesRatio, block.timestamp + _disputeManager().getDisputePeriod() ); @@ -539,7 +550,7 @@ contract SubgraphService is } emit QueryFeesCollected( - indexer, + _indexer, signedRav.rav.payer, allocationId, subgraphDeploymentId, @@ -551,31 +562,20 @@ contract SubgraphService is /** * @notice Collect indexing rewards - * @param indexer The address of the indexer - * @param data Encoded data: + * @param _indexer The address of the indexer + * @param _data Encoded data: * - address `allocationId`: The id of the allocation * - bytes32 `poi`: The POI being presented * - bytes `poiMetadata`: The metadata associated with the POI. See {AllocationManager-_presentPOI} for more details. * @return The amount of indexing rewards collected */ - function _collectIndexingRewards(address indexer, bytes calldata data) private returns (uint256) { - (address allocationId, bytes32 poi_, bytes memory poiMetadata_) = abi.decode(data, (address, bytes32, bytes)); + function _collectIndexingRewards(address _indexer, bytes calldata _data) private returns (uint256) { + (address allocationId, bytes32 poi_, bytes memory poiMetadata_) = abi.decode(_data, (address, bytes32, bytes)); require( - _allocations.get(allocationId).indexer == indexer, - SubgraphServiceAllocationNotAuthorized(indexer, allocationId) + _allocations.get(allocationId).indexer == _indexer, + SubgraphServiceAllocationNotAuthorized(_indexer, allocationId) ); - return _presentPOI(allocationId, poi_, poiMetadata_, _delegationRatio, paymentsDestination[indexer]); - } - - /** - * @notice Sets the payments destination for an indexer to receive payments - * @dev Emits a {PaymentsDestinationSet} event - * @param _indexer The address of the indexer - * @param _paymentsDestination The address where payments should be sent - */ - function _setPaymentsDestination(address _indexer, address _paymentsDestination) internal { - paymentsDestination[_indexer] = _paymentsDestination; - emit PaymentsDestinationSet(_indexer, _paymentsDestination); + return _presentPOI(allocationId, poi_, poiMetadata_, _delegationRatio, paymentsDestination[_indexer]); } /** @@ -591,14 +591,14 @@ contract SubgraphService is /** * @notice Encodes the data for the GraphTallyCollector * @dev The purpose of this function is just to avoid stack too deep errors - * @param signedRav The signed RAV - * @param curationCut The curation cut + * @param _signedRav The signed RAV + * @param _curationCut The curation cut * @return The encoded data */ function _encodeGraphTallyData( - IGraphTallyCollector.SignedRAV memory signedRav, - uint256 curationCut + IGraphTallyCollector.SignedRAV memory _signedRav, + uint256 _curationCut ) private view returns (bytes memory) { - return abi.encode(signedRav, curationCut, paymentsDestination[signedRav.rav.serviceProvider]); + return abi.encode(_signedRav, _curationCut, paymentsDestination[_signedRav.rav.serviceProvider]); } } diff --git a/packages/subgraph-service/contracts/mocks/imports.sol b/packages/subgraph-service/contracts/mocks/imports.sol index 56c34ad34..0ea38705e 100644 --- a/packages/subgraph-service/contracts/mocks/imports.sol +++ b/packages/subgraph-service/contracts/mocks/imports.sol @@ -21,4 +21,4 @@ interface IServiceRegistryToolshed is IServiceRegistry { interface IGNSToolshed is IGNS { function subgraphNFT() external view returns (address); -} \ No newline at end of file +} diff --git a/packages/subgraph-service/package.json b/packages/subgraph-service/package.json index 35a502176..c9b23e0f5 100644 --- a/packages/subgraph-service/package.json +++ b/packages/subgraph-service/package.json @@ -18,8 +18,8 @@ "lint": "pnpm lint:ts && pnpm lint:sol", "lint:ts": "eslint '**/*.{js,ts}' --fix --no-warn-ignored", "lint:sol": "pnpm lint:sol:prettier && pnpm lint:sol:solhint", - "lint:sol:prettier": "prettier --write contracts/**/*.sol test/**/*.sol", - "lint:sol:solhint": "solhint --noPrompt --fix contracts/**/*.sol --config node_modules/solhint-graph-config/index.js", + "lint:sol:prettier": "prettier --write \"contracts/**/*.sol\" \"test/**/*.sol\"", + "lint:sol:solhint": "solhint --noPrompt --fix \"contracts/**/*.sol\" --config node_modules/solhint-graph-config/index.js", "lint:sol:natspec": "natspec-smells --config natspec-smells.config.js", "clean": "rm -rf build dist cache cache_forge typechain-types", "build": "hardhat compile",