From dd2e735db0925e1357bb72ddb6b07cba87277de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Tue, 11 Feb 2025 12:12:07 -0300 Subject: [PATCH 1/2] chore: rename TAPCollector to GraphTallyCollector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- ...Collector.sol => IGraphTallyCollector.sol} | 36 +++--- ...PCollector.sol => GraphTallyCollector.sol} | 67 +++++----- .../configs/horizon-migrate.default.json5 | 4 +- ...n-migrate.horizon-virtualArbitrumOne.json5 | 4 +- .../ignition/configs/horizon.default.json5 | 4 +- ...TAPCollector.ts => GraphTallyCollector.ts} | 22 ++-- .../horizon/ignition/modules/core/core.ts | 10 +- packages/horizon/ignition/modules/deploy.ts | 4 +- .../ignition/modules/migrate/migrate-3.ts | 4 +- packages/horizon/test/GraphBase.t.sol | 8 +- .../GraphTallyCollector.t.sol} | 64 ++++----- .../collect/collect.t.sol | 122 +++++++++--------- .../signer/authorizeSigner.t.sol | 32 ++--- .../signer/cancelThawSigner.t.sol | 39 ++++++ .../signer/revokeSigner.t.sol | 54 ++++++++ .../signer/thawSigner.t.sol | 56 ++++++++ .../signer/cancelThawSigner.t.sol | 39 ------ .../tap-collector/signer/revokeSigner.t.sol | 54 -------- .../tap-collector/signer/thawSigner.t.sol | 56 -------- packages/horizon/test/utils/Constants.sol | 2 +- .../contracts/SubgraphService.sol | 18 +-- .../contracts/utilities/Directory.sol | 24 ++-- .../subgraph-service-migrate.default.json5 | 2 +- .../ignition/modules/SubgraphService.ts | 4 +- packages/subgraph-service/scripts/deploy.ts | 4 +- .../test/SubgraphBaseTest.t.sol | 10 +- .../subgraphService/SubgraphService.t.sol | 14 +- .../subgraphService/collect/query/query.t.sol | 24 ++-- .../subgraph-service/test/utils/Constants.sol | 2 +- 29 files changed, 394 insertions(+), 389 deletions(-) rename packages/horizon/contracts/interfaces/{ITAPCollector.sol => IGraphTallyCollector.sol} (87%) rename packages/horizon/contracts/payments/collectors/{TAPCollector.sol => GraphTallyCollector.sol} (79%) rename packages/horizon/ignition/modules/core/{TAPCollector.ts => GraphTallyCollector.ts} (67%) rename packages/horizon/test/payments/{tap-collector/TAPCollector.t.sol => graph-tally-collector/GraphTallyCollector.t.sol} (71%) rename packages/horizon/test/payments/{tap-collector => graph-tally-collector}/collect/collect.t.sol (74%) rename packages/horizon/test/payments/{tap-collector => graph-tally-collector}/signer/authorizeSigner.t.sol (61%) create mode 100644 packages/horizon/test/payments/graph-tally-collector/signer/cancelThawSigner.t.sol create mode 100644 packages/horizon/test/payments/graph-tally-collector/signer/revokeSigner.t.sol create mode 100644 packages/horizon/test/payments/graph-tally-collector/signer/thawSigner.t.sol delete mode 100644 packages/horizon/test/payments/tap-collector/signer/cancelThawSigner.t.sol delete mode 100644 packages/horizon/test/payments/tap-collector/signer/revokeSigner.t.sol delete mode 100644 packages/horizon/test/payments/tap-collector/signer/thawSigner.t.sol diff --git a/packages/horizon/contracts/interfaces/ITAPCollector.sol b/packages/horizon/contracts/interfaces/IGraphTallyCollector.sol similarity index 87% rename from packages/horizon/contracts/interfaces/ITAPCollector.sol rename to packages/horizon/contracts/interfaces/IGraphTallyCollector.sol index fd17d15c7..52cdb8647 100644 --- a/packages/horizon/contracts/interfaces/ITAPCollector.sol +++ b/packages/horizon/contracts/interfaces/IGraphTallyCollector.sol @@ -5,13 +5,13 @@ import { IPaymentsCollector } from "./IPaymentsCollector.sol"; import { IGraphPayments } from "./IGraphPayments.sol"; /** - * @title Interface for the {TAPCollector} contract + * @title Interface for the {GraphTallyCollector} contract * @dev Implements the {IPaymentCollector} interface as defined by the Graph * Horizon payments protocol. * @notice Implements a payments collector contract that can be used to collect - * payments using a TAP RAV (Receipt Aggregate Voucher). + * payments using a GraphTally RAV (Receipt Aggregate Voucher). */ -interface ITAPCollector is IPaymentsCollector { +interface IGraphTallyCollector is IPaymentsCollector { /// @notice Details for a payer-signer pair /// @dev Signers can be removed only after a thawing period struct PayerAuthorization { @@ -33,7 +33,7 @@ interface ITAPCollector is IPaymentsCollector { address serviceProvider; // The address of the data service the RAV was issued to address dataService; - // The RAV timestamp, indicating the latest TAP Receipt in the RAV + // The RAV timestamp, indicating the latest GraphTally Receipt in the RAV uint64 timestampNs; // Total amount owed to the service provider since the beginning of the // payer-service provider relationship, including all debt that is already paid for. @@ -107,77 +107,77 @@ interface ITAPCollector is IPaymentsCollector { * @param authorizingPayer The address of the payer authorizing the signer * @param signer The address of the signer */ - error TAPCollectorSignerAlreadyAuthorized(address authorizingPayer, address signer); + error GraphTallyCollectorSignerAlreadyAuthorized(address authorizingPayer, address signer); /** * Thrown when the signer proof deadline is invalid * @param proofDeadline The deadline for the proof provided by the signer * @param currentTimestamp The current timestamp */ - error TAPCollectorInvalidSignerProofDeadline(uint256 proofDeadline, uint256 currentTimestamp); + error GraphTallyCollectorInvalidSignerProofDeadline(uint256 proofDeadline, uint256 currentTimestamp); /** * Thrown when the signer proof is invalid */ - error TAPCollectorInvalidSignerProof(); + error GraphTallyCollectorInvalidSignerProof(); /** * Thrown when the signer is not authorized by the payer * @param payer The address of the payer * @param signer The address of the signer */ - error TAPCollectorSignerNotAuthorizedByPayer(address payer, address signer); + error GraphTallyCollectorSignerNotAuthorizedByPayer(address payer, address signer); /** * Thrown when the attempting to revoke a signer that was already revoked * @param signer The address of the signer */ - error TAPCollectorAuthorizationAlreadyRevoked(address payer, address signer); + error GraphTallyCollectorAuthorizationAlreadyRevoked(address payer, address signer); /** * Thrown when attempting to thaw a signer that is already thawing * @param signer The address of the signer * @param thawEndTimestamp The timestamp at which the thawing period ends */ - error TAPCollectorSignerAlreadyThawing(address signer, uint256 thawEndTimestamp); + error GraphTallyCollectorSignerAlreadyThawing(address signer, uint256 thawEndTimestamp); /** * Thrown when the signer is not thawing * @param signer The address of the signer */ - error TAPCollectorSignerNotThawing(address signer); + error GraphTallyCollectorSignerNotThawing(address signer); /** * Thrown when the signer is still thawing * @param currentTimestamp The current timestamp * @param thawEndTimestamp The timestamp at which the thawing period ends */ - error TAPCollectorSignerStillThawing(uint256 currentTimestamp, uint256 thawEndTimestamp); + error GraphTallyCollectorSignerStillThawing(uint256 currentTimestamp, uint256 thawEndTimestamp); /** * Thrown when the RAV signer is invalid */ - error TAPCollectorInvalidRAVSigner(); + error GraphTallyCollectorInvalidRAVSigner(); /** * Thrown when the RAV payer does not match the signers authorized payer * @param authorizedPayer The address of the authorized payer * @param ravPayer The address of the RAV payer */ - error TAPCollectorInvalidRAVPayer(address authorizedPayer, address ravPayer); + error GraphTallyCollectorInvalidRAVPayer(address authorizedPayer, address ravPayer); /** * Thrown when the RAV is for a data service the service provider has no provision for * @param dataService The address of the data service */ - error TAPCollectorUnauthorizedDataService(address dataService); + error GraphTallyCollectorUnauthorizedDataService(address dataService); /** * Thrown when the caller is not the data service the RAV was issued to * @param caller The address of the caller * @param dataService The address of the data service */ - error TAPCollectorCallerNotDataService(address caller, address dataService); + error GraphTallyCollectorCallerNotDataService(address caller, address dataService); /** * @notice Thrown when the tokens collected are inconsistent with the collection history @@ -185,14 +185,14 @@ interface ITAPCollector is IPaymentsCollector { * @param tokens The amount of tokens in the RAV * @param tokensCollected The amount of tokens already collected */ - error TAPCollectorInconsistentRAVTokens(uint256 tokens, uint256 tokensCollected); + error GraphTallyCollectorInconsistentRAVTokens(uint256 tokens, uint256 tokensCollected); /** * Thrown when the attempting to collect more tokens than what it's owed * @param tokensToCollect The amount of tokens to collect * @param maxTokensToCollect The maximum amount of tokens to collect */ - error TAPCollectorInvalidTokensToCollectAmount(uint256 tokensToCollect, uint256 maxTokensToCollect); + error GraphTallyCollectorInvalidTokensToCollectAmount(uint256 tokensToCollect, uint256 maxTokensToCollect); /** * @notice Authorize a signer to sign on behalf of the payer. diff --git a/packages/horizon/contracts/payments/collectors/TAPCollector.sol b/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol similarity index 79% rename from packages/horizon/contracts/payments/collectors/TAPCollector.sol rename to packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol index 6a19dbe54..b9c3c9df9 100644 --- a/packages/horizon/contracts/payments/collectors/TAPCollector.sol +++ b/packages/horizon/contracts/payments/collectors/GraphTallyCollector.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.27; import { IGraphPayments } from "../../interfaces/IGraphPayments.sol"; -import { ITAPCollector } from "../../interfaces/ITAPCollector.sol"; +import { IGraphTallyCollector } from "../../interfaces/IGraphTallyCollector.sol"; import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol"; import { PPMMath } from "../../libraries/PPMMath.sol"; @@ -12,9 +12,9 @@ import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; /** - * @title TAPCollector contract - * @dev Implements the {ITAPCollector} and {IPaymentCollector} interfaces. - * @notice A payments collector contract that can be used to collect payments using a TAP RAV (Receipt Aggregate Voucher). + * @title GraphTallyCollector contract + * @dev Implements the {IGraphTallyCollector} and {IPaymentCollector} interfaces. + * @notice A payments collector contract that can be used to collect payments using a GraphTally RAV (Receipt Aggregate Voucher). * @dev Note that the contract expects the RAV aggregate value to be monotonically increasing, each successive RAV for the same * (data service-payer-receiver) tuple should have a value greater than the previous one. The contract will keep track of the tokens * already collected and calculate the difference to collect. @@ -23,7 +23,7 @@ import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/Mes * @custom:security-contact Please email security+contracts@thegraph.com if you find any * bugs. We may have an active bug bounty program. */ -contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { +contract GraphTallyCollector is EIP712, GraphDirectory, IGraphTallyCollector { using PPMMath for uint256; /// @notice The EIP712 typehash for the ReceiptAggregateVoucher struct @@ -45,7 +45,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { uint256 public immutable REVOKE_SIGNER_THAWING_PERIOD; /** - * @notice Constructs a new instance of the TAPVerifier contract. + * @notice Constructs a new instance of the GraphTallyCollector contract. * @param eip712Name The name of the EIP712 domain. * @param eip712Version The version of the EIP712 domain. * @param controller The address of the Graph controller. @@ -61,12 +61,12 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { } /** - * See {ITAPCollector.authorizeSigner}. + * See {IGraphTallyCollector.authorizeSigner}. */ function authorizeSigner(address signer, uint256 proofDeadline, bytes calldata proof) external override { require( authorizedSigners[signer].payer == address(0), - TAPCollectorSignerAlreadyAuthorized(authorizedSigners[signer].payer, signer) + GraphTallyCollectorSignerAlreadyAuthorized(authorizedSigners[signer].payer, signer) ); _verifyAuthorizedSignerProof(proof, proofDeadline, signer); @@ -77,16 +77,16 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { } /** - * See {ITAPCollector.thawSigner}. + * See {IGraphTallyCollector.thawSigner}. */ function thawSigner(address signer) external override { PayerAuthorization storage authorization = authorizedSigners[signer]; - require(authorization.payer == msg.sender, TAPCollectorSignerNotAuthorizedByPayer(msg.sender, signer)); - require(!authorization.revoked, TAPCollectorAuthorizationAlreadyRevoked(msg.sender, signer)); + require(authorization.payer == msg.sender, GraphTallyCollectorSignerNotAuthorizedByPayer(msg.sender, signer)); + require(!authorization.revoked, GraphTallyCollectorAuthorizationAlreadyRevoked(msg.sender, signer)); require( authorization.thawEndTimestamp == 0, - TAPCollectorSignerAlreadyThawing(signer, authorization.thawEndTimestamp) + GraphTallyCollectorSignerAlreadyThawing(signer, authorization.thawEndTimestamp) ); authorization.thawEndTimestamp = block.timestamp + REVOKE_SIGNER_THAWING_PERIOD; @@ -94,29 +94,29 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { } /** - * See {ITAPCollector.cancelThawSigner}. + * See {IGraphTallyCollector.cancelThawSigner}. */ function cancelThawSigner(address signer) external override { PayerAuthorization storage authorization = authorizedSigners[signer]; - require(authorization.payer == msg.sender, TAPCollectorSignerNotAuthorizedByPayer(msg.sender, signer)); - require(authorization.thawEndTimestamp > 0, TAPCollectorSignerNotThawing(signer)); + require(authorization.payer == msg.sender, GraphTallyCollectorSignerNotAuthorizedByPayer(msg.sender, signer)); + require(authorization.thawEndTimestamp > 0, GraphTallyCollectorSignerNotThawing(signer)); authorization.thawEndTimestamp = 0; emit SignerThawCanceled(msg.sender, signer, 0); } /** - * See {ITAPCollector.revokeAuthorizedSigner}. + * See {IGraphTallyCollector.revokeAuthorizedSigner}. */ function revokeAuthorizedSigner(address signer) external override { PayerAuthorization storage authorization = authorizedSigners[signer]; - require(authorization.payer == msg.sender, TAPCollectorSignerNotAuthorizedByPayer(msg.sender, signer)); - require(authorization.thawEndTimestamp > 0, TAPCollectorSignerNotThawing(signer)); + require(authorization.payer == msg.sender, GraphTallyCollectorSignerNotAuthorizedByPayer(msg.sender, signer)); + require(authorization.thawEndTimestamp > 0, GraphTallyCollectorSignerNotThawing(signer)); require( authorization.thawEndTimestamp <= block.timestamp, - TAPCollectorSignerStillThawing(block.timestamp, authorization.thawEndTimestamp) + GraphTallyCollectorSignerStillThawing(block.timestamp, authorization.thawEndTimestamp) ); authorization.revoked = true; @@ -145,21 +145,21 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { } /** - * @notice See {ITAPCollector.recoverRAVSigner} + * @notice See {IGraphTallyCollector.recoverRAVSigner} */ function recoverRAVSigner(SignedRAV calldata signedRAV) external view override returns (address) { return _recoverRAVSigner(signedRAV); } /** - * @notice See {ITAPCollector.encodeRAV} + * @notice See {IGraphTallyCollector.encodeRAV} */ function encodeRAV(ReceiptAggregateVoucher calldata rav) external view returns (bytes32) { return _encodeRAV(rav); } /** - * @notice See {ITAPCollector.collect} + * @notice See {IGraphTallyCollector.collect} */ function _collect( IGraphPayments.PaymentTypes _paymentType, @@ -171,19 +171,19 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { // Ensure caller is the RAV data service require( signedRAV.rav.dataService == msg.sender, - TAPCollectorCallerNotDataService(msg.sender, signedRAV.rav.dataService) + GraphTallyCollectorCallerNotDataService(msg.sender, signedRAV.rav.dataService) ); // Ensure RAV signer is authorized for a payer address signer = _recoverRAVSigner(signedRAV); require( authorizedSigners[signer].payer != address(0) && !authorizedSigners[signer].revoked, - TAPCollectorInvalidRAVSigner() + GraphTallyCollectorInvalidRAVSigner() ); // Ensure RAV payer matches the authorized payer address payer = authorizedSigners[signer].payer; - require(signedRAV.rav.payer == payer, TAPCollectorInvalidRAVPayer(payer, signedRAV.rav.payer)); + require(signedRAV.rav.payer == payer, GraphTallyCollectorInvalidRAVPayer(payer, signedRAV.rav.payer)); bytes32 collectionId = signedRAV.rav.collectionId; address dataService = signedRAV.rav.dataService; @@ -197,7 +197,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { signedRAV.rav.serviceProvider, signedRAV.rav.dataService ); - require(tokensAvailable > 0, TAPCollectorUnauthorizedDataService(signedRAV.rav.dataService)); + require(tokensAvailable > 0, GraphTallyCollectorUnauthorizedDataService(signedRAV.rav.dataService)); } uint256 tokensToCollect = 0; @@ -206,7 +206,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { uint256 tokensAlreadyCollected = tokensCollected[dataService][collectionId][receiver][payer]; require( tokensRAV > tokensAlreadyCollected, - TAPCollectorInconsistentRAVTokens(tokensRAV, tokensAlreadyCollected) + GraphTallyCollectorInconsistentRAVTokens(tokensRAV, tokensAlreadyCollected) ); if (_tokensToCollect == 0) { @@ -214,7 +214,10 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { } else { require( _tokensToCollect <= tokensRAV - tokensAlreadyCollected, - TAPCollectorInvalidTokensToCollectAmount(_tokensToCollect, tokensRAV - tokensAlreadyCollected) + GraphTallyCollectorInvalidTokensToCollectAmount( + _tokensToCollect, + tokensRAV - tokensAlreadyCollected + ) ); tokensToCollect = _tokensToCollect; } @@ -243,7 +246,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { } /** - * @notice See {ITAPCollector.recoverRAVSigner} + * @notice See {IGraphTallyCollector.recoverRAVSigner} */ function _recoverRAVSigner(SignedRAV memory _signedRAV) private view returns (address) { bytes32 messageHash = _encodeRAV(_signedRAV.rav); @@ -251,7 +254,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { } /** - * @notice See {ITAPCollector.encodeRAV} + * @notice See {IGraphTallyCollector.encodeRAV} */ function _encodeRAV(ReceiptAggregateVoucher memory _rav) private view returns (bytes32) { return @@ -280,7 +283,7 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { // Verify that the proofDeadline has not passed require( _proofDeadline > block.timestamp, - TAPCollectorInvalidSignerProofDeadline(_proofDeadline, block.timestamp) + GraphTallyCollectorInvalidSignerProofDeadline(_proofDeadline, block.timestamp) ); // Generate the hash of the payer's address @@ -290,6 +293,6 @@ contract TAPCollector is EIP712, GraphDirectory, ITAPCollector { bytes32 digest = MessageHashUtils.toEthSignedMessageHash(messageHash); // Verify that the recovered signer matches the expected signer - require(ECDSA.recover(digest, _proof) == _signer, TAPCollectorInvalidSignerProof()); + require(ECDSA.recover(digest, _proof) == _signer, GraphTallyCollectorInvalidSignerProof()); } } diff --git a/packages/horizon/ignition/configs/horizon-migrate.default.json5 b/packages/horizon/ignition/configs/horizon-migrate.default.json5 index eb07fd743..e968be8f2 100644 --- a/packages/horizon/ignition/configs/horizon-migrate.default.json5 +++ b/packages/horizon/ignition/configs/horizon-migrate.default.json5 @@ -25,8 +25,8 @@ "PaymentsEscrow": { "withdrawEscrowThawingPeriod": 10000 }, - "TAPCollector": { - "eip712Name": "TAPCollector", + "GraphTallyCollector": { + "eip712Name": "GraphTallyCollector", "eip712Version": "1", "revokeSignerThawingPeriod": 10000 }, diff --git a/packages/horizon/ignition/configs/horizon-migrate.horizon-virtualArbitrumOne.json5 b/packages/horizon/ignition/configs/horizon-migrate.horizon-virtualArbitrumOne.json5 index 6411d955e..1633153d9 100644 --- a/packages/horizon/ignition/configs/horizon-migrate.horizon-virtualArbitrumOne.json5 +++ b/packages/horizon/ignition/configs/horizon-migrate.horizon-virtualArbitrumOne.json5 @@ -25,8 +25,8 @@ "PaymentsEscrow": { "withdrawEscrowThawingPeriod": 10000 }, - "TAPCollector": { - "eip712Name": "TAPCollector", + "GraphTallyCollector": { + "eip712Name": "GraphTallyCollector", "eip712Version": "1", "revokeSignerThawingPeriod": 10000 }, diff --git a/packages/horizon/ignition/configs/horizon.default.json5 b/packages/horizon/ignition/configs/horizon.default.json5 index 1151602c9..3849fb93a 100644 --- a/packages/horizon/ignition/configs/horizon.default.json5 +++ b/packages/horizon/ignition/configs/horizon.default.json5 @@ -28,8 +28,8 @@ "PaymentsEscrow": { "withdrawEscrowThawingPeriod": 10000 }, - "TAPCollector": { - "eip712Name": "TAPCollector", + "GraphTallyCollector": { + "eip712Name": "GraphTallyCollector", "eip712Version": "1", "revokeSignerThawingPeriod": 10000 } diff --git a/packages/horizon/ignition/modules/core/TAPCollector.ts b/packages/horizon/ignition/modules/core/GraphTallyCollector.ts similarity index 67% rename from packages/horizon/ignition/modules/core/TAPCollector.ts rename to packages/horizon/ignition/modules/core/GraphTallyCollector.ts index 343470e7e..1f1a7f767 100644 --- a/packages/horizon/ignition/modules/core/TAPCollector.ts +++ b/packages/horizon/ignition/modules/core/GraphTallyCollector.ts @@ -3,41 +3,41 @@ import { buildModule } from '@nomicfoundation/hardhat-ignition/modules' import GraphPeripheryModule, { MigratePeripheryModule } from '../periphery/periphery' import HorizonProxiesModule from './HorizonProxies' -import TAPCollectorArtifact from '../../../build/contracts/contracts/payments/collectors/TAPCollector.sol/TAPCollector.json' +import GraphTallyCollectorArtifact from '../../../build/contracts/contracts/payments/collectors/GraphTallyCollector.sol/GraphTallyCollector.json' -export default buildModule('TAPCollector', (m) => { +export default buildModule('GraphTallyCollector', (m) => { const { Controller } = m.useModule(GraphPeripheryModule) const name = m.getParameter('eip712Name') const version = m.getParameter('eip712Version') const revokeSignerThawingPeriod = m.getParameter('revokeSignerThawingPeriod') - const TAPCollector = m.contract( - 'TAPCollector', - TAPCollectorArtifact, + const GraphTallyCollector = m.contract( + 'GraphTallyCollector', + GraphTallyCollectorArtifact, [name, version, Controller, revokeSignerThawingPeriod], { after: [GraphPeripheryModule, HorizonProxiesModule] }, ) - return { TAPCollector } + return { GraphTallyCollector } }) // Note that this module requires MigrateHorizonProxiesGovernorModule to be executed first // The dependency is not made explicit to support the production workflow where the governor is a // multisig owned by the Graph Council. // For testnet, the dependency can be made explicit by having a parent module establish it. -export const MigrateTAPCollectorModule = buildModule('TAPCollector', (m) => { +export const MigrateGraphTallyCollectorModule = buildModule('GraphTallyCollector', (m) => { const { Controller } = m.useModule(MigratePeripheryModule) const name = m.getParameter('eip712Name') const version = m.getParameter('eip712Version') const revokeSignerThawingPeriod = m.getParameter('revokeSignerThawingPeriod') - const TAPCollector = m.contract( - 'TAPCollector', - TAPCollectorArtifact, + const GraphTallyCollector = m.contract( + 'GraphTallyCollector', + GraphTallyCollectorArtifact, [name, version, Controller, revokeSignerThawingPeriod], ) - return { TAPCollector } + return { GraphTallyCollector } }) diff --git a/packages/horizon/ignition/modules/core/core.ts b/packages/horizon/ignition/modules/core/core.ts index ef8561a8e..e634e5e65 100644 --- a/packages/horizon/ignition/modules/core/core.ts +++ b/packages/horizon/ignition/modules/core/core.ts @@ -3,22 +3,22 @@ import { buildModule } from '@nomicfoundation/hardhat-ignition/modules' import GraphPaymentsModule, { MigrateGraphPaymentsModule } from './GraphPayments' import HorizonStakingModule, { MigrateHorizonStakingDeployerModule } from './HorizonStaking' import PaymentsEscrowModule, { MigratePaymentsEscrowModule } from './PaymentsEscrow' -import TAPCollectorModule, { MigrateTAPCollectorModule } from './TAPCollector' +import GraphTallyCollectorModule, { MigrateGraphTallyCollectorModule } from './GraphTallyCollector' export default buildModule('GraphHorizon_Core', (m) => { const { HorizonStaking } = m.useModule(HorizonStakingModule) const { GraphPayments } = m.useModule(GraphPaymentsModule) const { PaymentsEscrow } = m.useModule(PaymentsEscrowModule) - const { TAPCollector } = m.useModule(TAPCollectorModule) + const { GraphTallyCollector } = m.useModule(GraphTallyCollectorModule) - return { HorizonStaking, GraphPayments, PaymentsEscrow, TAPCollector } + return { HorizonStaking, GraphPayments, PaymentsEscrow, GraphTallyCollector } }) export const MigrateHorizonCoreModule = buildModule('GraphHorizon_Core', (m) => { const { HorizonStakingProxy: HorizonStaking, HorizonStakingImplementation } = m.useModule(MigrateHorizonStakingDeployerModule) const { GraphPayments } = m.useModule(MigrateGraphPaymentsModule) const { PaymentsEscrow } = m.useModule(MigratePaymentsEscrowModule) - const { TAPCollector } = m.useModule(MigrateTAPCollectorModule) + const { GraphTallyCollector } = m.useModule(MigrateGraphTallyCollectorModule) - return { HorizonStaking, HorizonStakingImplementation, GraphPayments, PaymentsEscrow, TAPCollector } + return { HorizonStaking, HorizonStakingImplementation, GraphPayments, PaymentsEscrow, GraphTallyCollector } }) diff --git a/packages/horizon/ignition/modules/deploy.ts b/packages/horizon/ignition/modules/deploy.ts index f540d13c7..bd54ab6cb 100644 --- a/packages/horizon/ignition/modules/deploy.ts +++ b/packages/horizon/ignition/modules/deploy.ts @@ -17,7 +17,7 @@ export default buildModule('GraphHorizon_Deploy', (m) => { HorizonStaking, GraphPayments, PaymentsEscrow, - TAPCollector, + GraphTallyCollector, } = m.useModule(GraphHorizonCoreModule) const governor = m.getAccount(1) @@ -41,6 +41,6 @@ export default buildModule('GraphHorizon_Deploy', (m) => { HorizonStaking, GraphPayments, PaymentsEscrow, - TAPCollector, + GraphTallyCollector, } }) diff --git a/packages/horizon/ignition/modules/migrate/migrate-3.ts b/packages/horizon/ignition/modules/migrate/migrate-3.ts index 700253834..9c7727bbe 100644 --- a/packages/horizon/ignition/modules/migrate/migrate-3.ts +++ b/packages/horizon/ignition/modules/migrate/migrate-3.ts @@ -21,7 +21,7 @@ export default buildModule('GraphHorizon_Migrate_3', (m) => { HorizonStakingImplementation, GraphPayments, PaymentsEscrow, - TAPCollector, + GraphTallyCollector, } = m.useModule(MigrateHorizonCoreModule) return { @@ -33,7 +33,7 @@ export default buildModule('GraphHorizon_Migrate_3', (m) => { HorizonStakingImplementation, GraphPayments, PaymentsEscrow, - TAPCollector, + GraphTallyCollector, Controller, GraphProxyAdmin, EpochManager, diff --git a/packages/horizon/test/GraphBase.t.sol b/packages/horizon/test/GraphBase.t.sol index a01fb2958..afa914341 100644 --- a/packages/horizon/test/GraphBase.t.sol +++ b/packages/horizon/test/GraphBase.t.sol @@ -11,7 +11,7 @@ import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/trans import { PaymentsEscrow } from "contracts/payments/PaymentsEscrow.sol"; import { GraphPayments } from "contracts/payments/GraphPayments.sol"; -import { TAPCollector } from "contracts/payments/collectors/TAPCollector.sol"; +import { GraphTallyCollector } from "contracts/payments/collectors/GraphTallyCollector.sol"; import { IHorizonStaking } from "contracts/interfaces/IHorizonStaking.sol"; import { HorizonStaking } from "contracts/staking/HorizonStaking.sol"; import { HorizonStakingExtension } from "contracts/staking/HorizonStakingExtension.sol"; @@ -40,7 +40,7 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants { EpochManagerMock public epochManager; RewardsManagerMock public rewardsManager; CurationMock public curation; - TAPCollector tapCollector; + GraphTallyCollector graphTallyCollector; HorizonStaking private stakingBase; HorizonStakingExtension private stakingExtension; @@ -87,7 +87,7 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants { vm.label({ account: address(escrow), newLabel: "PaymentsEscrow" }); vm.label({ account: address(staking), newLabel: "HorizonStaking" }); vm.label({ account: address(stakingExtension), newLabel: "HorizonStakingExtension" }); - vm.label({ account: address(tapCollector), newLabel: "TAPCollector" }); + vm.label({ account: address(graphTallyCollector), newLabel: "GraphTallyCollector" }); // Ensure caller is back to the original msg.sender vm.stopPrank(); @@ -201,7 +201,7 @@ abstract contract GraphBaseTest is IHorizonStakingTypes, Utils, Constants { subgraphDataServiceLegacyAddress ); - tapCollector = new TAPCollector("TAPCollector", "1", address(controller), revokeSignerThawingPeriod); + graphTallyCollector = new GraphTallyCollector("GraphTallyCollector", "1", address(controller), revokeSignerThawingPeriod); resetPrank(users.governor); proxyAdmin.upgrade(stakingProxy, address(stakingBase)); diff --git a/packages/horizon/test/payments/tap-collector/TAPCollector.t.sol b/packages/horizon/test/payments/graph-tally-collector/GraphTallyCollector.t.sol similarity index 71% rename from packages/horizon/test/payments/tap-collector/TAPCollector.t.sol rename to packages/horizon/test/payments/graph-tally-collector/GraphTallyCollector.t.sol index 04d319589..b824d59ef 100644 --- a/packages/horizon/test/payments/tap-collector/TAPCollector.t.sol +++ b/packages/horizon/test/payments/graph-tally-collector/GraphTallyCollector.t.sol @@ -6,16 +6,16 @@ import "forge-std/Test.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; import { IHorizonStakingMain } from "../../../contracts/interfaces/internal/IHorizonStakingMain.sol"; -import { ITAPCollector } from "../../../contracts/interfaces/ITAPCollector.sol"; +import { IGraphTallyCollector } from "../../../contracts/interfaces/IGraphTallyCollector.sol"; import { IPaymentsCollector } from "../../../contracts/interfaces/IPaymentsCollector.sol"; import { IGraphPayments } from "../../../contracts/interfaces/IGraphPayments.sol"; -import { TAPCollector } from "../../../contracts/payments/collectors/TAPCollector.sol"; +import { GraphTallyCollector } from "../../../contracts/payments/collectors/GraphTallyCollector.sol"; import { PPMMath } from "../../../contracts/libraries/PPMMath.sol"; import { HorizonStakingSharedTest } from "../../shared/horizon-staking/HorizonStakingShared.t.sol"; import { PaymentsEscrowSharedTest } from "../../shared/payments-escrow/PaymentsEscrowShared.t.sol"; -contract TAPCollectorTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest { +contract GraphTallyTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest { using PPMMath for uint256; address signer; @@ -48,7 +48,7 @@ contract TAPCollectorTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest function _getSignerProof(uint256 _proofDeadline, uint256 _signer) internal returns (bytes memory) { (, address msgSender, ) = vm.readCallers(); - bytes32 messageHash = keccak256(abi.encodePacked(block.chainid, address(tapCollector), _proofDeadline, msgSender)); + bytes32 messageHash = keccak256(abi.encodePacked(block.chainid, address(graphTallyCollector), _proofDeadline, msgSender)); bytes32 proofToDigest = MessageHashUtils.toEthSignedMessageHash(messageHash); (uint8 v, bytes32 r, bytes32 s) = vm.sign(_signer, proofToDigest); return abi.encodePacked(r, s, v); @@ -61,12 +61,12 @@ contract TAPCollectorTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest function _authorizeSigner(address _signer, uint256 _proofDeadline, bytes memory _proof) internal { (, address msgSender, ) = vm.readCallers(); - vm.expectEmit(address(tapCollector)); - emit ITAPCollector.SignerAuthorized(msgSender, _signer); + vm.expectEmit(address(graphTallyCollector)); + emit IGraphTallyCollector.SignerAuthorized(msgSender, _signer); - tapCollector.authorizeSigner(_signer, _proofDeadline, _proof); + graphTallyCollector.authorizeSigner(_signer, _proofDeadline, _proof); - (address _payer, uint256 thawEndTimestamp, bool revoked) = tapCollector.authorizedSigners(_signer); + (address _payer, uint256 thawEndTimestamp, bool revoked) = graphTallyCollector.authorizedSigners(_signer); assertEq(_payer, msgSender); assertEq(thawEndTimestamp, 0); assertEq(revoked, false); @@ -76,12 +76,12 @@ contract TAPCollectorTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest (, address msgSender, ) = vm.readCallers(); uint256 expectedThawEndTimestamp = block.timestamp + revokeSignerThawingPeriod; - vm.expectEmit(address(tapCollector)); - emit ITAPCollector.SignerThawing(msgSender, _signer, expectedThawEndTimestamp); + vm.expectEmit(address(graphTallyCollector)); + emit IGraphTallyCollector.SignerThawing(msgSender, _signer, expectedThawEndTimestamp); - tapCollector.thawSigner(_signer); + graphTallyCollector.thawSigner(_signer); - (address _payer, uint256 thawEndTimestamp, bool revoked) = tapCollector.authorizedSigners(_signer); + (address _payer, uint256 thawEndTimestamp, bool revoked) = graphTallyCollector.authorizedSigners(_signer); assertEq(_payer, msgSender); assertEq(thawEndTimestamp, expectedThawEndTimestamp); assertEq(revoked, false); @@ -90,12 +90,12 @@ contract TAPCollectorTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest function _cancelThawSigner(address _signer) internal { (, address msgSender, ) = vm.readCallers(); - vm.expectEmit(address(tapCollector)); - emit ITAPCollector.SignerThawCanceled(msgSender, _signer, 0); + vm.expectEmit(address(graphTallyCollector)); + emit IGraphTallyCollector.SignerThawCanceled(msgSender, _signer, 0); - tapCollector.cancelThawSigner(_signer); + graphTallyCollector.cancelThawSigner(_signer); - (address _payer, uint256 thawEndTimestamp, bool revoked) = tapCollector.authorizedSigners(_signer); + (address _payer, uint256 thawEndTimestamp, bool revoked) = graphTallyCollector.authorizedSigners(_signer); assertEq(_payer, msgSender); assertEq(thawEndTimestamp, 0); assertEq(revoked, false); @@ -104,14 +104,14 @@ contract TAPCollectorTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest function _revokeAuthorizedSigner(address _signer) internal { (, address msgSender, ) = vm.readCallers(); - (address beforePayer, uint256 beforeThawEndTimestamp, ) = tapCollector.authorizedSigners(_signer); + (address beforePayer, uint256 beforeThawEndTimestamp, ) = graphTallyCollector.authorizedSigners(_signer); - vm.expectEmit(address(tapCollector)); - emit ITAPCollector.SignerRevoked(msgSender, _signer); + vm.expectEmit(address(graphTallyCollector)); + emit IGraphTallyCollector.SignerRevoked(msgSender, _signer); - tapCollector.revokeAuthorizedSigner(_signer); + graphTallyCollector.revokeAuthorizedSigner(_signer); - (address afterPayer, uint256 afterThawEndTimestamp, bool afterRevoked) = tapCollector.authorizedSigners( + (address afterPayer, uint256 afterThawEndTimestamp, bool afterRevoked) = graphTallyCollector.authorizedSigners( _signer ); @@ -133,14 +133,14 @@ contract TAPCollectorTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest bytes memory _data, uint256 _tokensToCollect ) internal { - (ITAPCollector.SignedRAV memory signedRAV, ) = abi.decode( + (IGraphTallyCollector.SignedRAV memory signedRAV, ) = abi.decode( _data, - (ITAPCollector.SignedRAV, uint256) + (IGraphTallyCollector.SignedRAV, uint256) ); - bytes32 messageHash = tapCollector.encodeRAV(signedRAV.rav); + bytes32 messageHash = graphTallyCollector.encodeRAV(signedRAV.rav); address _signer = ECDSA.recover(messageHash, signedRAV.signature); - (address _payer, , ) = tapCollector.authorizedSigners(_signer); - uint256 tokensAlreadyCollected = tapCollector.tokensCollected( + (address _payer, , ) = graphTallyCollector.authorizedSigners(_signer); + uint256 tokensAlreadyCollected = graphTallyCollector.tokensCollected( signedRAV.rav.dataService, signedRAV.rav.collectionId, signedRAV.rav.serviceProvider, @@ -150,7 +150,7 @@ contract TAPCollectorTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest ? signedRAV.rav.valueAggregate - tokensAlreadyCollected : _tokensToCollect; - vm.expectEmit(address(tapCollector)); + vm.expectEmit(address(graphTallyCollector)); emit IPaymentsCollector.PaymentCollected( _paymentType, signedRAV.rav.collectionId, @@ -159,8 +159,8 @@ contract TAPCollectorTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest signedRAV.rav.dataService, tokensToCollect ); - vm.expectEmit(address(tapCollector)); - emit ITAPCollector.RAVCollected( + vm.expectEmit(address(graphTallyCollector)); + emit IGraphTallyCollector.RAVCollected( signedRAV.rav.collectionId, _payer, signedRAV.rav.serviceProvider, @@ -171,10 +171,10 @@ contract TAPCollectorTest is HorizonStakingSharedTest, PaymentsEscrowSharedTest signedRAV.signature ); uint256 tokensCollected = _tokensToCollect == 0 - ? tapCollector.collect(_paymentType, _data) - : tapCollector.collect(_paymentType, _data, _tokensToCollect); + ? graphTallyCollector.collect(_paymentType, _data) + : graphTallyCollector.collect(_paymentType, _data, _tokensToCollect); - uint256 tokensCollectedAfter = tapCollector.tokensCollected( + uint256 tokensCollectedAfter = graphTallyCollector.tokensCollected( signedRAV.rav.dataService, signedRAV.rav.collectionId, signedRAV.rav.serviceProvider, diff --git a/packages/horizon/test/payments/tap-collector/collect/collect.t.sol b/packages/horizon/test/payments/graph-tally-collector/collect/collect.t.sol similarity index 74% rename from packages/horizon/test/payments/tap-collector/collect/collect.t.sol rename to packages/horizon/test/payments/graph-tally-collector/collect/collect.t.sol index 366305b0f..cf892b89e 100644 --- a/packages/horizon/test/payments/tap-collector/collect/collect.t.sol +++ b/packages/horizon/test/payments/graph-tally-collector/collect/collect.t.sol @@ -3,12 +3,12 @@ pragma solidity 0.8.27; import "forge-std/Test.sol"; -import { ITAPCollector } from "../../../../contracts/interfaces/ITAPCollector.sol"; +import { IGraphTallyCollector } from "../../../../contracts/interfaces/IGraphTallyCollector.sol"; import { IGraphPayments } from "../../../../contracts/interfaces/IGraphPayments.sol"; -import { TAPCollectorTest } from "../TAPCollector.t.sol"; +import { GraphTallyTest } from "../GraphTallyCollector.t.sol"; -contract TAPCollectorCollectTest is TAPCollectorTest { +contract GraphTallyCollectTest is GraphTallyTest { /* * HELPERS */ @@ -25,17 +25,17 @@ contract TAPCollectorCollectTest is TAPCollectorTest { uint256 _signerPrivateKey, CollectTestParams memory params ) private view returns (bytes memory) { - ITAPCollector.ReceiptAggregateVoucher memory rav = _getRAV( + IGraphTallyCollector.ReceiptAggregateVoucher memory rav = _getRAV( params.allocationId, params.payer, params.indexer, params.collector, uint128(params.tokens) ); - bytes32 messageHash = tapCollector.encodeRAV(rav); + bytes32 messageHash = graphTallyCollector.encodeRAV(rav); (uint8 v, bytes32 r, bytes32 s) = vm.sign(_signerPrivateKey, messageHash); bytes memory signature = abi.encodePacked(r, s, v); - ITAPCollector.SignedRAV memory signedRAV = ITAPCollector.SignedRAV(rav, signature); + IGraphTallyCollector.SignedRAV memory signedRAV = IGraphTallyCollector.SignedRAV(rav, signature); return abi.encode(signedRAV); } @@ -45,9 +45,9 @@ contract TAPCollectorCollectTest is TAPCollectorTest { address _indexer, address _dataService, uint128 _tokens - ) private pure returns (ITAPCollector.ReceiptAggregateVoucher memory rav) { + ) private pure returns (IGraphTallyCollector.ReceiptAggregateVoucher memory rav) { return - ITAPCollector.ReceiptAggregateVoucher({ + IGraphTallyCollector.ReceiptAggregateVoucher({ collectionId: bytes32(uint256(uint160(_allocationId))), payer: _payer, dataService: _dataService, @@ -62,12 +62,12 @@ contract TAPCollectorCollectTest is TAPCollectorTest { * TESTS */ - function testTAPCollector_Collect( + function testGraphTally_Collect( uint256 tokens ) public useIndexer useProvisionDataService(users.verifier, 100, 0, 0) useGateway useSigner { tokens = bound(tokens, 1, type(uint128).max); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); CollectTestParams memory params = CollectTestParams({ tokens: tokens, @@ -83,14 +83,14 @@ contract TAPCollectorCollectTest is TAPCollectorTest { _collect(IGraphPayments.PaymentTypes.QueryFee, data); } - function testTAPCollector_Collect_Multiple( + function testGraphTally_Collect_Multiple( uint256 tokens, uint8 steps ) public useIndexer useProvisionDataService(users.verifier, 100, 0, 0) useGateway useSigner { steps = uint8(bound(steps, 1, 100)); tokens = bound(tokens, steps, type(uint128).max); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); resetPrank(users.verifier); uint256 payed = 0; @@ -109,10 +109,10 @@ contract TAPCollectorCollectTest is TAPCollectorTest { } } - function testTAPCollector_Collect_RevertWhen_NoProvision(uint256 tokens) public useGateway useSigner { + function testGraphTally_Collect_RevertWhen_NoProvision(uint256 tokens) public useGateway useSigner { tokens = bound(tokens, 1, type(uint128).max); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); CollectTestParams memory params = CollectTestParams({ tokens: tokens, @@ -125,14 +125,14 @@ contract TAPCollectorCollectTest is TAPCollectorTest { resetPrank(users.verifier); bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorUnauthorizedDataService.selector, + IGraphTallyCollector.GraphTallyCollectorUnauthorizedDataService.selector, users.verifier ); vm.expectRevert(expectedError); - tapCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); + graphTallyCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); } - function testTAPCollector_Collect_RevertWhen_ProvisionEmpty( + function testGraphTally_Collect_RevertWhen_ProvisionEmpty( uint256 tokens ) public useIndexer useProvisionDataService(users.verifier, 100, 0, 0) useGateway useSigner { // thaw tokens from the provision @@ -142,7 +142,7 @@ contract TAPCollectorCollectTest is TAPCollectorTest { tokens = bound(tokens, 1, type(uint128).max); resetPrank(users.gateway); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); CollectTestParams memory params = CollectTestParams({ tokens: tokens, @@ -155,20 +155,20 @@ contract TAPCollectorCollectTest is TAPCollectorTest { resetPrank(users.verifier); bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorUnauthorizedDataService.selector, + IGraphTallyCollector.GraphTallyCollectorUnauthorizedDataService.selector, users.verifier ); vm.expectRevert(expectedError); - tapCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); + graphTallyCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); } - function testTAPCollector_Collect_PreventSignerAttack( + function testGraphTally_Collect_PreventSignerAttack( uint256 tokens ) public useIndexer useProvisionDataService(users.verifier, 100, 0, 0) useGateway useSigner { tokens = bound(tokens, 1, type(uint128).max); resetPrank(users.gateway); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); // The sender authorizes another signer (address anotherSigner, uint256 anotherSignerPrivateKey) = makeAddrAndKey("anotherSigner"); @@ -191,18 +191,18 @@ contract TAPCollectorCollectTest is TAPCollectorTest { // the call should revert because the service provider has no provision with the "data service" resetPrank(anotherSigner); bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorUnauthorizedDataService.selector, + IGraphTallyCollector.GraphTallyCollectorUnauthorizedDataService.selector, anotherSigner ); vm.expectRevert(expectedError); - tapCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); + graphTallyCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); } - function testTAPCollector_Collect_RevertWhen_CallerNotDataService(uint256 tokens) public useGateway useSigner { + function testGraphTally_Collect_RevertWhen_CallerNotDataService(uint256 tokens) public useGateway useSigner { tokens = bound(tokens, 1, type(uint128).max); resetPrank(users.gateway); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); CollectTestParams memory params = CollectTestParams({ tokens: tokens, @@ -215,21 +215,21 @@ contract TAPCollectorCollectTest is TAPCollectorTest { resetPrank(users.indexer); bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorCallerNotDataService.selector, + IGraphTallyCollector.GraphTallyCollectorCallerNotDataService.selector, users.indexer, users.verifier ); vm.expectRevert(expectedError); - tapCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); + graphTallyCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); } - function testTAPCollector_Collect_RevertWhen_PayerMismatch( + function testGraphTally_Collect_RevertWhen_PayerMismatch( uint256 tokens ) public useIndexer useProvisionDataService(users.verifier, 100, 0, 0) useGateway useSigner { tokens = bound(tokens, 1, type(uint128).max); resetPrank(users.gateway); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); (address anotherPayer, ) = makeAddrAndKey("anotherPayer"); CollectTestParams memory params = CollectTestParams({ @@ -243,20 +243,20 @@ contract TAPCollectorCollectTest is TAPCollectorTest { resetPrank(users.verifier); bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorInvalidRAVPayer.selector, + IGraphTallyCollector.GraphTallyCollectorInvalidRAVPayer.selector, users.gateway, anotherPayer ); vm.expectRevert(expectedError); - tapCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); + graphTallyCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); } - function testTAPCollector_Collect_RevertWhen_InconsistentRAVTokens( + function testGraphTally_Collect_RevertWhen_InconsistentRAVTokens( uint256 tokens ) public useIndexer useProvisionDataService(users.verifier, 100, 0, 0) useGateway useSigner { tokens = bound(tokens, 1, type(uint128).max); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); CollectTestParams memory params = CollectTestParams({ tokens: tokens, allocationId: _allocationId, @@ -271,15 +271,15 @@ contract TAPCollectorCollectTest is TAPCollectorTest { // Attempt to collect again vm.expectRevert( - abi.encodeWithSelector(ITAPCollector.TAPCollectorInconsistentRAVTokens.selector, tokens, tokens) + abi.encodeWithSelector(IGraphTallyCollector.GraphTallyCollectorInconsistentRAVTokens.selector, tokens, tokens) ); - tapCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); + graphTallyCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); } - function testTAPCollector_Collect_RevertWhen_SignerNotAuthorized(uint256 tokens) public useGateway { + function testGraphTally_Collect_RevertWhen_SignerNotAuthorized(uint256 tokens) public useGateway { tokens = bound(tokens, 1, type(uint128).max); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); CollectTestParams memory params = CollectTestParams({ tokens: tokens, @@ -291,16 +291,16 @@ contract TAPCollectorCollectTest is TAPCollectorTest { bytes memory data = _getQueryFeeEncodedData(signerPrivateKey, params); resetPrank(users.verifier); - vm.expectRevert(abi.encodeWithSelector(ITAPCollector.TAPCollectorInvalidRAVSigner.selector)); - tapCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); + vm.expectRevert(abi.encodeWithSelector(IGraphTallyCollector.GraphTallyCollectorInvalidRAVSigner.selector)); + graphTallyCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); } - function testTAPCollector_Collect_ThawingSigner( + function testGraphTally_Collect_ThawingSigner( uint256 tokens ) public useIndexer useProvisionDataService(users.verifier, 100, 0, 0) useGateway useSigner { tokens = bound(tokens, 1, type(uint128).max); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); // Start thawing signer _thawSigner(signer); @@ -319,10 +319,10 @@ contract TAPCollectorCollectTest is TAPCollectorTest { _collect(IGraphPayments.PaymentTypes.QueryFee, data); } - function testTAPCollector_Collect_RevertIf_SignerWasRevoked(uint256 tokens) public useGateway useSigner { + function testGraphTally_Collect_RevertIf_SignerWasRevoked(uint256 tokens) public useGateway useSigner { tokens = bound(tokens, 1, type(uint128).max); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); // Start thawing signer _thawSigner(signer); @@ -339,16 +339,16 @@ contract TAPCollectorCollectTest is TAPCollectorTest { bytes memory data = _getQueryFeeEncodedData(signerPrivateKey, params); resetPrank(users.verifier); - vm.expectRevert(abi.encodeWithSelector(ITAPCollector.TAPCollectorInvalidRAVSigner.selector)); - tapCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); + vm.expectRevert(abi.encodeWithSelector(IGraphTallyCollector.GraphTallyCollectorInvalidRAVSigner.selector)); + graphTallyCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); } - function testTAPCollector_Collect_ThawingSignerCanceled( + function testGraphTally_Collect_ThawingSignerCanceled( uint256 tokens ) public useIndexer useProvisionDataService(users.verifier, 100, 0, 0) useGateway useSigner { tokens = bound(tokens, 1, type(uint128).max); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); // Start thawing signer _thawSigner(signer); @@ -368,14 +368,14 @@ contract TAPCollectorCollectTest is TAPCollectorTest { _collect(IGraphPayments.PaymentTypes.QueryFee, data); } - function testTAPCollector_CollectPartial( + function testGraphTally_CollectPartial( uint256 tokens, uint256 tokensToCollect ) public useIndexer useProvisionDataService(users.verifier, 100, 0, 0) useGateway useSigner { tokens = bound(tokens, 1, type(uint128).max); tokensToCollect = bound(tokensToCollect, 1, tokens); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); CollectTestParams memory params = CollectTestParams({ tokens: tokens, @@ -390,13 +390,13 @@ contract TAPCollectorCollectTest is TAPCollectorTest { _collect(IGraphPayments.PaymentTypes.QueryFee, data, tokensToCollect); } - function testTAPCollector_CollectPartial_RevertWhen_AmountTooHigh( + function testGraphTally_CollectPartial_RevertWhen_AmountTooHigh( uint256 tokens, uint256 tokensToCollect ) public useIndexer useProvisionDataService(users.verifier, 100, 0, 0) useGateway useSigner { tokens = bound(tokens, 1, type(uint128).max - 1); - _depositTokens(address(tapCollector), users.indexer, tokens); + _depositTokens(address(graphTallyCollector), users.indexer, tokens); CollectTestParams memory params = CollectTestParams({ tokens: tokens, @@ -408,7 +408,7 @@ contract TAPCollectorCollectTest is TAPCollectorTest { bytes memory data = _getQueryFeeEncodedData(signerPrivateKey, params); resetPrank(users.verifier); - uint256 tokensAlreadyCollected = tapCollector.tokensCollected( + uint256 tokensAlreadyCollected = graphTallyCollector.tokensCollected( users.verifier, bytes32(uint256(uint160(_allocationId))), users.indexer, @@ -418,21 +418,21 @@ contract TAPCollectorCollectTest is TAPCollectorTest { vm.expectRevert( abi.encodeWithSelector( - ITAPCollector.TAPCollectorInvalidTokensToCollectAmount.selector, + IGraphTallyCollector.GraphTallyCollectorInvalidTokensToCollectAmount.selector, tokensToCollect, tokens - tokensAlreadyCollected ) ); - tapCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data, tokensToCollect); + graphTallyCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data, tokensToCollect); } - function testTAPCollector_Collect_SeparateAllocationTracking( + function testGraphTally_Collect_SeparateAllocationTracking( uint256 tokens ) public useIndexer useProvisionDataService(users.verifier, 100, 0, 0) useGateway useSigner { tokens = bound(tokens, 1, type(uint64).max); uint8 numAllocations = 10; - _depositTokens(address(tapCollector), users.indexer, tokens * numAllocations); + _depositTokens(address(graphTallyCollector), users.indexer, tokens * numAllocations); // Array with collectTestParams for each allocation CollectTestParams[] memory collectTestParams = new CollectTestParams[](numAllocations); @@ -453,7 +453,7 @@ contract TAPCollectorCollectTest is TAPCollectorTest { for (uint256 i = 0; i < numAllocations; i++) { assertEq( - tapCollector.tokensCollected( + graphTallyCollector.tokensCollected( collectTestParams[i].collector, bytes32(uint256(uint160(collectTestParams[i].allocationId))), collectTestParams[i].indexer, @@ -466,14 +466,14 @@ contract TAPCollectorCollectTest is TAPCollectorTest { // Try to collect again with the same allocation - should revert bytes memory data = _getQueryFeeEncodedData(signerPrivateKey, collectTestParams[i]); vm.expectRevert( - abi.encodeWithSelector(ITAPCollector.TAPCollectorInconsistentRAVTokens.selector, tokens, tokens) + abi.encodeWithSelector(IGraphTallyCollector.GraphTallyCollectorInconsistentRAVTokens.selector, tokens, tokens) ); - tapCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); + graphTallyCollector.collect(IGraphPayments.PaymentTypes.QueryFee, data); } // Increase tokens for allocation 0 by 1000 ether and collect again resetPrank(users.gateway); - _depositTokens(address(tapCollector), users.indexer, 1000 ether); + _depositTokens(address(graphTallyCollector), users.indexer, 1000 ether); resetPrank(users.verifier); collectTestParams[0].tokens = tokens + 1000 ether; diff --git a/packages/horizon/test/payments/tap-collector/signer/authorizeSigner.t.sol b/packages/horizon/test/payments/graph-tally-collector/signer/authorizeSigner.t.sol similarity index 61% rename from packages/horizon/test/payments/tap-collector/signer/authorizeSigner.t.sol rename to packages/horizon/test/payments/graph-tally-collector/signer/authorizeSigner.t.sol index 30ffd4610..192ac4c64 100644 --- a/packages/horizon/test/payments/tap-collector/signer/authorizeSigner.t.sol +++ b/packages/horizon/test/payments/graph-tally-collector/signer/authorizeSigner.t.sol @@ -3,11 +3,11 @@ pragma solidity 0.8.27; import "forge-std/Test.sol"; -import { ITAPCollector } from "../../../../contracts/interfaces/ITAPCollector.sol"; +import { IGraphTallyCollector } from "../../../../contracts/interfaces/IGraphTallyCollector.sol"; -import { TAPCollectorTest } from "../TAPCollector.t.sol"; +import { GraphTallyTest } from "../GraphTallyCollector.t.sol"; -contract TAPCollectorAuthorizeSignerTest is TAPCollectorTest { +contract GraphTallyAuthorizeSignerTest is GraphTallyTest { uint256 constant SECP256K1_CURVE_ORDER = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141; @@ -15,25 +15,25 @@ contract TAPCollectorAuthorizeSignerTest is TAPCollectorTest { * TESTS */ - function testTAPCollector_AuthorizeSigner(uint256 signerKey) public useGateway { + function testGraphTally_AuthorizeSigner(uint256 signerKey) public useGateway { signerKey = bound(signerKey, 1, SECP256K1_CURVE_ORDER - 1); uint256 proofDeadline = block.timestamp + 1; bytes memory signerProof = _getSignerProof(proofDeadline, signerKey); _authorizeSigner(vm.addr(signerKey), proofDeadline, signerProof); } - function testTAPCollector_AuthorizeSigner_RevertWhen_Invalid() public useGateway { + function testGraphTally_AuthorizeSigner_RevertWhen_Invalid() public useGateway { // Sign proof with payer uint256 proofDeadline = block.timestamp + 1; bytes memory signerProof = _getSignerProof(proofDeadline, signerPrivateKey); // Attempt to authorize delegator with payer's proof - bytes memory expectedError = abi.encodeWithSelector(ITAPCollector.TAPCollectorInvalidSignerProof.selector); + bytes memory expectedError = abi.encodeWithSelector(IGraphTallyCollector.GraphTallyCollectorInvalidSignerProof.selector); vm.expectRevert(expectedError); - tapCollector.authorizeSigner(users.delegator, proofDeadline, signerProof); + graphTallyCollector.authorizeSigner(users.delegator, proofDeadline, signerProof); } - function testTAPCollector_AuthorizeSigner_RevertWhen_AlreadyAuthroized() public useGateway { + function testGraphTally_AuthorizeSigner_RevertWhen_AlreadyAuthroized() public useGateway { // Authorize signer uint256 proofDeadline = block.timestamp + 1; bytes memory signerProof = _getSignerProof(proofDeadline, signerPrivateKey); @@ -41,15 +41,15 @@ contract TAPCollectorAuthorizeSignerTest is TAPCollectorTest { // Attempt to authorize signer again bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorSignerAlreadyAuthorized.selector, + IGraphTallyCollector.GraphTallyCollectorSignerAlreadyAuthorized.selector, users.gateway, signer ); vm.expectRevert(expectedError); - tapCollector.authorizeSigner(signer, proofDeadline, signerProof); + graphTallyCollector.authorizeSigner(signer, proofDeadline, signerProof); } - function testTAPCollector_AuthorizeSigner_RevertWhen_AlreadyAuthroizedAfterRevoking() public useGateway { + function testGraphTally_AuthorizeSigner_RevertWhen_AlreadyAuthroizedAfterRevoking() public useGateway { // Authorize signer uint256 proofDeadline = block.timestamp + 1; bytes memory signerProof = _getSignerProof(proofDeadline, signerPrivateKey); @@ -62,26 +62,26 @@ contract TAPCollectorAuthorizeSignerTest is TAPCollectorTest { // Attempt to authorize signer again bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorSignerAlreadyAuthorized.selector, + IGraphTallyCollector.GraphTallyCollectorSignerAlreadyAuthorized.selector, users.gateway, signer ); vm.expectRevert(expectedError); - tapCollector.authorizeSigner(signer, proofDeadline, signerProof); + graphTallyCollector.authorizeSigner(signer, proofDeadline, signerProof); } - function testTAPCollector_AuthorizeSigner_RevertWhen_ProofExpired() public useGateway { + function testGraphTally_AuthorizeSigner_RevertWhen_ProofExpired() public useGateway { // Sign proof with payer uint256 proofDeadline = block.timestamp - 1; bytes memory signerProof = _getSignerProof(proofDeadline, signerPrivateKey); // Attempt to authorize delegator with expired proof bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorInvalidSignerProofDeadline.selector, + IGraphTallyCollector.GraphTallyCollectorInvalidSignerProofDeadline.selector, proofDeadline, block.timestamp ); vm.expectRevert(expectedError); - tapCollector.authorizeSigner(users.delegator, proofDeadline, signerProof); + graphTallyCollector.authorizeSigner(users.delegator, proofDeadline, signerProof); } } diff --git a/packages/horizon/test/payments/graph-tally-collector/signer/cancelThawSigner.t.sol b/packages/horizon/test/payments/graph-tally-collector/signer/cancelThawSigner.t.sol new file mode 100644 index 000000000..fae5a943f --- /dev/null +++ b/packages/horizon/test/payments/graph-tally-collector/signer/cancelThawSigner.t.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import "forge-std/Test.sol"; + +import { IGraphTallyCollector } from "../../../../contracts/interfaces/IGraphTallyCollector.sol"; + +import { GraphTallyTest } from "../GraphTallyCollector.t.sol"; + +contract GraphTallyCancelThawSignerTest is GraphTallyTest { + + /* + * TESTS + */ + + function testGraphTally_CancelThawSigner() public useGateway useSigner { + _thawSigner(signer); + _cancelThawSigner(signer); + } + + function testGraphTally_CancelThawSigner_RevertWhen_NotAuthorized() public useGateway { + bytes memory expectedError = abi.encodeWithSelector( + IGraphTallyCollector.GraphTallyCollectorSignerNotAuthorizedByPayer.selector, + users.gateway, + signer + ); + vm.expectRevert(expectedError); + graphTallyCollector.thawSigner(signer); + } + + function testGraphTally_CancelThawSigner_RevertWhen_NotThawing() public useGateway useSigner { + bytes memory expectedError = abi.encodeWithSelector( + IGraphTallyCollector.GraphTallyCollectorSignerNotThawing.selector, + signer + ); + vm.expectRevert(expectedError); + graphTallyCollector.cancelThawSigner(signer); + } +} diff --git a/packages/horizon/test/payments/graph-tally-collector/signer/revokeSigner.t.sol b/packages/horizon/test/payments/graph-tally-collector/signer/revokeSigner.t.sol new file mode 100644 index 000000000..f6a53e9c3 --- /dev/null +++ b/packages/horizon/test/payments/graph-tally-collector/signer/revokeSigner.t.sol @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import "forge-std/Test.sol"; + +import { IGraphTallyCollector } from "../../../../contracts/interfaces/IGraphTallyCollector.sol"; + +import { GraphTallyTest } from "../GraphTallyCollector.t.sol"; + +contract GraphTallyRevokeAuthorizedSignerTest is GraphTallyTest { + + /* + * TESTS + */ + + function testGraphTally_RevokeAuthorizedSigner() public useGateway useSigner { + _thawSigner(signer); + + // Advance time to thaw signer + skip(revokeSignerThawingPeriod + 1); + + _revokeAuthorizedSigner(signer); + } + + function testGraphTally_RevokeAuthorizedSigner_RevertWhen_NotAuthorized() public useGateway { + bytes memory expectedError = abi.encodeWithSelector( + IGraphTallyCollector.GraphTallyCollectorSignerNotAuthorizedByPayer.selector, + users.gateway, + signer + ); + vm.expectRevert(expectedError); + graphTallyCollector.revokeAuthorizedSigner(signer); + } + + function testGraphTally_RevokeAuthorizedSigner_RevertWhen_NotThawing() public useGateway useSigner { + bytes memory expectedError = abi.encodeWithSelector( + IGraphTallyCollector.GraphTallyCollectorSignerNotThawing.selector, + signer + ); + vm.expectRevert(expectedError); + graphTallyCollector.revokeAuthorizedSigner(signer); + } + + function testGraphTally_RevokeAuthorizedSigner_RevertWhen_StillThawing() public useGateway useSigner { + _thawSigner(signer); + bytes memory expectedError = abi.encodeWithSelector( + IGraphTallyCollector.GraphTallyCollectorSignerStillThawing.selector, + block.timestamp, + block.timestamp + revokeSignerThawingPeriod + ); + vm.expectRevert(expectedError); + graphTallyCollector.revokeAuthorizedSigner(signer); + } +} diff --git a/packages/horizon/test/payments/graph-tally-collector/signer/thawSigner.t.sol b/packages/horizon/test/payments/graph-tally-collector/signer/thawSigner.t.sol new file mode 100644 index 000000000..7be6d28bf --- /dev/null +++ b/packages/horizon/test/payments/graph-tally-collector/signer/thawSigner.t.sol @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.27; + +import "forge-std/Test.sol"; + +import { IGraphTallyCollector } from "../../../../contracts/interfaces/IGraphTallyCollector.sol"; + +import { GraphTallyTest } from "../GraphTallyCollector.t.sol"; + +contract GraphTallyThawSignerTest is GraphTallyTest { + + /* + * TESTS + */ + + function testGraphTally_ThawSigner() public useGateway useSigner { + _thawSigner(signer); + } + + function testGraphTally_ThawSigner_RevertWhen_NotAuthorized() public useGateway { + bytes memory expectedError = abi.encodeWithSelector( + IGraphTallyCollector.GraphTallyCollectorSignerNotAuthorizedByPayer.selector, + users.gateway, + signer + ); + vm.expectRevert(expectedError); + graphTallyCollector.thawSigner(signer); + } + + function testGraphTally_ThawSigner_RevertWhen_AlreadyRevoked() public useGateway useSigner { + _thawSigner(signer); + skip(revokeSignerThawingPeriod + 1); + _revokeAuthorizedSigner(signer); + + bytes memory expectedError = abi.encodeWithSelector( + IGraphTallyCollector.GraphTallyCollectorAuthorizationAlreadyRevoked.selector, + users.gateway, + signer + ); + vm.expectRevert(expectedError); + graphTallyCollector.thawSigner(signer); + } + + function testGraphTally_ThawSigner_RevertWhen_AlreadyThawing() public useGateway useSigner { + _thawSigner(signer); + + (,uint256 thawEndTimestamp,) = graphTallyCollector.authorizedSigners(signer); + bytes memory expectedError = abi.encodeWithSelector( + IGraphTallyCollector.GraphTallyCollectorSignerAlreadyThawing.selector, + signer, + thawEndTimestamp + ); + vm.expectRevert(expectedError); + graphTallyCollector.thawSigner(signer); + } +} diff --git a/packages/horizon/test/payments/tap-collector/signer/cancelThawSigner.t.sol b/packages/horizon/test/payments/tap-collector/signer/cancelThawSigner.t.sol deleted file mode 100644 index dc25da8cf..000000000 --- a/packages/horizon/test/payments/tap-collector/signer/cancelThawSigner.t.sol +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.27; - -import "forge-std/Test.sol"; - -import { ITAPCollector } from "../../../../contracts/interfaces/ITAPCollector.sol"; - -import { TAPCollectorTest } from "../TAPCollector.t.sol"; - -contract TAPCollectorCancelThawSignerTest is TAPCollectorTest { - - /* - * TESTS - */ - - function testTAPCollector_CancelThawSigner() public useGateway useSigner { - _thawSigner(signer); - _cancelThawSigner(signer); - } - - function testTAPCollector_CancelThawSigner_RevertWhen_NotAuthorized() public useGateway { - bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorSignerNotAuthorizedByPayer.selector, - users.gateway, - signer - ); - vm.expectRevert(expectedError); - tapCollector.thawSigner(signer); - } - - function testTAPCollector_CancelThawSigner_RevertWhen_NotThawing() public useGateway useSigner { - bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorSignerNotThawing.selector, - signer - ); - vm.expectRevert(expectedError); - tapCollector.cancelThawSigner(signer); - } -} diff --git a/packages/horizon/test/payments/tap-collector/signer/revokeSigner.t.sol b/packages/horizon/test/payments/tap-collector/signer/revokeSigner.t.sol deleted file mode 100644 index 8c03245f8..000000000 --- a/packages/horizon/test/payments/tap-collector/signer/revokeSigner.t.sol +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.27; - -import "forge-std/Test.sol"; - -import { ITAPCollector } from "../../../../contracts/interfaces/ITAPCollector.sol"; - -import { TAPCollectorTest } from "../TAPCollector.t.sol"; - -contract TAPCollectorRevokeAuthorizedSignerTest is TAPCollectorTest { - - /* - * TESTS - */ - - function testTAPCollector_RevokeAuthorizedSigner() public useGateway useSigner { - _thawSigner(signer); - - // Advance time to thaw signer - skip(revokeSignerThawingPeriod + 1); - - _revokeAuthorizedSigner(signer); - } - - function testTAPCollector_RevokeAuthorizedSigner_RevertWhen_NotAuthorized() public useGateway { - bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorSignerNotAuthorizedByPayer.selector, - users.gateway, - signer - ); - vm.expectRevert(expectedError); - tapCollector.revokeAuthorizedSigner(signer); - } - - function testTAPCollector_RevokeAuthorizedSigner_RevertWhen_NotThawing() public useGateway useSigner { - bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorSignerNotThawing.selector, - signer - ); - vm.expectRevert(expectedError); - tapCollector.revokeAuthorizedSigner(signer); - } - - function testTAPCollector_RevokeAuthorizedSigner_RevertWhen_StillThawing() public useGateway useSigner { - _thawSigner(signer); - bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorSignerStillThawing.selector, - block.timestamp, - block.timestamp + revokeSignerThawingPeriod - ); - vm.expectRevert(expectedError); - tapCollector.revokeAuthorizedSigner(signer); - } -} diff --git a/packages/horizon/test/payments/tap-collector/signer/thawSigner.t.sol b/packages/horizon/test/payments/tap-collector/signer/thawSigner.t.sol deleted file mode 100644 index def79d831..000000000 --- a/packages/horizon/test/payments/tap-collector/signer/thawSigner.t.sol +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.27; - -import "forge-std/Test.sol"; - -import { ITAPCollector } from "../../../../contracts/interfaces/ITAPCollector.sol"; - -import { TAPCollectorTest } from "../TAPCollector.t.sol"; - -contract TAPCollectorThawSignerTest is TAPCollectorTest { - - /* - * TESTS - */ - - function testTAPCollector_ThawSigner() public useGateway useSigner { - _thawSigner(signer); - } - - function testTAPCollector_ThawSigner_RevertWhen_NotAuthorized() public useGateway { - bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorSignerNotAuthorizedByPayer.selector, - users.gateway, - signer - ); - vm.expectRevert(expectedError); - tapCollector.thawSigner(signer); - } - - function testTAPCollector_ThawSigner_RevertWhen_AlreadyRevoked() public useGateway useSigner { - _thawSigner(signer); - skip(revokeSignerThawingPeriod + 1); - _revokeAuthorizedSigner(signer); - - bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorAuthorizationAlreadyRevoked.selector, - users.gateway, - signer - ); - vm.expectRevert(expectedError); - tapCollector.thawSigner(signer); - } - - function testTAPCollector_ThawSigner_RevertWhen_AlreadyThawing() public useGateway useSigner { - _thawSigner(signer); - - (,uint256 thawEndTimestamp,) = tapCollector.authorizedSigners(signer); - bytes memory expectedError = abi.encodeWithSelector( - ITAPCollector.TAPCollectorSignerAlreadyThawing.selector, - signer, - thawEndTimestamp - ); - vm.expectRevert(expectedError); - tapCollector.thawSigner(signer); - } -} diff --git a/packages/horizon/test/utils/Constants.sol b/packages/horizon/test/utils/Constants.sol index 0c4721c67..df7e78e6d 100644 --- a/packages/horizon/test/utils/Constants.sol +++ b/packages/horizon/test/utils/Constants.sol @@ -18,6 +18,6 @@ abstract contract Constants { uint256 internal constant EPOCH_LENGTH = 1; // Rewards manager uint256 internal constant ALLOCATIONS_REWARD_CUT = 100 ether; - // TAPCollector + // GraphTallyCollector uint256 internal constant revokeSignerThawingPeriod = 7 days; } \ No newline at end of file diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index f43669133..eea79b2ea 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.27; import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; import { IGraphToken } from "@graphprotocol/contracts/contracts/token/IGraphToken.sol"; -import { ITAPCollector } from "@graphprotocol/horizon/contracts/interfaces/ITAPCollector.sol"; +import { IGraphTallyCollector } from "@graphprotocol/horizon/contracts/interfaces/IGraphTallyCollector.sol"; import { IRewardsIssuer } from "@graphprotocol/contracts/contracts/rewards/IRewardsIssuer.sol"; import { ISubgraphService } from "./interfaces/ISubgraphService.sol"; @@ -59,15 +59,15 @@ contract SubgraphService is * @dev DataService and Directory constructors set a bunch of immutable variables * @param graphController The address of the Graph Controller contract * @param disputeManager The address of the DisputeManager contract - * @param tapCollector The address of the TAPCollector contract + * @param graphTallyCollector The address of the GraphTallyCollector contract * @param curation The address of the Curation contract */ constructor( address graphController, address disputeManager, - address tapCollector, + address graphTallyCollector, address curation - ) DataService(graphController) Directory(address(this), disputeManager, tapCollector, curation) { + ) DataService(graphController) Directory(address(this), disputeManager, graphTallyCollector, curation) { _disableInitializers(); } @@ -269,7 +269,7 @@ contract SubgraphService is uint256 paymentCollected = 0; if (paymentType == IGraphPayments.PaymentTypes.QueryFee) { - ITAPCollector.SignedRAV memory signedRav = abi.decode(data, (ITAPCollector.SignedRAV)); + IGraphTallyCollector.SignedRAV memory signedRav = abi.decode(data, (IGraphTallyCollector.SignedRAV)); require( signedRav.rav.serviceProvider == indexer, SubgraphServiceIndexerMismatch(signedRav.rav.serviceProvider, indexer) @@ -500,7 +500,7 @@ contract SubgraphService is * manually release the claims, see {IDataServiceFees-releaseStake}, before attempting to collect again. * * @dev This function is the equivalent of the legacy `collect` function for query fees. - * @dev Uses the {TAPCollector} to collect payment from Graph Horizon payments protocol. + * @dev Uses the {GraphTallyCollector} to collect payment from Graph Horizon payments protocol. * Fees are distributed to service provider and delegators by {GraphPayments}, though curators * share is distributed by this function. * @@ -515,7 +515,9 @@ contract SubgraphService is * * @param _signedRav Signed RAV */ - function _collectQueryFees(ITAPCollector.SignedRAV memory _signedRav) private returns (uint256 feesCollected) { + function _collectQueryFees( + IGraphTallyCollector.SignedRAV memory _signedRav + ) private returns (uint256 feesCollected) { address indexer = _signedRav.rav.serviceProvider; // Check that collectionId (256 bits) is a valid address (160 bits) @@ -537,7 +539,7 @@ contract SubgraphService is uint256 balanceBefore = _graphToken().balanceOf(address(this)); uint256 curationCut = _curation().isCurated(subgraphDeploymentId) ? curationFeesCut : 0; - uint256 tokensCollected = _tapCollector().collect( + uint256 tokensCollected = _graphTallyCollector().collect( IGraphPayments.PaymentTypes.QueryFee, abi.encode(_signedRav, curationCut) ); diff --git a/packages/subgraph-service/contracts/utilities/Directory.sol b/packages/subgraph-service/contracts/utilities/Directory.sol index 53de7c6e7..6bc504d60 100644 --- a/packages/subgraph-service/contracts/utilities/Directory.sol +++ b/packages/subgraph-service/contracts/utilities/Directory.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.27; import { IDisputeManager } from "../interfaces/IDisputeManager.sol"; import { ISubgraphService } from "../interfaces/ISubgraphService.sol"; -import { ITAPCollector } from "@graphprotocol/horizon/contracts/interfaces/ITAPCollector.sol"; +import { IGraphTallyCollector } from "@graphprotocol/horizon/contracts/interfaces/IGraphTallyCollector.sol"; import { ICuration } from "@graphprotocol/contracts/contracts/curation/ICuration.sol"; /** @@ -19,9 +19,9 @@ abstract contract Directory { /// @notice The Dispute Manager contract address IDisputeManager private immutable DISPUTE_MANAGER; - /// @notice The TAP Collector contract address + /// @notice The Graph Tally Collector contract address /// @dev Required to collect payments via Graph Horizon payments protocol - ITAPCollector private immutable TAP_COLLECTOR; + IGraphTallyCollector private immutable GRAPH_TALLY_COLLECTOR; /// @notice The Curation contract address /// @dev Required for curation fees distribution @@ -31,13 +31,13 @@ abstract contract Directory { * @notice Emitted when the Directory is initialized * @param subgraphService The Subgraph Service contract address * @param disputeManager The Dispute Manager contract address - * @param tapCollector The TAP Collector contract address + * @param graphTallyCollector The Graph Tally Collector contract address * @param curation The Curation contract address */ event SubgraphServiceDirectoryInitialized( address subgraphService, address disputeManager, - address tapCollector, + address graphTallyCollector, address curation ); @@ -63,16 +63,16 @@ abstract contract Directory { * @notice Constructor for the Directory contract * @param subgraphService The Subgraph Service contract address * @param disputeManager The Dispute Manager contract address - * @param tapCollector The TAP Collector contract address + * @param graphTallyCollector The Graph Tally Collector contract address * @param curation The Curation contract address */ - constructor(address subgraphService, address disputeManager, address tapCollector, address curation) { + constructor(address subgraphService, address disputeManager, address graphTallyCollector, address curation) { SUBGRAPH_SERVICE = ISubgraphService(subgraphService); DISPUTE_MANAGER = IDisputeManager(disputeManager); - TAP_COLLECTOR = ITAPCollector(tapCollector); + GRAPH_TALLY_COLLECTOR = IGraphTallyCollector(graphTallyCollector); CURATION = ICuration(curation); - emit SubgraphServiceDirectoryInitialized(subgraphService, disputeManager, tapCollector, curation); + emit SubgraphServiceDirectoryInitialized(subgraphService, disputeManager, graphTallyCollector, curation); } /** @@ -90,10 +90,10 @@ abstract contract Directory { } /** - * @notice Returns the TAP Collector contract address + * @notice Returns the Graph Tally Collector contract address */ - function _tapCollector() internal view returns (ITAPCollector) { - return TAP_COLLECTOR; + function _graphTallyCollector() internal view returns (IGraphTallyCollector) { + return GRAPH_TALLY_COLLECTOR; } /** diff --git a/packages/subgraph-service/ignition/configs/subgraph-service-migrate.default.json5 b/packages/subgraph-service/ignition/configs/subgraph-service-migrate.default.json5 index 3a9cb7ea5..d8ce79391 100644 --- a/packages/subgraph-service/ignition/configs/subgraph-service-migrate.default.json5 +++ b/packages/subgraph-service/ignition/configs/subgraph-service-migrate.default.json5 @@ -7,7 +7,7 @@ // Addresses for contracts deployed in the original Graph Protocol "controllerAddress": "0x9DB3ee191681f092607035d9BDA6e59FbEaCa695", "curationAddress": "0xDe761f075200E75485F4358978FB4d1dC8644FD5", - "tapCollectorAddress": "0x0000000000000000000000000000000000000000", + "graphTallyCollectorAddress": "0x0000000000000000000000000000000000000000", // Must be set for step 2 of the migration "disputeManagerAddress": "0x0000000000000000000000000000000000000000", diff --git a/packages/subgraph-service/ignition/modules/SubgraphService.ts b/packages/subgraph-service/ignition/modules/SubgraphService.ts index 19a56e3a2..af90e8bf7 100644 --- a/packages/subgraph-service/ignition/modules/SubgraphService.ts +++ b/packages/subgraph-service/ignition/modules/SubgraphService.ts @@ -11,7 +11,7 @@ export default buildModule('SubgraphService', (m) => { const subgraphServiceProxyAddress = m.getParameter('subgraphServiceProxyAddress') const subgraphServiceProxyAdminAddress = m.getParameter('subgraphServiceProxyAdminAddress') const disputeManagerAddress = m.getParameter('disputeManagerAddress') - const tapCollectorAddress = m.getParameter('tapCollectorAddress') + const graphTallyCollectorAddress = m.getParameter('graphTallyCollectorAddress') const curationAddress = m.getParameter('curationAddress') const minimumProvisionTokens = m.getParameter('minimumProvisionTokens') const maximumDelegationRatio = m.getParameter('maximumDelegationRatio') @@ -23,7 +23,7 @@ export default buildModule('SubgraphService', (m) => { // Deploy implementation const SubgraphServiceImplementation = deployImplementation(m, { name: 'SubgraphService', - constructorArgs: [controllerAddress, disputeManagerAddress, tapCollectorAddress, curationAddress], + constructorArgs: [controllerAddress, disputeManagerAddress, graphTallyCollectorAddress, curationAddress], }) // Upgrade implementation diff --git a/packages/subgraph-service/scripts/deploy.ts b/packages/subgraph-service/scripts/deploy.ts index 7ea5e9b4f..00867588f 100644 --- a/packages/subgraph-service/scripts/deploy.ts +++ b/packages/subgraph-service/scripts/deploy.ts @@ -33,7 +33,7 @@ async function main() { }) // Deploy Horizon - const { Controller, TAPCollector, L2Curation } = await ignition.deploy(HorizonModule, { + const { Controller, GraphTallyCollector, L2Curation } = await ignition.deploy(HorizonModule, { displayUi: true, parameters: IgnitionHelper.patchConfig(HorizonConfig, { SubgraphService: { @@ -63,7 +63,7 @@ async function main() { subgraphServiceProxyAddress: SubgraphServiceProxy.target as string, subgraphServiceProxyAdminAddress: SubgraphServiceProxyAdmin.target as string, disputeManagerAddress: DisputeManagerProxy.target as string, - tapCollectorAddress: TAPCollector.target as string, + graphTallyCollectorAddress: GraphTallyCollector.target as string, curationAddress: L2Curation.target as string, }, }), diff --git a/packages/subgraph-service/test/SubgraphBaseTest.t.sol b/packages/subgraph-service/test/SubgraphBaseTest.t.sol index 878d341b0..176129ec2 100644 --- a/packages/subgraph-service/test/SubgraphBaseTest.t.sol +++ b/packages/subgraph-service/test/SubgraphBaseTest.t.sol @@ -12,8 +12,8 @@ import { HorizonStakingExtension } from "@graphprotocol/horizon/contracts/stakin import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; import { IHorizonStaking } from "@graphprotocol/horizon/contracts/interfaces/IHorizonStaking.sol"; import { IPaymentsEscrow } from "@graphprotocol/horizon/contracts/interfaces/IPaymentsEscrow.sol"; -import { ITAPCollector } from "@graphprotocol/horizon/contracts/interfaces/ITAPCollector.sol"; -import { TAPCollector } from "@graphprotocol/horizon/contracts/payments/collectors/TAPCollector.sol"; +import { IGraphTallyCollector } from "@graphprotocol/horizon/contracts/interfaces/IGraphTallyCollector.sol"; +import { GraphTallyCollector } from "@graphprotocol/horizon/contracts/payments/collectors/GraphTallyCollector.sol"; import { PaymentsEscrow } from "@graphprotocol/horizon/contracts/payments/PaymentsEscrow.sol"; import { UnsafeUpgrades } from "openzeppelin-foundry-upgrades/Upgrades.sol"; @@ -43,7 +43,7 @@ abstract contract SubgraphBaseTest is Utils, Constants { IHorizonStaking staking; GraphPayments graphPayments; IPaymentsEscrow escrow; - TAPCollector tapCollector; + GraphTallyCollector graphTallyCollector; HorizonStaking private stakingBase; HorizonStakingExtension private stakingExtension; @@ -147,9 +147,9 @@ abstract contract SubgraphBaseTest is Utils, Constants { disputeManager = DisputeManager(disputeManagerProxy); disputeManager.transferOwnership(users.governor); - tapCollector = new TAPCollector("TAPCollector", "1", address(controller), revokeSignerThawingPeriod); + graphTallyCollector = new GraphTallyCollector("GraphTallyCollector", "1", address(controller), revokeSignerThawingPeriod); address subgraphServiceImplementation = address( - new SubgraphService(address(controller), address(disputeManager), address(tapCollector), address(curation)) + new SubgraphService(address(controller), address(disputeManager), address(graphTallyCollector), address(curation)) ); address subgraphServiceProxy = UnsafeUpgrades.deployTransparentProxy( subgraphServiceImplementation, diff --git a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol index 1a37fed86..aecc2e5ea 100644 --- a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol +++ b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol @@ -7,7 +7,7 @@ import { IDataService } from "@graphprotocol/horizon/contracts/data-service/inte import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol"; import { IHorizonStakingTypes } from "@graphprotocol/horizon/contracts/interfaces/internal/IHorizonStakingTypes.sol"; -import { ITAPCollector } from "@graphprotocol/horizon/contracts/interfaces/ITAPCollector.sol"; +import { IGraphTallyCollector } from "@graphprotocol/horizon/contracts/interfaces/IGraphTallyCollector.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import { LinkedList } from "@graphprotocol/horizon/contracts/libraries/LinkedList.sol"; import { IDataServiceFees } from "@graphprotocol/horizon/contracts/data-service/interfaces/IDataServiceFees.sol"; @@ -262,11 +262,11 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { } function _handleQueryFeeCollection(address _indexer, bytes memory _data) private returns (uint256 paymentCollected) { - ITAPCollector.SignedRAV memory signedRav = abi.decode(_data, (ITAPCollector.SignedRAV)); + IGraphTallyCollector.SignedRAV memory signedRav = abi.decode(_data, (IGraphTallyCollector.SignedRAV)); Allocation.State memory allocation = subgraphService.getAllocation(address(uint160(uint256(signedRav.rav.collectionId)))); - (address payer, , ) = tapCollector.authorizedSigners(_recoverRAVSigner(signedRav)); + (address payer, , ) = graphTallyCollector.authorizedSigners(_recoverRAVSigner(signedRav)); - uint256 tokensCollected = tapCollector.tokensCollected( + uint256 tokensCollected = graphTallyCollector.tokensCollected( address(subgraphService), signedRav.rav.collectionId, _indexer, @@ -335,7 +335,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { CollectPaymentData memory collectPaymentDataBefore, CollectPaymentData memory collectPaymentDataAfter ) private view { - ITAPCollector.SignedRAV memory signedRav = abi.decode(_data, (ITAPCollector.SignedRAV)); + IGraphTallyCollector.SignedRAV memory signedRav = abi.decode(_data, (IGraphTallyCollector.SignedRAV)); Allocation.State memory allocation = subgraphService.getAllocation(address(uint160(uint256(signedRav.rav.collectionId)))); QueryFeeData memory queryFeeData = _queryFeeData(allocation.subgraphDeploymentId); uint256 tokensProtocol = _paymentCollected.mulPPMRoundUp(queryFeeData.protocolPaymentCut); @@ -456,8 +456,8 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { * PRIVATE FUNCTIONS */ - function _recoverRAVSigner(ITAPCollector.SignedRAV memory _signedRAV) private view returns (address) { - bytes32 messageHash = tapCollector.encodeRAV(_signedRAV.rav); + function _recoverRAVSigner(IGraphTallyCollector.SignedRAV memory _signedRAV) private view returns (address) { + bytes32 messageHash = graphTallyCollector.encodeRAV(_signedRAV.rav); return ECDSA.recover(messageHash, _signedRAV.signature); } diff --git a/packages/subgraph-service/test/subgraphService/collect/query/query.t.sol b/packages/subgraph-service/test/subgraphService/collect/query/query.t.sol index 321f01a75..bec328b6b 100644 --- a/packages/subgraph-service/test/subgraphService/collect/query/query.t.sol +++ b/packages/subgraph-service/test/subgraphService/collect/query/query.t.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.27; import "forge-std/Test.sol"; import { IGraphPayments } from "@graphprotocol/horizon/contracts/interfaces/IGraphPayments.sol"; -import { ITAPCollector } from "@graphprotocol/horizon/contracts/interfaces/ITAPCollector.sol"; +import { IGraphTallyCollector } from "@graphprotocol/horizon/contracts/interfaces/IGraphTallyCollector.sol"; import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol"; import { ProvisionManager } from "@graphprotocol/horizon/contracts/data-service/utilities/ProvisionManager.sol"; import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; @@ -25,18 +25,18 @@ contract SubgraphServiceRegisterTest is SubgraphServiceTest { function _getSignerProof(uint256 _proofDeadline, uint256 _signer) private returns (bytes memory) { (, address msgSender, ) = vm.readCallers(); - bytes32 messageHash = keccak256(abi.encodePacked(block.chainid, address(tapCollector), _proofDeadline, msgSender)); + bytes32 messageHash = keccak256(abi.encodePacked(block.chainid, address(graphTallyCollector), _proofDeadline, msgSender)); bytes32 proofToDigest = MessageHashUtils.toEthSignedMessageHash(messageHash); (uint8 v, bytes32 r, bytes32 s) = vm.sign(_signer, proofToDigest); return abi.encodePacked(r, s, v); } function _getQueryFeeEncodedData(address indexer, uint128 tokens) private view returns (bytes memory) { - ITAPCollector.ReceiptAggregateVoucher memory rav = _getRAV(indexer, bytes32(uint256(uint160(allocationID))), tokens); - bytes32 messageHash = tapCollector.encodeRAV(rav); + IGraphTallyCollector.ReceiptAggregateVoucher memory rav = _getRAV(indexer, bytes32(uint256(uint160(allocationID))), tokens); + bytes32 messageHash = graphTallyCollector.encodeRAV(rav); (uint8 v, bytes32 r, bytes32 s) = vm.sign(signerPrivateKey, messageHash); bytes memory signature = abi.encodePacked(r, s, v); - ITAPCollector.SignedRAV memory signedRAV = ITAPCollector.SignedRAV(rav, signature); + IGraphTallyCollector.SignedRAV memory signedRAV = IGraphTallyCollector.SignedRAV(rav, signature); return abi.encode(signedRAV); } @@ -44,9 +44,9 @@ contract SubgraphServiceRegisterTest is SubgraphServiceTest { address indexer, bytes32 collectionId, uint128 tokens - ) private view returns (ITAPCollector.ReceiptAggregateVoucher memory rav) { + ) private view returns (IGraphTallyCollector.ReceiptAggregateVoucher memory rav) { return - ITAPCollector.ReceiptAggregateVoucher({ + IGraphTallyCollector.ReceiptAggregateVoucher({ collectionId: collectionId, payer: users.gateway, serviceProvider: indexer, @@ -59,13 +59,13 @@ contract SubgraphServiceRegisterTest is SubgraphServiceTest { function _deposit(uint256 tokens) private { token.approve(address(escrow), tokens); - escrow.deposit(address(tapCollector), users.indexer, tokens); + escrow.deposit(address(graphTallyCollector), users.indexer, tokens); } function _authorizeSigner() private { uint256 proofDeadline = block.timestamp + 1; bytes memory proof = _getSignerProof(proofDeadline, signerPrivateKey); - tapCollector.authorizeSigner(signer, proofDeadline, proof); + graphTallyCollector.authorizeSigner(signer, proofDeadline, proof); } /* @@ -174,11 +174,11 @@ contract SubgraphServiceRegisterTest is SubgraphServiceTest { function testCollect_QueryFees_RevertWhen_CollectionIdTooLarge() public useIndexer useAllocation(1000 ether) { bytes32 collectionId = keccak256(abi.encodePacked("Large collection id, longer than 160 bits")); - ITAPCollector.ReceiptAggregateVoucher memory rav = _getRAV(users.indexer, collectionId, 1000 ether); - bytes32 messageHash = tapCollector.encodeRAV(rav); + IGraphTallyCollector.ReceiptAggregateVoucher memory rav = _getRAV(users.indexer, collectionId, 1000 ether); + bytes32 messageHash = graphTallyCollector.encodeRAV(rav); (uint8 v, bytes32 r, bytes32 s) = vm.sign(signerPrivateKey, messageHash); bytes memory signature = abi.encodePacked(r, s, v); - ITAPCollector.SignedRAV memory signedRAV = ITAPCollector.SignedRAV(rav, signature); + IGraphTallyCollector.SignedRAV memory signedRAV = IGraphTallyCollector.SignedRAV(rav, signature); bytes memory data = abi.encode(signedRAV); vm.expectRevert(abi.encodeWithSelector(ISubgraphService.SubgraphServiceInvalidCollectionId.selector, collectionId)); subgraphService.collect(users.indexer, IGraphPayments.PaymentTypes.QueryFee, data); diff --git a/packages/subgraph-service/test/utils/Constants.sol b/packages/subgraph-service/test/utils/Constants.sol index 150060a70..34be9ac74 100644 --- a/packages/subgraph-service/test/utils/Constants.sol +++ b/packages/subgraph-service/test/utils/Constants.sol @@ -28,6 +28,6 @@ abstract contract Constants { // RewardsMananger parameters uint256 public constant rewardsPerSignal = 10000; uint256 public constant rewardsPerSubgraphAllocationUpdate = 1000; - // TAPCollector parameters + // GraphTallyCollector parameters uint256 public constant revokeSignerThawingPeriod = 7 days; } From 94d541a5a2a96d8b87afd141b32a39a097164093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Tue, 11 Feb 2025 12:25:40 -0300 Subject: [PATCH 2/2] chore: rename TAPCollector in hardhat-graph-protocol package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../src/sdk/deployments/horizon/contracts.ts | 8 ++++---- .../test/fixtures/files/addresses-arbsep.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/hardhat-graph-protocol/src/sdk/deployments/horizon/contracts.ts b/packages/hardhat-graph-protocol/src/sdk/deployments/horizon/contracts.ts index 7cb828e73..86dd00be4 100644 --- a/packages/hardhat-graph-protocol/src/sdk/deployments/horizon/contracts.ts +++ b/packages/hardhat-graph-protocol/src/sdk/deployments/horizon/contracts.ts @@ -10,9 +10,9 @@ import type { } from '@graphprotocol/contracts' import type { GraphPayments, + GraphTallyCollector, HorizonStaking, PaymentsEscrow, - TAPCollector, } from '@graphprotocol/horizon' import type { ContractList } from '../../lib/contract' @@ -29,7 +29,7 @@ export const GraphHorizonContractNameList = [ 'HorizonStaking', 'GraphPayments', 'PaymentsEscrow', - 'TAPCollector', + 'GraphTallyCollector', ] as const const root = path.resolve(__dirname, '../../../../..') // hardhat-graph-protocol root @@ -49,7 +49,7 @@ export const GraphHorizonArtifactsMap = { HorizonStaking: HORIZON_ARTIFACTS_PATH, GraphPayments: HORIZON_ARTIFACTS_PATH, PaymentsEscrow: HORIZON_ARTIFACTS_PATH, - TAPCollector: HORIZON_ARTIFACTS_PATH, + GraphTallyCollector: HORIZON_ARTIFACTS_PATH, } as const export interface GraphHorizonContracts extends ContractList { @@ -65,7 +65,7 @@ export interface GraphHorizonContracts extends ContractList